From 0281a8dbecc4779eb1598483522ffe7f1894fb32 Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Fri, 4 Dec 2026 15:19:48 -0800 Subject: [PATCH 01/13] An app's steps are drawn one way, running or done, by the app's name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Google Calendar turn showed three steps three ways: finished steps read "List events Googlecalendar" (the app's key), while the step still running sat in a box of its own, app first: "Google Calendar · List events" with a spinner. The box (LiveConnectorStep) said nothing the row does not, so it goes: every step is one row, the action then the app, and a running row differs only by its shimmer and "In progress". Every step now names its app as it was added here (useAppName, from the apps the transcript already reads for logos), not from its key. A running line also tells a screen reader "In progress", as the box did. Co-Authored-By: Claude Opus 5.5 --- .../components/channels/chat-transcript.tsx | 22 +- app/src/components/channels/tool-activity.tsx | 148 +++++----- app/src/components/channels/tool-line.tsx | 5 + app/src/components/tasks/worked-for.tsx | 3 + app/tests/app-step-rows.test.tsx | 258 ++++++++++++++++++ app/tests/approval-carry-on-running.test.tsx | 2 +- app/tests/approval-left-carry-on.test.tsx | 2 +- .../carry-on-carried-turn-browser.test.tsx | 2 +- app/tests/carry-on-while-busy.test.tsx | 2 +- app/tests/reread-steps.test.tsx | 8 +- app/tests/running-step-shimmer.test.tsx | 20 +- app/tests/work-folded.test.tsx | 3 +- 12 files changed, 374 insertions(+), 101 deletions(-) create mode 100644 app/tests/app-step-rows.test.tsx diff --git a/app/src/components/channels/chat-transcript.tsx b/app/src/components/channels/chat-transcript.tsx index b4230fc611..f5b76cc260 100644 --- a/app/src/components/channels/chat-transcript.tsx +++ b/app/src/components/channels/chat-transcript.tsx @@ -200,11 +200,11 @@ import { attachmentReadName, dropRepeatedAppCards, groupToolSteps, - LiveConnectorStep, ServerStepIcon, ToolActivity, type ToolGroup, type TranscriptItem, + useAppName, useDrawnTool, useReportsDesktopActivity, } from "./tool-activity"; @@ -1898,7 +1898,6 @@ const ToolCallBody = memo(function ToolCallBody({ result, latest, spokeAfter, - liveConnector, }: { toolCallId: string; name: string; @@ -1908,7 +1907,6 @@ const ToolCallBody = memo(function ToolCallBody({ latest: boolean; /** The Bot said something after this call in its turn. See `ToolPlace`. */ spokeAfter: boolean; - liveConnector?: boolean; }) { const renderToolCall = useRenderToolCall(); const toolCall = useMemo( @@ -1978,7 +1976,6 @@ const ToolCallBody = memo(function ToolCallBody({ ) : ( ; - if (running && liveConnector && appId) - return ( -
- -
- ); /* * THAT TOOL'S OTHER ANSWERS ARE FOR THE MODEL. An app nobody can name comes back as plain text * telling the Bot to say so plainly and not to browse to it — an instruction, which read by the diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index 70caa04ad3..e547fc84f0 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -50,7 +50,6 @@ import { IconFilePlus, IconFileText, IconFolder, - IconLoader2, IconPlug, IconSearch, IconSend, @@ -541,21 +540,37 @@ export function stepDetails(step: ToolItem): StepDetails { return detailsOf(step, new Map()); } +/** An app's name from its key: as it was added here (`useAppName`), or its key in words. */ +export type AppName = (appId: string) => string; + /** * `stepDetails`, naming a folder step's folder from the conversation's folder names. `live`: the * steps' turn is still going. Once it is over, a command with no answer was stopped under way. + * `appName`: an app step's app, by the name it was added under (`useAppName`). */ export function stepDetailsIn( folders: FolderNames, live = true, + appName: AppName = connectorName, ): (step: ToolItem) => StepDetails { - return (step) => detailsOf(step, folders, live); + return (step) => detailsOf(step, folders, live, appName); +} + +/** + * The words beside an app's action, with the app said by its name: `readToolName` names it from its + * key ("Googlecalendar"), which only the apps added here know as "Google Calendar". + */ +function appDetail(detail: string, appId: string, appName: AppName): string { + return detail === appId || detail === connectorName(appId) + ? appName(appId) + : detail; } function detailsOf( step: ToolItem, folders: FolderNames, live = true, + appName: AppName = connectorName, ): StepDetails { if (cutOffStep(step.result)) { // Read as the step it was while under way, then marked: what the Bot was told is not shown. @@ -565,7 +580,7 @@ function detailsOf( subtask: _subtask, terminal: _terminal, ...details - } = detailsOf(underWay, folders); + } = detailsOf(underWay, folders, true, appName); return { ...details, // A subtask's own row reads its result; a cut-off one has none, so it is an ordinary step. @@ -654,7 +669,7 @@ function detailsOf( if (name === READ_RESULT_PART) { // The app's own answer, read on: its step is the app's, as the app's read is ("Used Fireflies"). const app = appOfRead(args); - const detail = partRead(args, part); + const detail = partRead(args, part, appName); return { ...outcome, label: readToolName(name, outcome.pending).label, @@ -663,7 +678,7 @@ function detailsOf( inputs: [], pages: 0, ...(app - ? { kind: "connector", connector: connectorName(app), appId: app } + ? { kind: "connector", connector: appName(app), appId: app } : { kind: "tool" }), }; } @@ -741,11 +756,9 @@ function detailsOf( return { ...base, kind: "connector", - ...(detail - ? { detail: detail === server ? connectorName(server) : detail } - : {}), + ...(detail ? { detail: appDetail(detail, server, appName) } : {}), pages: 0, - connector: connectorName(server), + connector: appName(server), appId: server, }; } @@ -787,14 +800,17 @@ function appOfRead(args: Record): string | undefined { function partRead( args: Record, part: { part?: number; parts?: number } | undefined, + appName: AppName, ): string | undefined { const whole = readOf(args); const read = whole ? readToolName(whole) : undefined; - const named = read - ? read.detail - ? `${read.label} on ${read.detail}` - : read.label + const app = appOfRead(args); + const on = read?.detail + ? app + ? appDetail(read.detail, app, appName) + : read.detail : undefined; + const named = read ? (on ? `${read.label} on ${on}` : read.label) : undefined; const number = part?.part ?? (typeof args.part === "number" @@ -1225,35 +1241,20 @@ const ActivityApps = createContext( undefined, ); -export function LiveConnectorStep({ - appId, - label, -}: { - appId: string; - label: string; -}) { +/** + * An app's name as it was added here ("Google Calendar"), read from the apps the transcript looked + * up for its icons (`ActivityAppMarks`), or its key in words until they are in. + * + * ONE NAME FOR AN APP ON EVERY ROW. An app's step was named from its key, so Google Calendar's + * finished steps read "Googlecalendar", while its step still running, drawn by a component of its + * own, read "Google Calendar". Every step now names its app here, running or done. + */ +export function useAppName(): AppName { const apps = useContext(ActivityApps); - const title = - apps?.find((app) => app.id === appId)?.title ?? connectorName(appId); - return ( - - - - {title} - - · - - {label} - - - In progress - + return useCallback( + (appId: string) => + apps?.find((app) => app.id === appId)?.title ?? connectorName(appId), + [apps], ); } @@ -1367,11 +1368,9 @@ export function StepStatus({ export function StepRow({ step, active, - liveConnector, }: { step: StepDetails; active: boolean; - liveConnector?: boolean; }) { if (step.kind === "subtask") return ; @@ -1379,32 +1378,34 @@ export function StepRow({ * The step still working shimmers, as the group's own line does while it runs. "In progress" in * muted text beside a label drawn exactly like the finished steps above it read as one more static * row: a person watching four "Fetch emails" lines and a fifth with no result took the Bot for dead. + * + * ONE ROW, RUNNING OR DONE. An app's step still running was drawn as a box of its own, the app + * first and the action after it, where every other row, its own finished steps beside it, says the + * action first and the app after, plain. Nothing on the box said more than the row does: it is the + * row, shimmering, with "In progress" where "Blocked" or "Didn't work" would be. */ const running = active && step.pending; - const line = - running && liveConnector && step.appId ? ( - - ) : ( - - - - {step.label} - - {step.href ? ( - - {step.detail ?? step.href} - - ) : step.detail ? ( - {step.detail} - ) : null} - + const line = ( + + + + {step.label} - ); + {step.href ? ( + + {step.detail ?? step.href} + + ) : step.detail ? ( + {step.detail} + ) : null} + + + ); const reason = step.failed && step.kind === "browser" ? (

@@ -1609,8 +1610,9 @@ export function WorkingNow({ steps }: { steps: readonly StepDetails[] }) { export function stepsUnderWay( items: readonly TranscriptItem[], folders: FolderNames, + appName?: AppName, ): StepDetails[] { - const details = stepDetailsIn(folders); + const details = stepDetailsIn(folders, true, appName); return items.flatMap((item) => item.kind === "tools" ? foldRereads(item.steps.map(details)).filter( @@ -1637,7 +1639,10 @@ export function ToolActivity({ const folders = useContext(FolderNamesContext); // A command with no answer runs while its turn does, whichever row it is in. const inFlight = useContext(TurnInFlightContext); - const steps = group.steps.map(stepDetailsIn(folders, active || inFlight)); + const appName = useAppName(); + const steps = group.steps.map( + stepDetailsIn(folders, active || inFlight, appName), + ); // What the line opens to: a run of rereads is one row. See `foldRereads`. const rows = foldRereads(steps); const running = active && steps.some((step) => step.pending); @@ -1672,12 +1677,7 @@ export function ToolActivity({ const list = (

    {rows.map((step) => ( - + ))}
); diff --git a/app/src/components/channels/tool-line.tsx b/app/src/components/channels/tool-line.tsx index 720f464af2..fc4cd30af0 100644 --- a/app/src/components/channels/tool-line.tsx +++ b/app/src/components/channels/tool-line.tsx @@ -242,6 +242,11 @@ export function ToolLine({ {detail}
) : null} + {/* + * Said to a screen reader, which hears no shimmer: the same "In progress" a step in a list + * says beside its label (`StepStatus`), on every line still running, whatever it does. + */} + {running ? In progress : null} ); diff --git a/app/src/components/tasks/worked-for.tsx b/app/src/components/tasks/worked-for.tsx index 492c9799a5..f167587de1 100644 --- a/app/src/components/tasks/worked-for.tsx +++ b/app/src/components/tasks/worked-for.tsx @@ -17,6 +17,7 @@ import { import { stepsUnderWay, type TranscriptItem, + useAppName, WorkAppIcons, WorkingNow, } from "@/components/channels/tool-activity"; @@ -225,10 +226,12 @@ function WorkLine({ * the step it is on and how many it has taken. Opened, the rows inside say the same and more. */ const folders = useContext(FolderNamesContext); + const appName = useAppName(); const underWay = running ? stepsUnderWay( work.rows.map((row) => row.item), folders, + appName, ) : []; const apps = work.rows.flatMap(({ item }) => { diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx new file mode 100644 index 0000000000..6c1916a808 --- /dev/null +++ b/app/tests/app-step-rows.test.tsx @@ -0,0 +1,258 @@ +import { afterAll, afterEach, beforeAll, expect, test } from "bun:test"; +import type { Message } from "@ag-ui/core"; +import { CopilotKitProvider } from "@copilotkit/react-core/v2"; +import { GlobalRegistrator } from "@happy-dom/global-registrator"; +import { QueryClientProvider } from "@tanstack/react-query"; +import { cleanup, fireEvent, render, waitFor } from "@testing-library/react"; +import { ChatTranscript } from "@/components/channels/chat-transcript"; +import { forgetOpenedLines } from "@/components/channels/tool-line"; +import { queryClient } from "@/query-client"; +import { approvalInboxResponse } from "./approvals-api"; +import { settleReactWork } from "./settle-react-work"; + +/** + * An app's steps are drawn one way, running or done, and name the app as it was added. + * + * Reported from the web app, on a Bot listing a person's events: three Google Calendar steps in a + * row, drawn three ways. The two finished ones read "List events" beside "Googlecalendar", the app's + * key, while the one still running sat in a box of its own, the app first, "Google Calendar · List + * events", with a spinner. The box said nothing the row does not: the action, the app, and that it + * was still going. So every step is one row, the action and then the app, by the name the person + * added it under, and a running one differs from a finished one only in that it is running. + */ + +const originalFetch = globalThis.fetch; + +/** Google Calendar, as the apps added here list it. Its key in words would be "Googlecalendar". */ +const APP = { + id: "googlecalendar", + title: "Google Calendar", + logo: "https://apps.example/google-calendar.svg", +}; + +beforeAll(() => { + GlobalRegistrator.register({ url: "http://localhost/" }); + globalThis.fetch = Object.assign( + async (input: Parameters[0]) => { + const url = new URL( + typeof input === "string" + ? input + : input instanceof URL + ? input.href + : input.url, + "http://localhost", + ); + { + const approvals = approvalInboxResponse(url.pathname, { + enabled: false, + requests: [], + rules: [], + teamRules: [], + questions: [], + }); + if (approvals) return approvals; + } + if (url.pathname === "/api/v2/organizations/default/apps") + return Response.json({ apps: [APP], nextCursor: null }); + return Response.json({ error: "not served" }, { status: 404 }); + }, + { preconnect: originalFetch.preconnect }, + ); +}); + +afterEach(() => { + cleanup(); + forgetOpenedLines(); + queryClient.clear(); +}); + +afterAll(async () => { + await settleReactWork(); + globalThis.fetch = originalFetch; + GlobalRegistrator.unregister(); +}); + +const LIST_EVENTS = "mcp__googlecalendar__list_events"; +const EVENTS = '{"events":[{"summary":"Design review"}]}'; +const NOTE = + '[OpenBot: this answer is 40,000 characters long, in 3 parts. This is part 2 of 3: characters 18,000 to 36,000. To read part 3, call read_result_part with {"tool":"mcp__googlecalendar__list_events","arguments":{},"part":3}.]'; + +/** One call, answered unless `result` is left out. */ +function call( + id: string, + name: string, + args: object, + result?: string, +): Message[] { + return [ + { + id: `a-${id}`, + role: "assistant", + content: "", + toolCalls: [ + { + id, + type: "function", + function: { name, arguments: JSON.stringify(args) }, + }, + ], + }, + ...(result === undefined + ? [] + : [ + { + id: `t-${id}`, + role: "tool" as const, + toolCallId: id, + content: result, + }, + ]), + ]; +} + +const ASKED: Message = { + id: "u1", + role: "user", + content: "What's on my calendar this week?", +}; + +/** The turn from the report: events listed, the next part of that answer read, events listed again. */ +function turn(lastAnswered: boolean): Message[] { + return [ + ASKED, + ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" }, EVENTS), + ...call( + "part-2", + "read_result_part", + { tool: LIST_EVENTS, arguments: {}, part: 2 }, + `${EVENTS}\n\n${NOTE}`, + ), + ...call( + "list-2", + LIST_EVENTS, + { timeMin: "2026-12-08" }, + lastAnswered ? EVENTS : undefined, + ), + ]; +} + +function transcript(messages: Message[], busy: boolean) { + return ( + + + + + + ); +} + +/** What a step's line says, in order, and how it is drawn: each part's tag and classes. */ +function shapeOf(line: Element) { + return { + tag: line.tagName, + classes: line.className, + parts: [...line.children].map((part) => part.tagName), + }; +} + +test("an app's step still running is drawn as its finished steps are: the action, then the app by its name", async () => { + const view = render(transcript(turn(false), true)); + + // The steps under way are listed, one row each, while the turn runs. + const steps = await view.findByRole("list", { name: "Tool steps" }); + await waitFor(() => expect(steps.textContent).toContain("Google Calendar")); + const rows = [...steps.querySelectorAll(":scope > li")]; + expect(rows).toHaveLength(3); + const lines = rows.map( + (row) => row.querySelector("summary > span:last-child") as Element, + ); + const [listed, partRead, running] = lines; + if (!listed || !partRead || !running) throw new Error("Expected 3 lines"); + + // The action first and the app after it, finished or running, the app by its added name. + expect(listed.textContent).toBe("List eventsGoogle Calendar"); + expect(partRead.textContent).toBe( + "Read the next part of an answerList events on Google Calendar, part 2 of 3", + ); + expect(running.textContent).toBe("List eventsGoogle CalendarIn progress"); + + // One shape: no box, no app before the action, the same parts in the same order. + const done = shapeOf(listed); + expect(shapeOf(running)).toEqual({ ...done, parts: [...done.parts, "SPAN"] }); + // Only its running says it is running: the label shimmers, and "In progress" where a status goes. + expect(running.querySelector(".tool-line-running")?.textContent).toBe( + "List events", + ); + expect(listed.querySelector(".tool-line-running")).toBeNull(); + // Each with the app's own logo, as added. + for (const line of lines) + expect(line.querySelector("img")?.getAttribute("src")).toBe(APP.logo); + + // The app's key is never shown as its name. + expect(view.container.textContent).not.toContain("Googlecalendar"); + expect(view.container.textContent).not.toContain("googlecalendar"); +}); + +test("answered, the step stops running and nothing else about it changes", async () => { + const view = render(transcript(turn(false), true)); + const steps = await view.findByRole("list", { name: "Tool steps" }); + await waitFor(() => expect(steps.textContent).toContain("Google Calendar")); + const before = shapeOf( + steps.querySelector( + ":scope > li:last-child summary > span:last-child", + ) as Element, + ); + + // Every step answered, the steps fold into one line, which names the app by its name too. + view.rerender(transcript(turn(true), true)); + const fold = await view.findByText("Used Google Calendar"); + fireEvent.click(fold); + const after = view.getByRole("list", { name: "Tool steps" }); + expect(after.querySelector(".tool-line-running")).toBeNull(); + const last = after.querySelector( + ":scope > li:last-child summary > span:last-child", + ) as Element; + expect(last.textContent).toBe("List eventsGoogle Calendar"); + expect(shapeOf(last)).toEqual({ + ...before, + parts: before.parts.slice(0, -1), + }); + expect(view.container.textContent).not.toContain("Googlecalendar"); +}); + +test("an app's call on a line of its own reads the same way, running or done", async () => { + const one = (answered: boolean) => [ + ASKED, + ...call( + "list-1", + LIST_EVENTS, + { timeMin: "2026-12-01" }, + answered ? EVENTS : undefined, + ), + ]; + const view = render(transcript(one(false), true)); + const line = (await view.findByText("List events")) + .parentElement as HTMLElement; + await waitFor(() => expect(line.textContent).toContain("Google Calendar")); + // The action, the app by its name, and "In progress" for a screen reader, which hears no shimmer. + expect(line.textContent).toBe("List eventsGoogle CalendarIn progress"); + expect(line.classList.contains("tool-line-running")).toBe(true); + expect(line.querySelector(".sr-only")?.textContent).toBe("In progress"); + expect(view.container.textContent).not.toContain("Googlecalendar"); + + view.rerender(transcript(one(true), true)); + await waitFor(() => + expect( + view + .getByText("List events") + .parentElement?.classList.contains("tool-line-running"), + ).toBe(false), + ); + const done = view.getByText("List events").parentElement; + expect(done?.textContent).toBe("List eventsGoogle Calendar"); + // Drawn as it was while running, less the running. + const running = new Set(["tool-line-running", "tabular-nums"]); + expect([...(done?.classList ?? [])]).toEqual( + [...line.classList].filter((name) => !running.has(name)), + ); +}); diff --git a/app/tests/approval-carry-on-running.test.tsx b/app/tests/approval-carry-on-running.test.tsx index dedb354f1b..fd7f5c69ed 100644 --- a/app/tests/approval-carry-on-running.test.tsx +++ b/app/tests/approval-carry-on-running.test.tsx @@ -280,7 +280,7 @@ function mounting() { } const STOP = '[data-testid="composer-stop"]'; -const WORKING = '.tool-line-running, [data-slot="live-connector-step"]'; +const WORKING = ".tool-line-running"; test("after Allow once, the conversation shows the Bot working until the server's turn ends", async () => { const view = mounting(); diff --git a/app/tests/approval-left-carry-on.test.tsx b/app/tests/approval-left-carry-on.test.tsx index 7b82d5bb27..645e381eb0 100644 --- a/app/tests/approval-left-carry-on.test.tsx +++ b/app/tests/approval-left-carry-on.test.tsx @@ -263,7 +263,7 @@ function mounting() { ); } -const WORKING = '.tool-line-running, [data-slot="live-connector-step"]'; +const WORKING = ".tool-line-running"; /** The person allows the DM, and the server carries the conversation on: shown as working. */ async function allowed(view: ReturnType) { diff --git a/app/tests/carry-on-carried-turn-browser.test.tsx b/app/tests/carry-on-carried-turn-browser.test.tsx index 65cdabcd6b..a0638e5511 100644 --- a/app/tests/carry-on-carried-turn-browser.test.tsx +++ b/app/tests/carry-on-carried-turn-browser.test.tsx @@ -643,7 +643,7 @@ describe.skipIf(!asked)("Carry on while the server carries a turn on", () => { // Allowed: the server carries the conversation on, and the Bot has the turn. await page.getByRole("button", { name: "Allow once" }).click(); await page - .locator('.tool-line-running, [data-slot="live-connector-step"]') + .locator(".tool-line-running") .first() .waitFor({ timeout: 15_000 }); diff --git a/app/tests/carry-on-while-busy.test.tsx b/app/tests/carry-on-while-busy.test.tsx index 4d2ea27141..025022364a 100644 --- a/app/tests/carry-on-while-busy.test.tsx +++ b/app/tests/carry-on-while-busy.test.tsx @@ -360,7 +360,7 @@ function mounting(idle = false) { ); } -const WORKING = '.tool-line-running, [data-slot="live-connector-step"]'; +const WORKING = ".tool-line-running"; test("Carry on pressed while the server still has the turn waits as a queued message, and is sent once when the turn ends", async () => { const view = mounting(); diff --git a/app/tests/reread-steps.test.tsx b/app/tests/reread-steps.test.tsx index b6815ebe43..25de27a407 100644 --- a/app/tests/reread-steps.test.tsx +++ b/app/tests/reread-steps.test.tsx @@ -2,7 +2,7 @@ import { afterAll, afterEach, beforeAll, expect, test } from "bun:test"; import type { Message } from "@ag-ui/core"; import { GlobalRegistrator } from "@happy-dom/global-registrator"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { cleanup, fireEvent, render } from "@testing-library/react"; +import { cleanup, fireEvent, render, within } from "@testing-library/react"; import { toVisibleChatItems } from "../src/components/channels/chat-messages"; import { groupToolSteps, @@ -134,7 +134,11 @@ test("while the last reread runs, the one row says it is rereading", () => { fireEvent(line, new Event("toggle")); expect(view.queryByRole("list", { name: "Working now" })).toBeNull(); expect(view.getByText("Rereading earlier results")).toBeDefined(); - expect(view.getByText("In progress")).toBeDefined(); + expect( + within(view.getByRole("list", { name: "Tool steps" })).getByText( + "In progress", + ), + ).toBeDefined(); expect(view.queryByText("Reread an earlier result")).toBeNull(); expect(view.container.querySelectorAll("ol > li")).toHaveLength(2); }); diff --git a/app/tests/running-step-shimmer.test.tsx b/app/tests/running-step-shimmer.test.tsx index 1fc52f8aba..2702665d7f 100644 --- a/app/tests/running-step-shimmer.test.tsx +++ b/app/tests/running-step-shimmer.test.tsx @@ -130,19 +130,29 @@ function transcript(messages: Message[], busy: boolean) { const SHIMMER = "tool-line-running"; -test("the running app step shows one progress indicator until it has an answer", async () => { +/** What a row says, as read: its icon is drawn, not read. */ +function said(row: HTMLElement): string { + const copy = row.cloneNode(true) as HTMLElement; + for (const hidden of copy.querySelectorAll("[aria-hidden]")) hidden.remove(); + return copy.textContent ?? ""; +} + +test("the running app step shimmers, beside the steps already done, until it has an answer", async () => { const view = render(transcript(run(false), true)); // Named as the app's page names it, not in its stored order ("Fetch message by thread id"). const running = await view.findByText("Fetch thread messages"); - const indicator = running.closest('[data-slot="live-connector-step"]'); - expect(indicator?.textContent).toContain("Gmail"); - expect(indicator?.textContent).toContain("In progress"); + expect(running.classList.contains(SHIMMER)).toBe(true); + // Its row says what the finished rows say, in the same order, and that it is under way. + const row = running.parentElement as HTMLElement; + expect(said(row)).toBe("Fetch thread messagesGmailIn progress"); // The steps already answered look as they always have. const finished = view.getAllByText("Fetch emails"); expect(finished).toHaveLength(4); - for (const step of finished) + for (const step of finished) { expect(step.classList.contains(SHIMMER)).toBe(false); + expect(step.parentElement?.className).toBe(row.className); + } // Answered: the step stays in the group and its progress indicator goes away. view.rerender(transcript(run(true), true)); diff --git a/app/tests/work-folded.test.tsx b/app/tests/work-folded.test.tsx index 58667d3ece..37ca6e8d95 100644 --- a/app/tests/work-folded.test.tsx +++ b/app/tests/work-folded.test.tsx @@ -267,7 +267,8 @@ test("a command still running shimmers on its line, and goes still when it is do const view = render(transcript(conversation([ranCommand("run-3")]), true)); const running = await foldOf(view, "Ran a command"); expect(running.open).toBe(false); - expect(lineOf(running)).toBe(`Running a command${COMMAND}`); + // A screen reader, which hears no shimmer, is told it is under way. + expect(lineOf(running)).toBe(`Running a command${COMMAND}In progress`); expect( running.querySelector("summary .tool-line-running")?.textContent, ).toContain("Running a command"); From dd763b01ea4bc2becf7d2eff8ea207e70741aa5a Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Fri, 4 Dec 2026 15:41:18 -0800 Subject: [PATCH 02/13] A run of steps on one app draws its logo once Three Google Calendar steps in a row drew three Google Calendar logos down one list. The first step of a run of steps with the same icon (the same app, or the same kind of step) draws it; the steps under it keep its room, empty, so their words stay lined up. Also in a subtask's list of steps. Co-Authored-By: Claude Opus 5.5 --- app/src/components/channels/subtask-step.tsx | 10 ++++- app/src/components/channels/tool-activity.tsx | 39 +++++++++++++++++-- app/tests/app-step-rows.test.tsx | 13 +++++-- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/app/src/components/channels/subtask-step.tsx b/app/src/components/channels/subtask-step.tsx index d826b3b93d..0c7033e6eb 100644 --- a/app/src/components/channels/subtask-step.tsx +++ b/app/src/components/channels/subtask-step.tsx @@ -13,6 +13,7 @@ import { StepIcon, StepOutput, StepRow, + sameIconAsAbove, stepDetails, } from "./tool-activity"; @@ -135,8 +136,13 @@ export function SubtaskStep({ {step.output ? : null} {steps.length ? (
    - {foldRereads(steps).map((inner) => ( - + {foldRereads(steps).map((inner, index, rows) => ( + ))}
) : null} diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index e547fc84f0..fb17912790 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -1364,13 +1364,37 @@ export function StepStatus({ return null; } +/** + * Whether the step at `index` draws the same icon as the one above it: the same app, or, for a step + * that is no app's, the same kind of step. + * + * ONE MARK FOR A RUN OF STEPS. A Bot listing a person's events drew the Google Calendar logo three + * times down one list, once on each of its steps, and the column of identical logos was the loudest + * thing on the screen while saying nothing new after the first. The mark is drawn on the first step + * of a run, as a conversation names who spoke once for several messages in a row, and the steps + * under it keep its room so their words stay lined up. + */ +export function sameIconAsAbove( + steps: readonly StepDetails[], + index: number, +): boolean { + const step = steps[index]; + const above = steps[index - 1]; + if (!step || !above) return false; + if (step.kind === "subtask" || above.kind === "subtask") return false; + return (step.appId ?? step.kind) === (above.appId ?? above.kind); +} + /** One step, as a folded line opens to it. Also how a subtask's card lists the steps it took. */ export function StepRow({ step, active, + iconAbove = false, }: { step: StepDetails; active: boolean; + /** The step above draws the same icon (`sameIconAsAbove`): this one keeps its room, empty. */ + iconAbove?: boolean; }) { if (step.kind === "subtask") return ; @@ -1387,7 +1411,11 @@ export function StepRow({ const running = active && step.pending; const line = ( - + {iconAbove ? ( + + ) : ( + + )} {step.label} @@ -1676,8 +1704,13 @@ export function ToolActivity({ rows.every((step) => step.kind === "connector"); const list = (
    - {rows.map((step) => ( - + {rows.map((step, index) => ( + ))}
); diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx index 6c1916a808..a6cf41af28 100644 --- a/app/tests/app-step-rows.test.tsx +++ b/app/tests/app-step-rows.test.tsx @@ -184,9 +184,16 @@ test("an app's step still running is drawn as its finished steps are: the action "List events", ); expect(listed.querySelector(".tool-line-running")).toBeNull(); - // Each with the app's own logo, as added. - for (const line of lines) - expect(line.querySelector("img")?.getAttribute("src")).toBe(APP.logo); + // The app's own logo, once for the run of its steps: the rows under it keep its room, empty. + expect(listed.querySelector("img")?.getAttribute("src")).toBe(APP.logo); + for (const line of [partRead, running]) { + expect(line.querySelector("img")).toBeNull(); + const room = line.firstElementChild; + expect(room?.getAttribute("aria-hidden")).toBe("true"); + expect(room?.className).toContain("size-4"); + expect(room?.childElementCount).toBe(0); + } + expect(listed.firstElementChild?.className).toContain("size-4"); // The app's key is never shown as its name. expect(view.container.textContent).not.toContain("Googlecalendar"); From 313d88553892db0a1bcd55c15422b4b99d30f9d2 Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Fri, 4 Dec 2026 16:03:48 -0800 Subject: [PATCH 03/13] A running line's text in the reduced-motion test includes "In progress" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A running ToolLine now also says "In progress" to a screen reader, so the line's text reads "Asked you…In progress" in the real-browser test. Co-Authored-By: Claude Opus 5.5 --- app/tests/tool-line-reduced-motion.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/tests/tool-line-reduced-motion.test.tsx b/app/tests/tool-line-reduced-motion.test.tsx index 189b9b4fa8..e3368b5d6f 100644 --- a/app/tests/tool-line-reduced-motion.test.tsx +++ b/app/tests/tool-line-reduced-motion.test.tsx @@ -139,8 +139,9 @@ for (const engine of engines) (probe) => getComputedStyle(probe).color, ); const lines = await painted(page); + // A running line also says "In progress" to a screen reader, which sees no shimmer. expect(lines.map((line) => line.text)).toEqual([ - "Asked youWhich city should I search?", + "Asked youWhich city should I search?In progress", "Asking Ana…", ]); for (const line of lines) { From 0a6997945f0b8499a737a4cb05c52dcbc29e81a9 Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Fri, 4 Dec 2026 20:37:29 -0800 Subject: [PATCH 04/13] An app leads its run of steps: named once, with what was done on it under it A run of steps on one app read "List events Google Calendar" on every row, the app's logo and name repeated down the list while the action was what set the rows apart. Now the app is the lead: its logo and name once, and each step under it says only what was done ("List events", "Read the next part of an answer List events, part 2 of 3"). - A folded line that already names the app ("Used Google Calendar") opens to its steps with no second lead. - In a "Worked through" fold, a run the Bot's words had split goes on under the app named just above it, so two "List events" sit under one "Google Calendar". - An app's call on a line of its own has the app over it, the same way. Co-Authored-By: Claude Opus 5.5 --- .../components/channels/chat-transcript.tsx | 48 ++++- app/src/components/channels/subtask-step.tsx | 12 +- app/src/components/channels/tool-activity.tsx | 203 ++++++++++++++++-- app/tests/app-step-rows.test.tsx | 77 ++++--- app/tests/long-answer-part-steps.test.tsx | 25 ++- app/tests/reread-steps.test.tsx | 44 ++-- app/tests/running-step-shimmer.test.tsx | 8 +- 7 files changed, 325 insertions(+), 92 deletions(-) diff --git a/app/src/components/channels/chat-transcript.tsx b/app/src/components/channels/chat-transcript.tsx index f5b76cc260..73e3f0fed6 100644 --- a/app/src/components/channels/chat-transcript.tsx +++ b/app/src/components/channels/chat-transcript.tsx @@ -35,7 +35,6 @@ import { type ComponentProps, type CSSProperties, createContext, - Fragment, memo, type ReactNode, useCallback, @@ -197,9 +196,12 @@ import { TeamBotConsentCard } from "./team-bot-consent"; import { ReplyToolbar } from "./telemetry-assistant-message"; import { ActivityAppMarks, + AppAbove, + AppLead, attachmentReadName, dropRepeatedAppCards, groupToolSteps, + rowApps, ServerStepIcon, ToolActivity, type ToolGroup, @@ -2136,6 +2138,8 @@ export function ServerToolLine({ !role && name.startsWith("mcp__") ? name.split("__")[1] : undefined; const folders = useContext(FolderNamesContext); const appName = useAppName(); + // Among a "Worked for" line's rows, the app the row above ends on: a run on it goes on unnamed. + const appAbove = useContext(AppAbove); // The file a file step read or saved, as a computer's own file steps name it; a step on a folder // on the person's computer names the folder too ("todo.txt in share"). An app's step names the // app as it was added here, "Google Calendar", as its steps folded together do (`useAppName`). @@ -2256,18 +2260,22 @@ export function ServerToolLine({ /> ); - return ( + /* + * An app's call leads with the app, and says what was done under it, as a run of an app's steps + * does (`AppRun`): the app is not said again beside the action. + */ + const app = appId ? appName(appId) : undefined; + const said = folderRefusal ?? (app && detail === app ? undefined : detail); + const line = ( } + {...(appId ? {} : { icon: })} label={label} refused={refused} failed={failed} @@ -2281,6 +2289,13 @@ export function ServerToolLine({ ) : null} ); + if (!appId || !app) return line; + return ( +
+ {appAbove === appId ? null : } +
{line}
+
+ ); } /** @@ -3168,11 +3183,22 @@ export function ChatTranscript({ threadId={taskThread ? threadId : undefined} work={work} > - {work.rows.map((row) => ( - - {rowContent(row.item, row.index, !taskThread)} - - ))} + {work.rows.map((row, at) => { + /* + * The Bot's words that split its steps are drawn outside the fold, so a run on one + * app goes on from the row above: under the same name, as close as its own steps. + */ + const above = work.rows[at - 1]; + const app = above ? rowApps(above.item).last : undefined; + const goesOn = + app !== undefined && rowApps(row.item).first === app; + const drawn = rowContent(row.item, row.index, !taskThread); + return ( + + {goesOn ?
{drawn}
: drawn} +
+ ); + })} ); diff --git a/app/src/components/channels/subtask-step.tsx b/app/src/components/channels/subtask-step.tsx index 0c7033e6eb..722dc42a44 100644 --- a/app/src/components/channels/subtask-step.tsx +++ b/app/src/components/channels/subtask-step.tsx @@ -12,8 +12,7 @@ import { type StepDetails, StepIcon, StepOutput, - StepRow, - sameIconAsAbove, + StepRows, stepDetails, } from "./tool-activity"; @@ -136,14 +135,7 @@ export function SubtaskStep({ {step.output ? : null} {steps.length ? (
    - {foldRereads(steps).map((inner, index, rows) => ( - - ))} +
) : null} diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index fb17912790..1a6e18756a 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -421,6 +421,11 @@ export type StepDetails = { label: string; /** What it was done to: a query, a page, a connector. Muted beside the label. */ detail?: string; + /** + * An app's step drawn under its app's name (`AppRun`): what it was done to with the app left out, + * since the row above names it. Unset where the detail was only the app. + */ + detailUnderApp?: string; href?: string; pending: boolean; failed: boolean; @@ -670,10 +675,12 @@ function detailsOf( // The app's own answer, read on: its step is the app's, as the app's read is ("Used Fireflies"). const app = appOfRead(args); const detail = partRead(args, part, appName); + const underApp = app ? partRead(args, part, appName, false) : undefined; return { ...outcome, label: readToolName(name, outcome.pending).label, ...(detail ? { detail } : {}), + ...(underApp ? { detailUnderApp: underApp } : {}), // What it was given is for the model: the read's tool name and arguments, and a number. inputs: [], pages: 0, @@ -753,10 +760,12 @@ function detailsOf( pages: Math.max(urls.length, 1), }; } + const shown = detail ? appDetail(detail, server, appName) : undefined; return { ...base, kind: "connector", - ...(detail ? { detail: appDetail(detail, server, appName) } : {}), + ...(shown ? { detail: shown } : {}), + ...(shown && shown !== appName(server) ? { detailUnderApp: shown } : {}), pages: 0, connector: appName(server), appId: server, @@ -796,20 +805,25 @@ function appOfRead(args: Record): string | undefined { return prefix === "mcp" && server ? server : undefined; } -/** The words beside a `read_result_part` step: see `readOf`. */ +/** + * The words beside a `read_result_part` step: see `readOf`. `withApp` false leaves the app out, for + * the step drawn under its app's name: "Get transcript, part 2 of 3". + */ function partRead( args: Record, part: { part?: number; parts?: number } | undefined, appName: AppName, + withApp = true, ): string | undefined { const whole = readOf(args); const read = whole ? readToolName(whole) : undefined; const app = appOfRead(args); - const on = read?.detail + const said = read?.detail ? app ? appDetail(read.detail, app, appName) : read.detail : undefined; + const on = withApp || !app || said !== appName(app) ? said : undefined; const named = read ? (on ? `${read.label} on ${on}` : read.label) : undefined; const number = part?.part ?? @@ -1385,16 +1399,160 @@ export function sameIconAsAbove( return (step.appId ?? step.kind) === (above.appId ?? above.kind); } +/** A list's steps: a run of steps on one app gathered under it (`AppRun`), any other step alone. */ +type StepRun = + | { kind: "app"; appId: string; steps: StepDetails[] } + | { kind: "step"; step: StepDetails; index: number }; + +function stepRuns(rows: readonly StepDetails[]): StepRun[] { + const runs: StepRun[] = []; + rows.forEach((step, index) => { + const last = runs.at(-1); + if (step.kind !== "connector" || !step.appId) + runs.push({ kind: "step", step, index }); + else if (last?.kind === "app" && last.appId === step.appId) + last.steps.push(step); + else runs.push({ kind: "app", appId: step.appId, steps: [step] }); + }); + return runs; +} + +/** + * An app, leading what was done on it: its logo and its name, the first thing on the line. + * + * THE APP LEADS ITS RUN. A run of steps on one app read "List events Google Calendar" three times + * down the list, the app's logo and name on every row, while what set the rows apart was the action. + * The app is said once, as a conversation names who spoke once for several messages in a row, and + * what was done on it is listed under it. + */ +export function AppLead({ appId, name }: { appId: string; name: string }) { + return ( +
+ + {name} +
+ ); +} + +/** + * The app the row above ends on, where rows are drawn as one list though they are not one group: a + * "Worked for" line gathers a turn's groups of steps, which the Bot's words between them had split, + * and draws them one under the other. A run of steps on that app goes on under its name, not under + * the same name again. + */ +export const AppAbove = createContext(undefined); + +/** The apps a row's first and last steps are on, as its list draws them (`AppRun`), or none. */ +export function rowApps(item: TranscriptItem): { + first?: string; + last?: string; +} { + const steps = + item.kind === "tools" + ? foldRereads(item.steps.map(stepDetails)) + : item.kind === "tool" + ? [stepDetails(item)] + : []; + const app = (step: StepDetails | undefined) => + step?.kind === "connector" ? step.appId : undefined; + return { first: app(steps[0]), last: app(steps.at(-1)) }; +} + +/** + * A run of steps on one app: the app (`AppLead`), and under it each step, as every step is drawn, + * less the app it would otherwise say again. Its steps line up under the app's name. A run that goes + * on from the row above (`AppAbove`), or under a line that already names the app, has no lead. + */ +function AppRun({ + appId, + steps, + active, + lead = "here", +}: { + appId: string; + steps: readonly StepDetails[]; + active: boolean; + /** + * Where the app is named: on a lead of the run's own, on the row above whose run this goes on (its + * steps stay lined up under that name), or on the folded line the list opens from. + */ + lead?: "here" | "above" | "line"; +}) { + const name = steps[0]?.connector ?? connectorName(appId); + return ( +
  • + {lead === "here" ? : null} +
      + {steps.map((step) => ( + + ))} +
    +
  • + ); +} + +/** + * The rows of a list of steps: each run of an app's steps under the app, every other step alone. + * `appAbove`: the app already named just above the list, whose run its first steps go on. + */ +export function StepRows({ + rows, + active, + appAbove, + appOnLine = false, +}: { + rows: readonly StepDetails[]; + active: boolean; + appAbove?: string; + /** `appAbove` is named on the folded line the list opens from, not on a row above it. */ + appOnLine?: boolean; +}) { + return ( + <> + {stepRuns(rows).map((run, index) => + run.kind === "app" ? ( + + ) : ( + + ), + )} + + ); +} + /** One step, as a folded line opens to it. Also how a subtask's card lists the steps it took. */ export function StepRow({ step, active, iconAbove = false, + underApp = false, }: { step: StepDetails; active: boolean; /** The step above draws the same icon (`sameIconAsAbove`): this one keeps its room, empty. */ iconAbove?: boolean; + /** Drawn under its app's name (`AppRun`): no icon, and the app is not said again. */ + underApp?: boolean; }) { if (step.kind === "subtask") return ; @@ -1409,9 +1567,10 @@ export function StepRow({ * row, shimmering, with "In progress" where "Blocked" or "Didn't work" would be. */ const running = active && step.pending; + const detail = underApp ? step.detailUnderApp : step.detail; const line = ( - {iconAbove ? ( + {underApp ? null : iconAbove ? ( ) : ( @@ -1426,10 +1585,10 @@ export function StepRow({ rel="noopener noreferrer" className="truncate text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-current" > - {step.detail ?? step.href} + {detail ?? step.href} - ) : step.detail ? ( - {step.detail} + ) : detail ? ( + {detail} ) : null} @@ -1702,16 +1861,30 @@ export function ToolActivity({ inFlight && rows.some((step) => step.pending && !step.interrupted) && rows.every((step) => step.kind === "connector"); + /* + * The app already named above the list, which its first run goes on without naming again: drawn + * open among a "Worked for" line's rows, the app the row above ends on (`AppAbove`); folded, the + * group's own line, when every step is on one app ("Used Google Calendar"). + */ + const rowAbove = useContext(AppAbove); + const onlyApp = rows[0]?.appId; + const appAbove = + expanded || showLiveSteps + ? rowAbove + : onlyApp && + rows.every( + (step) => step.kind === "connector" && step.appId === onlyApp, + ) + ? onlyApp + : undefined; const list = (
      - {rows.map((step, index) => ( - - ))} +
    ); const approvals = ( diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx index a6cf41af28..ee287afd5c 100644 --- a/app/tests/app-step-rows.test.tsx +++ b/app/tests/app-step-rows.test.tsx @@ -3,7 +3,13 @@ import type { Message } from "@ag-ui/core"; import { CopilotKitProvider } from "@copilotkit/react-core/v2"; import { GlobalRegistrator } from "@happy-dom/global-registrator"; import { QueryClientProvider } from "@tanstack/react-query"; -import { cleanup, fireEvent, render, waitFor } from "@testing-library/react"; +import { + cleanup, + fireEvent, + render, + waitFor, + within, +} from "@testing-library/react"; import { ChatTranscript } from "@/components/channels/chat-transcript"; import { forgetOpenedLines } from "@/components/channels/tool-line"; import { queryClient } from "@/query-client"; @@ -11,14 +17,14 @@ import { approvalInboxResponse } from "./approvals-api"; import { settleReactWork } from "./settle-react-work"; /** - * An app's steps are drawn one way, running or done, and name the app as it was added. + * An app's steps are drawn one way, running or done, under the app's name as it was added. * * Reported from the web app, on a Bot listing a person's events: three Google Calendar steps in a * row, drawn three ways. The two finished ones read "List events" beside "Googlecalendar", the app's * key, while the one still running sat in a box of its own, the app first, "Google Calendar · List * events", with a spinner. The box said nothing the row does not: the action, the app, and that it - * was still going. So every step is one row, the action and then the app, by the name the person - * added it under, and a running one differs from a finished one only in that it is running. + * was still going. So the app is named once, by the name the person added it under and beside its + * logo, and its steps are listed under it, one row each, the same row whether it is running or done. */ const originalFetch = globalThis.fetch; @@ -155,13 +161,18 @@ function shapeOf(line: Element) { }; } -test("an app's step still running is drawn as its finished steps are: the action, then the app by its name", async () => { +test("an app's step still running is drawn as its finished steps are, all under the app's name", async () => { const view = render(transcript(turn(false), true)); - // The steps under way are listed, one row each, while the turn runs. + // The steps under way are listed while the turn runs: the app once, its steps under it. const steps = await view.findByRole("list", { name: "Tool steps" }); - await waitFor(() => expect(steps.textContent).toContain("Google Calendar")); - const rows = [...steps.querySelectorAll(":scope > li")]; + const run = await within(steps).findByRole("list", { + name: "Steps on Google Calendar", + }); + const lead = run.previousElementSibling as Element; + expect(lead.textContent).toBe("Google Calendar"); + expect(lead.querySelector("img")?.getAttribute("src")).toBe(APP.logo); + const rows = [...run.querySelectorAll(":scope > li")]; expect(rows).toHaveLength(3); const lines = rows.map( (row) => row.querySelector("summary > span:last-child") as Element, @@ -169,12 +180,12 @@ test("an app's step still running is drawn as its finished steps are: the action const [listed, partRead, running] = lines; if (!listed || !partRead || !running) throw new Error("Expected 3 lines"); - // The action first and the app after it, finished or running, the app by its added name. - expect(listed.textContent).toBe("List eventsGoogle Calendar"); + // Under its app, a step says what was done, finished or running, and not the app again. + expect(listed.textContent).toBe("List events"); expect(partRead.textContent).toBe( - "Read the next part of an answerList events on Google Calendar, part 2 of 3", + "Read the next part of an answerList events, part 2 of 3", ); - expect(running.textContent).toBe("List eventsGoogle CalendarIn progress"); + expect(running.textContent).toBe("List eventsIn progress"); // One shape: no box, no app before the action, the same parts in the same order. const done = shapeOf(listed); @@ -184,16 +195,8 @@ test("an app's step still running is drawn as its finished steps are: the action "List events", ); expect(listed.querySelector(".tool-line-running")).toBeNull(); - // The app's own logo, once for the run of its steps: the rows under it keep its room, empty. - expect(listed.querySelector("img")?.getAttribute("src")).toBe(APP.logo); - for (const line of [partRead, running]) { - expect(line.querySelector("img")).toBeNull(); - const room = line.firstElementChild; - expect(room?.getAttribute("aria-hidden")).toBe("true"); - expect(room?.className).toContain("size-4"); - expect(room?.childElementCount).toBe(0); - } - expect(listed.firstElementChild?.className).toContain("size-4"); + // The app's logo is drawn once, beside its name: the rows under it draw none. + for (const line of lines) expect(line.querySelector("img")).toBeNull(); // The app's key is never shown as its name. expect(view.container.textContent).not.toContain("Googlecalendar"); @@ -202,10 +205,11 @@ test("an app's step still running is drawn as its finished steps are: the action test("answered, the step stops running and nothing else about it changes", async () => { const view = render(transcript(turn(false), true)); - const steps = await view.findByRole("list", { name: "Tool steps" }); - await waitFor(() => expect(steps.textContent).toContain("Google Calendar")); + const run = await view.findByRole("list", { + name: "Steps on Google Calendar", + }); const before = shapeOf( - steps.querySelector( + run.querySelector( ":scope > li:last-child summary > span:last-child", ) as Element, ); @@ -214,12 +218,15 @@ test("answered, the step stops running and nothing else about it changes", async view.rerender(transcript(turn(true), true)); const fold = await view.findByText("Used Google Calendar"); fireEvent.click(fold); - const after = view.getByRole("list", { name: "Tool steps" }); + // Opened, the steps sit under the line that names the app, which is not named again over them. + const after = view.getByRole("list", { name: "Steps on Google Calendar" }); + expect(after.previousElementSibling).toBeNull(); + expect(view.queryByText("Google Calendar")).toBeNull(); expect(after.querySelector(".tool-line-running")).toBeNull(); const last = after.querySelector( ":scope > li:last-child summary > span:last-child", ) as Element; - expect(last.textContent).toBe("List eventsGoogle Calendar"); + expect(last.textContent).toBe("List events"); expect(shapeOf(last)).toEqual({ ...before, parts: before.parts.slice(0, -1), @@ -240,9 +247,16 @@ test("an app's call on a line of its own reads the same way, running or done", a const view = render(transcript(one(false), true)); const line = (await view.findByText("List events")) .parentElement as HTMLElement; - await waitFor(() => expect(line.textContent).toContain("Google Calendar")); - // The action, the app by its name, and "In progress" for a screen reader, which hears no shimmer. - expect(line.textContent).toBe("List eventsGoogle CalendarIn progress"); + // The app leads, by its name and beside its logo, and the call is the line under it. + const lead = await view.findByText("Google Calendar"); + expect(lead.parentElement?.querySelector("img")?.getAttribute("src")).toBe( + APP.logo, + ); + expect( + lead.compareDocumentPosition(line) & Node.DOCUMENT_POSITION_FOLLOWING, + ).toBeTruthy(); + // The action, and "In progress" for a screen reader, which hears no shimmer. + expect(line.textContent).toBe("List eventsIn progress"); expect(line.classList.contains("tool-line-running")).toBe(true); expect(line.querySelector(".sr-only")?.textContent).toBe("In progress"); expect(view.container.textContent).not.toContain("Googlecalendar"); @@ -256,7 +270,8 @@ test("an app's call on a line of its own reads the same way, running or done", a ).toBe(false), ); const done = view.getByText("List events").parentElement; - expect(done?.textContent).toBe("List eventsGoogle Calendar"); + expect(done?.textContent).toBe("List events"); + expect(view.getAllByText("Google Calendar")).toHaveLength(1); // Drawn as it was while running, less the running. const running = new Set(["tool-line-running", "tabular-nums"]); expect([...(done?.classList ?? [])]).toEqual( diff --git a/app/tests/long-answer-part-steps.test.tsx b/app/tests/long-answer-part-steps.test.tsx index f4b3c66af3..aedff6c6fd 100644 --- a/app/tests/long-answer-part-steps.test.tsx +++ b/app/tests/long-answer-part-steps.test.tsx @@ -119,13 +119,19 @@ function openSteps(view: ReturnType) { /** Each step's own line, as it reads with nothing opened. */ function lines(view: ReturnType): (string | null)[] { - return [...view.container.querySelectorAll("ol > li")].map((row) => { - const line = (row.querySelector("summary") ?? row).cloneNode( - true, - ) as Element; + return [...view.container.querySelectorAll("ol > li")].flatMap((row) => { + // A run of an app's steps: its own line is the app's name, where it leads; its steps follow. + const run = row.querySelector(":scope > ol"); + const shown = run + ? run === row.firstElementChild + ? null + : row.firstElementChild + : (row.querySelector("summary") ?? row); + if (!shown) return []; + const line = shown.cloneNode(true) as Element; for (const decoration of line.querySelectorAll("[aria-hidden]")) decoration.remove(); - return line.textContent; + return [line.textContent]; }); } @@ -170,10 +176,11 @@ for (const [who, tool] of [ expect(shown).not.toContain("fireflies__fireflies_get_transcript"); // The folded line counts the reads as the app's: they are its answer, read on. expect(view.getByText("Used Fireflies")).toBeDefined(); - // Each read says, in words, which answer it read on in and which part. + // Each read says, in words, which answer it read on in and which part, under the line that + // names the app. expect(lines(view)).toEqual([ - "Get transcriptFireflies", - "Read the next part of an answerGet transcript on Fireflies, part 2 of 3", - "Read the next part of an answerGet transcript on Fireflies, part 3 of 3", + "Get transcript", + "Read the next part of an answerGet transcript, part 2 of 3", + "Read the next part of an answerGet transcript, part 3 of 3", ]); }); diff --git a/app/tests/reread-steps.test.tsx b/app/tests/reread-steps.test.tsx index 25de27a407..a0dc0db2a0 100644 --- a/app/tests/reread-steps.test.tsx +++ b/app/tests/reread-steps.test.tsx @@ -79,6 +79,23 @@ function drawRow(messages: Message[], active: boolean) { ); } +/** Each line as read, top to bottom: an app's name over its run of steps, then each step's line. */ +function lines(view: ReturnType): (string | null)[] { + return [...view.container.querySelectorAll("ol > li")].flatMap((row) => { + const run = row.querySelector(":scope > ol"); + const shown = run + ? run === row.firstElementChild + ? null + : row.firstElementChild + : (row.querySelector("summary") ?? row); + if (!shown) return []; + const line = shown.cloneNode(true) as Element; + for (const decoration of line.querySelectorAll("[aria-hidden]")) + decoration.remove(); + return [line.textContent]; + }); +} + test("a run of rereads is one row that counts them, and a different step between two runs splits them", () => { const view = drawRow( [ @@ -101,21 +118,16 @@ test("a run of rereads is one row that counts them, and a different step between expect(view.getByText("Reread 3 earlier results")).toBeDefined(); // One on its own keeps its own words. expect(view.getAllByText("Reread an earlier result")).toHaveLength(1); - // Each row's own line, as it reads with nothing opened. - const rows = [...view.container.querySelectorAll("ol > li")].map((row) => { - const line = (row.querySelector("summary") ?? row).cloneNode( - true, - ) as Element; - for (const decoration of line.querySelectorAll("[aria-hidden]")) - decoration.remove(); - return line.textContent; - }); - expect(rows).toEqual([ - "Fetch emailsGmail", + // Each row's own line, as it reads with nothing opened: each Gmail step under the app's name. + expect(lines(view)).toEqual([ + "Gmail", + "Fetch emails", "Reread 12 earlier results", - "Fetch emailsGmail", + "Gmail", + "Fetch emails", "Reread 3 earlier results", - "Fetch emailsGmail", + "Gmail", + "Fetch emails", "Reread an earlier result", ]); }); @@ -140,5 +152,9 @@ test("while the last reread runs, the one row says it is rereading", () => { ), ).toBeDefined(); expect(view.queryByText("Reread an earlier result")).toBeNull(); - expect(view.container.querySelectorAll("ol > li")).toHaveLength(2); + expect(lines(view)).toEqual([ + "Gmail", + "Fetch emails", + "Rereading earlier resultsIn progress", + ]); }); diff --git a/app/tests/running-step-shimmer.test.tsx b/app/tests/running-step-shimmer.test.tsx index 2702665d7f..d9a6d888f7 100644 --- a/app/tests/running-step-shimmer.test.tsx +++ b/app/tests/running-step-shimmer.test.tsx @@ -143,9 +143,13 @@ test("the running app step shimmers, beside the steps already done, until it has // Named as the app's page names it, not in its stored order ("Fetch message by thread id"). const running = await view.findByText("Fetch thread messages"); expect(running.classList.contains(SHIMMER)).toBe(true); - // Its row says what the finished rows say, in the same order, and that it is under way. + // Its row says what the finished rows say, in the same order, and that it is under way, under + // the app's name with them. const row = running.parentElement as HTMLElement; - expect(said(row)).toBe("Fetch thread messagesGmailIn progress"); + expect(said(row)).toBe("Fetch thread messagesIn progress"); + expect(view.getByRole("list", { name: "Steps on Gmail" }).contains(row)).toBe( + true, + ); // The steps already answered look as they always have. const finished = view.getAllByText("Fetch emails"); expect(finished).toHaveLength(4); From 17f2e5bddd30d471a2a2b9db930a1232a8c33cbb Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Fri, 4 Dec 2026 22:50:33 -0800 Subject: [PATCH 05/13] A run of one app's steps is that app's line, and rows show its logo, not its name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the nested "app leads its run" rows with what Atai settled on: - While a step runs, a run of one app's steps is one line, "Using Google Calendar…", shimmering and folded, as it already was once done ("Used Google Calendar"). Opened, it lists one row per step. The open live list (`showLiveSteps`) and the `conversation` prop it needed are gone. - A row says what was done, not the app's name after it. Under a line that already shows its one app (`LineShowsApp`), rows draw no logo. Where the steps are on several apps, each row draws its app's logo (`AppMark`), which shows the app's name on hover and is what a screen reader hears. - In a "Worked through" line, a lone app call is drawn as a step row like the others, and app rows the Bot's words had split sit 8px apart as one list's steps do. - Rows line up: a step that doesn't open keeps the chevron's room where others open, a step row is spaced as a line of its own is, and an opened list of steps is drawn at one size everywhere. Co-Authored-By: Claude Opus 5.5 --- .../components/channels/chat-transcript.tsx | 116 +++--- app/src/components/channels/subtask-step.tsx | 14 +- app/src/components/channels/tool-activity.tsx | 354 ++++++++---------- app/tests/app-step-rows.test.tsx | 235 ++++++++++-- app/tests/long-answer-part-steps.test.tsx | 21 +- app/tests/reread-steps.test.tsx | 38 +- app/tests/running-step-shimmer.test.tsx | 19 +- app/tests/tool-result-parts.test.tsx | 3 +- app/tests/work-folded.test.tsx | 5 +- 9 files changed, 466 insertions(+), 339 deletions(-) diff --git a/app/src/components/channels/chat-transcript.tsx b/app/src/components/channels/chat-transcript.tsx index 73e3f0fed6..6a67b8d3c9 100644 --- a/app/src/components/channels/chat-transcript.tsx +++ b/app/src/components/channels/chat-transcript.tsx @@ -35,6 +35,7 @@ import { type ComponentProps, type CSSProperties, createContext, + Fragment, memo, type ReactNode, useCallback, @@ -196,11 +197,13 @@ import { TeamBotConsentCard } from "./team-bot-consent"; import { ReplyToolbar } from "./telemetry-assistant-message"; import { ActivityAppMarks, - AppAbove, - AppLead, + AppMark, + appOfCall, attachmentReadName, dropRepeatedAppCards, groupToolSteps, + LineShowsApp, + onlyApp, rowApps, ServerStepIcon, ToolActivity, @@ -2031,8 +2034,9 @@ type ToolRowProps = { latest: boolean; /** The Bot said something after this row in its turn. See `ToolPlace`. */ spokeAfter: boolean; - conversation?: boolean; expanded?: boolean; + /** A run of calls drawn as plain lines (a `tools` group), which folds, even a run of one. */ + folds?: boolean; }; /** @@ -2049,8 +2053,8 @@ export function sameToolRow(a: ToolRowProps, b: ToolRowProps): boolean { a.inFlight === b.inFlight && a.latest === b.latest && a.spokeAfter === b.spokeAfter && - a.conversation === b.conversation && a.expanded === b.expanded && + a.folds === b.folds && a.steps.length === b.steps.length && a.steps.every((step, index) => { const other = b.steps[index]; @@ -2072,8 +2076,8 @@ const ToolRow = memo(function ToolRow({ inFlight, latest, spokeAfter, - conversation, expanded, + folds, }: ToolRowProps) { const [only] = steps; useReportsDesktopActivity(steps, active); @@ -2083,6 +2087,9 @@ const ToolRow = memo(function ToolRow({ {steps.length === 1 && only && !isBrowserStep(only) && + // Drawn open among a "Worked for" line's rows, a lone app call is a step as theirs are, not + // a muted line of its own beside them (`ToolActivity`). + !(expanded && folds && appOfCall(only.toolCall.function.name)) && // A subtask is drawn as work even alone, so a second call joining it does not change its shape. only.toolCall.function.name !== SUBAGENT_TOOL ? ( @@ -2098,7 +2105,6 @@ const ToolRow = memo(function ToolRow({ ) : ( @@ -2138,14 +2144,14 @@ export function ServerToolLine({ !role && name.startsWith("mcp__") ? name.split("__")[1] : undefined; const folders = useContext(FolderNamesContext); const appName = useAppName(); - // Among a "Worked for" line's rows, the app the row above ends on: a run on it goes on unnamed. - const appAbove = useContext(AppAbove); + // On the one app the folded line above it shows (`LineShowsApp`), it doesn't draw its logo again. + const lineShows = useContext(LineShowsApp); // The file a file step read or saved, as a computer's own file steps name it; a step on a folder - // on the person's computer names the folder too ("todo.txt in share"). An app's step names the - // app as it was added here, "Google Calendar", as its steps folded together do (`useAppName`). + // on the person's computer names the folder too ("todo.txt in share"). An app's step doesn't say + // its app's name: its logo does, and names it on hover (`AppMark`). const detail = (appId && (named.detail === appId || named.detail === connectorName(appId)) - ? appName(appId) + ? undefined : named.detail) ?? folderStepSubject(name, args, folders) ?? ownToolSubject(name, args) ?? @@ -2260,22 +2266,26 @@ export function ServerToolLine({ /> ); - /* - * An app's call leads with the app, and says what was done under it, as a run of an app's steps - * does (`AppRun`): the app is not said again beside the action. - */ - const app = appId ? appName(appId) : undefined; - const said = folderRefusal ?? (app && detail === app ? undefined : detail); - const line = ( + return ( })} + {...(appId && appId === lineShows + ? {} + : { + icon: appId ? ( + + ) : ( + + ), + })} label={label} refused={refused} failed={failed} @@ -2289,13 +2299,6 @@ export function ServerToolLine({ ) : null} ); - if (!appId || !app) return line; - return ( -
    - {appAbove === appId ? null : } -
    {line}
    -
    - ); } /** @@ -2619,6 +2622,21 @@ function TranscriptRenderersWatch({ ); } +/** + * How far a row of app steps is drawn up under one drawn like it, so the two sit as two steps of one + * list do, 8px apart: a "Worked for" line's rows are 12px apart, and an open list of steps keeps 4px + * above and below it, a call on a line of its own 6px. + */ +const JOINED = { list: "-mt-3", line: "-mt-4" } as const; + +/** + * Whether a row with an app's steps is drawn as an open list of them or as one call's line: in a + * "Worked for" line, a run of them is a list, a lone one in a run included (`ToolRow`). + */ +function stepsShape(item: TranscriptItem): "list" | "line" { + return item.kind === "tools" ? "list" : "line"; +} + export function ChatTranscript({ threadId, busy = false, @@ -3124,8 +3142,8 @@ export function ChatTranscript({ > = turnStart} latest={index >= latestIndex} @@ -3183,22 +3201,32 @@ export function ChatTranscript({ threadId={taskThread ? threadId : undefined} work={work} > - {work.rows.map((row, at) => { - /* - * The Bot's words that split its steps are drawn outside the fold, so a run on one - * app goes on from the row above: under the same name, as close as its own steps. - */ - const above = work.rows[at - 1]; - const app = above ? rowApps(above.item).last : undefined; - const goesOn = - app !== undefined && rowApps(row.item).first === app; - const drawn = rowContent(row.item, row.index, !taskThread); - return ( - - {goesOn ?
    {drawn}
    : drawn} -
    - ); - })} + row.item))} + > + {work.rows.map((row, at) => { + // App steps the Bot's words had split into rows of their own sit as one list: its + // words are drawn outside this line, and the gap they left says nothing in here. Only + // rows drawn alike: a call on a line of its own is a muted line, a list's steps aren't. + const above = work.rows[at - 1]; + const shape = stepsShape(row.item); + const joins = + above !== undefined && + stepsShape(above.item) === shape && + rowApps(above.item).last !== undefined && + rowApps(row.item).first !== undefined; + const drawn = rowContent(row.item, row.index, !taskThread); + return ( + + {joins ? ( +
    {drawn}
    + ) : ( + drawn + )} +
    + ); + })} +
    ); diff --git a/app/src/components/channels/subtask-step.tsx b/app/src/components/channels/subtask-step.tsx index 722dc42a44..0766d268d9 100644 --- a/app/src/components/channels/subtask-step.tsx +++ b/app/src/components/channels/subtask-step.tsx @@ -12,8 +12,9 @@ import { type StepDetails, StepIcon, StepOutput, - StepRows, + StepRow, stepDetails, + stepOpens, } from "./tool-activity"; type ToolItem = Extract; @@ -134,8 +135,15 @@ export function SubtaskStep({ {handedBack ? : null} {step.output ? : null} {steps.length ? ( -
      - +
        + {foldRereads(steps).map((inner, _, rows) => ( + + ))}
      ) : null} diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index 1a6e18756a..29cd6e2039 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -64,6 +64,11 @@ import { PluginLogo, } from "@/components/plugins/plugin-logo"; import { settingsToolCardFor } from "@/components/settings-tools/settings-tool-card"; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/ui/tooltip"; import { useOverflows } from "@/hooks/use-overflows"; import { appsQueryOptions } from "@/lib/apps/queries"; import { readOutcome } from "@/lib/computers/activity"; @@ -421,11 +426,6 @@ export type StepDetails = { label: string; /** What it was done to: a query, a page, a connector. Muted beside the label. */ detail?: string; - /** - * An app's step drawn under its app's name (`AppRun`): what it was done to with the app left out, - * since the row above names it. Unset where the detail was only the app. - */ - detailUnderApp?: string; href?: string; pending: boolean; failed: boolean; @@ -674,13 +674,12 @@ function detailsOf( if (name === READ_RESULT_PART) { // The app's own answer, read on: its step is the app's, as the app's read is ("Used Fireflies"). const app = appOfRead(args); - const detail = partRead(args, part, appName); - const underApp = app ? partRead(args, part, appName, false) : undefined; + // Its app is its logo (`AppMark`), as on every app step: "List events, part 2 of 3". + const detail = partRead(args, part, appName, false); return { ...outcome, label: readToolName(name, outcome.pending).label, ...(detail ? { detail } : {}), - ...(underApp ? { detailUnderApp: underApp } : {}), // What it was given is for the model: the read's tool name and arguments, and a number. inputs: [], pages: 0, @@ -760,12 +759,12 @@ function detailsOf( pages: Math.max(urls.length, 1), }; } + // Words beside the action that were only the app's name go: the row's logo says it (`AppMark`). const shown = detail ? appDetail(detail, server, appName) : undefined; return { ...base, kind: "connector", - ...(shown ? { detail: shown } : {}), - ...(shown && shown !== appName(server) ? { detailUnderApp: shown } : {}), + ...(shown && shown !== appName(server) ? { detail: shown } : {}), pages: 0, connector: appName(server), appId: server, @@ -806,8 +805,8 @@ function appOfRead(args: Record): string | undefined { } /** - * The words beside a `read_result_part` step: see `readOf`. `withApp` false leaves the app out, for - * the step drawn under its app's name: "Get transcript, part 2 of 3". + * The words beside a `read_result_part` step: see `readOf`. `withApp` false leaves the app out, for a + * row whose logo says it: "Get transcript, part 2 of 3". */ function partRead( args: Record, @@ -823,6 +822,7 @@ function partRead( ? appDetail(read.detail, app, appName) : read.detail : undefined; + // `withApp` false: the app is left out where its logo already says it (`AppMark`). const on = withApp || !app || said !== appName(app) ? said : undefined; const named = read ? (on ? `${read.label} on ${on}` : read.label) : undefined; const number = @@ -1322,6 +1322,11 @@ function IconStack({ marks }: { marks: { kind: StepKind; appId?: string }[] }) { ); } +/** The app a call is a step on (`mcp__googlecalendar__list_events`), or none for any other call. */ +export function appOfCall(name: string): string | undefined { + return serverStepKind(name) === "connector" ? name.split("__")[1] : undefined; +} + /** The kind of step a call the server ran is, as `stepDetails` names it: research, an app, or one of ours. */ function serverStepKind(name: string): StepKind { // A part of an attached file read: a file, as the folded row draws it. @@ -1379,180 +1384,120 @@ export function StepStatus({ } /** - * Whether the step at `index` draws the same icon as the one above it: the same app, or, for a step - * that is no app's, the same kind of step. + * The one app every step under a folded line is on, which that line already shows ("Used Google + * Calendar", or "Worked through 2 steps" beside Google Calendar's logo). Its steps don't draw its + * logo again. * - * ONE MARK FOR A RUN OF STEPS. A Bot listing a person's events drew the Google Calendar logo three - * times down one list, once on each of its steps, and the column of identical logos was the loudest - * thing on the screen while saying nothing new after the first. The mark is drawn on the first step - * of a run, as a conversation names who spoke once for several messages in a row, and the steps - * under it keep its room so their words stay lined up. + * ONE LOGO FOR ONE APP. Opened, "Used Google Calendar" listed three steps, each beside the Google + * Calendar logo the line above them had just drawn: the same mark four times, telling nothing the + * first didn't. Where the steps are on several apps, each still draws its own, since that is how + * they are told apart. */ -export function sameIconAsAbove( - steps: readonly StepDetails[], - index: number, -): boolean { - const step = steps[index]; - const above = steps[index - 1]; - if (!step || !above) return false; - if (step.kind === "subtask" || above.kind === "subtask") return false; - return (step.appId ?? step.kind) === (above.appId ?? above.kind); -} +export const LineShowsApp = createContext(undefined); -/** A list's steps: a run of steps on one app gathered under it (`AppRun`), any other step alone. */ -type StepRun = - | { kind: "app"; appId: string; steps: StepDetails[] } - | { kind: "step"; step: StepDetails; index: number }; - -function stepRuns(rows: readonly StepDetails[]): StepRun[] { - const runs: StepRun[] = []; - rows.forEach((step, index) => { - const last = runs.at(-1); - if (step.kind !== "connector" || !step.appId) - runs.push({ kind: "step", step, index }); - else if (last?.kind === "app" && last.appId === step.appId) - last.steps.push(step); - else runs.push({ kind: "app", appId: step.appId, steps: [step] }); - }); - return runs; +/** The one app every step in `items` is on, or none if any step is another app's or none's. */ +export function onlyApp(items: readonly TranscriptItem[]): string | undefined { + const apps = new Set(); + for (const item of items) { + if (item.kind === "tool") apps.add(appOfCall(item.toolCall.function.name)); + else if (item.kind === "tools") + for (const step of item.steps.map(stepDetails)) + apps.add(step.kind === "connector" ? step.appId : undefined); + else return undefined; + } + const [app] = apps; + return apps.size === 1 ? app : undefined; } /** - * An app, leading what was done on it: its logo and its name, the first thing on the line. + * An app's logo on a step's row, which says the app's name when the pointer rests on it, and to a + * screen reader. * - * THE APP LEADS ITS RUN. A run of steps on one app read "List events Google Calendar" three times - * down the list, the app's logo and name on every row, while what set the rows apart was the action. - * The app is said once, as a conversation names who spoke once for several messages in a row, and - * what was done on it is listed under it. + * THE LOGO SAYS THE APP. Every app step read "List events Google Calendar", "Search messages + * Slack": the app's name again after every action, beside the logo that already said it. The row + * now says what was done, and its logo which app it was done on; the name is there on hover for a + * logo someone doesn't know. */ -export function AppLead({ appId, name }: { appId: string; name: string }) { +export function AppMark({ appId, name }: { appId: string; name: string }) { return ( -
      - - {name} -
      + + } + > + + + {name} + ); } /** - * The app the row above ends on, where rows are drawn as one list though they are not one group: a - * "Worked for" line gathers a turn's groups of steps, which the Bot's words between them had split, - * and draws them one under the other. A run of steps on that app goes on under its name, not under - * the same name again. + * A step's mark: an app's logo named on hover (`AppMark`), or the icon for its kind of step. None for + * a step on the app the line above it already shows (`LineShowsApp`). */ -export const AppAbove = createContext(undefined); - -/** The apps a row's first and last steps are on, as its list draws them (`AppRun`), or none. */ -export function rowApps(item: TranscriptItem): { - first?: string; - last?: string; -} { - const steps = - item.kind === "tools" - ? foldRereads(item.steps.map(stepDetails)) - : item.kind === "tool" - ? [stepDetails(item)] - : []; - const app = (step: StepDetails | undefined) => - step?.kind === "connector" ? step.appId : undefined; - return { first: app(steps[0]), last: app(steps.at(-1)) }; +function StepMark({ step }: { step: StepDetails }) { + const shown = useContext(LineShowsApp); + if (step.kind === "connector" && step.appId && step.appId === shown) + return null; + return step.kind === "connector" && step.appId ? ( + + ) : ( + + ); } /** - * A run of steps on one app: the app (`AppLead`), and under it each step, as every step is drawn, - * less the app it would otherwise say again. Its steps line up under the app's name. A run that goes - * on from the row above (`AppAbove`), or under a line that already names the app, has no lead. + * Whether a step's row opens (`StepRow`): a subtask to its steps, a command to its terminal, and any + * other step but a browser one to what it was given and what came back, when it has either. */ -function AppRun({ - appId, - steps, - active, - lead = "here", -}: { - appId: string; - steps: readonly StepDetails[]; - active: boolean; - /** - * Where the app is named: on a lead of the run's own, on the row above whose run this goes on (its - * steps stay lined up under that name), or on the folded line the list opens from. - */ - lead?: "here" | "above" | "line"; -}) { - const name = steps[0]?.connector ?? connectorName(appId); +export function stepOpens(step: StepDetails): boolean { + if (step.kind === "subtask" || step.terminal) return true; return ( -
    1. - {lead === "here" ? : null} -
        - {steps.map((step) => ( - - ))} -
      -
    2. + step.kind !== "browser" && (step.inputs.length > 0 || Boolean(step.output)) ); } /** - * The rows of a list of steps: each run of an app's steps under the app, every other step alone. - * `appAbove`: the app already named just above the list, whose run its first steps go on. + * The apps a row of steps starts and ends on: a list of steps by its first and last, an app's call + * on a line of its own by its app. None for any other row, or a step that is no app's. */ -export function StepRows({ - rows, - active, - appAbove, - appOnLine = false, -}: { - rows: readonly StepDetails[]; - active: boolean; - appAbove?: string; - /** `appAbove` is named on the folded line the list opens from, not on a row above it. */ - appOnLine?: boolean; -}) { - return ( - <> - {stepRuns(rows).map((run, index) => - run.kind === "app" ? ( - - ) : ( - - ), - )} - - ); +export function rowApps(item: TranscriptItem): { + first?: string; + last?: string; +} { + const lone = + item.kind === "tool" + ? item + : item.kind === "tools" && item.steps.length === 1 + ? item.steps[0] + : undefined; + if (lone) { + const app = appOfCall(lone.toolCall.function.name); + return { first: app, last: app }; + } + if (item.kind !== "tools") return {}; + const steps = foldRereads(item.steps.map(stepDetails)); + const app = (step: StepDetails | undefined) => + step?.kind === "connector" ? step.appId : undefined; + return { first: app(steps[0]), last: app(steps.at(-1)) }; } /** One step, as a folded line opens to it. Also how a subtask's card lists the steps it took. */ export function StepRow({ step, active, - iconAbove = false, - underApp = false, + chevronRoom = false, }: { step: StepDetails; active: boolean; - /** The step above draws the same icon (`sameIconAsAbove`): this one keeps its room, empty. */ - iconAbove?: boolean; - /** Drawn under its app's name (`AppRun`): no icon, and the app is not said again. */ - underApp?: boolean; + /** + * Another row in its list opens (`stepOpens`): a row that doesn't keeps the chevron's room, so its + * mark and words line up with theirs. + */ + chevronRoom?: boolean; }) { if (step.kind === "subtask") return ; @@ -1567,14 +1512,10 @@ export function StepRow({ * row, shimmering, with "In progress" where "Blocked" or "Didn't work" would be. */ const running = active && step.pending; - const detail = underApp ? step.detailUnderApp : step.detail; const line = ( - - {underApp ? null : iconAbove ? ( - - ) : ( - - )} + // Spaced as a line of its own is (`ToolLine`), so a step and a lone call line up in one list. + + {step.label} @@ -1585,10 +1526,10 @@ export function StepRow({ rel="noopener noreferrer" className="truncate text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-current" > - {detail ?? step.href} + {step.detail ?? step.href} - ) : detail ? ( - {detail} + ) : step.detail ? ( + {step.detail} ) : null} @@ -1610,9 +1551,9 @@ export function StepRow({ ); // A browser step says everything it has in its line. Anything else opens to what it was given // and what came back, which no other place in the transcript shows. - if (step.kind === "browser" || (!step.inputs.length && !step.output)) + if (!stepOpens(step)) return ( -
    3. +
    4. {line} {reason}
    5. @@ -1779,7 +1720,7 @@ export function WorkingNow({ steps }: { steps: readonly StepDetails[] }) { ) : (
    6. - + {step.label} @@ -1814,13 +1755,11 @@ export function stepsUnderWay( export function ToolActivity({ group, active, - conversation = false, expanded, }: { group: ToolGroup; /** This is the newest row of a turn still in flight, so a step without a result is running. */ active: boolean; - conversation?: boolean; expanded?: boolean; }) { const folders = useContext(FolderNamesContext); @@ -1853,46 +1792,53 @@ export function ToolActivity({ * each step under way is a line of its own beneath it: the Bot's own, and each subtask with what it * was asked, the step it is on and how many it has taken. Opened, the group lists everything. */ + /* + * A RUN OF APP STEPS IS ITS APPS' LINE, RUNNING OR DONE. While it ran, a run of Google Calendar + * steps was listed open, one row each, and folded into "Used Google Calendar" only once every step + * had its answer. Now it is that line from the start, "Using Google Calendar…", shimmering while a + * step is under way, and opened, it lists the steps as it does once they are done. + */ + const apps = [ + ...new Set( + rows.map((step) => (step.kind === "connector" ? step.connector : null)), + ), + ]; + const appsOnly = apps.every(Boolean); + const using = + appsOnly && apps.length === 1 + ? `Using ${apps[0]}…` + : `Using ${plural(apps.length, "app", "apps")}…`; const live = running ? rows.filter((step) => step.pending && !step.interrupted) : []; - const showLiveSteps = - conversation && - inFlight && - rows.some((step) => step.pending && !step.interrupted) && - rows.every((step) => step.kind === "connector"); - /* - * The app already named above the list, which its first run goes on without naming again: drawn - * open among a "Worked for" line's rows, the app the row above ends on (`AppAbove`); folded, the - * group's own line, when every step is on one app ("Used Google Calendar"). - */ - const rowAbove = useContext(AppAbove); - const onlyApp = rows[0]?.appId; - const appAbove = - expanded || showLiveSteps - ? rowAbove - : onlyApp && - rows.every( - (step) => step.kind === "connector" && step.appId === onlyApp, - ) - ? onlyApp - : undefined; - const list = ( -
        - + const chevronRoom = rows.some(stepOpens); + const oneApp = appsOnly && apps.length === 1 ? rows[0]?.appId : undefined; + const rowsList = ( + // One size wherever it is opened: a folded line's own body is drawn smaller, a "Worked for" + // line's isn't, and the same steps read at two sizes in one conversation. +
          + {rows.map((step) => ( + + ))}
        ); + // Folded, its own line shows its app; drawn open, the line it sits under does (`LineShowsApp`). + const list = expanded ? ( + rowsList + ) : ( + {rowsList} + ); const approvals = ( step.toolCall.id)} /> ); - if (expanded || showLiveSteps) { + if (expanded) { return ( <> {list} @@ -1909,15 +1855,19 @@ export function ToolActivity({ drawnWhenOpened icon={} openKey={group.id} - live={live.length ? : undefined} + live={ + live.length && !appsOnly ? : undefined + } label={ running && working ? working === 1 ? "Working on a subtask…" : `Working on ${working} subtasks…` - : running && current - ? `${current.label}…` - : summarise(steps) + : running && appsOnly + ? using + : running && current + ? `${current.label}…` + : summarise(steps) } detail={asides.length ? asides.join(" · ") : undefined} running={running} diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx index ee287afd5c..c35ca5713c 100644 --- a/app/tests/app-step-rows.test.tsx +++ b/app/tests/app-step-rows.test.tsx @@ -17,14 +17,18 @@ import { approvalInboxResponse } from "./approvals-api"; import { settleReactWork } from "./settle-react-work"; /** - * An app's steps are drawn one way, running or done, under the app's name as it was added. + * An app's steps are drawn one way, running or done, and say their app once. * * Reported from the web app, on a Bot listing a person's events: three Google Calendar steps in a * row, drawn three ways. The two finished ones read "List events" beside "Googlecalendar", the app's * key, while the one still running sat in a box of its own, the app first, "Google Calendar · List * events", with a spinner. The box said nothing the row does not: the action, the app, and that it - * was still going. So the app is named once, by the name the person added it under and beside its - * logo, and its steps are listed under it, one row each, the same row whether it is running or done. + * was still going. + * + * So a run of steps on one app is that app's line, "Using Google Calendar…" while a step runs and + * "Used Google Calendar" once it is done, and opened, each step is one row saying what was done, the + * same row running or done, with no logo the line above already draws. Where the steps are on + * several apps, each row draws its app's logo, which names the app on hover and to a screen reader. */ const originalFetch = globalThis.fetch; @@ -161,18 +165,34 @@ function shapeOf(line: Element) { }; } -test("an app's step still running is drawn as its finished steps are, all under the app's name", async () => { +/** What a row says, as read: a logo, or a letter standing in for one, is drawn, not read. */ +function said(line: Element): string { + const copy = line.cloneNode(true) as Element; + for (const hidden of copy.querySelectorAll("[aria-hidden]")) hidden.remove(); + return copy.textContent ?? ""; +} + +/** The app a row's logo names, to a screen reader and on hover (`AppMark`). */ +function markOf(line: Element) { + const mark = line.querySelector('[role="img"]'); + return { + name: mark?.getAttribute("aria-label"), + logo: mark?.querySelector("img")?.getAttribute("src"), + }; +} + +test("a run of one app's steps is that app's line while it runs, and opens to one row per step", async () => { const view = render(transcript(turn(false), true)); - // The steps under way are listed while the turn runs: the app once, its steps under it. - const steps = await view.findByRole("list", { name: "Tool steps" }); - const run = await within(steps).findByRole("list", { - name: "Steps on Google Calendar", - }); - const lead = run.previousElementSibling as Element; - expect(lead.textContent).toBe("Google Calendar"); - expect(lead.querySelector("img")?.getAttribute("src")).toBe(APP.logo); - const rows = [...run.querySelectorAll(":scope > li")]; + // While a step runs, the run is its app's line, by the app's name, shimmering, and folded. + const line = await view.findByText("Using Google Calendar…"); + expect(line.closest(".tool-line-running")).not.toBeNull(); + expect(view.queryByRole("list", { name: "Tool steps" })).toBeNull(); + fireEvent.click(line); + + // Opened, one row a step. + const steps = view.getByRole("list", { name: "Tool steps" }); + const rows = [...steps.querySelectorAll(":scope > li")]; expect(rows).toHaveLength(3); const lines = rows.map( (row) => row.querySelector("summary > span:last-child") as Element, @@ -180,12 +200,14 @@ test("an app's step still running is drawn as its finished steps are, all under const [listed, partRead, running] = lines; if (!listed || !partRead || !running) throw new Error("Expected 3 lines"); - // Under its app, a step says what was done, finished or running, and not the app again. + // What was done, finished or running, and not the app again: the line above says it, and draws its + // logo, so the rows under it don't. expect(listed.textContent).toBe("List events"); expect(partRead.textContent).toBe( "Read the next part of an answerList events, part 2 of 3", ); expect(running.textContent).toBe("List eventsIn progress"); + for (const row of lines) expect(markOf(row).name).toBeUndefined(); // One shape: no box, no app before the action, the same parts in the same order. const done = shapeOf(listed); @@ -195,33 +217,29 @@ test("an app's step still running is drawn as its finished steps are, all under "List events", ); expect(listed.querySelector(".tool-line-running")).toBeNull(); - // The app's logo is drawn once, beside its name: the rows under it draw none. - for (const line of lines) expect(line.querySelector("img")).toBeNull(); + // Opened, its rows are drawn at the size every list of steps is. + expect(steps.className).toContain("text-sm"); // The app's key is never shown as its name. expect(view.container.textContent).not.toContain("Googlecalendar"); expect(view.container.textContent).not.toContain("googlecalendar"); }); -test("answered, the step stops running and nothing else about it changes", async () => { +test("answered, the line says what the run did, and its steps stop running and nothing else changes", async () => { const view = render(transcript(turn(false), true)); - const run = await view.findByRole("list", { - name: "Steps on Google Calendar", - }); + fireEvent.click(await view.findByText("Using Google Calendar…")); const before = shapeOf( - run.querySelector( - ":scope > li:last-child summary > span:last-child", - ) as Element, + view + .getByRole("list", { name: "Tool steps" }) + .querySelector( + ":scope > li:last-child summary > span:last-child", + ) as Element, ); - // Every step answered, the steps fold into one line, which names the app by its name too. + // Every step answered, the same line says what was done. view.rerender(transcript(turn(true), true)); - const fold = await view.findByText("Used Google Calendar"); - fireEvent.click(fold); - // Opened, the steps sit under the line that names the app, which is not named again over them. - const after = view.getByRole("list", { name: "Steps on Google Calendar" }); - expect(after.previousElementSibling).toBeNull(); - expect(view.queryByText("Google Calendar")).toBeNull(); + expect(await view.findByText("Used Google Calendar")).toBeTruthy(); + const after = view.getByRole("list", { name: "Tool steps" }); expect(after.querySelector(".tool-line-running")).toBeNull(); const last = after.querySelector( ":scope > li:last-child summary > span:last-child", @@ -234,6 +252,61 @@ test("answered, the step stops running and nothing else about it changes", async expect(view.container.textContent).not.toContain("Googlecalendar"); }); +test("steps on several apps each draw their app's logo, which names the app", async () => { + const view = render( + transcript( + [ + ASKED, + ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" }, EVENTS), + ...call( + "mail-1", + "mcp__gmail__fetch_emails", + { query: "is:unread" }, + '{"messages":[]}', + ), + ], + true, + ), + ); + fireEvent.click(await view.findByText("Used 2 apps")); + const lines = [ + ...view + .getByRole("list", { name: "Tool steps" }) + .querySelectorAll(":scope > li summary > span:last-child"), + ]; + expect(lines.map(said)).toEqual(["List events", "Fetch emails"]); + expect(lines.map((line) => markOf(line))).toEqual([ + { name: APP.title, logo: APP.logo }, + expect.objectContaining({ name: "Gmail" }), + ]); + // The app's name is the logo's, not written on the row. + expect(view.queryByText("Google Calendar")).toBeNull(); +}); + +test("resting the pointer on an app's logo names the app", async () => { + const view = render( + transcript( + [ASKED, ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" })], + true, + ), + ); + const mark = await waitFor(() => { + const found = view.container.querySelector( + '[role="img"][aria-label="Google Calendar"]', + ); + if (!found) throw new Error("Expected the app's logo"); + return found; + }); + expect(view.queryByText("Google Calendar")).toBeNull(); + fireEvent.pointerEnter(mark, { pointerType: "mouse" }); + fireEvent.mouseEnter(mark); + fireEvent.pointerMove(mark, { pointerType: "mouse" }); + fireEvent.mouseMove(mark); + expect( + await view.findByText("Google Calendar", {}, { timeout: 3000 }), + ).toBeTruthy(); +}); + test("an app's call on a line of its own reads the same way, running or done", async () => { const one = (answered: boolean) => [ ASKED, @@ -247,15 +320,10 @@ test("an app's call on a line of its own reads the same way, running or done", a const view = render(transcript(one(false), true)); const line = (await view.findByText("List events")) .parentElement as HTMLElement; - // The app leads, by its name and beside its logo, and the call is the line under it. - const lead = await view.findByText("Google Calendar"); - expect(lead.parentElement?.querySelector("img")?.getAttribute("src")).toBe( - APP.logo, - ); - expect( - lead.compareDocumentPosition(line) & Node.DOCUMENT_POSITION_FOLLOWING, - ).toBeTruthy(); - // The action, and "In progress" for a screen reader, which hears no shimmer. + await waitFor(() => expect(markOf(line).logo).toBe(APP.logo)); + // The app's logo, naming the app; the action; and "In progress" for a screen reader, which hears + // no shimmer. + expect(markOf(line).name).toBe(APP.title); expect(line.textContent).toBe("List eventsIn progress"); expect(line.classList.contains("tool-line-running")).toBe(true); expect(line.querySelector(".sr-only")?.textContent).toBe("In progress"); @@ -271,10 +339,97 @@ test("an app's call on a line of its own reads the same way, running or done", a ); const done = view.getByText("List events").parentElement; expect(done?.textContent).toBe("List events"); - expect(view.getAllByText("Google Calendar")).toHaveLength(1); // Drawn as it was while running, less the running. const running = new Set(["tool-line-running", "tabular-nums"]); expect([...(done?.classList ?? [])]).toEqual( [...line.classList].filter((name) => !running.has(name)), ); }); + +test("a step that doesn't open keeps the chevron's room in a list where others open, so the rows line up", async () => { + const view = render( + transcript( + [ + ASKED, + ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" }, EVENTS), + // Given nothing and answered with nothing: nothing to open to. + ...call("calendars", "mcp__googlecalendar__list_calendars", {}, ""), + ], + true, + ), + ); + fireEvent.click(await view.findByText("Used Google Calendar")); + const rows = [ + ...view + .getByRole("list", { name: "Tool steps" }) + .querySelectorAll(":scope > li"), + ]; + expect(rows).toHaveLength(2); + const [opens, doesnt] = rows; + expect(opens?.querySelector("summary")).not.toBeNull(); + expect(doesnt?.querySelector("summary")).toBeNull(); + // The chevron is 14px and 6px from what follows it: the row without one is drawn 20px in. + expect(doesnt?.className).toContain("pl-5"); + expect(opens?.className).not.toContain("pl-5"); +}); + +const BETWEEN = "I found the design review. I'm checking next week too."; + +/** A finished turn: calls on Google Calendar, `before` then `after` of them with the Bot's words between. */ +function splitTurn(before: number, after: number): Message[] { + const list = (n: number) => + call(`list-${n}`, LIST_EVENTS, { timeMin: `2026-12-0${n}` }, EVENTS); + return [ + ASKED, + ...Array.from({ length: before }, (_, n) => list(n + 1)).flat(), + { id: "between", role: "assistant", content: BETWEEN }, + ...Array.from({ length: after }, (_, n) => list(before + n + 1)).flat(), + { + id: "answer", + role: "assistant", + content: "You have a design review on Tuesday.", + }, + ]; +} + +for (const [shape, before, after] of [ + ["a call on a line of its own", 1, 1], + ["a list of calls", 2, 2], +] as const) + test(`app steps the Bot spoke between sit as one list once the turn is folded: ${shape} each side`, async () => { + const view = render(transcript(splitTurn(before, after), false)); + const fold = await waitFor(() => { + const found = view.container.querySelector( + '[data-slot="worked-for"] details', + ); + if (!found) throw new Error("Expected the turn's steps folded"); + return found; + }); + fireEvent.click(fold.querySelector("summary") as HTMLElement); + // The apps added here are in: the line draws Google Calendar's own logo. + await waitFor(() => + expect(fold.querySelector("summary img")?.getAttribute("src")).toBe( + APP.logo, + ), + ); + + // Each call is a row of its own, drawn alike, a lone call included: what was done, with no logo, + // since every step in the line is on the one app its line draws. + const lines = within(fold) + .getAllByText("List events") + .map((label) => label.parentElement as Element); + expect(lines).toHaveLength(before + after); + for (const line of lines) { + expect(line.textContent).toBe("List events"); + expect(markOf(line).name).toBeUndefined(); + expect(line.closest('ol[aria-label="Tool steps"]')).not.toBeNull(); + } + + // The rows after the words are drawn up under the ones before, the gap the words left closed. + const drawnUp = (line: Element | undefined) => + line?.closest('[class*="-mt-"]') ?? null; + expect(drawnUp(lines[before - 1])).toBeNull(); + expect(drawnUp(lines[before])).not.toBeNull(); + // The Bot's words are said outside the fold, as always. + expect(view.getByText(BETWEEN).closest("details")).toBeNull(); + }); diff --git a/app/tests/long-answer-part-steps.test.tsx b/app/tests/long-answer-part-steps.test.tsx index aedff6c6fd..5162f98302 100644 --- a/app/tests/long-answer-part-steps.test.tsx +++ b/app/tests/long-answer-part-steps.test.tsx @@ -119,19 +119,13 @@ function openSteps(view: ReturnType) { /** Each step's own line, as it reads with nothing opened. */ function lines(view: ReturnType): (string | null)[] { - return [...view.container.querySelectorAll("ol > li")].flatMap((row) => { - // A run of an app's steps: its own line is the app's name, where it leads; its steps follow. - const run = row.querySelector(":scope > ol"); - const shown = run - ? run === row.firstElementChild - ? null - : row.firstElementChild - : (row.querySelector("summary") ?? row); - if (!shown) return []; - const line = shown.cloneNode(true) as Element; + return [...view.container.querySelectorAll("ol > li")].map((row) => { + const line = (row.querySelector("summary") ?? row).cloneNode( + true, + ) as Element; for (const decoration of line.querySelectorAll("[aria-hidden]")) decoration.remove(); - return [line.textContent]; + return line.textContent; }); } @@ -176,11 +170,12 @@ for (const [who, tool] of [ expect(shown).not.toContain("fireflies__fireflies_get_transcript"); // The folded line counts the reads as the app's: they are its answer, read on. expect(view.getByText("Used Fireflies")).toBeDefined(); - // Each read says, in words, which answer it read on in and which part, under the line that - // names the app. + // Each read says, in words, which answer it read on in and which part. expect(lines(view)).toEqual([ "Get transcript", "Read the next part of an answerGet transcript, part 2 of 3", "Read the next part of an answerGet transcript, part 3 of 3", ]); + // The line above already shows Fireflies, so no row draws its logo again. + expect(view.queryAllByRole("img", { name: "Fireflies" })).toHaveLength(0); }); diff --git a/app/tests/reread-steps.test.tsx b/app/tests/reread-steps.test.tsx index a0dc0db2a0..2418f80f72 100644 --- a/app/tests/reread-steps.test.tsx +++ b/app/tests/reread-steps.test.tsx @@ -79,23 +79,6 @@ function drawRow(messages: Message[], active: boolean) { ); } -/** Each line as read, top to bottom: an app's name over its run of steps, then each step's line. */ -function lines(view: ReturnType): (string | null)[] { - return [...view.container.querySelectorAll("ol > li")].flatMap((row) => { - const run = row.querySelector(":scope > ol"); - const shown = run - ? run === row.firstElementChild - ? null - : row.firstElementChild - : (row.querySelector("summary") ?? row); - if (!shown) return []; - const line = shown.cloneNode(true) as Element; - for (const decoration of line.querySelectorAll("[aria-hidden]")) - decoration.remove(); - return [line.textContent]; - }); -} - test("a run of rereads is one row that counts them, and a different step between two runs splits them", () => { const view = drawRow( [ @@ -118,15 +101,20 @@ test("a run of rereads is one row that counts them, and a different step between expect(view.getByText("Reread 3 earlier results")).toBeDefined(); // One on its own keeps its own words. expect(view.getAllByText("Reread an earlier result")).toHaveLength(1); - // Each row's own line, as it reads with nothing opened: each Gmail step under the app's name. - expect(lines(view)).toEqual([ - "Gmail", + // Each row's own line, as it reads with nothing opened. + const rows = [...view.container.querySelectorAll("ol > li")].map((row) => { + const line = (row.querySelector("summary") ?? row).cloneNode( + true, + ) as Element; + for (const decoration of line.querySelectorAll("[aria-hidden]")) + decoration.remove(); + return line.textContent; + }); + expect(rows).toEqual([ "Fetch emails", "Reread 12 earlier results", - "Gmail", "Fetch emails", "Reread 3 earlier results", - "Gmail", "Fetch emails", "Reread an earlier result", ]); @@ -152,9 +140,5 @@ test("while the last reread runs, the one row says it is rereading", () => { ), ).toBeDefined(); expect(view.queryByText("Reread an earlier result")).toBeNull(); - expect(lines(view)).toEqual([ - "Gmail", - "Fetch emails", - "Rereading earlier resultsIn progress", - ]); + expect(view.container.querySelectorAll("ol > li")).toHaveLength(2); }); diff --git a/app/tests/running-step-shimmer.test.tsx b/app/tests/running-step-shimmer.test.tsx index d9a6d888f7..cd8927dc47 100644 --- a/app/tests/running-step-shimmer.test.tsx +++ b/app/tests/running-step-shimmer.test.tsx @@ -140,16 +140,20 @@ function said(row: HTMLElement): string { test("the running app step shimmers, beside the steps already done, until it has an answer", async () => { const view = render(transcript(run(false), true)); + // While it works, the group is its app's line, shimmering, folded until it is opened. + const line = await view.findByText("Using Gmail…"); + expect(line.closest(`.${SHIMMER}`)).not.toBeNull(); + expect(view.queryByText("Fetch thread messages")).toBeNull(); + fireEvent.click(line); + // Named as the app's page names it, not in its stored order ("Fetch message by thread id"). const running = await view.findByText("Fetch thread messages"); expect(running.classList.contains(SHIMMER)).toBe(true); - // Its row says what the finished rows say, in the same order, and that it is under way, under - // the app's name with them. + // Its row says what the finished rows say, in the same order, and that it is under way. The line + // above already shows Gmail, so the row doesn't draw its logo again. const row = running.parentElement as HTMLElement; expect(said(row)).toBe("Fetch thread messagesIn progress"); - expect(view.getByRole("list", { name: "Steps on Gmail" }).contains(row)).toBe( - true, - ); + expect(row.querySelector('[role="img"]')).toBeNull(); // The steps already answered look as they always have. const finished = view.getAllByText("Fetch emails"); expect(finished).toHaveLength(4); @@ -158,10 +162,9 @@ test("the running app step shimmers, beside the steps already done, until it has expect(step.parentElement?.className).toBe(row.className); } - // Answered: the step stays in the group and its progress indicator goes away. + // Answered: the step stays in the group, which says what it did, and its progress indicator goes. view.rerender(transcript(run(true), true)); - // The group folds once every step has its answer: opened, the step is in it, still. - fireEvent.click(await view.findByText("Used Gmail")); + expect(await view.findByText("Used Gmail")).toBeTruthy(); expect( view.getByText("Fetch thread messages").classList.contains(SHIMMER), ).toBe(false); diff --git a/app/tests/tool-result-parts.test.tsx b/app/tests/tool-result-parts.test.tsx index 6f524cdb95..54ea45a84a 100644 --- a/app/tests/tool-result-parts.test.tsx +++ b/app/tests/tool-result-parts.test.tsx @@ -142,7 +142,8 @@ test("a result in several text parts reads as those parts, a paragraph each", as const view = draw(read.messages); expect(await view.findByText("It is a ribbon diagram.")).toBeTruthy(); fireEvent.click(view.getByText("Worked through 1 step")); - expect(await view.findByText("Search")).toBeTruthy(); + // An app's step in the line is a row that opens to its answer, as a person opens it. + fireEvent.click(await view.findByText("Search")); // Each part its own paragraph: run together, they read "Found 2 pages Ribbon diagrams …". expect(view.getByText("Found 2 pages").tagName).toBe("P"); expect(view.getByText("Ribbon diagrams Protein folds").tagName).toBe("P"); diff --git a/app/tests/work-folded.test.tsx b/app/tests/work-folded.test.tsx index 37ca6e8d95..27fcafca2d 100644 --- a/app/tests/work-folded.test.tsx +++ b/app/tests/work-folded.test.tsx @@ -194,11 +194,14 @@ test("regular chat folds finished app calls and keeps all answer text outside", const view = render(transcript([ask, ...steps.slice(0, 1)], true)); expect(view.container.querySelector('[data-slot="worked-for"]')).toBeNull(); expect(view.container.querySelector('img[src*="notion.svg"]')).not.toBeNull(); - expect(view.getByText("Notion")).toBeTruthy(); + // The app is its logo, which says its name (to a screen reader, and on hover). + expect(view.getByRole("img", { name: "Notion" })).toBeTruthy(); expect(view.getByText("Search pages")).toBeTruthy(); expect(view.getByText("In progress")).toBeTruthy(); view.rerender(transcript([ask, ...steps.slice(0, 3)], true)); + // Two calls on Notion while the turn runs: Notion's line, shimmering, which opens to its steps. + fireEvent.click(await view.findByText("Using Notion…")); const liveSteps = view.getByRole("list", { name: "Tool steps" }); expect(liveSteps.textContent).toContain("Get page"); expect(view.getAllByText("Get page")).toHaveLength(1); From 78e910991c53bb23ddff1c7828c4fac95635ff91 Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Sat, 5 Dec 2026 03:55:23 -0800 Subject: [PATCH 06/13] A turn's line on one app names it, and every app's logo names its app on hover "Worked through 2 steps" beside Google Calendar's logo now reads "Worked through 2 steps Google Calendar", the name in gray as a step's detail is. A line whose logos are several apps' names none. The logos on folded lines (a turn's "Worked through", a run's "Used 2 apps") now name their app on hover and to a screen reader, as a step's logo already did (`AppMark`). Co-Authored-By: Claude Opus 5.5 --- app/src/components/channels/tool-activity.tsx | 57 ++++++++++++++---- app/src/components/tasks/worked-for.tsx | 8 +++ app/tests/app-step-rows.test.tsx | 60 +++++++++++++++++++ app/tests/long-answer-part-steps.test.tsx | 12 +++- 4 files changed, 121 insertions(+), 16 deletions(-) diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index 29cd6e2039..dc5d40a558 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -1298,26 +1298,57 @@ export function ActivityAppMarks({ * and a magnifying glass with its handle cut off reads as the letter C. */ function IconStack({ marks }: { marks: { kind: StepKind; appId?: string }[] }) { + const appName = useAppName(); const icons = Array.from( new Map(marks.map((mark) => [mark.appId ?? mark.kind, mark])).values(), ); if (icons.length === 1) { const [mark] = icons; - if (mark?.appId) return ; + if (mark?.appId) + return ; } + /* + * AN APP'S LOGO NAMES IT WHEREVER IT IS. A step's row named its app on hover (`AppMark`), but the + * folded line above, "Worked through 8 steps" beside Gmail's, Slack's and Google Calendar's logos, + * named none: the same logo told something in one place and nothing in the other. + */ return ( - - {icons.map(({ kind, appId }, index) => ( - 0 ? "-ml-1.5" : "" - }`} - > - - - ))} + + {icons.map(({ kind, appId }, index) => { + const style = { zIndex: icons.length - index }; + const shape = `relative flex size-6 items-center justify-center rounded-full bg-muted text-muted-foreground ring-2 ring-background ${ + index > 0 ? "-ml-1.5" : "" + }`; + const icon = ( + + ); + return appId ? ( + + + } + > + {icon} + + {appName(appId)} + + ) : ( + + {icon} + + ); + })} ); } diff --git a/app/src/components/tasks/worked-for.tsx b/app/src/components/tasks/worked-for.tsx index f167587de1..e65d5a3f1b 100644 --- a/app/src/components/tasks/worked-for.tsx +++ b/app/src/components/tasks/worked-for.tsx @@ -245,6 +245,8 @@ function WorkLine({ : []; }); }); + // The one app the line's logo shows, if it shows one. + const [app, other] = new Set(apps); return (
        : undefined} label={text} + /* + * THE ONE APP, NAMED. "Worked through 2 steps" beside Google Calendar's logo said which app + * only to someone who knew the logo; its rows don't name it (`LineShowsApp`). Where every + * step is on one app, the line names it after what it did, as a step names what it acted on. + */ + {...(app && other === undefined ? { detail: appName(app) } : {})} running={running} openKey={work.id} live={underWay.length ? : undefined} diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx index c35ca5713c..5f068e690f 100644 --- a/app/tests/app-step-rows.test.tsx +++ b/app/tests/app-step-rows.test.tsx @@ -413,6 +413,15 @@ for (const [shape, before, after] of [ ), ); + // The line names the one app its logo shows, after what it did, in gray as a step's detail is. + const label = within( + fold.querySelector("summary") as HTMLElement, + ).getByText(`Worked through ${before + after} steps`); + expect(label.nextElementSibling?.textContent).toBe(APP.title); + expect(label.nextElementSibling?.className).toContain( + "text-muted-foreground", + ); + // Each call is a row of its own, drawn alike, a lone call included: what was done, with no logo, // since every step in the line is on the one app its line draws. const lines = within(fold) @@ -433,3 +442,54 @@ for (const [shape, before, after] of [ // The Bot's words are said outside the fold, as always. expect(view.getByText(BETWEEN).closest("details")).toBeNull(); }); + +test("a turn's line on several apps names none after what it did, and each logo names its app on hover", async () => { + const view = render( + transcript( + [ + ASKED, + ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" }, EVENTS), + { id: "between", role: "assistant", content: BETWEEN }, + ...call( + "mail-1", + "mcp__gmail__fetch_emails", + { query: "is:unread" }, + '{"messages":[]}', + ), + { + id: "answer", + role: "assistant", + content: "You have a design review on Tuesday.", + }, + ], + false, + ), + ); + const summary = await waitFor(() => { + const found = view.container.querySelector( + '[data-slot="worked-for"] summary', + ); + if (!found) throw new Error("Expected the turn's steps folded"); + return found; + }); + await waitFor(() => + expect( + [...summary.querySelectorAll('[role="img"]')].map((mark) => + mark.getAttribute("aria-label"), + ), + ).toEqual([APP.title, "Gmail"]), + ); + // Two apps: no one app to name; each logo names its own. + expect( + within(summary).getByText("Worked through 2 steps").nextElementSibling, + ).toBeNull(); + expect(view.queryByText("Gmail")).toBeNull(); + const gmail = summary.querySelector( + '[role="img"][aria-label="Gmail"]', + ) as HTMLElement; + fireEvent.pointerEnter(gmail, { pointerType: "mouse" }); + fireEvent.mouseEnter(gmail); + fireEvent.pointerMove(gmail, { pointerType: "mouse" }); + fireEvent.mouseMove(gmail); + expect(await view.findByText("Gmail", {}, { timeout: 3000 })).toBeTruthy(); +}); diff --git a/app/tests/long-answer-part-steps.test.tsx b/app/tests/long-answer-part-steps.test.tsx index 5162f98302..ad7651f6fb 100644 --- a/app/tests/long-answer-part-steps.test.tsx +++ b/app/tests/long-answer-part-steps.test.tsx @@ -2,7 +2,7 @@ import { afterAll, afterEach, beforeAll, expect, test } from "bun:test"; import type { Message } from "@ag-ui/core"; import { GlobalRegistrator } from "@happy-dom/global-registrator"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { cleanup, fireEvent, render } from "@testing-library/react"; +import { cleanup, fireEvent, render, within } from "@testing-library/react"; import { toVisibleChatItems } from "../src/components/channels/chat-messages"; import { groupToolSteps, @@ -176,6 +176,12 @@ for (const [who, tool] of [ "Read the next part of an answerGet transcript, part 2 of 3", "Read the next part of an answerGet transcript, part 3 of 3", ]); - // The line above already shows Fireflies, so no row draws its logo again. - expect(view.queryAllByRole("img", { name: "Fireflies" })).toHaveLength(0); + // The line above already shows Fireflies, its logo naming it, so no row draws that logo again. + expect(view.getAllByRole("img", { name: "Fireflies" })).toHaveLength(1); + expect( + within(view.getByRole("list", { name: "Tool steps" })).queryAllByRole( + "img", + { name: "Fireflies" }, + ), + ).toHaveLength(0); }); From 683d732b3601c391460a603e53776197da5e9cc0 Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Sat, 5 Dec 2026 04:16:56 -0800 Subject: [PATCH 07/13] A turn's line on one app leads with its name, and its rows on that app draw no logo "Worked through 2 steps Google Calendar" now reads "Google Calendar Worked through 2 steps": the app beside its logo, then what was done (`ToolLine`'s new `lead`). The line names its app and its rows leave out that app's logo by one rule (`onlyApp`): the one app among the steps that are on an app. A turn that looked for a tool, then listed events, named Google Calendar on its line and still drew the Google Calendar logo beside "List events", since the rows asked whether every step was on the app. Co-Authored-By: Claude Opus 5.5 --- app/src/components/channels/tool-activity.tsx | 33 +++++++---- app/src/components/channels/tool-line.tsx | 4 ++ app/src/components/tasks/worked-for.tsx | 12 ++-- app/tests/app-step-rows.test.tsx | 56 ++++++++++++++++--- 4 files changed, 83 insertions(+), 22 deletions(-) diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index dc5d40a558..d5832a3a87 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -1415,9 +1415,8 @@ export function StepStatus({ } /** - * The one app every step under a folded line is on, which that line already shows ("Used Google - * Calendar", or "Worked through 2 steps" beside Google Calendar's logo). Its steps don't draw its - * logo again. + * The one app a folded line already shows ("Used Google Calendar", or "Google Calendar Worked + * through 2 steps" beside its logo). Its steps on that app don't draw its logo again. * * ONE LOGO FOR ONE APP. Opened, "Used Google Calendar" listed three steps, each beside the Google * Calendar logo the line above them had just drawn: the same mark four times, telling nothing the @@ -1426,15 +1425,29 @@ export function StepStatus({ */ export const LineShowsApp = createContext(undefined); -/** The one app every step in `items` is on, or none if any step is another app's or none's. */ +/** + * The one app the steps in `items` are on, leaving out steps on no app ("Looked for a tool"); none + * if they are on several apps, or on none. + * + * ONE RULE FOR THE LINE AND ITS ROWS. A turn that looked for a tool, then listed events, read + * "Google Calendar Worked through 2 steps", and opened to "List events" beside the Google + * Calendar logo again: the line named the one app among its logos, the rows asked whether every + * step was on it. Both now ask this. + */ export function onlyApp(items: readonly TranscriptItem[]): string | undefined { - const apps = new Set(); + const apps = new Set(); for (const item of items) { - if (item.kind === "tool") apps.add(appOfCall(item.toolCall.function.name)); - else if (item.kind === "tools") - for (const step of item.steps.map(stepDetails)) - apps.add(step.kind === "connector" ? step.appId : undefined); - else return undefined; + const onApps = + item.kind === "tool" + ? [appOfCall(item.toolCall.function.name)] + : item.kind === "tools" + ? item.steps + .map(stepDetails) + .map((step) => + step.kind === "connector" ? step.appId : undefined, + ) + : []; + for (const app of onApps) if (app) apps.add(app); } const [app] = apps; return apps.size === 1 ? app : undefined; diff --git a/app/src/components/channels/tool-line.tsx b/app/src/components/channels/tool-line.tsx index fc4cd30af0..09011fe931 100644 --- a/app/src/components/channels/tool-line.tsx +++ b/app/src/components/channels/tool-line.tsx @@ -89,6 +89,7 @@ export function ToolLine({ label, attempted, detail, + lead, running, refused, failed, @@ -128,6 +129,8 @@ export function ToolLine({ * step, where it is the reason and wraps in full. */ detail?: string; + /** What the line is about, said before what was done ("Google Calendar Worked through 2 steps"). */ + lead?: string; running?: boolean; /** A policy or a boundary said no. Final: nothing the Bot does differently will help. */ refused?: boolean; @@ -207,6 +210,7 @@ export function ToolLine({ } ${saysWhy ? "flex-wrap" : ""}`} > {icon ? {icon} : null} + {lead ? {lead} : null} {/* * Free to shrink, so a long label (a folded run's "Read 1 file, searched for 2 patterns and * listed 1 directory") wraps in a phone-width column instead of running past it. The detail diff --git a/app/src/components/tasks/worked-for.tsx b/app/src/components/tasks/worked-for.tsx index e65d5a3f1b..e9db377dbf 100644 --- a/app/src/components/tasks/worked-for.tsx +++ b/app/src/components/tasks/worked-for.tsx @@ -15,6 +15,7 @@ import { useSyncExternalStore, } from "react"; import { + onlyApp, stepsUnderWay, type TranscriptItem, useAppName, @@ -245,8 +246,8 @@ function WorkLine({ : []; }); }); - // The one app the line's logo shows, if it shows one. - const [app, other] = new Set(apps); + // The one app the line's logo shows, if it shows one: named on the line, not again on its rows. + const app = onlyApp(work.rows.map((row) => row.item)); return (
        : undefined} diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx index 5f068e690f..a56f27ad65 100644 --- a/app/tests/app-step-rows.test.tsx +++ b/app/tests/app-step-rows.test.tsx @@ -413,14 +413,16 @@ for (const [shape, before, after] of [ ), ); - // The line names the one app its logo shows, after what it did, in gray as a step's detail is. + // The line names the one app its logo shows, beside the logo and before what was done. const label = within( fold.querySelector("summary") as HTMLElement, ).getByText(`Worked through ${before + after} steps`); - expect(label.nextElementSibling?.textContent).toBe(APP.title); - expect(label.nextElementSibling?.className).toContain( - "text-muted-foreground", - ); + const named = label.previousElementSibling; + expect(named?.textContent).toBe(APP.title); + expect( + named?.previousElementSibling?.querySelector("img")?.getAttribute("src"), + ).toBe(APP.logo); + expect(label.nextElementSibling).toBeNull(); // Each call is a row of its own, drawn alike, a lone call included: what was done, with no logo, // since every step in the line is on the one app its line draws. @@ -480,9 +482,11 @@ test("a turn's line on several apps names none after what it did, and each logo ).toEqual([APP.title, "Gmail"]), ); // Two apps: no one app to name; each logo names its own. + const label = within(summary).getByText("Worked through 2 steps"); expect( - within(summary).getByText("Worked through 2 steps").nextElementSibling, - ).toBeNull(); + label.previousElementSibling?.querySelector('[role="img"]'), + ).not.toBeNull(); + expect(label.nextElementSibling).toBeNull(); expect(view.queryByText("Gmail")).toBeNull(); const gmail = summary.querySelector( '[role="img"][aria-label="Gmail"]', @@ -493,3 +497,41 @@ test("a turn's line on several apps names none after what it did, and each logo fireEvent.mouseMove(gmail); expect(await view.findByText("Gmail", {}, { timeout: 3000 })).toBeTruthy(); }); + +test("a turn that also took a step on no app is still its one app's line, and that app's rows draw no logo", async () => { + const view = render( + transcript( + [ + ASKED, + ...call("search", "search_tools", { query: "calendar" }, "[]"), + { id: "between", role: "assistant", content: BETWEEN }, + ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" }, EVENTS), + { + id: "answer", + role: "assistant", + content: "You have a design review on Tuesday.", + }, + ], + false, + ), + ); + const fold = await waitFor(() => { + const found = view.container.querySelector( + '[data-slot="worked-for"] details', + ); + if (!found) throw new Error("Expected the turn's steps folded"); + return found; + }); + const summary = fold.querySelector("summary") as HTMLElement; + await waitFor(() => + expect( + within(summary).getByText("Worked through 2 steps").previousElementSibling + ?.textContent, + ).toBe(APP.title), + ); + fireEvent.click(summary); + expect(within(fold).getByText("Looked for a tool")).toBeTruthy(); + const listed = within(fold).getByText("List events").parentElement as Element; + expect(said(listed)).toBe("List events"); + expect(markOf(listed).name).toBeUndefined(); +}); From 5bad4f4cbb3d18e2ff42522e812f0abad440c32b Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Sat, 5 Dec 2026 04:26:41 -0800 Subject: [PATCH 08/13] A step that doesn't open draws its mark in the chevrons' column when the rows that open draw none Under "Google Calendar Worked through 2 steps", "List events" is its chevron and its words, no logo. "Looked for a tool", which opens to nothing, kept the chevron's room and drew its wrench after it, so its words started 21px further in. Where the rows in a list that open draw no mark, a row that doesn't open now draws its mark where their chevron is, as wide, and its words start where theirs do (`markInChevron`). Where they draw marks, it keeps the chevron's room as before. step-rows-layout measures it in Chromium and WebKit: the wrench's centre on the chevron's, and both labels at one x. Co-Authored-By: Claude Opus 5.5 --- app/src/components/channels/tool-activity.tsx | 51 ++++++++++++-- app/tests/app-step-rows.test.tsx | 15 ++++- app/tests/step-rows-layout.fixture.tsx | 25 ++++++- app/tests/step-rows-layout.test.tsx | 66 +++++++++++++++++-- 4 files changed, 138 insertions(+), 19 deletions(-) diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index d5832a3a87..30c8ae5117 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -1475,14 +1475,21 @@ export function AppMark({ appId, name }: { appId: string; name: string }) { ); } +/** Whether a step's row draws a mark: every step does, but one on the app its line shows (`shown`). */ +export function drawsMark( + step: StepDetails, + shown: string | undefined, +): boolean { + return !(step.kind === "connector" && step.appId && step.appId === shown); +} + /** * A step's mark: an app's logo named on hover (`AppMark`), or the icon for its kind of step. None for * a step on the app the line above it already shows (`LineShowsApp`). */ function StepMark({ step }: { step: StepDetails }) { const shown = useContext(LineShowsApp); - if (step.kind === "connector" && step.appId && step.appId === shown) - return null; + if (!drawsMark(step, shown)) return null; return step.kind === "connector" && step.appId ? ( ; /* @@ -1556,10 +1570,10 @@ export function StepRow({ * row, shimmering, with "In progress" where "Blocked" or "Didn't work" would be. */ const running = active && step.pending; - const line = ( + const lineWith = (mark: ReactNode) => ( // Spaced as a line of its own is (`ToolLine`), so a step and a lone call line up in one list. - + {mark} {step.label} @@ -1578,6 +1592,7 @@ export function StepRow({ ); + const line = lineWith(); const reason = step.failed && step.kind === "browser" ? (

        @@ -1595,13 +1610,28 @@ export function StepRow({ ); // A browser step says everything it has in its line. Anything else opens to what it was given // and what came back, which no other place in the transcript shows. - if (!stepOpens(step)) + if (!stepOpens(step)) { + /* + * THE MARK IN THE CHEVRON'S COLUMN. Under "Google Calendar Worked through 2 steps", "List + * events" is its chevron and its words, no logo; "Looked for a tool" kept the chevron's room and + * drew its wrench after it, so its words started a mark further in. Where the rows that open + * draw no mark, this one's stands where their chevron does, as wide, and its words start where + * theirs do. + */ + const inChevron = markInChevron && drawsMark(step, shown); return ( -

      1. - {line} +
      2. + {inChevron + ? lineWith( + + + , + ) + : line} {reason}
      3. ); + } return (
      4. @@ -1809,6 +1839,7 @@ export function ToolActivity({ const folders = useContext(FolderNamesContext); // A command with no answer runs while its turn does, whichever row it is in. const inFlight = useContext(TurnInFlightContext); + const lineShows = useContext(LineShowsApp); const appName = useAppName(); const steps = group.steps.map( stepDetailsIn(folders, active || inFlight, appName), @@ -1857,6 +1888,11 @@ export function ToolActivity({ : []; const chevronRoom = rows.some(stepOpens); const oneApp = appsOnly && apps.length === 1 ? rows[0]?.appId : undefined; + // The app the line above these rows shows: their own line's, or, drawn open, the one around them. + const shown = expanded ? lineShows : oneApp; + const markInChevron = + chevronRoom && + !rows.some((step) => stepOpens(step) && drawsMark(step, shown)); const rowsList = ( // One size wherever it is opened: a folded line's own body is drawn smaller, a "Worked for" // line's isn't, and the same steps read at two sizes in one conversation. @@ -1867,6 +1903,7 @@ export function ToolActivity({ step={step} active={active} chevronRoom={chevronRoom} + markInChevron={markInChevron} /> ))}
      diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx index a56f27ad65..4a337ed764 100644 --- a/app/tests/app-step-rows.test.tsx +++ b/app/tests/app-step-rows.test.tsx @@ -503,8 +503,8 @@ test("a turn that also took a step on no app is still its one app's line, and th transcript( [ ASKED, - ...call("search", "search_tools", { query: "calendar" }, "[]"), - { id: "between", role: "assistant", content: BETWEEN }, + // Given nothing and answered with nothing: a step that opens to nothing. + ...call("search", "search_tools", {}, ""), ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" }, EVENTS), { id: "answer", @@ -530,8 +530,17 @@ test("a turn that also took a step on no app is still its one app's line, and th ).toBe(APP.title), ); fireEvent.click(summary); - expect(within(fold).getByText("Looked for a tool")).toBeTruthy(); const listed = within(fold).getByText("List events").parentElement as Element; expect(said(listed)).toBe("List events"); expect(markOf(listed).name).toBeUndefined(); + // "List events" is a chevron and its words: the step that doesn't open draws its wrench in the + // chevron's column, as wide (14px), not after the chevron's room. + const looked = within(fold) + .getByText("Looked for a tool") + .closest("li") as Element; + expect(looked.querySelector("summary")).toBeNull(); + expect(looked.className).not.toContain("pl-5"); + expect(looked.querySelector("svg")?.parentElement?.className).toContain( + "w-3.5", + ); }); diff --git a/app/tests/step-rows-layout.fixture.tsx b/app/tests/step-rows-layout.fixture.tsx index 5aedbbafa8..14de596c2e 100644 --- a/app/tests/step-rows-layout.fixture.tsx +++ b/app/tests/step-rows-layout.fixture.tsx @@ -19,6 +19,8 @@ setCurrentOrganization("default"); * said a line on the way, as Bots now do on a long job, and then read one more page on its own: a * single "Read web pages" line between the Bot's words. `?state=running`: that page is still being * read, in a turn that is still going. `?state=done`: it was read and the Bot answered. + * `?state=tool-then-app`: another turn, which looked for a tool (a step that opens to nothing) and + * then listed events on Google Calendar, and answered. */ type Call = { id: string; name: string; args: unknown; result?: unknown }; @@ -137,9 +139,26 @@ const before: Message[] = [ ]; const messages: Message[] = - state === "running" - ? [...before, ...call(10, { ...READ_ONE, result: undefined })] - : [...before, ...call(10, READ_ONE), ANSWER]; + state === "tool-then-app" + ? [ + ASKED, + ...call(20, { + id: "search", + name: "search_tools", + args: {}, + result: "", + }), + ...call(21, { + id: "list", + name: "mcp__googlecalendar__list_events", + args: { timeMin: "2026-12-06" }, + result: { events: [{ summary: "Design review" }] }, + }), + ANSWER, + ] + : state === "running" + ? [...before, ...call(10, { ...READ_ONE, result: undefined })] + : [...before, ...call(10, READ_ONE), ANSWER]; /** The server, as far as this conversation asks it anything: no approvals are waiting. */ const realFetch = window.fetch.bind(window); diff --git a/app/tests/step-rows-layout.test.tsx b/app/tests/step-rows-layout.test.tsx index 0ffca7fc0e..6a7482da76 100644 --- a/app/tests/step-rows-layout.test.tsx +++ b/app/tests/step-rows-layout.test.tsx @@ -47,13 +47,15 @@ const WINDOWS = [ { width: 1440, height: 900 }, ]; type Theme = (typeof THEMES)[number]; -type State = "running" | "done"; +type State = "running" | "done" | "tool-then-app"; /** The folded line of the search and the two pages read beside it. */ const FOLDED = "Searched the web and read 2 pages"; const COMPLETED = "Worked through 3 steps"; /** The page read on its own. */ const SINGLE = "Read web pages"; +/** The turn that looked for a tool, then listed events on Google Calendar. */ +const ON_ONE_APP = "Worked through 2 steps"; function singleLine(page: Page) { return page @@ -174,12 +176,15 @@ async function open( // The single line itself, beside the Bot's narration. await singleLine(page).waitFor(); } else { - await page.getByText(COMPLETED, { exact: true }).waitFor(); + await page + .getByText(state === "done" ? COMPLETED : ON_ONE_APP, { exact: true }) + .waitFor(); } - await page - .getByText("press release", { exact: false }) - .first() - .waitFor({ timeout: 15_000 }); + if (state !== "tool-then-app") + await page + .getByText("press release", { exact: false }) + .first() + .waitFor({ timeout: 15_000 }); await style(page); await page.evaluate(() => document.fonts.ready); await still(page); @@ -366,5 +371,54 @@ describe.skipIf(!asked)("a Bot's step lines among its words", () => { await done.close(); } }, 60_000); + + test(`a step that doesn't open draws its mark where the chevrons of the rows that open are, and its words start where theirs do, ${where}`, async () => { + const page = await open(engine, theme, window, "tool-then-app"); + try { + await page + .locator('[data-slot="worked-for"] summary') + .filter({ hasText: ON_ONE_APP }) + .click(); + await page.getByText("List events", { exact: true }).waitFor(); + await style(page); + await still(page); + const placed = await page.evaluate(() => { + const rows = [ + ...document.querySelectorAll( + '[data-slot="worked-for"] ol[aria-label="Tool steps"] > li', + ), + ]; + const row = (words: string) => { + const li = rows.find((one) => one.textContent?.includes(words)); + const label = [...(li?.querySelectorAll("span") ?? [])].find( + (span) => + span.childElementCount === 0 && span.textContent === words, + ); + return { li, label }; + }; + const looked = row("Looked for a tool"); + const listed = row("List events"); + const mark = looked.li?.querySelector("svg"); + const chevron = listed.li?.querySelector(".tool-line-chevron"); + if (!mark || !chevron || !looked.label || !listed.label) + throw new Error("no wrench, chevron or words"); + const centre = (element: Element) => { + const box = element.getBoundingClientRect(); + return box.left + box.width / 2; + }; + return { + markOffChevron: Math.abs(centre(mark) - centre(chevron)), + wordsApart: Math.abs( + looked.label.getBoundingClientRect().left - + listed.label.getBoundingClientRect().left, + ), + }; + }); + expect(placed.markOffChevron).toBeLessThan(1); + expect(placed.wordsApart).toBeLessThan(1); + } finally { + await page.close(); + } + }, 60_000); } }); From 395e6808bd88cb0f16c5faa6a2bd6ea25656252d Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Sat, 5 Dec 2026 07:26:44 -0800 Subject: [PATCH 09/13] A conversation's turn never folds: its steps are rows from their first frame, and stay put Filmed through a real run, a conversation's turn was drawn one way while the Bot worked and rebuilt when it finished: its steps folded into one "Worked through 2 steps" line where the first step was, and a step taken after the Bot spoke jumped above its words. Now what the turn shows while it runs is what it keeps. - Only a task's thread folds (`foldTurnWork` loses its "conversation" scope). - A run of app steps, or OpenBot's own tools, is listed open from its first step, one row each, the chevron's room kept on every row; a run on one app names the app on its first row. - "Thinking" is a row shaped like a step's, where the next step goes, inside the run when its steps are all answered. - What the Bot said before a step it went on to take is muted; its answer is not. - A running step says "In progress" to a screen reader only; the shimmer says it to everybody. - Commands, files, pages, subtasks, and refused or failed calls keep the card or line they had. Co-Authored-By: Claude Opus 5.5 --- .../components/channels/chat-transcript.tsx | 99 ++++- app/src/components/channels/tool-activity.tsx | 113 +++++- app/src/components/tasks/turn-work.ts | 44 +- app/tests/app-step-rows.test.tsx | 384 +++++++----------- app/tests/flat-turn.test.tsx | 225 ++++++++++ app/tests/plan-turns.test.ts | 2 +- app/tests/running-step-shimmer.test.tsx | 41 +- app/tests/tool-result-parts.test.tsx | 16 +- app/tests/work-folded.test.tsx | 32 +- 9 files changed, 627 insertions(+), 329 deletions(-) create mode 100644 app/tests/flat-turn.test.tsx diff --git a/app/src/components/channels/chat-transcript.tsx b/app/src/components/channels/chat-transcript.tsx index 6a67b8d3c9..603d734043 100644 --- a/app/src/components/channels/chat-transcript.tsx +++ b/app/src/components/channels/chat-transcript.tsx @@ -78,7 +78,7 @@ import { publishThreadWork, threadWorkOf, } from "@/components/tasks/thread-work"; -import { foldTurnWork } from "@/components/tasks/turn-work"; +import { foldTurnWork, NO_TURN_WORK } from "@/components/tasks/turn-work"; import { isTaskThread, useWaitingToolCalls, @@ -201,11 +201,14 @@ import { appOfCall, attachmentReadName, dropRepeatedAppCards, + FLAT_STEPS, groupToolSteps, LineShowsApp, + listsFlat, onlyApp, rowApps, ServerStepIcon, + ThinkingStep, ToolActivity, type ToolGroup, type TranscriptItem, @@ -457,7 +460,20 @@ export function RestoringTranscript() { * on it, and the person needs nothing more than that. Only if the tries run out does the turn's * notice say so. */ -function Thinking({ reconnecting = false }: { reconnecting?: boolean }) { +function Thinking({ + reconnecting = false, + flat = false, +}: { + reconnecting?: boolean; + /** In a conversation, drawn as a step's row is, where the turn's first step will be (`ThinkingStep`). */ + flat?: boolean; +}) { + if (flat) + return ( +
        + +
      + ); return (

      {isUser ? ( @@ -2037,6 +2058,10 @@ type ToolRowProps = { expanded?: boolean; /** A run of calls drawn as plain lines (a `tools` group), which folds, even a run of one. */ folds?: boolean; + /** A conversation's row: a run is listed open, one row per step (`ToolActivity`'s `flat`). */ + flat?: boolean; + /** Its steps are answered and the Bot is still on it: "Thinking" where the next step goes. */ + thinking?: boolean; }; /** @@ -2055,6 +2080,8 @@ export function sameToolRow(a: ToolRowProps, b: ToolRowProps): boolean { a.spokeAfter === b.spokeAfter && a.expanded === b.expanded && a.folds === b.folds && + a.flat === b.flat && + a.thinking === b.thinking && a.steps.length === b.steps.length && a.steps.every((step, index) => { const other = b.steps[index]; @@ -2078,9 +2105,28 @@ const ToolRow = memo(function ToolRow({ spokeAfter, expanded, folds, + flat, + thinking, }: ToolRowProps) { const [only] = steps; useReportsDesktopActivity(steps, active); + const isDrawn = useDrawnTool(); + /* + * A conversation's run of app steps is its rows from the first step, drawn at once where + * "Thinking" was: no entrance, since the row that was there turns into it (`ThinkingStep`). A + * command, a file or a page keeps its card (`listsFlat`). + */ + if (flat && folds && steps.every((step) => listsFlat(step, isDrawn))) + return ( + + + + ); return ( @@ -2680,14 +2726,12 @@ export function ChatTranscript({ dropRepeatedAppCards(toVisibleChatItems(messages, isComponent)), ); const items = groupToolSteps(visible, isDrawn, rowIdsRef.current); - // Task threads fold narration too. Regular conversation only folds completed tool work. + // A task's thread folds each turn's work into one line; a conversation's turn never folds. const queryClient = useContext(QueryClientContext); const taskThread = isTaskThread(threadId, items, queryClient); // What waits on the person's approval stays out of the fold, its card with it. const waiting = useWaitingToolCalls(queryClient); - const folds = taskThread - ? foldTurnWork(items, busy, waiting) - : foldTurnWork(items, busy || Boolean(stopped), waiting, "conversation"); + const folds = taskThread ? foldTurnWork(items, busy, waiting) : NO_TURN_WORK; // What the task read and made, for its Details pane beside the thread (`thread-work.ts`). useEffect(() => { if (taskThread && threadId) @@ -2857,6 +2901,38 @@ export function ChatTranscript({ const lastBotWords = items.findLastIndex( (item) => item.kind === "text" && item.role === "assistant", ); + /* + * In a conversation, "Thinking" after a run whose steps all have their answers is that run's next + * row (`ThinkingStep`): a step that joins the run takes its place, where a line under the run would + * have stood a gap lower than the step that replaced it. + */ + const thinkingInRun = + !taskThread && + waitingOnTheModel && + !reconnectingNow && + lastItem?.kind === "tools" && + lastItem.steps.every((step) => listsFlat(step, isDrawn)); + /* + * WHAT A CONVERSATION'S BOT SAID BEFORE A STEP IT WENT ON TO TAKE IS MUTED, once that step is + * there, so the answer is the one line of its turn in the conversation's own color. Its color is + * all that changes: it stays where it was said. + */ + const asides = new Set(); + if (!taskThread) { + let stepAfter = false; + for (let at = items.length - 1; at >= 0; at -= 1) { + const item = items[at]; + if (!item) continue; + if ( + (item.kind === "text" && item.role === "user") || + item.kind === "attachments" + ) + stepAfter = false; + else if (item.kind === "tools") stepAfter = true; + else if (item.kind === "text" && item.role === "assistant" && stepAfter) + asides.add(item.id); + } + } /* One rule for both kinds of row — see `anchorRowIds`, which is where it is written down. */ const anchorRows = anchorRowIds(items); @@ -3144,17 +3220,20 @@ export function ChatTranscript({ active={busy && index === items.length - 1} expanded={expanded} folds={item.kind === "tools"} + flat={!taskThread} id={item.id} inFlight={busy && index >= turnStart} latest={index >= latestIndex} spokeAfter={lastBotWords > index} steps={item.kind === "tools" ? item.steps : [item]} + thinking={thinkingInRun && index === items.length - 1} /> ) : item.kind === "activity" ? ( ) : item.kind === "text" ? ( ) - ) : waitingOnTheModel || reconnectingNow ? ( - + ) : (waitingOnTheModel && !thinkingInRun) || + reconnectingNow ? ( + ) : null} {working} {queued.map((message) => ( diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index 30c8ae5117..86a5572bfe 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -53,6 +53,7 @@ import { IconPlug, IconSearch, IconSend, + IconSparkles, IconSubtask, IconTerminal2, IconTool, @@ -1399,11 +1400,16 @@ export function StepStatus({ step: StepDetails; active: boolean; }) { + /* + * A step under way says so in its shimmer, and to a screen reader in words, as a line of its own + * does (`ToolLine`). Written beside it too, "In progress" was one more word that went away when the + * step was done, the row's last word changing under the person's eye. + */ + if (active && step.pending) + return In progress; if (step.pending || step.stopped) return ( - - {active && step.pending ? "In progress" : "Not completed"} - + Not completed ); if (step.interrupted) return Interrupted; @@ -1542,9 +1548,15 @@ export function StepRow({ active, chevronRoom = false, markInChevron = false, + lead, }: { step: StepDetails; active: boolean; + /** + * What the row is about, said before what was done: the app, on the first of a conversation's + * steps on it (`ToolActivity`'s `flat`). + */ + lead?: string; /** * Another row in its list opens (`stepOpens`): a row that doesn't keeps the chevron's room, so its * mark and words line up with theirs. @@ -1574,6 +1586,7 @@ export function StepRow({ // Spaced as a line of its own is (`ToolLine`), so a step and a lone call line up in one list. {mark} + {lead ? {lead} : null} {step.label} @@ -1826,15 +1839,75 @@ export function stepsUnderWay( ); } +/** + * Whether a conversation lists a call as a row of its own (`ToolActivity`'s `flat`): an app's call, + * or one of OpenBot's own tools (a tool search), that nothing else draws. A command, a file, a page, + * a subtask, a search of the web keeps the card or line it has, which says more than a row can. So + * does a call refused, failed or cut off: its line says why in its own words ("Didn't draw an + * interface"), and a refusal draws the card that fixes it. + */ +export function listsFlat( + step: ToolItem, + isDrawn: (name: string) => boolean, +): boolean { + if (isDrawn(step.toolCall.function.name)) return false; + const details = stepDetails(step); + if (details.failed || details.refused || details.interrupted) return false; + return details.kind === "connector" || details.kind === "tool"; +} + +/** + * How a conversation's steps are listed (`ToolActivity`'s `flat`), and its "Thinking" row with them: + * one size and one tone, so a row that turns into another is the same row with other words. + */ +export const FLAT_STEPS = "space-y-2 py-1 text-muted-foreground text-sm"; + +/** + * The Bot's turn while it has nothing to show: a step's row, where its next step will be. + * + * ONE ROW FOR WAITING AND WORKING. "Thinking" was a line of its own, drawn under the turn and + * swapped for a step's line of another shape once a step began, so the first thing a person saw + * after sending jumped as the work started. Filmed through a real run: "Thinking", "Looking for a + * tool" in a tile, "Thinking" again, "List events" sliding in. Now waiting is a row like a step's, + * the chevron's room and a mark and the words where a step's are: when the step begins, only the + * mark and the words change. + */ +export function ThinkingStep({ + reconnecting = false, +}: { + reconnecting?: boolean; +}) { + return ( +

    7. + + + {/* `status`, not `alert`: progress, said as the shimmer shows it. */} + + {reconnecting ? "Reconnecting…" : "Thinking"} + + +
    8. + ); +} + export function ToolActivity({ group, active, expanded, + flat = false, + thinking = false, }: { group: ToolGroup; /** This is the newest row of a turn still in flight, so a step without a result is running. */ active: boolean; expanded?: boolean; + /** + * A conversation's run of steps: listed open from its first step, one row each, never a line that + * folds them. See `NO_TURN_WORK`. + */ + flat?: boolean; + /** Every step has its answer and the Bot is still on it: "Thinking" where its next step goes. */ + thinking?: boolean; }) { const folders = useContext(FolderNamesContext); // A command with no answer runs while its turn does, whichever row it is in. @@ -1919,6 +1992,40 @@ export function ToolActivity({ toolCallIds={group.steps.map((step) => step.toolCall.id)} /> ); + /* + * A CONVERSATION'S STEPS ARE LISTED AS THEY HAPPEN, AND STAY THAT WAY. A run of app steps was a + * muted line for its first step and became "Using Gmail…" when a second joined it, then folded + * into "Used Gmail" when it finished: the row a person was watching changed shape twice. Here every + * step is a row from the first frame, every row keeps the chevron's room (a step comes to open + * once its call is sent, and its words must not move when it does), and a run on one app names it + * on its first row, beside its logo, as the steps arrive. + */ + if (flat) + return ( + <> +
        + {rows.map((step, at) => { + const app = step.kind === "connector" ? step.appId : undefined; + const above = rows[at - 1]; + const named = + app && !(above?.kind === "connector" && above.appId === app) + ? (step.connector ?? appName(app)) + : undefined; + return ( + + ); + })} + {thinking ? : null} +
      + {approvals} + + ); if (expanded) { return ( <> diff --git a/app/src/components/tasks/turn-work.ts b/app/src/components/tasks/turn-work.ts index 5c9a5a6fef..7f6ae97e7e 100644 --- a/app/src/components/tasks/turn-work.ts +++ b/app/src/components/tasks/turn-work.ts @@ -9,13 +9,6 @@ import { isPersonSentMessage } from "@/components/channels/transcript-turns"; import { readOutcome } from "@/lib/computers/activity"; import { sentFileOf } from "@/lib/computers/sent-file"; import { claudeCodeCall } from "@/lib/copilot/coding-calls"; -import { - asText, - cutOffStep, - refusalOf, - toolResultFailed, - unofferedTool, -} from "@/lib/plugins/tool-result"; /* * A task's thread, read the way dots reads one: what it was asked, one "Worked for 2m" row, and @@ -49,7 +42,16 @@ export type TurnWorkFolds = { inside: Set; }; -/** No folds: a thread that is not a task's. */ +/** + * No folds: a thread that is not a task's. + * + * A CONVERSATION'S TURN NEVER FOLDS. It used to fold once it was over: the steps the person had + * just watched appear one by one were rebuilt, as the answer arrived, into one "Worked through 2 + * steps" line drawn where the first step was, and a step the Bot took after saying something + * jumped above those words. Filmed through a real run, every frame looked fine and the turn read as + * two different drawings of one answer. What a conversation's turn shows while it runs is what it + * keeps: its steps, in order, with what the Bot said between them. + */ export const NO_TURN_WORK: TurnWorkFolds = { at: new Map(), inside: new Set() }; /** @@ -102,24 +104,6 @@ function isPersons(item: TranscriptItem): boolean { ); } -function hasVisibleOutcome(item: TranscriptItem): boolean { - const steps = - item.kind === "tools" ? item.steps : item.kind === "tool" ? [item] : []; - return steps.some(({ result, toolCall }) => { - if (result === undefined) return false; - return ( - cutOffStep(result) || - refusalOf(asText(result)) !== undefined || - unofferedTool(result) || - toolResultFailed(result) || - // A send that sent nothing reads the same whichever of the two tools tried it. - ((toolCall.function.name.startsWith("computer_") || - isSendFileTool(toolCall.function.name)) && - readOutcome(result)?.ok === false) - ); - }); -} - /** * The folds of a task thread's turns. `running` says the last turn is still under way: the person's * browser is streaming it, or the task reads Working. `waiting` is the tool calls held for the @@ -129,7 +113,6 @@ export function foldTurnWork( items: readonly TranscriptItem[], running: boolean, waiting: ReadonlySet = new Set(), - scope: "task" | "conversation" = "task", ): TurnWorkFolds { const folds: TurnWorkFolds = { at: new Map(), inside: new Set() }; // Where each turn starts: just after what the person (or the brief) said. @@ -160,21 +143,16 @@ export function foldTurnWork( ? end - 1 : -1 : (said.at(-1) ?? -1); - // Every piece of a conversation reply stays visible, including text around a chart. - // Leave work visible while the turn is live or when the Bot never produced an answer. - if (scope === "conversation" && (inFlight || answer === -1)) return; const rows: TurnWork["rows"] = []; for (let index = start.from; index < end; index += 1) { const item = items[index]; if (!item || index === answer) continue; // The plan stays in view while its turn runs: it is how the person sees how far along it is. if (inFlight && isPlanStep(item)) continue; - // Keep existing refusal and issue notices at their original place in conversation replies. - if (scope === "conversation" && hasVisibleOutcome(item)) continue; if ( (item.kind === "tools" && !waitsOnThePerson(item, inFlight, waiting)) || (item.kind === "tool" && isWorkStep(item)) || - (scope === "task" && item.kind === "text" && item.role === "assistant") + (item.kind === "text" && item.role === "assistant") ) rows.push({ item, index }); } diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx index 4a337ed764..c4b5bfda51 100644 --- a/app/tests/app-step-rows.test.tsx +++ b/app/tests/app-step-rows.test.tsx @@ -3,13 +3,7 @@ import type { Message } from "@ag-ui/core"; import { CopilotKitProvider } from "@copilotkit/react-core/v2"; import { GlobalRegistrator } from "@happy-dom/global-registrator"; import { QueryClientProvider } from "@tanstack/react-query"; -import { - cleanup, - fireEvent, - render, - waitFor, - within, -} from "@testing-library/react"; +import { cleanup, fireEvent, render, waitFor } from "@testing-library/react"; import { ChatTranscript } from "@/components/channels/chat-transcript"; import { forgetOpenedLines } from "@/components/channels/tool-line"; import { queryClient } from "@/query-client"; @@ -25,10 +19,10 @@ import { settleReactWork } from "./settle-react-work"; * events", with a spinner. The box said nothing the row does not: the action, the app, and that it * was still going. * - * So a run of steps on one app is that app's line, "Using Google Calendar…" while a step runs and - * "Used Google Calendar" once it is done, and opened, each step is one row saying what was done, the - * same row running or done, with no logo the line above already draws. Where the steps are on - * several apps, each row draws its app's logo, which names the app on hover and to a screen reader. + * So each step is one row saying what was done, the same row running or done, listed as the steps + * happen and never folded into a line of their own (a conversation's turn never folds: see + * `NO_TURN_WORK`). Each row draws its app's logo, which names the app on hover and to a screen + * reader, and a run of steps on one app writes the app's name once, on its first row. */ const originalFetch = globalThis.fetch; @@ -181,74 +175,85 @@ function markOf(line: Element) { }; } -test("a run of one app's steps is that app's line while it runs, and opens to one row per step", async () => { - const view = render(transcript(turn(false), true)); +/** The rows of the turn's steps, in order, leaving out "Thinking" where the next step will go. */ +function rowsOf(view: ReturnType): Element[] { + return view + .getAllByRole("list", { name: "Tool steps" }) + .flatMap((list) => [...list.querySelectorAll(":scope > li")]) + .filter((row) => !row.querySelector('[role="status"]')); +} - // While a step runs, the run is its app's line, by the app's name, shimmering, and folded. - const line = await view.findByText("Using Google Calendar…"); - expect(line.closest(".tool-line-running")).not.toBeNull(); - expect(view.queryByRole("list", { name: "Tool steps" })).toBeNull(); - fireEvent.click(line); +/** A row's line: its mark, what it is about and what was done, without the chevron. */ +function lineOf(row: Element): Element { + return (row.querySelector("summary > span:last-child") ?? + row.firstElementChild) as Element; +} + +test("a run of one app's steps is listed as it happens, one row per step, its app named once", async () => { + const view = render(transcript(turn(false), true)); - // Opened, one row a step. - const steps = view.getByRole("list", { name: "Tool steps" }); - const rows = [...steps.querySelectorAll(":scope > li")]; + // Never a line that folds them: each step is a row from the first. + await view.findAllByText("List events"); + expect(view.queryByText("Using Google Calendar…")).toBeNull(); + const rows = rowsOf(view); expect(rows).toHaveLength(3); - const lines = rows.map( - (row) => row.querySelector("summary > span:last-child") as Element, - ); - const [listed, partRead, running] = lines; + const [listed, partRead, running] = rows.map(lineOf); if (!listed || !partRead || !running) throw new Error("Expected 3 lines"); - // What was done, finished or running, and not the app again: the line above says it, and draws its - // logo, so the rows under it don't. - expect(listed.textContent).toBe("List events"); - expect(partRead.textContent).toBe( + // The app by its name on the run's first row; what was done, finished or running, on every row. + expect(said(listed)).toBe("Google CalendarList events"); + expect(said(partRead)).toBe( "Read the next part of an answerList events, part 2 of 3", ); - expect(running.textContent).toBe("List eventsIn progress"); - for (const row of lines) expect(markOf(row).name).toBeUndefined(); + expect(said(running)).toBe("List eventsIn progress"); + // Every row draws its app's logo, which names the app. + await waitFor(() => + expect(rows.map(lineOf).map((line) => markOf(line))).toEqual([ + { name: APP.title, logo: APP.logo }, + { name: APP.title, logo: APP.logo }, + { name: APP.title, logo: APP.logo }, + ]), + ); - // One shape: no box, no app before the action, the same parts in the same order. - const done = shapeOf(listed); - expect(shapeOf(running)).toEqual({ ...done, parts: [...done.parts, "SPAN"] }); - // Only its running says it is running: the label shimmers, and "In progress" where a status goes. + // One shape: the same parts in the same order, running or done; only the running label shimmers, + // and "In progress" is said to a screen reader, which hears no shimmer. + const done = shapeOf(partRead); + const { parts: _parts, ...drawn } = shapeOf(running); + expect(drawn).toEqual({ tag: done.tag, classes: done.classes }); expect(running.querySelector(".tool-line-running")?.textContent).toBe( "List events", ); + expect(running.querySelector(".sr-only")?.textContent).toBe("In progress"); expect(listed.querySelector(".tool-line-running")).toBeNull(); - // Opened, its rows are drawn at the size every list of steps is. - expect(steps.className).toContain("text-sm"); + expect(view.getByRole("list", { name: "Tool steps" }).className).toContain( + "text-sm", + ); // The app's key is never shown as its name. expect(view.container.textContent).not.toContain("Googlecalendar"); expect(view.container.textContent).not.toContain("googlecalendar"); }); -test("answered, the line says what the run did, and its steps stop running and nothing else changes", async () => { +test("answered, its steps stop running and nothing else changes", async () => { const view = render(transcript(turn(false), true)); - fireEvent.click(await view.findByText("Using Google Calendar…")); - const before = shapeOf( - view - .getByRole("list", { name: "Tool steps" }) - .querySelector( - ":scope > li:last-child summary > span:last-child", - ) as Element, - ); + await view.findAllByText("List events"); + const before = rowsOf(view); + const shape = shapeOf(lineOf(before[2] as Element)); - // Every step answered, the same line says what was done. view.rerender(transcript(turn(true), true)); - expect(await view.findByText("Used Google Calendar")).toBeTruthy(); - const after = view.getByRole("list", { name: "Tool steps" }); - expect(after.querySelector(".tool-line-running")).toBeNull(); - const last = after.querySelector( - ":scope > li:last-child summary > span:last-child", - ) as Element; - expect(last.textContent).toBe("List events"); - expect(shapeOf(last)).toEqual({ - ...before, - parts: before.parts.slice(0, -1), - }); + await waitFor(() => + expect( + rowsOf(view).some((row) => row.querySelector(".tool-line-running")), + ).toBe(false), + ); + // The very rows that were there, the last one less its running. + const after = rowsOf(view); + expect(after).toEqual(before); + for (const [at, row] of after.entries()) + expect(row).toBe(before[at] as Element); + const last = lineOf(after[2] as Element); + expect(said(last)).toBe("List events"); + expect(shapeOf(last)).toEqual({ ...shape, parts: shape.parts.slice(0, -1) }); expect(view.container.textContent).not.toContain("Googlecalendar"); }); @@ -268,46 +273,55 @@ test("steps on several apps each draw their app's logo, which names the app", as true, ), ); - fireEvent.click(await view.findByText("Used 2 apps")); - const lines = [ - ...view - .getByRole("list", { name: "Tool steps" }) - .querySelectorAll(":scope > li summary > span:last-child"), - ]; - expect(lines.map(said)).toEqual(["List events", "Fetch emails"]); - expect(lines.map((line) => markOf(line))).toEqual([ - { name: APP.title, logo: APP.logo }, - expect.objectContaining({ name: "Gmail" }), + await view.findByText("Fetch emails"); + const lines = rowsOf(view).map(lineOf); + // Each app's first row names it, beside its logo. + expect(lines.map(said)).toEqual([ + "Google CalendarList events", + "GmailFetch emails", ]); - // The app's name is the logo's, not written on the row. - expect(view.queryByText("Google Calendar")).toBeNull(); + await waitFor(() => + expect(lines.map((line) => markOf(line))).toEqual([ + { name: APP.title, logo: APP.logo }, + expect.objectContaining({ name: "Gmail" }), + ]), + ); }); test("resting the pointer on an app's logo names the app", async () => { const view = render( transcript( - [ASKED, ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" })], + [ + ASKED, + ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" }, EVENTS), + ...call("list-2", LIST_EVENTS, { timeMin: "2026-12-08" }), + ], true, ), ); + // The second row on the app writes no name: its logo is what names it. + await view.findAllByText("List events"); + const second = lineOf(rowsOf(view)[1] as Element); + expect(said(second)).toBe("List eventsIn progress"); const mark = await waitFor(() => { - const found = view.container.querySelector( + const found = second.querySelector( '[role="img"][aria-label="Google Calendar"]', ); if (!found) throw new Error("Expected the app's logo"); return found; }); - expect(view.queryByText("Google Calendar")).toBeNull(); + expect(view.getAllByText("Google Calendar")).toHaveLength(1); fireEvent.pointerEnter(mark, { pointerType: "mouse" }); fireEvent.mouseEnter(mark); fireEvent.pointerMove(mark, { pointerType: "mouse" }); fireEvent.mouseMove(mark); - expect( - await view.findByText("Google Calendar", {}, { timeout: 3000 }), - ).toBeTruthy(); + await waitFor( + () => expect(view.getAllByText("Google Calendar")).toHaveLength(2), + { timeout: 3000 }, + ); }); -test("an app's call on a line of its own reads the same way, running or done", async () => { +test("an app's call on its own reads the same way, running or done", async () => { const one = (answered: boolean) => [ ASKED, ...call( @@ -321,32 +335,29 @@ test("an app's call on a line of its own reads the same way, running or done", a const line = (await view.findByText("List events")) .parentElement as HTMLElement; await waitFor(() => expect(markOf(line).logo).toBe(APP.logo)); - // The app's logo, naming the app; the action; and "In progress" for a screen reader, which hears - // no shimmer. + // A row like any run's: the app's logo, naming the app; the app; the action, shimmering; and + // "In progress" for a screen reader. expect(markOf(line).name).toBe(APP.title); - expect(line.textContent).toBe("List eventsIn progress"); - expect(line.classList.contains("tool-line-running")).toBe(true); + expect(said(line)).toBe("Google CalendarList eventsIn progress"); + expect( + view.getByText("List events").classList.contains("tool-line-running"), + ).toBe(true); expect(line.querySelector(".sr-only")?.textContent).toBe("In progress"); expect(view.container.textContent).not.toContain("Googlecalendar"); view.rerender(transcript(one(true), true)); await waitFor(() => expect( - view - .getByText("List events") - .parentElement?.classList.contains("tool-line-running"), + view.getByText("List events").classList.contains("tool-line-running"), ).toBe(false), ); const done = view.getByText("List events").parentElement; - expect(done?.textContent).toBe("List events"); + expect(said(done as Element)).toBe("Google CalendarList events"); // Drawn as it was while running, less the running. - const running = new Set(["tool-line-running", "tabular-nums"]); - expect([...(done?.classList ?? [])]).toEqual( - [...line.classList].filter((name) => !running.has(name)), - ); + expect(done?.className).toBe(line.className); }); -test("a step that doesn't open keeps the chevron's room in a list where others open, so the rows line up", async () => { +test("every row keeps the chevron's room, so a row that doesn't open lines up with those that do", async () => { const view = render( transcript( [ @@ -358,12 +369,8 @@ test("a step that doesn't open keeps the chevron's room in a list where others o true, ), ); - fireEvent.click(await view.findByText("Used Google Calendar")); - const rows = [ - ...view - .getByRole("list", { name: "Tool steps" }) - .querySelectorAll(":scope > li"), - ]; + await view.findByText("List events"); + const rows = rowsOf(view); expect(rows).toHaveLength(2); const [opens, doesnt] = rows; expect(opens?.querySelector("summary")).not.toBeNull(); @@ -374,131 +381,54 @@ test("a step that doesn't open keeps the chevron's room in a list where others o }); const BETWEEN = "I found the design review. I'm checking next week too."; +const ANSWER = "You have a design review on Tuesday."; -/** A finished turn: calls on Google Calendar, `before` then `after` of them with the Bot's words between. */ -function splitTurn(before: number, after: number): Message[] { +test("app steps the Bot spoke between stay on each side of its words, which are muted", async () => { const list = (n: number) => call(`list-${n}`, LIST_EVENTS, { timeMin: `2026-12-0${n}` }, EVENTS); - return [ - ASKED, - ...Array.from({ length: before }, (_, n) => list(n + 1)).flat(), - { id: "between", role: "assistant", content: BETWEEN }, - ...Array.from({ length: after }, (_, n) => list(before + n + 1)).flat(), - { - id: "answer", - role: "assistant", - content: "You have a design review on Tuesday.", - }, - ]; -} - -for (const [shape, before, after] of [ - ["a call on a line of its own", 1, 1], - ["a list of calls", 2, 2], -] as const) - test(`app steps the Bot spoke between sit as one list once the turn is folded: ${shape} each side`, async () => { - const view = render(transcript(splitTurn(before, after), false)); - const fold = await waitFor(() => { - const found = view.container.querySelector( - '[data-slot="worked-for"] details', - ); - if (!found) throw new Error("Expected the turn's steps folded"); - return found; - }); - fireEvent.click(fold.querySelector("summary") as HTMLElement); - // The apps added here are in: the line draws Google Calendar's own logo. - await waitFor(() => - expect(fold.querySelector("summary img")?.getAttribute("src")).toBe( - APP.logo, - ), - ); - - // The line names the one app its logo shows, beside the logo and before what was done. - const label = within( - fold.querySelector("summary") as HTMLElement, - ).getByText(`Worked through ${before + after} steps`); - const named = label.previousElementSibling; - expect(named?.textContent).toBe(APP.title); - expect( - named?.previousElementSibling?.querySelector("img")?.getAttribute("src"), - ).toBe(APP.logo); - expect(label.nextElementSibling).toBeNull(); - - // Each call is a row of its own, drawn alike, a lone call included: what was done, with no logo, - // since every step in the line is on the one app its line draws. - const lines = within(fold) - .getAllByText("List events") - .map((label) => label.parentElement as Element); - expect(lines).toHaveLength(before + after); - for (const line of lines) { - expect(line.textContent).toBe("List events"); - expect(markOf(line).name).toBeUndefined(); - expect(line.closest('ol[aria-label="Tool steps"]')).not.toBeNull(); - } - - // The rows after the words are drawn up under the ones before, the gap the words left closed. - const drawnUp = (line: Element | undefined) => - line?.closest('[class*="-mt-"]') ?? null; - expect(drawnUp(lines[before - 1])).toBeNull(); - expect(drawnUp(lines[before])).not.toBeNull(); - // The Bot's words are said outside the fold, as always. - expect(view.getByText(BETWEEN).closest("details")).toBeNull(); - }); - -test("a turn's line on several apps names none after what it did, and each logo names its app on hover", async () => { const view = render( transcript( [ ASKED, - ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" }, EVENTS), + ...list(1), + ...list(2), { id: "between", role: "assistant", content: BETWEEN }, - ...call( - "mail-1", - "mcp__gmail__fetch_emails", - { query: "is:unread" }, - '{"messages":[]}', - ), - { - id: "answer", - role: "assistant", - content: "You have a design review on Tuesday.", - }, + ...list(3), + { id: "answer", role: "assistant", content: ANSWER }, ], false, ), ); - const summary = await waitFor(() => { - const found = view.container.querySelector( - '[data-slot="worked-for"] summary', - ); - if (!found) throw new Error("Expected the turn's steps folded"); - return found; - }); - await waitFor(() => - expect( - [...summary.querySelectorAll('[role="img"]')].map((mark) => - mark.getAttribute("aria-label"), - ), - ).toEqual([APP.title, "Gmail"]), - ); - // Two apps: no one app to name; each logo names its own. - const label = within(summary).getByText("Worked through 2 steps"); + await view.findByText(ANSWER); + // Nothing folds: two runs, in the order they happened, each naming its app on its first row. + expect(view.container.querySelector('[data-slot="worked-for"]')).toBeNull(); + const runs = view.getAllByRole("list", { name: "Tool steps" }); + expect(runs).toHaveLength(2); + expect( + runs.map((run) => + [...run.querySelectorAll(":scope > li")].map((row) => said(lineOf(row))), + ), + ).toEqual([ + ["Google CalendarList events", "List events"], + ["Google CalendarList events"], + ]); + const words = view.getByText(BETWEEN); + const [first, second] = runs; + if (!first || !second) throw new Error("Expected two runs"); + expect( + first.compareDocumentPosition(words) & Node.DOCUMENT_POSITION_FOLLOWING, + ).toBeTruthy(); expect( - label.previousElementSibling?.querySelector('[role="img"]'), - ).not.toBeNull(); - expect(label.nextElementSibling).toBeNull(); - expect(view.queryByText("Gmail")).toBeNull(); - const gmail = summary.querySelector( - '[role="img"][aria-label="Gmail"]', - ) as HTMLElement; - fireEvent.pointerEnter(gmail, { pointerType: "mouse" }); - fireEvent.mouseEnter(gmail); - fireEvent.pointerMove(gmail, { pointerType: "mouse" }); - fireEvent.mouseMove(gmail); - expect(await view.findByText("Gmail", {}, { timeout: 3000 })).toBeTruthy(); + words.compareDocumentPosition(second) & Node.DOCUMENT_POSITION_FOLLOWING, + ).toBeTruthy(); + // What it said on the way is muted; its answer is not. + const bubble = (text: string) => + view.getByText(text).closest('[data-slot="bubble-content"]')?.className; + expect(bubble(BETWEEN)).toContain("text-muted-foreground"); + expect(bubble(ANSWER)).not.toContain("text-muted-foreground"); }); -test("a turn that also took a step on no app is still its one app's line, and that app's rows draw no logo", async () => { +test("a step on no app is a row of the same shape, its words where an app step's are", async () => { const view = render( transcript( [ @@ -506,41 +436,21 @@ test("a turn that also took a step on no app is still its one app's line, and th // Given nothing and answered with nothing: a step that opens to nothing. ...call("search", "search_tools", {}, ""), ...call("list-1", LIST_EVENTS, { timeMin: "2026-12-01" }, EVENTS), - { - id: "answer", - role: "assistant", - content: "You have a design review on Tuesday.", - }, + { id: "answer", role: "assistant", content: ANSWER }, ], false, ), ); - const fold = await waitFor(() => { - const found = view.container.querySelector( - '[data-slot="worked-for"] details', - ); - if (!found) throw new Error("Expected the turn's steps folded"); - return found; - }); - const summary = fold.querySelector("summary") as HTMLElement; - await waitFor(() => - expect( - within(summary).getByText("Worked through 2 steps").previousElementSibling - ?.textContent, - ).toBe(APP.title), - ); - fireEvent.click(summary); - const listed = within(fold).getByText("List events").parentElement as Element; - expect(said(listed)).toBe("List events"); - expect(markOf(listed).name).toBeUndefined(); - // "List events" is a chevron and its words: the step that doesn't open draws its wrench in the - // chevron's column, as wide (14px), not after the chevron's room. - const looked = within(fold) - .getByText("Looked for a tool") - .closest("li") as Element; + await view.findByText(ANSWER); + const looked = view.getByText("Looked for a tool").closest("li") as Element; + const listed = view.getByText("List events").closest("li") as Element; + // "List events" opens: its chevron, then its logo. "Looked for a tool" doesn't: the chevron's + // room (20px), then its wrench. Their marks, and their words, start at the same place. + expect(listed.querySelector("summary")).not.toBeNull(); expect(looked.querySelector("summary")).toBeNull(); - expect(looked.className).not.toContain("pl-5"); - expect(looked.querySelector("svg")?.parentElement?.className).toContain( - "w-3.5", + expect(looked.className).toContain("pl-5"); + expect(looked.querySelector("svg")?.getAttribute("class")).toContain( + "size-4", ); + expect(said(lineOf(listed))).toBe("Google CalendarList events"); }); diff --git a/app/tests/flat-turn.test.tsx b/app/tests/flat-turn.test.tsx new file mode 100644 index 0000000000..57cb78f581 --- /dev/null +++ b/app/tests/flat-turn.test.tsx @@ -0,0 +1,225 @@ +import { afterAll, afterEach, beforeAll, expect, test } from "bun:test"; +import type { Message } from "@ag-ui/core"; +import { CopilotKitProvider } from "@copilotkit/react-core/v2"; +import { GlobalRegistrator } from "@happy-dom/global-registrator"; +import { QueryClientProvider } from "@tanstack/react-query"; +import { cleanup, render, within } from "@testing-library/react"; +import { ChatTranscript } from "@/components/channels/chat-transcript"; +import { forgetOpenedLines } from "@/components/channels/tool-line"; +import { queryClient } from "@/query-client"; +import { approvalInboxResponse } from "./approvals-api"; +import { settleReactWork } from "./settle-react-work"; + +/** + * A conversation's turn is drawn one way from send to done: what it showed while it ran is what it + * keeps. + * + * Filmed through a real run ("what's on my calendar tomorrow?": a tool search, a sentence, a Google + * Calendar call, the answer), the turn was drawn one way while the Bot worked and rebuilt when it + * finished: its steps folded into one "Worked through 2 steps" line drawn where the first step was, + * and "List events" jumped above the sentence the Bot had said before it. Every frame looked fine; + * the turn read as two drawings of one answer. + * + * So a conversation's turn never folds. Its steps are rows from their first frame, in the order they + * happened, with what the Bot said between them; "Thinking" is a row in the place the next step + * takes; and when the run ends, nothing is drawn again. + */ + +const originalFetch = globalThis.fetch; + +const APP = { + id: "googlecalendar", + title: "Google Calendar", + logo: "https://apps.example/google-calendar.svg", +}; + +beforeAll(() => { + GlobalRegistrator.register({ url: "http://localhost/" }); + globalThis.fetch = Object.assign( + async (input: Parameters[0]) => { + const url = new URL( + typeof input === "string" + ? input + : input instanceof URL + ? input.href + : input.url, + "http://localhost", + ); + const approvals = approvalInboxResponse(url.pathname, { + enabled: false, + requests: [], + rules: [], + teamRules: [], + questions: [], + }); + if (approvals) return approvals; + if (url.pathname === "/api/v2/organizations/default/apps") + return Response.json({ apps: [APP], nextCursor: null }); + return Response.json({ error: "not served" }, { status: 404 }); + }, + { preconnect: originalFetch.preconnect }, + ); +}); + +afterEach(() => { + cleanup(); + forgetOpenedLines(); + queryClient.clear(); +}); + +afterAll(async () => { + await settleReactWork(); + globalThis.fetch = originalFetch; + GlobalRegistrator.unregister(); +}); + +const ASKED: Message = { + id: "u1", + role: "user", + content: "What's on my calendar tomorrow?", +}; +const SAID_ON_THE_WAY = "Tomorrow is Sunday, December 6."; +const ANSWER = "Tomorrow you have a design review at 9:30."; + +/** The run, as far as it has got: `stage` 1 has the tool search answered, 2 the calendar call, 3 the answer. */ +function run(stage: 1 | 2 | 3): Message[] { + return [ + ASKED, + { + id: "a1", + role: "assistant", + content: "", + toolCalls: [ + { + id: "search", + type: "function", + function: { + name: "search_tools", + arguments: '{"query":"calendar events","limit":5}', + }, + }, + ], + }, + { + id: "t-search", + role: "tool", + toolCallId: "search", + content: '[{"name":"GOOGLECALENDAR_EVENTS_LIST"}]', + }, + ...(stage < 2 + ? [] + : ([ + { + id: "a2", + role: "assistant", + content: SAID_ON_THE_WAY, + toolCalls: [ + { + id: "list", + type: "function", + function: { + name: "mcp__googlecalendar__list_events", + arguments: '{"calendarId":"primary"}', + }, + }, + ], + }, + { + id: "t-list", + role: "tool", + toolCallId: "list", + content: '{"items":[{"summary":"Design review"}]}', + }, + ] satisfies Message[])), + ...(stage < 3 + ? [] + : ([ + { id: "a3", role: "assistant", content: ANSWER }, + ] satisfies Message[])), + ]; +} + +function transcript(messages: Message[], busy: boolean) { + return ( + + + + + + ); +} + +/** The turn's rows and words, in the order they are drawn, as a person reads them. */ +function reading(container: HTMLElement): string[] { + return [ + ...container.querySelectorAll( + '[aria-label="Tool steps"] > li, [data-reply-prose]', + ), + ].map((row) => { + const copy = row.cloneNode(true) as Element; + for (const hidden of copy.querySelectorAll("[aria-hidden], .sr-only")) + hidden.remove(); + // Each piece of a row read as its own word: "Google Calendar", then "List events". + const words: string[] = []; + const walk = document.createTreeWalker(copy, NodeFilter.SHOW_TEXT); + for (let node = walk.nextNode(); node; node = walk.nextNode()) + if (node.textContent?.trim()) words.push(node.textContent.trim()); + return words.join(" ").replace(/\s+/g, " "); + }); +} + +test("a finished turn keeps every row where it was, the same rows, when its run ends", async () => { + const view = render(transcript(run(3), true)); + await view.findByText(ANSWER); + const listed = view.getByText("List events").closest("li"); + const searched = view.getByText("Looked for a tool").closest("li"); + const before = reading(view.container); + expect(before).toEqual([ + "Looked for a tool", + SAID_ON_THE_WAY, + "Google Calendar List events", + ANSWER, + ]); + + view.rerender(transcript(run(3), false)); + await view.findByText(ANSWER); + + // Nothing folds, nothing is reordered, and the rows are the very rows that were there. + expect(view.queryByText(/Worked (through|for)/)).toBeNull(); + expect(reading(view.container)).toEqual(before); + expect(view.getByText("List events").closest("li")).toBe(listed); + expect(view.getByText("Looked for a tool").closest("li")).toBe(searched); +}); + +test("what the Bot said before a step it took is muted, and its answer is not", async () => { + const view = render(transcript(run(3), false)); + await view.findByText(ANSWER); + const muted = (text: string) => + ( + view.getByText(text).closest('[data-slot="bubble-content"]')?.className ?? + "" + ).includes("text-muted-foreground"); + expect(muted(SAID_ON_THE_WAY)).toBe(true); + expect(muted(ANSWER)).toBe(false); +}); + +test("Thinking is a row where the next step goes: under a run's answered steps, in their list", async () => { + const view = render(transcript(run(1), true)); + const thinking = await view.findByRole("status"); + expect(thinking.textContent).toBe("Thinking"); + const steps = view.getByRole("list", { name: "Tool steps" }); + // In the run's own list, after its step: the row a step that joins the run takes. + expect(within(steps).getByRole("status")).toBe(thinking); + expect( + [...steps.querySelectorAll(":scope > li")].map((row) => row.textContent), + ).toEqual(["Looked for a tool", "Thinking"]); +}); + +test("Thinking, before any step, is a row shaped like a step's", async () => { + const view = render(transcript([ASKED], true)); + const thinking = await view.findByRole("status"); + const row = thinking.closest("li"); + // The chevron's room and a mark, as every step's row has, so a step that takes its place moves nothing. + expect(row?.className).toContain("pl-5"); + expect(row?.querySelector("svg")).not.toBeNull(); +}); diff --git a/app/tests/plan-turns.test.ts b/app/tests/plan-turns.test.ts index cc2d8cb3fb..2bacd1dc44 100644 --- a/app/tests/plan-turns.test.ts +++ b/app/tests/plan-turns.test.ts @@ -234,7 +234,7 @@ describe("the plan in a turn's fold", () => { gmail("g1"), said("a1", "Four drafts are in Gmail."), ]); - const folds = foldTurnWork(items, false, new Set(), "conversation"); + const folds = foldTurnWork(items, false); expect(folds.inside.has("p1")).toBe(true); const work = folds.at.get("p1"); expect(work && stepsIn(work)).toBe(1); diff --git a/app/tests/running-step-shimmer.test.tsx b/app/tests/running-step-shimmer.test.tsx index cd8927dc47..ddaebcbb08 100644 --- a/app/tests/running-step-shimmer.test.tsx +++ b/app/tests/running-step-shimmer.test.tsx @@ -3,7 +3,7 @@ import type { Message } from "@ag-ui/core"; import { CopilotKitProvider } from "@copilotkit/react-core/v2"; import { GlobalRegistrator } from "@happy-dom/global-registrator"; import { QueryClientProvider } from "@tanstack/react-query"; -import { cleanup, fireEvent, render } from "@testing-library/react"; +import { cleanup, render, waitFor } from "@testing-library/react"; import { ChatTranscript } from "@/components/channels/chat-transcript"; import { forgetOpenedLines } from "@/components/channels/tool-line"; import { queryClient } from "@/query-client"; @@ -140,34 +140,32 @@ function said(row: HTMLElement): string { test("the running app step shimmers, beside the steps already done, until it has an answer", async () => { const view = render(transcript(run(false), true)); - // While it works, the group is its app's line, shimmering, folded until it is opened. - const line = await view.findByText("Using Gmail…"); - expect(line.closest(`.${SHIMMER}`)).not.toBeNull(); - expect(view.queryByText("Fetch thread messages")).toBeNull(); - fireEvent.click(line); - + // A conversation lists its steps as they happen, one row each, never folded (`NO_TURN_WORK`). // Named as the app's page names it, not in its stored order ("Fetch message by thread id"). const running = await view.findByText("Fetch thread messages"); expect(running.classList.contains(SHIMMER)).toBe(true); - // Its row says what the finished rows say, in the same order, and that it is under way. The line - // above already shows Gmail, so the row doesn't draw its logo again. + expect(view.queryByText("Using Gmail…")).toBeNull(); + // Its row says what the finished rows say, in the same order, and, to a screen reader, that it is + // under way: the shimmer says it to everybody else. const row = running.parentElement as HTMLElement; expect(said(row)).toBe("Fetch thread messagesIn progress"); - expect(row.querySelector('[role="img"]')).toBeNull(); - // The steps already answered look as they always have. + expect(row.querySelector(".sr-only")?.textContent).toBe("In progress"); + // The steps already answered look as they always have. The run names Gmail once, on its first row. const finished = view.getAllByText("Fetch emails"); expect(finished).toHaveLength(4); for (const step of finished) { expect(step.classList.contains(SHIMMER)).toBe(false); expect(step.parentElement?.className).toBe(row.className); } + expect(view.getAllByText("Gmail")).toHaveLength(1); - // Answered: the step stays in the group, which says what it did, and its progress indicator goes. + // Answered: the step stays where it was, and its progress indicator goes. view.rerender(transcript(run(true), true)); - expect(await view.findByText("Used Gmail")).toBeTruthy(); - expect( - view.getByText("Fetch thread messages").classList.contains(SHIMMER), - ).toBe(false); + await waitFor(() => + expect( + view.getByText("Fetch thread messages").classList.contains(SHIMMER), + ).toBe(false), + ); expect(view.queryByText("In progress")).toBeNull(); expect(view.queryByRole("list", { name: "Working now" })).toBeNull(); }); @@ -175,10 +173,15 @@ test("the running app step shimmers, beside the steps already done, until it has test("once every step has its answer and the model is still going, the transcript says it is thinking", async () => { const view = render(transcript(run(true), true)); - expect(await view.findByText("Used Gmail")).toBeTruthy(); - const thinking = view.getByText("Thinking"); - expect(thinking.getAttribute("role")).toBe("status"); + // In the run's own list, where its next step would go (`ThinkingStep`). + const thinking = await view.findByRole("status"); + expect(thinking.textContent).toBe("Thinking"); expect(thinking.classList.contains(SHIMMER)).toBe(true); + expect( + thinking + .closest('[aria-label="Tool steps"]') + ?.contains(view.getByText("Fetch thread messages")), + ).toBe(true); // The turn ends: nothing says it is still working. view.rerender(transcript(run(true), false)); diff --git a/app/tests/tool-result-parts.test.tsx b/app/tests/tool-result-parts.test.tsx index 54ea45a84a..41303e7195 100644 --- a/app/tests/tool-result-parts.test.tsx +++ b/app/tests/tool-result-parts.test.tsx @@ -3,7 +3,7 @@ import type { Message } from "@ag-ui/core"; import { CopilotKitProvider } from "@copilotkit/react-core/v2"; import { GlobalRegistrator } from "@happy-dom/global-registrator"; import { QueryClientProvider } from "@tanstack/react-query"; -import { cleanup, fireEvent, render } from "@testing-library/react"; +import { cleanup, fireEvent, render, waitFor } from "@testing-library/react"; import { toVisibleChatItems } from "@/components/channels/chat-messages"; import { ChatTranscript } from "@/components/channels/chat-transcript"; import { dropRepeatedAppCards } from "@/components/channels/tool-activity"; @@ -125,8 +125,7 @@ test("a stored Read of a picture opens, and draws the Read step and the reply", const view = draw(read.messages); expect(await view.findByText("It is a ribbon diagram.")).toBeTruthy(); - // The finished turn's work is folded; opened, as a person does, it shows the Read step. - fireEvent.click(view.getByText("Worked through 1 step")); + // A conversation's turn never folds: the Read step is in view where it happened. expect(await view.findByText("model2.png")).toBeTruthy(); expect(view.getByText("Read")).toBeTruthy(); expect(view.getByText("Returned an image.")).toBeTruthy(); @@ -141,8 +140,7 @@ test("a result in several text parts reads as those parts, a paragraph each", as const view = draw(read.messages); expect(await view.findByText("It is a ribbon diagram.")).toBeTruthy(); - fireEvent.click(view.getByText("Worked through 1 step")); - // An app's step in the line is a row that opens to its answer, as a person opens it. + // An app's step is a row that opens to its answer, as a person opens it. fireEvent.click(await view.findByText("Search")); // Each part its own paragraph: run together, they read "Found 2 pages Ribbon diagrams …". expect(view.getByText("Found 2 pages").tagName).toBe("P"); @@ -159,9 +157,11 @@ test("a live result that is a JSON object is drawn as JSON", async () => { const view = draw(live); expect(await view.findByText("It is a ribbon diagram.")).toBeTruthy(); - fireEvent.click(view.getByText("Worked through 1 step")); - expect(await view.findByText("Lookup rows")).toBeTruthy(); - expect(view.container.textContent).toContain('"rows": 2'); + // Its row opens to what came back, as a person opens it. + fireEvent.click(await view.findByText("Lookup rows")); + await waitFor(() => + expect(view.container.textContent).toContain('"rows": 2'), + ); }); test("the result readers take a list of parts as text", () => { diff --git a/app/tests/work-folded.test.tsx b/app/tests/work-folded.test.tsx index 27fcafca2d..97f2cd933c 100644 --- a/app/tests/work-folded.test.tsx +++ b/app/tests/work-folded.test.tsx @@ -169,7 +169,7 @@ function lineOf(fold: HTMLDetailsElement): string { return summary.textContent ?? ""; } -test("regular chat folds finished app calls and keeps all answer text outside", async () => { +test("regular chat never folds its app calls, running or finished, and keeps all answer text outside", async () => { const [ask, ...steps] = conversation([ { id: "notion-1", @@ -200,30 +200,22 @@ test("regular chat folds finished app calls and keeps all answer text outside", expect(view.getByText("In progress")).toBeTruthy(); view.rerender(transcript([ask, ...steps.slice(0, 3)], true)); - // Two calls on Notion while the turn runs: Notion's line, shimmering, which opens to its steps. - fireEvent.click(await view.findByText("Using Notion…")); + // Two calls on Notion while the turn runs: a row each, listed as they happen, never one line. + expect(await view.findByText("Get page")).toBeTruthy(); + expect(view.queryByText("Using Notion…")).toBeNull(); const liveSteps = view.getByRole("list", { name: "Tool steps" }); - expect(liveSteps.textContent).toContain("Get page"); + expect(liveSteps.textContent).toContain("Search pages"); expect(view.getAllByText("Get page")).toHaveLength(1); + // Finished, nothing folds: the same rows, where they were (`NO_TURN_WORK`). view.rerender(transcript(messages)); - const fold = view.container.querySelector( - '[data-slot="worked-for"] details', - ); - expect(fold?.open).toBe(false); - expect(fold?.querySelector("summary")?.textContent).toContain( - "Worked through 2 steps", - ); - expect(fold?.querySelector('summary img[src*="notion.svg"]')).not.toBeNull(); - fireEvent.click(fold?.querySelector("summary") as HTMLElement); - const completedSteps = view.getByRole("list", { name: "Tool steps" }); - expect(completedSteps.textContent).toContain("Search pages"); - expect(completedSteps.textContent).toContain("Get page"); - expect( - (await view.findByText("Here are the figures.")).closest("details"), - ).toBeNull(); + expect(await view.findByText("The busiest day was Tuesday.")).toBeTruthy(); + expect(view.container.querySelector('[data-slot="worked-for"]')).toBeNull(); + expect(view.getByRole("list", { name: "Tool steps" })).toBe(liveSteps); + expect(liveSteps.textContent).toContain("Get page"); + expect(view.getByText("Here are the figures.").closest("details")).toBeNull(); expect( - (await view.findByText("The busiest day was Tuesday.")).closest("details"), + view.getByText("The busiest day was Tuesday.").closest("details"), ).toBeNull(); }); From 7f168f8aaaa51b9aab23f036af4ed05a37b07b19 Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Sat, 5 Dec 2026 07:28:13 -0800 Subject: [PATCH 10/13] A tool search is one more entry in a conversation's list of steps, pinned Its row is in the same list as the app step after it, drawn with the same line, and its wrench is a bare 16px icon in that line, not set in a tile. Co-Authored-By: Claude Opus 5.5 --- app/tests/app-step-rows.test.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx index c4b5bfda51..3f3fff41d9 100644 --- a/app/tests/app-step-rows.test.tsx +++ b/app/tests/app-step-rows.test.tsx @@ -449,8 +449,16 @@ test("a step on no app is a row of the same shape, its words where an app step's expect(listed.querySelector("summary")).not.toBeNull(); expect(looked.querySelector("summary")).toBeNull(); expect(looked.className).toContain("pl-5"); - expect(looked.querySelector("svg")?.getAttribute("class")).toContain( - "size-4", - ); expect(said(lineOf(listed))).toBe("Google CalendarList events"); + + // ONE MORE ENTRY IN THE LIST (Atai: "it should just be one more entry in the list with its own + // icon… no weird spacing"). The same list as the app's step, so the same gap to it; its line drawn + // with the same classes, so the same size, tone and height; and its wrench a bare 16px icon + // straight in that line, where an app step has its logo, not set in a tile of its own. + expect(looked.parentElement).toBe(listed.parentElement); + expect(lineOf(looked).className).toBe(lineOf(listed).className); + const wrench = looked.querySelector("svg") as SVGElement; + expect(wrench.getAttribute("class")).toContain("size-4"); + expect(wrench.parentElement).toBe(lineOf(looked) as HTMLElement); + expect(looked.querySelector('[class*="rounded-full"]')).toBeNull(); }); From fe85f2187e1d432d189502858e9aef167b458afa Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Sat, 5 Dec 2026 07:48:39 -0800 Subject: [PATCH 11/13] A step the server ran is one more row in a turn's opened list, and "worked" follows an app's name in lower case Opened, "Worked through 4 steps" listed "Looked for a tool" as a muted line of its own, its wrench in a gray circle and a gap under it, above rows of app steps drawn bare. A lone call the server ran is now a step row in the same list (ToolActivity), with its own mark, the chevron's room kept, and the same spacing; a tool search opens to the tools it found, as its line of its own does. Calls the app draws itself (a command and its terminal) keep their own cards. Every row draws its own mark, the app's logo included where the line names the app, and a single mark is drawn bare everywhere. Where the line names its one app, what was done carries on from the name in lower case: "Google Calendar worked through 2 steps". Co-Authored-By: Claude Opus 5.5 --- .../components/channels/chat-transcript.tsx | 122 ++++++------ app/src/components/channels/tool-activity.tsx | 132 +++++-------- app/src/components/tasks/worked-for.tsx | 9 +- app/tests/app-step-rows.test.tsx | 40 ++-- app/tests/long-answer-part-steps.test.tsx | 5 +- app/tests/running-step-shimmer.test.tsx | 8 +- app/tests/step-rows-layout.test.tsx | 187 +++++++++++------- app/tests/task-worked-for.test.tsx | 7 +- app/tests/tool-result-parts.test.tsx | 6 +- app/tests/work-folded.test.tsx | 3 +- 10 files changed, 262 insertions(+), 257 deletions(-) diff --git a/app/src/components/channels/chat-transcript.tsx b/app/src/components/channels/chat-transcript.tsx index 6a67b8d3c9..9da38f4e35 100644 --- a/app/src/components/channels/chat-transcript.tsx +++ b/app/src/components/channels/chat-transcript.tsx @@ -28,7 +28,7 @@ import { ownToolSubject, readToolName, } from "@openbot/shared/tool-name"; -import { SEARCH_TOOLS, toolsFound } from "@openbot/shared/tool-search"; +import { SEARCH_TOOLS } from "@openbot/shared/tool-search"; import { QueryClientContext, useQuery } from "@tanstack/react-query"; import { motion, useReducedMotion } from "motion/react"; import { @@ -198,12 +198,10 @@ import { ReplyToolbar } from "./telemetry-assistant-message"; import { ActivityAppMarks, AppMark, - appOfCall, attachmentReadName, dropRepeatedAppCards, + foundToolsInWords, groupToolSteps, - LineShowsApp, - onlyApp, rowApps, ServerStepIcon, ToolActivity, @@ -2069,6 +2067,28 @@ export function sameToolRow(a: ToolRowProps, b: ToolRowProps): boolean { ); } +/** + * Whether a row of calls is drawn as steps (`ToolActivity`), not as a lone call's own line or card + * (`ToolCallBody`). A run is steps, and so is a lone browser step, and a subtask, which is drawn as + * work even alone, so a second call joining it does not change its shape. + * + * `openAmongRows`: drawn open among a conversation's "Worked for" line's rows, where a lone call the + * server ran is a step as theirs are. "Looked for a tool" was a muted line in a gray circle, a gap + * above "Find free slots"; it is one more entry in the list, with its own mark. A call the app draws + * itself (a command and its terminal) keeps its own card there. + */ +function drawnAsSteps( + steps: ToolGroup["steps"], + isDrawn: (name: string) => boolean, + openAmongRows: boolean, +): boolean { + const [only] = steps; + if (steps.length !== 1 || !only || isBrowserStep(only)) return true; + const name = only.toolCall.function.name; + if (name === SUBAGENT_TOOL) return true; + return openAmongRows && (name.startsWith("mcp__") || !isDrawn(name)); +} + const ToolRow = memo(function ToolRow({ id, steps, @@ -2080,18 +2100,12 @@ const ToolRow = memo(function ToolRow({ folds, }: ToolRowProps) { const [only] = steps; + const isDrawn = useDrawnTool(); useReportsDesktopActivity(steps, active); return ( - {steps.length === 1 && - only && - !isBrowserStep(only) && - // Drawn open among a "Worked for" line's rows, a lone app call is a step as theirs are, not - // a muted line of its own beside them (`ToolActivity`). - !(expanded && folds && appOfCall(only.toolCall.function.name)) && - // A subtask is drawn as work even alone, so a second call joining it does not change its shape. - only.toolCall.function.name !== SUBAGENT_TOOL ? ( + {only && !drawnAsSteps(steps, isDrawn, Boolean(expanded && folds)) ? ( - ) : ( - - ), - })} + icon={ + appId ? ( + + ) : ( + + ) + } label={label} refused={refused} failed={failed} @@ -2301,22 +2311,6 @@ export function ServerToolLine({ ); } -/** - * The tools a search found, one to a line by the name a step gives each ("Send email on Gmail"). The - * search answers the model, naming each tool by the id it is offered under - * (`mcp__composio-gmail__GMAIL_SEND_EMAIL`), and the step opened to that answer as it was. - */ -function foundToolsInWords(answer: string | undefined): string | undefined { - const names = answer ? toolsFound(answer) : []; - if (names.length === 0) return undefined; - return names - .map((name) => { - const { label, detail } = readToolName(name); - return `- ${detail ? `${label} on ${detail}` : label}`; - }) - .join("\n"); -} - /* * Moved beside the turns it also decides; re-exported for the callers that read it from here. And * the lightbox's picture, now in attachment-view.tsx, where the transcript's tests import it from. @@ -3201,32 +3195,30 @@ export function ChatTranscript({ threadId={taskThread ? threadId : undefined} work={work} > - row.item))} - > - {work.rows.map((row, at) => { - // App steps the Bot's words had split into rows of their own sit as one list: its - // words are drawn outside this line, and the gap they left says nothing in here. Only - // rows drawn alike: a call on a line of its own is a muted line, a list's steps aren't. - const above = work.rows[at - 1]; - const shape = stepsShape(row.item); - const joins = - above !== undefined && - stepsShape(above.item) === shape && - rowApps(above.item).last !== undefined && - rowApps(row.item).first !== undefined; - const drawn = rowContent(row.item, row.index, !taskThread); - return ( - - {joins ? ( -
      {drawn}
      - ) : ( - drawn - )} -
      - ); - })} -
      + {work.rows.map((row, at) => { + // Steps the Bot's words had split into rows of their own sit as one list: its words + // are drawn outside this line, and the gap they left says nothing in here. Only rows + // drawn alike: a card is not a step. In a conversation every run of steps is drawn + // open, as a list (`drawnAsSteps`); in a task's thread, only an app's are joined. + const above = work.rows[at - 1]; + const listOfSteps = (item: TranscriptItem) => + item.kind === "tools" && + drawnAsSteps(item.steps, isDrawn, true); + const shape = taskThread ? stepsShape(row.item) : "list"; + const joins = + above !== undefined && + (taskThread + ? stepsShape(above.item) === shape && + rowApps(above.item).last !== undefined && + rowApps(row.item).first !== undefined + : listOfSteps(above.item) && listOfSteps(row.item)); + const drawn = rowContent(row.item, row.index, !taskThread); + return ( + + {joins ?
      {drawn}
      : drawn} +
      + ); + })} ); diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index 30c8ae5117..ac271c980b 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -26,6 +26,7 @@ import { ownToolLabel, readToolName, } from "@openbot/shared/tool-name"; +import { SEARCH_TOOLS, toolsFound } from "@openbot/shared/tool-search"; import { QueryClientContext, useQuery } from "@tanstack/react-query"; import { createContext, @@ -704,9 +705,13 @@ function detailsOf( pages: 0, }; } - if (!name.startsWith("mcp__")) + if (!name.startsWith("mcp__")) { + // A tool search opens to the tools it found, in words, as its line of its own does. + const found = + name === SEARCH_TOOLS && !refused ? foundToolsInWords(answer) : undefined; return { ...outcome, + ...(found ? { output: found } : {}), kind: "tool", // Beside "Blocked", what was tried: "Save a file", not "Saved a file", which did not happen. // So too beside "Didn't work", for a step that then did not happen: "Draw an interface". @@ -718,6 +723,7 @@ function detailsOf( ...(name === RECALL_EARLIER_RESULTS ? { rereads: 1 } : {}), pages: 0, }; + } const [, server = "", ...rest] = name.split("__"); const role = researchRoleOfTool(server, rest.join("__")); @@ -771,6 +777,25 @@ function detailsOf( }; } +/** + * The tools a search found, one to a line by the name a step gives each ("Send email on Gmail"). The + * search answers the model, naming each tool by the id it is offered under + * (`mcp__composio-gmail__GMAIL_SEND_EMAIL`), and the step opened to that answer as it was. Its line + * of its own (`ServerToolLine`) and its row in a list open to the same words. + */ +export function foundToolsInWords( + answer: string | undefined, +): string | undefined { + const names = answer ? toolsFound(answer) : []; + if (names.length === 0) return undefined; + return names + .map((name) => { + const { label, detail } = readToolName(name); + return `- ${detail ? `${label} on ${detail}` : label}`; + }) + .join("\n"); +} + /** * The name of the attached file a `read_attachment` step read part of, from the server's answer * (`{ attachment_id, name, offset, text, next_offset, total_length }`), or undefined while it runs or @@ -1302,10 +1327,16 @@ function IconStack({ marks }: { marks: { kind: StepKind; appId?: string }[] }) { const icons = Array.from( new Map(marks.map((mark) => [mark.appId ?? mark.kind, mark])).values(), ); + /* + * ONE MARK IS BARE. A lone "Looked for a tool" drew its wrench in a gray circle, and the app steps + * beside it their logos bare: two kinds of row for one kind of thing. A single mark is drawn as a + * step's row draws it (`StepMark`); only marks that overlap need the circle that parts them. + */ if (icons.length === 1) { const [mark] = icons; if (mark?.appId) return ; + if (mark) return ; } /* * AN APP'S LOGO NAMES IT WHEREVER IT IS. A step's row named its app on hover (`AppMark`), but the @@ -1414,25 +1445,10 @@ export function StepStatus({ return null; } -/** - * The one app a folded line already shows ("Used Google Calendar", or "Google Calendar Worked - * through 2 steps" beside its logo). Its steps on that app don't draw its logo again. - * - * ONE LOGO FOR ONE APP. Opened, "Used Google Calendar" listed three steps, each beside the Google - * Calendar logo the line above them had just drawn: the same mark four times, telling nothing the - * first didn't. Where the steps are on several apps, each still draws its own, since that is how - * they are told apart. - */ -export const LineShowsApp = createContext(undefined); - /** * The one app the steps in `items` are on, leaving out steps on no app ("Looked for a tool"); none - * if they are on several apps, or on none. - * - * ONE RULE FOR THE LINE AND ITS ROWS. A turn that looked for a tool, then listed events, read - * "Google Calendar Worked through 2 steps", and opened to "List events" beside the Google - * Calendar logo again: the line named the one app among its logos, the rows asked whether every - * step was on it. Both now ask this. + * if they are on several apps, or on none. A turn's folded line names it: "Google Calendar Worked + * through 2 steps". */ export function onlyApp(items: readonly TranscriptItem[]): string | undefined { const apps = new Set(); @@ -1475,21 +1491,14 @@ export function AppMark({ appId, name }: { appId: string; name: string }) { ); } -/** Whether a step's row draws a mark: every step does, but one on the app its line shows (`shown`). */ -export function drawsMark( - step: StepDetails, - shown: string | undefined, -): boolean { - return !(step.kind === "connector" && step.appId && step.appId === shown); -} - /** - * A step's mark: an app's logo named on hover (`AppMark`), or the icon for its kind of step. None for - * a step on the app the line above it already shows (`LineShowsApp`). + * A step's mark: an app's logo named on hover (`AppMark`), or the icon for its kind of step. + * + * EVERY ROW DRAWS ITS OWN. Under "Google Calendar Worked through 2 steps", "List events" drew no + * logo (the line had just shown it) while "Looked for a tool" drew its wrench, so one list held two + * shapes of row. Every step is one more entry in the list, with its own mark. */ function StepMark({ step }: { step: StepDetails }) { - const shown = useContext(LineShowsApp); - if (!drawsMark(step, shown)) return null; return step.kind === "connector" && step.appId ? ( ; /* @@ -1570,10 +1572,10 @@ export function StepRow({ * row, shimmering, with "In progress" where "Blocked" or "Didn't work" would be. */ const running = active && step.pending; - const lineWith = (mark: ReactNode) => ( + const line = ( // Spaced as a line of its own is (`ToolLine`), so a step and a lone call line up in one list. - {mark} + {step.label} @@ -1592,7 +1594,6 @@ export function StepRow({ ); - const line = lineWith(); const reason = step.failed && step.kind === "browser" ? (

      @@ -1610,28 +1611,13 @@ export function StepRow({ ); // A browser step says everything it has in its line. Anything else opens to what it was given // and what came back, which no other place in the transcript shows. - if (!stepOpens(step)) { - /* - * THE MARK IN THE CHEVRON'S COLUMN. Under "Google Calendar Worked through 2 steps", "List - * events" is its chevron and its words, no logo; "Looked for a tool" kept the chevron's room and - * drew its wrench after it, so its words started a mark further in. Where the rows that open - * draw no mark, this one's stands where their chevron does, as wide, and its words start where - * theirs do. - */ - const inChevron = markInChevron && drawsMark(step, shown); + if (!stepOpens(step)) return ( -

    9. - {inChevron - ? lineWith( - - - , - ) - : line} +
    10. + {line} {reason}
    11. ); - } return (
    12. @@ -1839,7 +1825,6 @@ export function ToolActivity({ const folders = useContext(FolderNamesContext); // A command with no answer runs while its turn does, whichever row it is in. const inFlight = useContext(TurnInFlightContext); - const lineShows = useContext(LineShowsApp); const appName = useAppName(); const steps = group.steps.map( stepDetailsIn(folders, active || inFlight, appName), @@ -1886,34 +1871,17 @@ export function ToolActivity({ const live = running ? rows.filter((step) => step.pending && !step.interrupted) : []; - const chevronRoom = rows.some(stepOpens); - const oneApp = appsOnly && apps.length === 1 ? rows[0]?.appId : undefined; - // The app the line above these rows shows: their own line's, or, drawn open, the one around them. - const shown = expanded ? lineShows : oneApp; - const markInChevron = - chevronRoom && - !rows.some((step) => stepOpens(step) && drawsMark(step, shown)); - const rowsList = ( + const list = ( // One size wherever it is opened: a folded line's own body is drawn smaller, a "Worked for" // line's isn't, and the same steps read at two sizes in one conversation.
        {rows.map((step) => ( - + // The chevron's room is kept whether or not any row here opens: a list of one step that + // doesn't sits beside lists whose steps do, and their marks and words line up. + ))}
      ); - // Folded, its own line shows its app; drawn open, the line it sits under does (`LineShowsApp`). - const list = expanded ? ( - rowsList - ) : ( - {rowsList} - ); const approvals = ( step.toolCall.id)} diff --git a/app/src/components/tasks/worked-for.tsx b/app/src/components/tasks/worked-for.tsx index e9db377dbf..964c6ed199 100644 --- a/app/src/components/tasks/worked-for.tsx +++ b/app/src/components/tasks/worked-for.tsx @@ -259,13 +259,14 @@ function WorkLine({ */ drawnWhenOpened={!running} icon={apps.length ? : undefined} - label={text} /* * THE ONE APP, NAMED. "Worked through 2 steps" beside Google Calendar's logo said which app - * only to someone who knew the logo; its rows don't name it (`LineShowsApp`). Where the - * line's logo is one app's, the line names it beside the logo, before what was done: - * "Google Calendar Worked through 2 steps". + * only to someone who knew the logo, and its rows don't name it in words (`AppMark`). Where + * the line's logo is one app's, the line names it beside the logo, before what was done, and + * what was done carries on from the name, in lower case: "Google Calendar worked through 2 + * steps". Every word the line can start with ("Worked", "Working") is an ordinary word. */ + label={app ? text.charAt(0).toLowerCase() + text.slice(1) : text} {...(app ? { lead: appName(app) } : {})} running={running} openKey={work.id} diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx index 4a337ed764..d876fe60f5 100644 --- a/app/tests/app-step-rows.test.tsx +++ b/app/tests/app-step-rows.test.tsx @@ -27,8 +27,8 @@ import { settleReactWork } from "./settle-react-work"; * * So a run of steps on one app is that app's line, "Using Google Calendar…" while a step runs and * "Used Google Calendar" once it is done, and opened, each step is one row saying what was done, the - * same row running or done, with no logo the line above already draws. Where the steps are on - * several apps, each row draws its app's logo, which names the app on hover and to a screen reader. + * same row running or done, beside its app's logo, which names the app on hover and to a screen + * reader. Every step is one more entry in the list, a step on no app included, with its own mark. */ const originalFetch = globalThis.fetch; @@ -200,14 +200,13 @@ test("a run of one app's steps is that app's line while it runs, and opens to on const [listed, partRead, running] = lines; if (!listed || !partRead || !running) throw new Error("Expected 3 lines"); - // What was done, finished or running, and not the app again: the line above says it, and draws its - // logo, so the rows under it don't. + // What was done, finished or running, and not the app's name again: its logo says it, on every row. expect(listed.textContent).toBe("List events"); expect(partRead.textContent).toBe( "Read the next part of an answerList events, part 2 of 3", ); expect(running.textContent).toBe("List eventsIn progress"); - for (const row of lines) expect(markOf(row).name).toBeUndefined(); + for (const row of lines) expect(markOf(row).name).toBe(APP.title); // One shape: no box, no app before the action, the same parts in the same order. const done = shapeOf(listed); @@ -413,10 +412,11 @@ for (const [shape, before, after] of [ ), ); - // The line names the one app its logo shows, beside the logo and before what was done. + // The line names the one app its logo shows, beside the logo and before what was done, which + // carries on from the name in lower case: "Google Calendar worked through 2 steps". const label = within( fold.querySelector("summary") as HTMLElement, - ).getByText(`Worked through ${before + after} steps`); + ).getByText(`worked through ${before + after} steps`); const named = label.previousElementSibling; expect(named?.textContent).toBe(APP.title); expect( @@ -424,15 +424,15 @@ for (const [shape, before, after] of [ ).toBe(APP.logo); expect(label.nextElementSibling).toBeNull(); - // Each call is a row of its own, drawn alike, a lone call included: what was done, with no logo, - // since every step in the line is on the one app its line draws. + // Each call is a row of its own, drawn alike, a lone call included: what was done, beside its + // app's logo. const lines = within(fold) .getAllByText("List events") .map((label) => label.parentElement as Element); expect(lines).toHaveLength(before + after); for (const line of lines) { expect(line.textContent).toBe("List events"); - expect(markOf(line).name).toBeUndefined(); + expect(markOf(line).name).toBe(APP.title); expect(line.closest('ol[aria-label="Tool steps"]')).not.toBeNull(); } @@ -498,7 +498,7 @@ test("a turn's line on several apps names none after what it did, and each logo expect(await view.findByText("Gmail", {}, { timeout: 3000 })).toBeTruthy(); }); -test("a turn that also took a step on no app is still its one app's line, and that app's rows draw no logo", async () => { +test("a turn that also took a step on no app is still its one app's line, and the step on no app is one more row in its list", async () => { const view = render( transcript( [ @@ -525,22 +525,24 @@ test("a turn that also took a step on no app is still its one app's line, and th const summary = fold.querySelector("summary") as HTMLElement; await waitFor(() => expect( - within(summary).getByText("Worked through 2 steps").previousElementSibling + within(summary).getByText("worked through 2 steps").previousElementSibling ?.textContent, ).toBe(APP.title), ); fireEvent.click(summary); const listed = within(fold).getByText("List events").parentElement as Element; expect(said(listed)).toBe("List events"); - expect(markOf(listed).name).toBeUndefined(); - // "List events" is a chevron and its words: the step that doesn't open draws its wrench in the - // chevron's column, as wide (14px), not after the chevron's room. + expect(markOf(listed).name).toBe(APP.title); + // "Looked for a tool" is one more entry in the same list as "List events", not a line of its own + // in a gray circle: its wrench bare, where the logo is, and the chevron's room kept, since it + // opens to nothing. const looked = within(fold) .getByText("Looked for a tool") .closest("li") as Element; + const list = listed.closest('ol[aria-label="Tool steps"]'); + expect(list).not.toBeNull(); + expect(looked.closest('ol[aria-label="Tool steps"]')).toBe(list); expect(looked.querySelector("summary")).toBeNull(); - expect(looked.className).not.toContain("pl-5"); - expect(looked.querySelector("svg")?.parentElement?.className).toContain( - "w-3.5", - ); + expect(looked.className).toContain("pl-5"); + expect(looked.querySelector(".rounded-full")).toBeNull(); }); diff --git a/app/tests/long-answer-part-steps.test.tsx b/app/tests/long-answer-part-steps.test.tsx index ad7651f6fb..0ac5911e63 100644 --- a/app/tests/long-answer-part-steps.test.tsx +++ b/app/tests/long-answer-part-steps.test.tsx @@ -176,12 +176,11 @@ for (const [who, tool] of [ "Read the next part of an answerGet transcript, part 2 of 3", "Read the next part of an answerGet transcript, part 3 of 3", ]); - // The line above already shows Fireflies, its logo naming it, so no row draws that logo again. - expect(view.getAllByRole("img", { name: "Fireflies" })).toHaveLength(1); + // Each row draws its app's logo, as every step's row does, and the logo names it. expect( within(view.getByRole("list", { name: "Tool steps" })).queryAllByRole( "img", { name: "Fireflies" }, ), - ).toHaveLength(0); + ).toHaveLength(3); }); diff --git a/app/tests/running-step-shimmer.test.tsx b/app/tests/running-step-shimmer.test.tsx index cd8927dc47..70b8237242 100644 --- a/app/tests/running-step-shimmer.test.tsx +++ b/app/tests/running-step-shimmer.test.tsx @@ -149,11 +149,13 @@ test("the running app step shimmers, beside the steps already done, until it has // Named as the app's page names it, not in its stored order ("Fetch message by thread id"). const running = await view.findByText("Fetch thread messages"); expect(running.classList.contains(SHIMMER)).toBe(true); - // Its row says what the finished rows say, in the same order, and that it is under way. The line - // above already shows Gmail, so the row doesn't draw its logo again. + // Its row says what the finished rows say, in the same order, and that it is under way, beside + // its app's logo, as every step's row is. const row = running.parentElement as HTMLElement; expect(said(row)).toBe("Fetch thread messagesIn progress"); - expect(row.querySelector('[role="img"]')).toBeNull(); + expect(row.querySelector('[role="img"]')?.getAttribute("aria-label")).toBe( + "Gmail", + ); // The steps already answered look as they always have. const finished = view.getAllByText("Fetch emails"); expect(finished).toHaveLength(4); diff --git a/app/tests/step-rows-layout.test.tsx b/app/tests/step-rows-layout.test.tsx index 6a7482da76..db0042087e 100644 --- a/app/tests/step-rows-layout.test.tsx +++ b/app/tests/step-rows-layout.test.tsx @@ -54,8 +54,11 @@ const FOLDED = "Searched the web and read 2 pages"; const COMPLETED = "Worked through 3 steps"; /** The page read on its own. */ const SINGLE = "Read web pages"; -/** The turn that looked for a tool, then listed events on Google Calendar. */ -const ON_ONE_APP = "Worked through 2 steps"; +/** + * The turn that looked for a tool, then listed events on Google Calendar. Said after the app's + * name, so in lower case: "Google Calendar worked through 2 steps". + */ +const ON_ONE_APP = "worked through 2 steps"; function singleLine(page: Page) { return page @@ -216,59 +219,64 @@ async function style(page: Page) { await page.addStyleTag({ content: await stylesheet([...new Set(classes)]) }); } -/** A step line by its words: where its words start, and the icon drawn before them. */ -function line(page: Page, label: string) { - return page.evaluate((label) => { - // A line's own words, not a row of the same name inside what a folded line opens to. - const words = [...document.querySelectorAll("span")].find( - (span) => - span.childElementCount === 0 && - span.textContent === label && - span.closest("li") === null, - ); - if (!words) throw new Error(`no line reading "${label}"`); - const box = words.getBoundingClientRect(); - // The line's own text: its icon, if it has one, and its words. - const icon = words.parentElement?.querySelector("svg") ?? null; - const tile = icon?.parentElement ?? null; - const rounded = (rect: DOMRect) => [ - Math.round(rect.width), - Math.round(rect.height), - ]; - const look = (element: Element | null) => { - if (!element) return null; - const style = getComputedStyle(element); - return { - size: rounded(element.getBoundingClientRect()), - colour: style.color, - background: style.backgroundColor, - radius: style.borderRadius, +/** + * A step line by its words: where its words start, and the icon drawn before them. A line of its + * own by default; `inList`, a row of the same name inside what a folded line opens to. + */ +function line(page: Page, label: string, inList = false) { + return page.evaluate( + ([label, inList]) => { + const words = [...document.querySelectorAll("span")].find( + (span) => + span.childElementCount === 0 && + span.textContent === label && + (span.closest("li") !== null) === inList, + ); + if (!words) throw new Error(`no line reading "${label}"`); + const box = words.getBoundingClientRect(); + // The line's own text: its icon, if it has one, and its words. + const icon = words.parentElement?.querySelector("svg") ?? null; + const tile = icon?.parentElement ?? null; + const rounded = (rect: DOMRect) => [ + Math.round(rect.width), + Math.round(rect.height), + ]; + const look = (element: Element | null) => { + if (!element) return null; + const style = getComputedStyle(element); + return { + size: rounded(element.getBoundingClientRect()), + colour: style.color, + background: style.backgroundColor, + radius: style.borderRadius, + }; }; - }; - return { - // Where the line's first icon starts: a folded line of two kinds has two, so its words start later. - iconLeft: tile ? Math.round(tile.getBoundingClientRect().left) : null, - top: box.top, - icon: look(icon), - tile: look(tile), - // The icon's centre against the words' centre: lined up on the line. - iconOffCentre: icon - ? Math.round( - icon.getBoundingClientRect().top + - icon.getBoundingClientRect().height / 2 - - (box.top + box.height / 2), - ) - : null, - // From the last of the line's icons (a folded line overlaps one per kind) to its words. - wordsFromIcon: - icon && words.previousElementSibling + return { + // Where the line's first icon starts: a folded line of two kinds has two, so its words start later. + iconLeft: tile ? Math.round(tile.getBoundingClientRect().left) : null, + top: box.top, + icon: look(icon), + tile: look(tile), + // The icon's centre against the words' centre: lined up on the line. + iconOffCentre: icon ? Math.round( - box.left - - words.previousElementSibling.getBoundingClientRect().right, + icon.getBoundingClientRect().top + + icon.getBoundingClientRect().height / 2 - + (box.top + box.height / 2), ) : null, - }; - }, label); + // From the last of the line's icons (a folded line overlaps one per kind) to its words. + wordsFromIcon: + icon && words.previousElementSibling + ? Math.round( + box.left - + words.previousElementSibling.getBoundingClientRect().right, + ) + : null, + }; + }, + [label, inList] as const, + ); } /** From the foot of the Bot's line on the way to the top of the single page's line. */ @@ -327,31 +335,35 @@ describe.skipIf(!asked)("a Bot's step lines among its words", () => { await done.locator('[data-message-id="on-the-way"]').isVisible(), ).toBe(true); await summary.click(); - expect(await singleLine(done).isVisible()).toBe(true); + // Opened, it is one more row of the list the line opens to. + expect( + await done + .locator( + '[data-slot="worked-for"] ol[aria-label="Tool steps"] li', + { hasText: SINGLE }, + ) + // The folded search's list reads a page too; the single one is the turn's last. + .last() + .isVisible(), + ).toBe(true); } finally { await running.close(); await done.close(); } }, 60_000); - test(`a single "${SINGLE}" line has the icon the folded line beside it has, ${where}`, async () => { + test(`a single "${SINGLE}" line draws its icon bare, as its row does once the work is reopened, ${where}`, async () => { const running = await open(engine, theme, window, "running"); const done = await open(engine, theme, window, "done"); try { - // The single line and earlier folded group use the same icon treatment while working. - const { icon, tile, iconOffCentre, wordsFromIcon } = await line( - running, - FOLDED, - ); + // While working, a lone step's icon is bare, no tile behind it: only a folded line's + // overlapping icons, one per kind ("Searched the web and read 2 pages"), sit in circles. const single = await line(running, SINGLE); expect(single.icon).not.toBeNull(); - expect(single).toMatchObject({ - icon, - tile, - iconOffCentre, - wordsFromIcon, - }); - // Its completed disclosure preserves the treatment when the work is reopened. + expect(single.icon?.size).toEqual([16, 16]); + expect(single.tile?.background).toBe("rgba(0, 0, 0, 0)"); + expect((await line(running, FOLDED)).tile?.radius).not.toBe("0px"); + // Reopened, it is a row of the list, and its icon is drawn the same way. await done .locator('[data-slot="worked-for"] summary') .filter({ @@ -360,9 +372,10 @@ describe.skipIf(!asked)("a Bot's step lines among its words", () => { .click(); // A finished turn's rows are drawn once it is opened, so styled once they are. await style(done); - expect(await line(done, SINGLE)).toMatchObject({ - icon: single.icon, - tile: single.tile, + const row = await line(done, SINGLE, true); + expect(row.icon?.size).toEqual(single.icon?.size); + expect(row.tile?.background).toBe("rgba(0, 0, 0, 0)"); + expect(row).toMatchObject({ iconOffCentre: single.iconOffCentre, wordsFromIcon: single.wordsFromIcon, }); @@ -372,7 +385,7 @@ describe.skipIf(!asked)("a Bot's step lines among its words", () => { } }, 60_000); - test(`a step that doesn't open draws its mark where the chevrons of the rows that open are, and its words start where theirs do, ${where}`, async () => { + test(`a step on no app is one more row of the list: its mark where the logos are, its words where theirs start, ${where}`, async () => { const page = await open(engine, theme, window, "tool-then-app"); try { await page @@ -398,24 +411,48 @@ describe.skipIf(!asked)("a Bot's step lines among its words", () => { }; const looked = row("Looked for a tool"); const listed = row("List events"); - const mark = looked.li?.querySelector("svg"); - const chevron = listed.li?.querySelector(".tool-line-chevron"); - if (!mark || !chevron || !looked.label || !listed.label) - throw new Error("no wrench, chevron or words"); + const wrench = looked.li?.querySelector("svg"); + const logo = listed.li?.querySelector('[role="img"]'); + if (!wrench || !logo || !looked.label || !listed.label) + throw new Error("no wrench, logo or words"); const centre = (element: Element) => { const box = element.getBoundingClientRect(); return box.left + box.width / 2; }; + // No tile behind the wrench: bare, as the logo beside it is. + const tiled = [ + wrench.parentElement, + wrench.parentElement?.parentElement, + ] + .filter((element): element is HTMLElement => Boolean(element)) + .some( + (element) => + getComputedStyle(element).backgroundColor !== + "rgba(0, 0, 0, 0)", + ); + const lookedBox = looked.li?.getBoundingClientRect(); + const listedBox = listed.li?.getBoundingClientRect(); return { - markOffChevron: Math.abs(centre(mark) - centre(chevron)), + markApart: Math.abs(centre(wrench) - centre(logo)), wordsApart: Math.abs( looked.label.getBoundingClientRect().left - listed.label.getBoundingClientRect().left, ), + tiled, + heights: [lookedBox?.height, listedBox?.height], + // The rows sit one under the other, a row's gap apart (`space-y-2`), no wider. + gap: + lookedBox && listedBox + ? listedBox.top - lookedBox.bottom + : -1, }; }); - expect(placed.markOffChevron).toBeLessThan(1); + expect(placed.markApart).toBeLessThan(1); expect(placed.wordsApart).toBeLessThan(1); + expect(placed.tiled).toBe(false); + expect(placed.heights[0]).toBe(placed.heights[1]); + expect(placed.gap).toBeGreaterThanOrEqual(0); + expect(placed.gap).toBeLessThanOrEqual(8); } finally { await page.close(); } diff --git a/app/tests/task-worked-for.test.tsx b/app/tests/task-worked-for.test.tsx index 4fe3049631..e09177aeb4 100644 --- a/app/tests/task-worked-for.test.tsx +++ b/app/tests/task-worked-for.test.tsx @@ -174,7 +174,8 @@ test("a finished turn folds its steps and what it said on the way into one Worke const view = draw(); await waitFor(() => - expect(workedFor(view.container)?.textContent).toContain("Worked for 52s"), + // Its one app named first, and what was done carrying on from the name, in lower case. + expect(workedFor(view.container)?.textContent).toContain("worked for 52s"), ); const row = workedFor(view.container); if (!row) throw new Error("No Worked for row."); @@ -192,7 +193,7 @@ test("a finished turn folds its steps and what it said on the way into one Worke ).toBeTruthy(); // It opens to the steps and the line said on the way, drawn once it is opened. - await userEvent.click(view.getByText("Worked for 52s")); + await userEvent.click(view.getByText("worked for 52s")); expect(fold?.open).toBe(true); await waitFor(() => expect(fold?.textContent).toContain(NARRATION)); }); @@ -202,7 +203,7 @@ test("a turn the server has not listed says how many steps it took", async () => const view = draw(); await waitFor(() => expect(workedFor(view.container)?.textContent).toContain( - "Worked through 1 step", + "worked through 1 step", ), ); expect(view.getByText(ANSWER)).toBeTruthy(); diff --git a/app/tests/tool-result-parts.test.tsx b/app/tests/tool-result-parts.test.tsx index 54ea45a84a..2d4c907a70 100644 --- a/app/tests/tool-result-parts.test.tsx +++ b/app/tests/tool-result-parts.test.tsx @@ -141,7 +141,8 @@ test("a result in several text parts reads as those parts, a paragraph each", as const view = draw(read.messages); expect(await view.findByText("It is a ribbon diagram.")).toBeTruthy(); - fireEvent.click(view.getByText("Worked through 1 step")); + // Said after its app's name, so in lower case. + fireEvent.click(view.getByText("worked through 1 step")); // An app's step in the line is a row that opens to its answer, as a person opens it. fireEvent.click(await view.findByText("Search")); // Each part its own paragraph: run together, they read "Found 2 pages Ribbon diagrams …". @@ -160,7 +161,8 @@ test("a live result that is a JSON object is drawn as JSON", async () => { const view = draw(live); expect(await view.findByText("It is a ribbon diagram.")).toBeTruthy(); fireEvent.click(view.getByText("Worked through 1 step")); - expect(await view.findByText("Lookup rows")).toBeTruthy(); + fireEvent.click(await view.findByText("Lookup rows")); + await view.findByText(/"rows": 2/); expect(view.container.textContent).toContain('"rows": 2'); }); diff --git a/app/tests/work-folded.test.tsx b/app/tests/work-folded.test.tsx index 27fcafca2d..ffb1faf652 100644 --- a/app/tests/work-folded.test.tsx +++ b/app/tests/work-folded.test.tsx @@ -211,8 +211,9 @@ test("regular chat folds finished app calls and keeps all answer text outside", '[data-slot="worked-for"] details', ); expect(fold?.open).toBe(false); + // After the one app's name, so in lower case: "Notion worked through 2 steps". expect(fold?.querySelector("summary")?.textContent).toContain( - "Worked through 2 steps", + "Notionworked through 2 steps", ); expect(fold?.querySelector('summary img[src*="notion.svg"]')).not.toBeNull(); fireEvent.click(fold?.querySelector("summary") as HTMLElement); From 81b85626e1e6bf6dff5ce0de7da8bd4fc5830ad6 Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Sat, 5 Dec 2026 08:13:24 -0800 Subject: [PATCH 12/13] The answered-approval layout test finds the turn's work line in either case A line on one app names it first, and "worked" carries on from the name in lower case: "Google Calendar worked through 1 step". The test's locator read only "Worked through", so it waited for a line that now reads otherwise. Co-Authored-By: Claude Opus 5.5 --- app/tests/approval-answered-layout.test.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/tests/approval-answered-layout.test.tsx b/app/tests/approval-answered-layout.test.tsx index 65e6524202..8b30c6d8ba 100644 --- a/app/tests/approval-answered-layout.test.tsx +++ b/app/tests/approval-answered-layout.test.tsx @@ -394,8 +394,9 @@ const answerLine = (page: Page, said: string) => const workLine = (page: Page) => page .locator("details.tool-line > summary", { - // After the app's mark (Google's "G" here), so not anchored to the start. - hasText: /Worked through \d+ steps?/, + // After the app's mark and name ("Google Calendar worked through 1 step"), so not anchored to + // the start, and in lower case there. + hasText: /[Ww]orked through \d+ steps?/, }) .locator(".."); From e0b106f5eb71cdd5d70cbf2a1fc079a049aee0fc Mon Sep 17 00:00:00 2001 From: Atai Barkai Date: Sat, 5 Dec 2026 08:51:10 -0800 Subject: [PATCH 13/13] Thinking is main's line again, with no mark, where a step's words will be; apps looked up early MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Atai: "I really hate that icon we put next to Thinking, and I really dislike the new Thinking font… I like the shimmer." So "Thinking" is the line it is on main and in a task (the same words, size, tone, and the shimmer swept across the whole line), with no mark beside it. Set in by the chevron's room and a mark's, its word stands where a step's words start: when a step takes its place, the word stays and only the step's mark appears (filmed both ways; flush left, every swap jumped ~30px). The apps added here are looked up as soon as the Bot is on it, not once an app's step is there: a turn's first app step was drawn for a beat as "Googlecalendar" with a letter for its logo. Co-Authored-By: Claude Opus 5.5 --- .../components/channels/chat-transcript.tsx | 15 ++++++--- app/src/components/channels/tool-activity.tsx | 31 +++++++++---------- app/tests/flat-turn.test.tsx | 16 +++++++--- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/app/src/components/channels/chat-transcript.tsx b/app/src/components/channels/chat-transcript.tsx index 603d734043..2cc601c45e 100644 --- a/app/src/components/channels/chat-transcript.tsx +++ b/app/src/components/channels/chat-transcript.tsx @@ -974,10 +974,11 @@ const AT_REST: React.RefObject = { current: null }; function ArrivalsLive({ children, - hasConnector, + needsApps, }: { children: React.ReactNode; - hasConnector: boolean; + /** The apps added here are looked up, for their names and logos (`ActivityAppMarks`). */ + needsApps: boolean; }) { const live = useRef(null); useEffect(() => { @@ -985,7 +986,7 @@ function ArrivalsLive({ }, []); return ( - {children} + {children} ); } @@ -3346,8 +3347,14 @@ export function ChatTranscript({ (item) => item.kind === "tool" && item.toolCall.function.name.startsWith("mcp__"), ); + /* + * LOOKED UP AS SOON AS THE BOT IS ON IT, not once an app's step is there. Looked up only then, a + * turn's first app step was drawn for a beat by its key ("Googlecalendar") and a letter for its + * logo, then again as "Google Calendar" beside its logo: filmed through a real run, the row's words + * changed under the person's eye. Asked for while the Bot thinks, the names are in before its step. + */ return ( - + {hasActivities ? ( ) : null} diff --git a/app/src/components/channels/tool-activity.tsx b/app/src/components/channels/tool-activity.tsx index 86a5572bfe..685d51bd7c 100644 --- a/app/src/components/channels/tool-activity.tsx +++ b/app/src/components/channels/tool-activity.tsx @@ -53,7 +53,6 @@ import { IconPlug, IconSearch, IconSend, - IconSparkles, IconSubtask, IconTerminal2, IconTool, @@ -1863,14 +1862,14 @@ export function listsFlat( export const FLAT_STEPS = "space-y-2 py-1 text-muted-foreground text-sm"; /** - * The Bot's turn while it has nothing to show: a step's row, where its next step will be. + * The Bot's turn while it has nothing to show: "Thinking", where its next step's words will be. * - * ONE ROW FOR WAITING AND WORKING. "Thinking" was a line of its own, drawn under the turn and - * swapped for a step's line of another shape once a step began, so the first thing a person saw - * after sending jumped as the work started. Filmed through a real run: "Thinking", "Looking for a - * tool" in a tile, "Thinking" again, "List events" sliding in. Now waiting is a row like a step's, - * the chevron's room and a mark and the words where a step's are: when the step begins, only the - * mark and the words change. + * ONE PLACE FOR WAITING AND WORKING. "Thinking" was a line of its own under the turn, swapped for a + * step's line once a step began, so the first thing a person saw after sending jumped as the work + * started (filmed through a real run). It is the line it always was, on `main` and in a task: the + * same words, size, tone and shimmer, the shimmer swept across the whole line, and no mark beside it + * (Atai: "I really hate that icon"). It is set in by the chevron's room and a mark's, so its word is + * where a step's words are: when a step takes its place, the word stays and the step's mark appears. */ export function ThinkingStep({ reconnecting = false, @@ -1878,14 +1877,14 @@ export function ThinkingStep({ reconnecting?: boolean; }) { return ( -
    13. - - - {/* `status`, not `alert`: progress, said as the shimmer shows it. */} - - {reconnecting ? "Reconnecting…" : "Thinking"} - - +
    14. + {/* `status`, not `alert`: progress, said as the shimmer shows it. */} +

      + {reconnecting ? "Reconnecting…" : "Thinking"} +

    15. ); } diff --git a/app/tests/flat-turn.test.tsx b/app/tests/flat-turn.test.tsx index 57cb78f581..8b1ca5773c 100644 --- a/app/tests/flat-turn.test.tsx +++ b/app/tests/flat-turn.test.tsx @@ -215,11 +215,17 @@ test("Thinking is a row where the next step goes: under a run's answered steps, ).toEqual(["Looked for a tool", "Thinking"]); }); -test("Thinking, before any step, is a row shaped like a step's", async () => { +test("Thinking is main's line, with no mark, its word where a step's words will be", async () => { const view = render(transcript([ASKED], true)); const thinking = await view.findByRole("status"); - const row = thinking.closest("li"); - // The chevron's room and a mark, as every step's row has, so a step that takes its place moves nothing. - expect(row?.className).toContain("pl-5"); - expect(row?.querySelector("svg")).not.toBeNull(); + // The words, size, tone and shimmer it has on main and in a task, on the whole line. + expect(thinking.tagName).toBe("P"); + expect(thinking.textContent).toBe("Thinking"); + for (const name of ["tool-line-running", "text-muted-foreground", "text-sm"]) + expect(thinking.classList.contains(name)).toBe(true); + // No mark beside it (Atai: "I really hate that icon"). + expect(thinking.closest("li")?.querySelector("svg")).toBeNull(); + // Set in by the chevron's room (20px) and a mark's (16px and its 6px gap): where a step's words + // start, so a step that takes its place leaves the word where it was. + expect(thinking.classList.contains("pl-10.5")).toBe(true); });