@agent-native/toolkit 0.23.0 → 0.23.1-nightly-20260928222833

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.
@@ -70,7 +70,7 @@ export function AgentSuggestionBar({
70
70
  size="sm"
71
71
  disabled={suggestion.disabled}
72
72
  onClick={() => onSelect(suggestion)}
73
- className="h-7 shrink-0 snap-start whitespace-nowrap rounded-full border-transparent bg-muted/55 px-2.5 text-[11px] font-normal text-muted-foreground shadow-none transition-[border-color,background-color,color] hover:border-border/55 hover:bg-muted hover:text-foreground"
73
+ className="h-7 shrink-0 snap-start whitespace-nowrap rounded-full border-transparent bg-muted/55 px-2.5 text-[11px] font-normal text-foreground/80 shadow-none transition-[border-color,background-color,color] hover:border-border/55 hover:bg-muted hover:text-foreground"
74
74
  >
75
75
  <span>
76
76
  {renderSuggestion
@@ -18,6 +18,16 @@ import type { TiptapComposerHandle } from "./TiptapComposer.js";
18
18
  let container: HTMLDivElement;
19
19
  let root: Root;
20
20
 
21
+ function KeyedStaleIndexBoundary({
22
+ resetKey,
23
+ children,
24
+ }: {
25
+ resetKey: string;
26
+ children: React.ReactNode;
27
+ }) {
28
+ return <React.Fragment key={resetKey}>{children}</React.Fragment>;
29
+ }
30
+
21
31
  beforeEach(() => {
22
32
  vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
23
33
  container = document.createElement("div");
@@ -32,6 +42,44 @@ afterEach(() => {
32
42
  });
33
43
 
34
44
  describe("controlled composer context", () => {
45
+ it("keeps the editor mounted while the host echoes each edit as initial text", async () => {
46
+ const composerRef = React.createRef<TiptapComposerHandle>();
47
+ const onSubmit = vi.fn();
48
+ const EchoingPrompt = () => {
49
+ const [text, setText] = React.useState("");
50
+ return (
51
+ <ComposerRuntimeAdaptersProvider
52
+ adapters={{
53
+ agentChat: {
54
+ StaleIndexBoundary: KeyedStaleIndexBoundary,
55
+ },
56
+ }}
57
+ >
58
+ <PromptComposer
59
+ composerRef={composerRef}
60
+ onSubmit={onSubmit}
61
+ initialText={text}
62
+ initialTextKey="stable-while-typing"
63
+ onTextChange={setText}
64
+ showModelSelector={false}
65
+ modelStatusChecksEnabled={false}
66
+ includeDefaultSlashSkills={false}
67
+ voiceEnabled={false}
68
+ />
69
+ </ComposerRuntimeAdaptersProvider>
70
+ );
71
+ };
72
+
73
+ await act(async () => root.render(<EchoingPrompt />));
74
+ const editor = container.querySelector<HTMLElement>(".ProseMirror")!;
75
+ expect(editor).not.toBeNull();
76
+
77
+ await act(async () => composerRef.current!.setText("typed at the end"));
78
+
79
+ expect(container.querySelector(".ProseMirror")).toBe(editor);
80
+ expect(editor.textContent).toBe("typed at the end");
81
+ });
82
+
35
83
  it("uses the shared upload menu without host entries and retains the explicit hidden mode", async () => {
36
84
  await mount();
37
85
  const trigger = container.querySelector<HTMLButtonElement>(
@@ -1009,11 +1009,9 @@ function PromptComposerRuntime(props: PromptComposerProps) {
1009
1009
  const runtime = useLocalRuntime(NOOP_ADAPTER, {
1010
1010
  adapters: { attachments: attachmentAdapter },
1011
1011
  });
1012
- const resetKey = [
1013
- props.draftScope ?? "",
1014
- props.initialTextKey ?? "",
1015
- props.initialText ?? "",
1016
- ].join(":");
1012
+ const resetKey = [props.draftScope ?? "", props.initialTextKey ?? ""].join(
1013
+ ":",
1014
+ );
1017
1015
 
1018
1016
  return (
1019
1017
  <TooltipProvider delayDuration={200}>
@@ -4728,14 +4728,27 @@ export function TiptapComposer({
4728
4728
  type="button"
4729
4729
  onClick={() => void submitComposer("immediate")}
4730
4730
  disabled={!canSend}
4731
- aria-label={sendButtonTooltip}
4731
+ aria-label={
4732
+ submitting
4733
+ ? t("agentChat.setup.checkingProvider")
4734
+ : sendButtonTooltip
4735
+ }
4736
+ aria-busy={submitting || undefined}
4732
4737
  data-agent-composer-slot="send-button"
4733
4738
  className="agent-composer-send-button shrink-0 flex h-7 w-7 items-center justify-center rounded-md bg-primary text-primary-foreground hover:opacity-90 transition-[opacity,transform] duration-150 active:scale-[0.97] disabled:opacity-30 disabled:cursor-not-allowed"
4734
4739
  >
4735
- <IconArrowUp className="h-3.5 w-3.5" />
4740
+ {submitting ? (
4741
+ <IconLoader2 className="size-3.5 animate-spin motion-reduce:animate-none" />
4742
+ ) : (
4743
+ <IconArrowUp className="h-3.5 w-3.5" />
4744
+ )}
4736
4745
  </button>
4737
4746
  </TooltipTrigger>
4738
- <TooltipContent>{sendButtonTooltip}</TooltipContent>
4747
+ <TooltipContent>
4748
+ {submitting
4749
+ ? t("agentChat.setup.checkingProvider")
4750
+ : sendButtonTooltip}
4751
+ </TooltipContent>
4739
4752
  </Tooltip>
4740
4753
  )}
4741
4754
  </>