@tangle-network/agent-app 0.43.44 → 0.43.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import {
3
3
  ChatMessages,
4
4
  ModelPicker,
5
5
  ProviderLogo
6
- } from "../chunk-Q4EU6MGU.js";
6
+ } from "../chunk-7VMUOD3G.js";
7
7
  import "../chunk-65P3HJY3.js";
8
8
  import "../chunk-LCNY3DCM.js";
9
9
  import "../chunk-2QI7XV2T.js";
@@ -905,12 +905,15 @@ var STATUS_LABELS2 = interactionStatusLabels({
905
905
  var TERMINAL_NOTES2 = interactionTerminalNotes("plan", {
906
906
  declined: "The agent was asked to revise the plan."
907
907
  });
908
+ var DEFAULT_RE_REQUEST_LABEL = "Ask agent to re-submit the plan";
908
909
  var COLLAPSED_MAX_HEIGHT = 320;
909
910
  function InteractionPlanCard({
910
911
  interaction,
911
912
  canWrite,
912
913
  submitAnswer,
913
914
  onResolved,
915
+ onReRequest,
916
+ reRequestLabel,
914
917
  renderMarkdown,
915
918
  className
916
919
  }) {
@@ -918,9 +921,12 @@ function InteractionPlanCard({
918
921
  const [expanded, setExpanded] = useState5(false);
919
922
  const [submitting, setSubmitting] = useState5(null);
920
923
  const [localStatus, setLocalStatus] = useState5(null);
924
+ const [reRequested, setReRequested] = useState5(false);
921
925
  const [error, setError] = useState5(null);
922
926
  const submitInFlightRef = useRef4(false);
923
927
  const status = isTerminalInteractionStatus(interaction.status) ? interaction.status : localStatus ?? interaction.status;
928
+ const reRequestable = isLateAnswerableStatus(status) && onReRequest !== void 0;
929
+ const canReRequest = canWrite && reRequestable && !reRequested;
924
930
  const disabled = !canWrite || status !== "pending" || submitting !== null;
925
931
  const approveData = useMemo3(() => buildAnswerData(interaction.fields, values), [interaction.fields, values]);
926
932
  const rejectData = useMemo3(() => {
@@ -956,6 +962,26 @@ function InteractionPlanCard({
956
962
  setSubmitting(null);
957
963
  }
958
964
  }
965
+ async function requestReSubmission() {
966
+ if (submitInFlightRef.current || !canReRequest || !onReRequest) return;
967
+ submitInFlightRef.current = true;
968
+ setSubmitting("requesting");
969
+ setError(null);
970
+ let accepted;
971
+ try {
972
+ accepted = await onReRequest(interaction);
973
+ } catch {
974
+ accepted = false;
975
+ } finally {
976
+ submitInFlightRef.current = false;
977
+ setSubmitting(null);
978
+ }
979
+ if (accepted === false) {
980
+ setError("The re-request was not sent. Try again.");
981
+ return;
982
+ }
983
+ setReRequested(true);
984
+ }
959
985
  const terminalNote = TERMINAL_NOTES2[status];
960
986
  const approved = status === "answered";
961
987
  return /* @__PURE__ */ jsxs5("div", { className: `rounded-xl border border-border bg-card p-4 shadow-sm ${className ?? ""}`, children: [
@@ -1017,6 +1043,11 @@ function InteractionPlanCard({
1017
1043
  ] }, field.name)) }),
1018
1044
  error && /* @__PURE__ */ jsx6("p", { className: "mt-3 text-xs text-destructive", children: error }),
1019
1045
  terminalNote && /* @__PURE__ */ jsx6("p", { className: "mt-3 text-xs text-muted-foreground", children: terminalNote }),
1046
+ canReRequest && /* @__PURE__ */ jsx6("div", { className: "mt-4 flex items-center justify-end", children: /* @__PURE__ */ jsx6(InteractionActionButton, { variant: "outline", onClick: () => void requestReSubmission(), disabled: submitting !== null, children: submitting === "requesting" ? "Asking\u2026" : reRequestLabel ?? DEFAULT_RE_REQUEST_LABEL }) }),
1047
+ reRequested && /* @__PURE__ */ jsx6("div", { className: "mt-4 flex items-center justify-end", children: /* @__PURE__ */ jsxs5("span", { className: "inline-flex items-center gap-1 text-xs text-muted-foreground", children: [
1048
+ /* @__PURE__ */ jsx6(CheckGlyph2, { className: "h-3 w-3" }),
1049
+ "Re-submission requested"
1050
+ ] }) }),
1020
1051
  status === "pending" && /* @__PURE__ */ jsxs5("div", { className: "mt-4 flex items-center justify-end gap-2", children: [
1021
1052
  /* @__PURE__ */ jsx6(InteractionActionButton, { variant: "outline", onClick: () => void submit("declined"), disabled, children: submitting === "reject" ? "Sending\u2026" : "Request changes" }),
1022
1053
  /* @__PURE__ */ jsx6(InteractionActionButton, { onClick: () => void submit("accepted"), disabled: disabled || approveData === null, children: submitting === "approve" ? "Approving\u2026" : "Approve plan" })
@@ -1063,6 +1094,8 @@ function DurableChatCards({
1063
1094
  planError,
1064
1095
  onInteractionResolved,
1065
1096
  onLateAnswer,
1097
+ onReRequest,
1098
+ reRequestLabel,
1066
1099
  renderMarkdown,
1067
1100
  className
1068
1101
  }) {
@@ -1091,6 +1124,8 @@ function DurableChatCards({
1091
1124
  canWrite,
1092
1125
  submitAnswer: submitInteraction,
1093
1126
  onResolved: onInteractionResolved,
1127
+ onReRequest,
1128
+ reRequestLabel,
1094
1129
  renderMarkdown
1095
1130
  },
1096
1131
  card.key
@@ -3359,4 +3394,4 @@ export {
3359
3394
  useThinkingSeconds,
3360
3395
  ChatMessages
3361
3396
  };
3362
- //# sourceMappingURL=chunk-Q4EU6MGU.js.map
3397
+ //# sourceMappingURL=chunk-7VMUOD3G.js.map