@tangle-network/agent-app 0.46.24 → 0.46.26

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.
@@ -9,7 +9,7 @@ import "../chunk-ENLRJYVW.js";
9
9
  import "../chunk-GEYACSFW.js";
10
10
  import {
11
11
  ChatComposer
12
- } from "../chunk-P2EC5VHG.js";
12
+ } from "../chunk-MWEX2M6M.js";
13
13
  import "../chunk-L7MB2LLM.js";
14
14
  import {
15
15
  ModelPicker
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ComposerModeControls,
3
3
  EntryComposer
4
- } from "../chunk-P2EC5VHG.js";
4
+ } from "../chunk-MWEX2M6M.js";
5
5
  import "../chunk-L7MB2LLM.js";
6
6
  import "../chunk-YDOQE47G.js";
7
7
  import "../chunk-EDTWGSQT.js";
@@ -272,53 +272,26 @@ import {
272
272
  } from "react";
273
273
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
274
274
  function createLazyMentionEditor() {
275
- return lazy(() => import("./mention-editor-WW7UVZMR.js").then((m) => m.loadMentionEditor()));
275
+ return lazy(() => import("./mention-editor-NDJAEMRP.js").then((m) => m.loadMentionEditor()));
276
276
  }
277
277
  var MentionEditorBoundary = class extends Component {
278
- state = { error: null };
279
- static getDerivedStateFromError(error) {
280
- return { error };
281
- }
282
- componentDidCatch() {
283
- this.props.onFailed();
278
+ state = { failed: false };
279
+ static getDerivedStateFromError() {
280
+ return { failed: true };
284
281
  }
285
282
  render() {
286
- if (this.state.error === null) return this.props.children;
287
- const message = this.state.error instanceof Error ? this.state.error.message : String(this.state.error);
288
- return /* @__PURE__ */ jsxs(
289
- "div",
290
- {
291
- role: "alert",
292
- "data-testid": "composer-mention-editor-error",
293
- className: "rounded-xl border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",
294
- children: [
295
- /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
296
- /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
297
- "The mention input failed to load: ",
298
- message
299
- ] }),
300
- /* @__PURE__ */ jsx(
301
- "button",
302
- {
303
- type: "button",
304
- "aria-label": "Retry loading the mention input",
305
- onClick: this.props.onRetry,
306
- className: "shrink-0 font-medium underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",
307
- children: "Retry"
308
- }
309
- )
310
- ] }),
311
- this.props.draft.trim() !== "" && /* @__PURE__ */ jsx(
312
- "p",
313
- {
314
- "data-testid": "composer-error-held-draft",
315
- className: "mt-1.5 max-h-20 overflow-y-auto whitespace-pre-wrap rounded-lg border border-destructive/30 bg-card px-2 py-1 text-foreground",
316
- children: this.props.draft
317
- }
318
- )
319
- ]
320
- }
321
- );
283
+ if (!this.state.failed) return this.props.children;
284
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
285
+ this.props.fallback,
286
+ /* @__PURE__ */ jsx(
287
+ "div",
288
+ {
289
+ role: "alert",
290
+ className: "rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",
291
+ children: "Mentions are unavailable. You can still send."
292
+ }
293
+ )
294
+ ] });
322
295
  }
323
296
  };
324
297
  var IS_APPLE_PLATFORM = typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform);
@@ -425,6 +398,7 @@ function ChatComposer({
425
398
  const isControlled = value !== void 0;
426
399
  const [internal, setInternal] = useState2(initialValue ?? "");
427
400
  const text = isControlled ? value : internal;
401
+ const MentionEditor = useMemo(createLazyMentionEditor, []);
428
402
  const textRef = useRef2(text);
429
403
  textRef.current = text;
430
404
  const textareaRef = useRef2(null);
@@ -432,9 +406,6 @@ function ChatComposer({
432
406
  const registerRichFocus = useCallback2((focus) => {
433
407
  richFocusRef.current = focus;
434
408
  }, []);
435
- const [editorEpoch, setEditorEpoch] = useState2(0);
436
- const MentionEditor = useMemo(createLazyMentionEditor, [editorEpoch]);
437
- const [editorFailed, setEditorFailed] = useState2(false);
438
409
  const fileInputRef = useRef2(null);
439
410
  const folderInputRef = useRef2(null);
440
411
  const [dragOver, setDragOver] = useState2(false);
@@ -513,9 +484,9 @@ function ChatComposer({
513
484
  if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "l") {
514
485
  if (mentionEnabled) {
515
486
  const focus = richFocusRef.current;
516
- if (!focus) return;
517
487
  e.preventDefault();
518
- focus();
488
+ if (focus) focus();
489
+ else textareaRef.current?.focus();
519
490
  } else {
520
491
  e.preventDefault();
521
492
  textareaRef.current?.focus();
@@ -528,8 +499,7 @@ function ChatComposer({
528
499
  const sendableFiles = canSubmitAttachmentsOnly ? pendingFiles : pendingFiles.filter((f) => f.status === "ready");
529
500
  const hasSendable = text.trim().length > 0 || sendableFiles.length > 0;
530
501
  const sendBlockedByStream = isStreaming && !canSubmitWhileBusy;
531
- const editorInputLost = mention != null && editorFailed;
532
- const canSend = hasSendable && !sendBlockedByStream && !disabled && !editorInputLost;
502
+ const canSend = hasSendable && !sendBlockedByStream && !disabled;
533
503
  const [failedSend, setFailedSend] = useState2(null);
534
504
  const failSend = useCallback2(
535
505
  (error, draft, trimmed, parts, caret) => {
@@ -574,7 +544,7 @@ function ChatComposer({
574
544
  );
575
545
  const send = useCallback2(() => {
576
546
  const trimmed = text.trim();
577
- if (sendBlockedByStream || disabled || editorInputLost) return;
547
+ if (sendBlockedByStream || disabled) return;
578
548
  const readyFiles = pendingFiles.filter((f) => f.status === "ready");
579
549
  const sendable = canSubmitAttachmentsOnly ? pendingFiles : readyFiles;
580
550
  if (!trimmed && sendable.length === 0) return;
@@ -594,7 +564,6 @@ function ChatComposer({
594
564
  text,
595
565
  sendBlockedByStream,
596
566
  disabled,
597
- editorInputLost,
598
567
  canSubmitAttachmentsOnly,
599
568
  attachmentsNotReadyMessage,
600
569
  onSendParts,
@@ -768,6 +737,23 @@ function ChatComposer({
768
737
  const showAbove = controls != null && controlsPlacement === "above";
769
738
  const showInline = controls != null && !showAbove;
770
739
  const inputMinHeight = minRows * LINE_HEIGHT + TEXTAREA_PADDING_Y;
740
+ const textareaInput = /* @__PURE__ */ jsx(
741
+ "textarea",
742
+ {
743
+ ref: textareaRef,
744
+ value: text,
745
+ onChange: (e) => setText(e.target.value),
746
+ onKeyDown: handleKeyDown,
747
+ onPaste: onAttach ? handlePaste : void 0,
748
+ placeholder,
749
+ disabled,
750
+ autoFocus,
751
+ rows: minRows,
752
+ style: { minHeight: inputMinHeight, maxHeight },
753
+ "aria-label": "Message input",
754
+ className: "w-full resize-none bg-transparent px-1.5 py-1 text-base leading-6 text-foreground outline-none placeholder:text-muted-foreground disabled:opacity-50"
755
+ }
756
+ );
771
757
  return /* @__PURE__ */ jsxs(
772
758
  "div",
773
759
  {
@@ -919,78 +905,35 @@ function ChatComposer({
919
905
  className: `flex flex-col gap-1.5 rounded-2xl border border-card-edge bg-card px-3 py-2.5 transition focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15 ${floating ? "shadow-raised" : ""}`,
920
906
  children: [
921
907
  mention ? (
922
- // The editor arrives as a lazy chunk; until it lands, a read-only
923
- // textarea with the same metrics holds the layout so the card
924
- // doesn't jump. The boundary contains a failed load (e.g. the
925
- // missing-peer error) to the input area instead of unmounting the
926
- // host's region.
908
+ // The basic textarea stays usable through download, initialization,
909
+ // and failure.
927
910
  /* @__PURE__ */ jsx(
928
911
  MentionEditorBoundary,
929
912
  {
930
- onRetry: () => {
931
- setEditorFailed(false);
932
- setEditorEpoch((epoch) => epoch + 1);
933
- },
934
- onFailed: () => setEditorFailed(true),
935
- draft: text,
936
- children: /* @__PURE__ */ jsx(
937
- Suspense,
913
+ fallback: textareaInput,
914
+ children: /* @__PURE__ */ jsx(Suspense, { fallback: textareaInput, children: /* @__PURE__ */ jsx(
915
+ MentionEditor,
938
916
  {
939
- fallback: /* @__PURE__ */ jsx(
940
- "textarea",
941
- {
942
- rows: minRows,
943
- value: text,
944
- readOnly: true,
945
- disabled: true,
946
- placeholder,
947
- "aria-label": "Message input",
948
- style: { minHeight: inputMinHeight, maxHeight },
949
- className: "w-full resize-none bg-transparent px-1.5 py-1 text-base leading-6 text-foreground outline-none placeholder:text-muted-foreground disabled:opacity-50"
950
- }
951
- ),
952
- children: /* @__PURE__ */ jsx(
953
- MentionEditor,
954
- {
955
- value: text,
956
- onChange: setText,
957
- onSubmit: send,
958
- placeholder,
959
- disabled,
960
- autoFocus,
961
- minHeight: inputMinHeight,
962
- maxHeight,
963
- mention,
964
- registerFocus: registerRichFocus,
965
- onPasteFiles: onAttach ? ingestPastedFiles : void 0
966
- }
967
- )
917
+ value: text,
918
+ onChange: setText,
919
+ onSubmit: send,
920
+ placeholder,
921
+ disabled,
922
+ autoFocus,
923
+ minHeight: inputMinHeight,
924
+ maxHeight,
925
+ mention,
926
+ fallback: textareaInput,
927
+ registerFocus: registerRichFocus,
928
+ onPasteFiles: onAttach ? ingestPastedFiles : void 0
968
929
  }
969
- )
970
- },
971
- editorEpoch
972
- )
973
- ) : (
974
- // Focus: `outline-none` is safe because the card above draws the
975
- // keyboard indicator through `focus-within:` — one ring for
976
- // whichever input mode is mounted.
977
- /* @__PURE__ */ jsx(
978
- "textarea",
979
- {
980
- ref: textareaRef,
981
- value: text,
982
- onChange: (e) => setText(e.target.value),
983
- onKeyDown: handleKeyDown,
984
- onPaste: onAttach ? handlePaste : void 0,
985
- placeholder,
986
- disabled,
987
- autoFocus,
988
- rows: minRows,
989
- style: { minHeight: inputMinHeight, maxHeight },
990
- "aria-label": "Message input",
991
- className: "w-full resize-none bg-transparent px-1.5 py-1 text-base leading-6 text-foreground outline-none placeholder:text-muted-foreground disabled:opacity-50"
930
+ ) })
992
931
  }
993
932
  )
933
+ ) : (
934
+ // The card draws the keyboard indicator through `focus-within:`, so
935
+ // the input does not need a second outline.
936
+ textareaInput
994
937
  ),
995
938
  /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
996
939
  onAttach && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -1894,4 +1837,4 @@ export {
1894
1837
  ComposerModeControls,
1895
1838
  EntryComposer
1896
1839
  };
1897
- //# sourceMappingURL=chunk-P2EC5VHG.js.map
1840
+ //# sourceMappingURL=chunk-MWEX2M6M.js.map