diff --git a/app/src/components/channels/chat-transcript.tsx b/app/src/components/channels/chat-transcript.tsx
index 73d48f1f55..9688e399c4 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 {
@@ -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,
@@ -202,14 +202,20 @@ import {
} from "./telemetry-assistant-message";
import {
ActivityAppMarks,
+ AppMark,
attachmentReadName,
dropRepeatedAppCards,
+ FLAT_STEPS,
+ foundToolsInWords,
groupToolSteps,
- LiveConnectorStep,
+ listsFlat,
+ rowApps,
ServerStepIcon,
+ ThinkingStep,
ToolActivity,
type ToolGroup,
type TranscriptItem,
+ useAppName,
useDrawnTool,
useReportsDesktopActivity,
} from "./tool-activity";
@@ -464,7 +470,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 (
= { 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(() => {
@@ -976,7 +996,7 @@ function ArrivalsLive({
}, []);
return (
- {children}
+ {children}
);
}
@@ -1195,6 +1215,7 @@ const ON_HOVER =
"transition-opacity focus-within:opacity-100 motion-reduce:transition-none [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/message:opacity-100";
const TranscriptMessage = memo(function TranscriptMessage({
+ aside = false,
commandLabels = "",
copy,
newestReply = false,
@@ -1208,6 +1229,8 @@ const TranscriptMessage = memo(function TranscriptMessage({
underItsCard = false,
refused = false,
}: {
+ /** The Bot said it before a step it went on to take, in a conversation: drawn muted. */
+ aside?: boolean;
commandLabels?: string;
/**
* The words of the finished reply this message ends, when it ends one: the toolbar under it copies
@@ -1323,6 +1346,8 @@ const TranscriptMessage = memo(function TranscriptMessage({
className={cn(
"text-(length:--text-conversation)/(--text-conversation--line-height)",
!isUser && "w-full",
+ // The reply's type sets its own color (`.typeset`), so muting is said to it.
+ aside && "[&_.typeset]:text-muted-foreground",
)}
>
{isUser ? (
@@ -1949,7 +1974,6 @@ const ToolCallBody = memo(function ToolCallBody({
result,
latest,
spokeAfter,
- liveConnector,
}: {
toolCallId: string;
name: string;
@@ -1959,7 +1983,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(
@@ -2029,7 +2052,6 @@ const ToolCallBody = memo(function ToolCallBody({
) : (
{
@@ -2123,6 +2152,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,
@@ -2130,26 +2181,41 @@ const ToolRow = memo(function ToolRow({
inFlight,
latest,
spokeAfter,
- conversation,
expanded,
+ folds,
+ flat,
+ thinking,
workAlone,
}: ToolRowProps) {
const [only] = steps;
+ const isDrawn = useDrawnTool();
useReportsDesktopActivity(steps, active);
+ /*
+ * 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 (
- {steps.length === 1 &&
- only &&
+ {only &&
!workAlone &&
- !isBrowserStep(only) &&
- // 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 ? (
+ !drawnAsSteps(steps, isDrawn, Boolean(expanded && folds)) ? (
@@ -2182,7 +2247,6 @@ export function ServerToolLine({
args,
result,
place,
- liveConnector,
}: {
name: string;
/** What the call was given, as the model wrote it. Read only for what a step acted on. */
@@ -2190,7 +2254,6 @@ export function ServerToolLine({
result?: string;
/** Where this call sits in the conversation, for an app card that may carry the task on. */
place?: CardPlace;
- liveConnector?: boolean;
}) {
const running = result === undefined;
// Cut off with its outcome unknown: named as it is while under way, since nobody knows it was done.
@@ -2200,10 +2263,14 @@ export function ServerToolLine({
const appId =
!role && name.startsWith("mcp__") ? name.split("__")[1] : undefined;
const folders = useContext(FolderNamesContext);
+ const appName = useAppName();
// 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").
+ // 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 ? connectorName(appId) : named.detail) ??
+ (appId && (named.detail === appId || named.detail === connectorName(appId))
+ ? undefined
+ : named.detail) ??
folderStepSubject(name, args, folders) ??
ownToolSubject(name, args) ??
// The attached file a read was of, by the name its answer carries.
@@ -2262,12 +2329,6 @@ export function ServerToolLine({
? readAnotherAccountPrompt(answer)
: null;
if (another) return ;
- 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
@@ -2334,7 +2395,13 @@ export function ServerToolLine({
{...(failed && ownToolFailedLabel(name)
? { failedLabel: ownToolFailedLabel(name) ?? undefined }
: {})}
- icon={}
+ icon={
+ appId ? (
+
+ ) : (
+
+ )
+ }
label={label}
refused={refused}
failed={failed}
@@ -2350,22 +2417,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.
@@ -2671,6 +2722,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,
@@ -2717,14 +2783,12 @@ export function ChatTranscript({
const items = groupToolSteps(visible, isDrawn, rowIdsRef.current);
// A send that delivered nothing and that its reply then made good is drawn as work (`mendedSends`).
const mended = mendedSends(visible);
- // 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)
@@ -2902,6 +2966,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);
@@ -3187,13 +3283,15 @@ export function ChatTranscript({
>
= turnStart}
latest={index >= latestIndex}
spokeAfter={lastBotWords > index}
steps={item.kind === "tools" ? item.steps : [item]}
+ thinking={thinkingInRun && index === items.length - 1}
workAlone={mended.has(
item.kind === "tools" ? (item.steps[0]?.id ?? "") : item.id,
)}
@@ -3203,6 +3301,7 @@ export function ChatTranscript({
) : item.kind === "text" ? (
- {work.rows.map((row) => (
-
- {rowContent(row.item, row.index, !taskThread)}
-
- ))}
+ {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}
+
+ );
+ })}
);
@@ -3319,8 +3437,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}
@@ -3436,8 +3560,12 @@ export function ChatTranscript({
reason={stopped}
/>
)
- ) : waitingOnTheModel || reconnectingNow ? (
-
+ ) : (waitingOnTheModel && !thinkingInRun) ||
+ reconnectingNow ? (
+
) : null}
{working}
{queued.map((message) => (
diff --git a/app/src/components/channels/subtask-step.tsx b/app/src/components/channels/subtask-step.tsx
index d826b3b93d..0766d268d9 100644
--- a/app/src/components/channels/subtask-step.tsx
+++ b/app/src/components/channels/subtask-step.tsx
@@ -14,6 +14,7 @@ import {
StepOutput,
StepRow,
stepDetails,
+ stepOpens,
} from "./tool-activity";
type ToolItem = Extract;
@@ -134,9 +135,14 @@ export function SubtaskStep({
{handedBack ? : null}
{step.output ? : null}
{steps.length ? (
-
- {foldRereads(steps).map((inner) => (
-
+
+ {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 70caa04ad3..b6f2ae7acf 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,
@@ -50,7 +51,6 @@ import {
IconFilePlus,
IconFileText,
IconFolder,
- IconLoader2,
IconPlug,
IconSearch,
IconSend,
@@ -65,6 +65,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";
@@ -541,21 +546,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 +586,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 +675,8 @@ 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);
+ // 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,
@@ -663,7 +685,7 @@ function detailsOf(
inputs: [],
pages: 0,
...(app
- ? { kind: "connector", connector: connectorName(app), appId: app }
+ ? { kind: "connector", connector: appName(app), appId: app }
: { kind: "tool" }),
};
}
@@ -683,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".
@@ -697,6 +723,7 @@ function detailsOf(
...(name === RECALL_EARLIER_RESULTS ? { rereads: 1 } : {}),
pages: 0,
};
+ }
const [, server = "", ...rest] = name.split("__");
const role = researchRoleOfTool(server, rest.join("__"));
@@ -738,18 +765,37 @@ 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",
- ...(detail
- ? { detail: detail === server ? connectorName(server) : detail }
- : {}),
+ ...(shown && shown !== appName(server) ? { detail: shown } : {}),
pages: 0,
- connector: connectorName(server),
+ connector: appName(server),
appId: server,
};
}
+/**
+ * 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
@@ -783,18 +829,27 @@ 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 a
+ * row whose logo says it: "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 named = read
- ? read.detail
- ? `${read.label} on ${read.detail}`
- : read.label
+ const app = appOfRead(args);
+ const said = read?.detail
+ ? app
+ ? 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 =
part?.part ??
(typeof args.part === "number"
@@ -1225,35 +1280,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],
);
}
@@ -1283,30 +1323,72 @@ 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(),
);
+ /*
+ * 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?.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
+ * 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}
+
+ );
+ })}
);
}
+/** 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.
@@ -1348,11 +1430,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;
@@ -1363,15 +1450,125 @@ export function StepStatus({
return null;
}
+/**
+ * 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. 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();
+ for (const item of items) {
+ 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;
+}
+
+/**
+ * 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 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 AppMark({ appId, name }: { appId: string; name: string }) {
+ return (
+
+ }
+ >
+
+
+ {name}
+
+ );
+}
+
+/**
+ * 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 }) {
+ return step.kind === "connector" && step.appId ? (
+
+ ) : (
+
+ );
+}
+
+/**
+ * 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.
+ */
+export function stepOpens(step: StepDetails): boolean {
+ if (step.kind === "subtask" || step.terminal) return true;
+ return (
+ step.kind !== "browser" && (step.inputs.length > 0 || Boolean(step.output))
+ );
+}
+
+/**
+ * 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 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,
- liveConnector,
+ chevronRoom = false,
+ lead,
}: {
step: StepDetails;
active: boolean;
- liveConnector?: 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;
+ /**
+ * A row that doesn't open keeps the chevron's room, so its mark and words line up with the rows
+ * that do, in its list and in the lists beside it.
+ */
+ chevronRoom?: boolean;
}) {
if (step.kind === "subtask")
return ;
@@ -1379,32 +1576,36 @@ 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 = (
+ // Spaced as a line of its own is (`ToolLine`), so a step and a lone call line up in one list.
+
+
+ {lead ? {lead} : null}
+
+ {step.label}
- );
+ {step.href ? (
+
+ {step.detail ?? step.href}
+
+ ) : step.detail ? (
+ {step.detail}
+ ) : null}
+
+
+ );
const reason =
step.failed && step.kind === "browser" ? (
@@ -1422,9 +1623,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 (
-
-
+
-
{line}
{reason}
@@ -1591,7 +1792,7 @@ export function WorkingNow({ steps }: { steps: readonly StepDetails[] }) {
) : (
-
-
+
{step.label}
@@ -1609,8 +1810,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(
@@ -1622,22 +1824,83 @@ 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: "Thinking", where its next step's words will be.
+ *
+ * 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,
+}: {
+ reconnecting?: boolean;
+}) {
+ return (
+
-
+ {/* `status`, not `alert`: progress, said as the shimmer shows it. */}
+
+ {reconnecting ? "Reconnecting…" : "Thinking"}
+
+
+ );
+}
+
export function ToolActivity({
group,
active,
- conversation = false,
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;
- conversation?: 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.
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);
@@ -1661,23 +1924,33 @@ 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");
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.
+
))}
);
@@ -1686,7 +1959,41 @@ export function ToolActivity({
toolCallIds={group.steps.map((step) => step.toolCall.id)}
/>
);
- if (expanded || showLiveSteps) {
+ /*
+ * 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 (
<>
{list}
@@ -1703,15 +2010,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/src/components/channels/tool-line.tsx b/app/src/components/channels/tool-line.tsx
index 720f464af2..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
@@ -242,6 +246,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/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/src/components/tasks/worked-for.tsx b/app/src/components/tasks/worked-for.tsx
index 492c9799a5..964c6ed199 100644
--- a/app/src/components/tasks/worked-for.tsx
+++ b/app/src/components/tasks/worked-for.tsx
@@ -15,8 +15,10 @@ import {
useSyncExternalStore,
} from "react";
import {
+ onlyApp,
stepsUnderWay,
type TranscriptItem,
+ useAppName,
WorkAppIcons,
WorkingNow,
} from "@/components/channels/tool-activity";
@@ -225,10 +227,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 }) => {
@@ -242,6 +246,8 @@ function WorkLine({
: [];
});
});
+ // 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}
- 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, 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}
live={underWay.length ? : undefined}
diff --git a/app/tests/app-step-rows.test.tsx b/app/tests/app-step-rows.test.tsx
new file mode 100644
index 0000000000..3f3fff41d9
--- /dev/null
+++ b/app/tests/app-step-rows.test.tsx
@@ -0,0 +1,464 @@
+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 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 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;
+
+/** 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),
+ };
+}
+
+/** 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"),
+ };
+}
+
+/** 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"]'));
+}
+
+/** 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));
+
+ // 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 [listed, partRead, running] = rows.map(lineOf);
+ if (!listed || !partRead || !running) throw new Error("Expected 3 lines");
+
+ // 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(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: 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();
+ 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, its steps stop running and nothing else changes", async () => {
+ const view = render(transcript(turn(false), true));
+ await view.findAllByText("List events");
+ const before = rowsOf(view);
+ const shape = shapeOf(lineOf(before[2] as Element));
+
+ view.rerender(transcript(turn(true), true));
+ 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");
+});
+
+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,
+ ),
+ );
+ 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",
+ ]);
+ 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" }, 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 = second.querySelector(
+ '[role="img"][aria-label="Google Calendar"]',
+ );
+ if (!found) throw new Error("Expected the app's logo");
+ return found;
+ });
+ expect(view.getAllByText("Google Calendar")).toHaveLength(1);
+ fireEvent.pointerEnter(mark, { pointerType: "mouse" });
+ fireEvent.mouseEnter(mark);
+ fireEvent.pointerMove(mark, { pointerType: "mouse" });
+ fireEvent.mouseMove(mark);
+ await waitFor(
+ () => expect(view.getAllByText("Google Calendar")).toHaveLength(2),
+ { timeout: 3000 },
+ );
+});
+
+test("an app's call on 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(markOf(line).logo).toBe(APP.logo));
+ // 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(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").classList.contains("tool-line-running"),
+ ).toBe(false),
+ );
+ const done = view.getByText("List events").parentElement;
+ expect(said(done as Element)).toBe("Google CalendarList events");
+ // Drawn as it was while running, less the running.
+ expect(done?.className).toBe(line.className);
+});
+
+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(
+ [
+ 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,
+ ),
+ );
+ await view.findByText("List events");
+ const rows = rowsOf(view);
+ 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.";
+const ANSWER = "You have a design review on Tuesday.";
+
+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);
+ const view = render(
+ transcript(
+ [
+ ASKED,
+ ...list(1),
+ ...list(2),
+ { id: "between", role: "assistant", content: BETWEEN },
+ ...list(3),
+ { id: "answer", role: "assistant", content: ANSWER },
+ ],
+ false,
+ ),
+ );
+ 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(
+ 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 step on no app is a row of the same shape, its words where an app step's are", async () => {
+ const view = render(
+ transcript(
+ [
+ ASKED,
+ // 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: ANSWER },
+ ],
+ false,
+ ),
+ );
+ 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).toContain("pl-5");
+ 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();
+});
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("..");
diff --git a/app/tests/approval-carry-on-running.test.tsx b/app/tests/approval-carry-on-running.test.tsx
index 25c082c268..70b50f55ba 100644
--- a/app/tests/approval-carry-on-running.test.tsx
+++ b/app/tests/approval-carry-on-running.test.tsx
@@ -288,7 +288,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/flat-turn.test.tsx b/app/tests/flat-turn.test.tsx
new file mode 100644
index 0000000000..8b1ca5773c
--- /dev/null
+++ b/app/tests/flat-turn.test.tsx
@@ -0,0 +1,231 @@
+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 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");
+ // 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);
+});
diff --git a/app/tests/long-answer-part-steps.test.tsx b/app/tests/long-answer-part-steps.test.tsx
index f4b3c66af3..0ac5911e63 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,
@@ -172,8 +172,15 @@ for (const [who, tool] of [
expect(view.getByText("Used Fireflies")).toBeDefined();
// Each read says, in words, which answer it read on in and which part.
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",
]);
+ // 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(3);
});
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/reread-steps.test.tsx b/app/tests/reread-steps.test.tsx
index b6815ebe43..2418f80f72 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,
@@ -111,11 +111,11 @@ test("a run of rereads is one row that counts them, and a different step between
return line.textContent;
});
expect(rows).toEqual([
- "Fetch emailsGmail",
+ "Fetch emails",
"Reread 12 earlier results",
- "Fetch emailsGmail",
+ "Fetch emails",
"Reread 3 earlier results",
- "Fetch emailsGmail",
+ "Fetch emails",
"Reread an earlier result",
]);
});
@@ -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..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";
@@ -130,27 +130,42 @@ 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));
+ // 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");
- const indicator = running.closest('[data-slot="live-connector-step"]');
- expect(indicator?.textContent).toContain("Gmail");
- expect(indicator?.textContent).toContain("In progress");
- // The steps already answered look as they always have.
+ expect(running.classList.contains(SHIMMER)).toBe(true);
+ 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(".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)
+ 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 and its progress indicator goes away.
+ // Answered: the step stays where it was, 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(
- 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();
});
@@ -158,10 +173,15 @@ test("the running app step shows one progress indicator until it has an answer",
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/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..db0042087e 100644
--- a/app/tests/step-rows-layout.test.tsx
+++ b/app/tests/step-rows-layout.test.tsx
@@ -47,13 +47,18 @@ 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. 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
@@ -174,12 +179,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);
@@ -211,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. */
@@ -322,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({
@@ -355,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,
});
@@ -366,5 +384,78 @@ describe.skipIf(!asked)("a Bot's step lines among its words", () => {
await done.close();
}
}, 60_000);
+
+ 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
+ .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 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 {
+ 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.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();
+ }
+ }, 60_000);
}
});
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-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) {
diff --git a/app/tests/tool-result-parts.test.tsx b/app/tests/tool-result-parts.test.tsx
index 6f524cdb95..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,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 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");
@@ -158,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 58667d3ece..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",
@@ -194,33 +194,28 @@ 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: 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();
});
@@ -267,7 +262,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");