Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Declare clipped on the wire type; cancel full-output fetch on close

AdityaUmale385f460df412
diff --git a/shared/wire.ts b/shared/wire.ts
index f9ad2274ac..0c734b4fc7 100644
--- a/shared/wire.ts
+++ b/shared/wire.ts
@@ -497,7 +497,7 @@ export interface WireMessage extends HelperIntroField, SetupCardFields, WaitLine
call?: LiveCallRecord;
/** activity messages: tool name + outcome. */
tool?: {
- name: string; ok?: boolean; spoken?: string; setup?: boolean; terminal?: boolean; summary?: string; input?: string; output?: string;
+ name: string; ok?: boolean; spoken?: string; setup?: boolean; terminal?: boolean; summary?: string; input?: string; output?: string; clipped?: boolean;
/** What the call works on, as its live status said it: the chip's and the "Now" card's specific words. `whose`: the person whose own app or MCP server the call used. */
step?: import("./turn-progress.ts").LiveStep; whose?: { person: string; app: string };
/** error rows: the installed Claude Code is too old for the model, and
diff --git a/src/components/ToolActivity.full.test.ts b/src/components/ToolActivity.full.test.ts
index 151420d1bf..042dd1dde8 100644
--- a/src/components/ToolActivity.full.test.ts
+++ b/src/components/ToolActivity.full.test.ts
@@ -52,11 +52,14 @@ describe("ToolActivity: a clipped step", () => {
expect(host.textContent).toContain("Showing the start of the result only");
});
- it("asks again after being closed mid-load", async () => {
+ it("cancels the request when closed mid-load, and asks again on reopen", async () => {
api.mockReturnValueOnce(new Promise(() => {})).mockResolvedValueOnce({ output: whole });
render({ output: preview, clipped: true });
await toggle(true);
+ const first = (api.mock.calls[0]![1] as RequestInit).signal!;
+ expect(first.aborted).toBe(false);
await toggle(false);
+ expect(first.aborted).toBe(true);
await toggle(true);
expect(api).toHaveBeenCalledTimes(2);
expect(shown()).toBe(whole);
diff --git a/src/components/ToolActivity.tsx b/src/components/ToolActivity.tsx
index 5bdb34544c..f61a60c673 100644
--- a/src/components/ToolActivity.tsx
+++ b/src/components/ToolActivity.tsx
@@ -67,11 +67,12 @@ function useFullOutput(source: MessageAttachmentContext | undefined, preview: st
useEffect(() => {
if (!url || have) return;
let current = true;
+ const abort = new AbortController();
setFull({ state: "loading", key });
- api<{ output: string }>(url)
+ api<{ output: string }>(url, { signal: abort.signal })
.then((body) => { if (current) setFull({ state: "done", key, output: body.output }); })
.catch(() => { if (current) setFull({ state: "failed", key }); });
- return () => { current = false; };
+ return () => { current = false; abort.abort(); };
}, [url, key, have]);
return full.key === key ? full : { state: "idle" };
}