Skip to content
TypeScript

fix(web): keep trailing tool groups out of "Worked for" accordion (#9384)

Yash Singh4b26132d2c74
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
index ac83d8608f0..a198c3edc0d 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
@@ -157,11 +157,11 @@ describe("work entry labels", () => {
);
it.each([
- ["preview_click", "Clicked in the preview browser", "browser"],
- ["task_status", "Got delegated task status", "t3-code"],
+ ["preview_click", "Clicked in the preview browser"],
+ ["task_status", "Got delegated task status"],
] as const)(
- "uses the completed %s call presentation for a settled legacy tool",
- (tool, summary, summaryToolIcon) => {
+ "renders a settled legacy %s call directly with its completed presentation",
+ (tool, label) => {
const rows = deriveMessagesTimelineRows({
timelineEntries: [
{
@@ -180,9 +180,12 @@ describe("work entry labels", () => {
turnDiffSummaryByAssistantMessageId: new Map(),
revertTurnCountByUserMessageId: new Map(),
});
- expect(rows).toMatchObject([
- { kind: "work-toggle", hiddenCount: 1, summary, summaryToolIcon },
- ]);
+ const directRow = rows.find((row) => row.kind === "work");
+ expect(directRow).toMatchObject({
+ groupedEntries: [expect.objectContaining({ id: "tool-1" })],
+ isExpandedToolGroup: false,
+ displayLabel: label,
+ });
},
);
});
@@ -741,7 +744,7 @@ describe("deriveMessagesTimelineRows", () => {
"user-entry",
"turn-fold:turn-1",
"assistant-first-entry",
- "work-toggle:work-entry-1",
+ "work-entry-1",
"assistant-final-entry",
]);
expect(
@@ -749,6 +752,88 @@ describe("deriveMessagesTimelineRows", () => {
).toBeDefined();
});
+ it("keeps a tool group after the terminal response visible when the turn is folded", () => {
+ const turnId = TurnId.make("turn-1");
+ const timelineEntries = [
+ {
+ id: "work-entry-before-text",
+ kind: "work" as const,
+ createdAt: "2026-01-01T00:00:01Z",
+ entry: {
+ id: "work-before-text",
+ createdAt: "2026-01-01T00:00:01Z",
+ turnId,
+ label: "Status updated",
+ tone: "info" as const,
+ },
+ },
+ {
+ id: "assistant-final-entry",
+ kind: "message" as const,
+ createdAt: "2026-01-01T00:00:05Z",
+ message: {
+ id: "assistant-final" as never,
+ role: "assistant" as const,
+ text: "I could not finish the task.",
+ turnId,
+ createdAt: "2026-01-01T00:00:05Z",
+ updatedAt: "2026-01-01T00:00:06Z",
+ streaming: false,
+ },
+ },
+ ...Array.from({ length: 3 }, (_, index) => ({
+ id: `work-entry-after-text-${index}`,
+ kind: "work" as const,
+ createdAt: `2026-01-01T00:00:0${index + 7}Z`,
+ entry: {
+ id: `work-after-text-${index}`,
+ createdAt: `2026-01-01T00:00:0${index + 7}Z`,
+ turnId,
+ label: "Ran command",
+ tone: "tool" as const,
+ itemType: "command_execution" as const,
+ toolLifecycleStatus: "completed" as const,
+ },
+ })),
+ ];
+
+ const rows = deriveMessagesTimelineRows({
+ timelineEntries,
+ latestTurn: {
+ turnId,
+ state: "error",
+ startedAt: "2026-01-01T00:00:00Z",
+ completedAt: "2026-01-01T00:00:10Z",
+ },
+ isWorking: false,
+ activeTurnStartedAt: null,
+ turnDiffSummaryByAssistantMessageId: new Map(),
+ revertTurnCountByUserMessageId: new Map(),
+ });
+
+ expect(rows.map((row) => row.id)).toEqual([
+ "turn-fold:turn-1",
+ "assistant-final-entry",
+ "work-toggle:work-entry-after-text-0",
+ "assistant-meta:assistant-final",
+ ]);
+ expect(rows.at(-2)).toMatchObject({
+ kind: "work-toggle",
+ hiddenCount: 3,
+ summary: "Ran 3 commands",
+ });
+ expect(rows.at(-1)).toMatchObject({
+ kind: "assistant-meta",
+ message: { id: "assistant-final" },
+ showAssistantCopyButton: true,
+ });
+ expect(rows.at(-3)).toMatchObject({
+ kind: "message",
+ showAssistantMeta: false,
+ showAssistantCopyButton: false,
+ });
+ });
+
it("folds all assistant messages before the terminal message", () => {
const timelineEntries = [
{
@@ -827,6 +912,18 @@ describe("deriveMessagesTimelineRows", () => {
streaming: false,
},
},
+ {
+ id: "work-entry-before-message",
+ kind: "work",
+ createdAt: "2026-01-01T00:00:07Z",
+ entry: {
+ id: "work-before-message",
+ createdAt: "2026-01-01T00:00:07Z",
+ turnId: "turn-1" as never,
+ label: "Status updated",
+ tone: "info" as const,
+ },
+ },
{
id: "assistant-commentary-entry",
kind: "message",
@@ -1135,7 +1232,7 @@ describe("deriveMessagesTimelineRows", () => {
});
});
- it("labels a single completed tool call without summarizing it", () => {
+ it("renders a single completed tool call directly", () => {
const rows = deriveMessagesTimelineRows({
timelineEntries: [
{
@@ -1195,11 +1292,64 @@ describe("deriveMessagesTimelineRows", () => {
revertTurnCountByUserMessageId: new Map(),
});
- expect(rows.map((row) => row.kind)).toEqual(["working", "work-toggle", "message", "work-live"]);
- expect(rows.find((row) => row.kind === "work-toggle")).toMatchObject({
- hiddenCount: 1,
- summary: "rg toolCall",
+ expect(rows.map((row) => row.kind)).toEqual(["working", "work", "message", "work-live"]);
+ expect(rows.find((row) => row.kind === "work")).toMatchObject({
+ groupedEntries: [{ id: "completed-command", command: "rg toolCall" }],
+ isExpandedToolGroup: false,
+ displayLabel: "rg toolCall",
+ });
+ });
+
+ it("renders one tool call directly after collapsing its lifecycle updates", () => {
+ const turnId = TurnId.make("turn-1");
+ const rows = deriveMessagesTimelineRows({
+ timelineEntries: [
+ {
+ id: "command-started-entry",
+ kind: "work",
+ createdAt: "2026-01-01T00:00:05Z",
+ entry: {
+ id: "command-started",
+ createdAt: "2026-01-01T00:00:05Z",
+ turnId,
+ toolCallId: "call-1",
+ label: "Running rg",
+ command: "rg toolCall",
+ tone: "tool" as const,
+ itemType: "command_execution" as const,
+ toolLifecycleStatus: "inProgress" as const,
+ },
+ },
+ {
+ id: "command-completed-entry",
+ kind: "work",
+ createdAt: "2026-01-01T00:00:06Z",
+ entry: {
+ id: "command-completed",
+ createdAt: "2026-01-01T00:00:06Z",
+ turnId,
+ toolCallId: "call-1",
+ label: "Ran rg",
+ command: "rg toolCall",
+ tone: "tool" as const,
+ itemType: "command_execution" as const,
+ toolLifecycleStatus: "completed" as const,
+ },
+ },
+ ],
+ expandedTurnIds: new Set([turnId]),
+ isWorking: false,
+ activeTurnStartedAt: null,
+ turnDiffSummaryByAssistantMessageId: new Map(),
+ revertTurnCountByUserMessageId: new Map(),
+ });
+
+ expect(rows.find((row) => row.kind === "work")).toMatchObject({
+ groupedEntries: [{ id: "command-completed", toolCallId: "call-1" }],
+ isExpandedToolGroup: false,
+ displayLabel: "rg toolCall",
});
+ expect(rows.some((row) => row.kind === "work-toggle")).toBe(false);
});
it("keeps separated in-progress tool runs visible", () => {
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts
index 39c40f8e351..4b4540a27e2 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts
@@ -284,6 +284,7 @@ export type MessagesTimelineRow =
createdAt: string;
groupedEntries: WorkLogEntry[];
isExpandedToolGroup: boolean;
+ displayLabel?: string;
}
| {
kind: "work-live";
@@ -299,6 +300,7 @@ export type MessagesTimelineRow =
kind: "work-toggle";
id: string;
createdAt: string;
+ turnId?: TurnId | null;
groupId: string;
hiddenCount: number;
expanded: boolean;
@@ -329,6 +331,14 @@ export type MessagesTimelineRow =
assistantTurnDiffSummary?: TurnDiffSummary | undefined;
revertTurnCount?: number | undefined;
}
+ | {
+ kind: "assistant-meta";
+ id: string;
+ createdAt: string;
+ message: ChatMessage;
+ showAssistantCopyButton: boolean;
+ assistantCopyStreaming: boolean;
+ }
| {
kind: "proposed-plan";
id: string;
@@ -492,9 +502,9 @@ function workEntryIsActiveTurnActivity(entry: WorkLogEntry): boolean {
}
/**
- * Settled turns keep only their terminal assistant message visible.
- * Everything before it folds behind a "Worked for ..." row anchored at the
- * first hidden entry, so the duration leads directly into the final response.
+ * Settled turns fold activity before their terminal assistant message behind
+ * a "Worked for ..." row. Work that lands after that message stays visible so
+ * failed or interrupted turns do not hide their trailing tool-call summary.
*/
function deriveTurnFolds(input: {
timelineEntries: ReadonlyArray<TimelineEntry>;
@@ -565,10 +575,16 @@ function deriveTurnFolds(input: {
continue;
}
const hiddenEntryIds = new Set<string>();
- for (const entry of group.entries) {
+ const terminalEntryIndex = group.terminalEntry
+ ? group.entries.findIndex((entry) => entry.id === group.terminalEntry?.id)
+ : group.entries.length;
+ for (const [index, entry] of group.entries.entries()) {
if (entry.id === group.terminalEntry?.id) {
continue;
}
+ if (index > terminalEntryIndex) {
+ continue;
+ }
// Agent-spawn CTA rows never fold: workflows outlive their launching
// turn (dynamic spawns, background execution), and folding the CTA
// when the turn settles makes a still-running fleet invisible.
@@ -624,6 +640,89 @@ function deriveTurnFolds(input: {
return foldsByAnchorEntryId;
}
+/**
+ * When a settled turn ends with tool calls after its terminal text, treat the
+ * text and tools as one visual response. The message metadata becomes the
+ * footer for the whole block instead of separating the prose from the tools.
+ */
+function attachTrailingToolGroupsToAssistant(
+ rows: ReadonlyArray<MessagesTimelineRow>,
+): MessagesTimelineRow[] {
+ const messageRowsWithoutMeta = new Set<string>();
+ const metaRowsAfterIndex = new Map<
+ number,
+ Extract<MessagesTimelineRow, { kind: "assistant-meta" }>
+ >();
+
+ for (const [messageIndex, row] of rows.entries()) {
+ const turnId = row.kind === "message" ? (row.message.turnId ?? null) : null;
+ if (
+ row.kind !== "message" ||
+ row.message.role !== "assistant" ||
+ !row.showAssistantMeta ||
+ turnId === null
+ ) {
+ continue;
+ }
+
+ let lastTrailingWorkIndex = -1;
+ let hasTrailingToolGroup = false;
+ for (let index = messageIndex + 1; index < rows.length; index += 1) {
+ const candidate = rows[index];
+ if (!candidate || candidate.kind === "message") {
+ break;
+ }
+ if (candidate.kind === "work-toggle" && candidate.turnId === turnId) {
+ hasTrailingToolGroup = true;
+ lastTrailingWorkIndex = index;
+ continue;
+ }
+ if (
+ candidate.kind === "work" &&
+ candidate.groupedEntries.some((entry) => entry.turnId === turnId)
+ ) {
+ if (
+ !candidate.isExpandedToolGroup &&
+ candidate.groupedEntries.some(workLogEntryIsToolLike)
+ ) {
+ hasTrailingToolGroup = true;
+ }
+ if (hasTrailingToolGroup) {
+ lastTrailingWorkIndex = index;
+ }
+ }
+ }
+
+ if (lastTrailingWorkIndex < 0) {
+ continue;
+ }
+
+ messageRowsWithoutMeta.add(row.id);
+ metaRowsAfterIndex.set(lastTrailingWorkIndex, {
+ kind: "assistant-meta",
+ id: `assistant-meta:${row.message.id}`,
+ createdAt: rows[lastTrailingWorkIndex]?.createdAt ?? row.message.updatedAt,
+ message: row.message,
+ showAssistantCopyButton: row.showAssistantCopyButton,
+ assistantCopyStreaming: row.assistantCopyStreaming,
+ });
+ }
+
+ const result: MessagesTimelineRow[] = [];
+ for (const [index, row] of rows.entries()) {
+ if (row.kind === "message" && messageRowsWithoutMeta.has(row.id)) {
+ result.push({ ...row, showAssistantMeta: false, showAssistantCopyButton: false });
+ } else {
+ result.push(row);
+ }
+ const metaRow = metaRowsAfterIndex.get(index);
+ if (metaRow) {
+ result.push(metaRow);
+ }
+ }
+ return result;
+}
+
export function deriveMessagesTimelineRows(input: {
timelineEntries: ReadonlyArray<TimelineEntry>;
latestTurn?: TimelineLatestTurn | null;
@@ -847,6 +946,22 @@ export function deriveMessagesTimelineRows(input: {
expandedWorkGroupRow(groupId, timelineEntry.createdAt, visibleGroupedEntries),
);
}
+ } else if (
+ visibleGroupedEntries.length === 1 &&
+ workLogEntryIsToolLike(visibleGroupedEntries[0]!)
+ ) {
+ const singleEntry = visibleGroupedEntries[0]!;
+ nextRows.push({
+ kind: "work",
+ id: timelineEntry.id,
+ createdAt: timelineEntry.createdAt,
+ groupedEntries: visibleGroupedEntries,
+ isExpandedToolGroup: false,
+ displayLabel:
+ toolGroupAction(singleEntry) === "edit"
+ ? summarizeToolGroup(visibleGroupedEntries)
+ : singleToolCallLabel(singleEntry),
+ });
} else {
const groupId = workGroupId(timelineEntry.id, timelineEntry.entry);
const expanded = input.expandedWorkGroupIds?.has(groupId) ?? false;
@@ -881,6 +996,7 @@ export function deriveMessagesTimelineRows(input: {
kind: "work-toggle",
id: `work-toggle:${timelineEntry.id}`,
createdAt: timelineEntry.createdAt,
+ turnId: timelineEntry.entry.turnId ?? null,
groupId,
hiddenCount: visibleGroupedEntries.length,
expanded,
@@ -965,7 +1081,7 @@ export function deriveMessagesTimelineRows(input: {
});
}
- return nextRows;
+ return attachTrailingToolGroupsToAssistant(nextRows);
}
export function computeStableMessagesTimelineRows(
@@ -997,6 +1113,16 @@ function isRowUnchanged(a: MessagesTimelineRow, b: MessagesTimelineRow): boolean
case "thinking":
return a.createdAt === (b as typeof a).createdAt;
+ case "assistant-meta": {
+ const bm = b as typeof a;
+ return (
+ a.createdAt === bm.createdAt &&
+ a.message === bm.message &&
+ a.showAssistantCopyButton === bm.showAssistantCopyButton &&
+ a.assistantCopyStreaming === bm.assistantCopyStreaming
+ );
+ }
+
case "turn-fold": {
const bf = b as typeof a;
return a.createdAt === bf.createdAt && a.label === bf.label && a.expanded === bf.expanded;
@@ -1009,6 +1135,7 @@ function isRowUnchanged(a: MessagesTimelineRow, b: MessagesTimelineRow): boolean
const bw = b as typeof a;
return (
a.isExpandedToolGroup === bw.isExpandedToolGroup &&
+ a.displayLabel === bw.displayLabel &&
Equal.equals(a.groupedEntries, bw.groupedEntries)
);
}
@@ -1029,6 +1156,7 @@ function isRowUnchanged(a: MessagesTimelineRow, b: MessagesTimelineRow): boolean
const bw = b as typeof a;
return (
a.createdAt === bw.createdAt &&
+ a.turnId === bw.turnId &&
a.groupId === bw.groupId &&
a.hiddenCount === bw.hiddenCount &&
a.expanded === bw.expanded &&
diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsx
index 7c8014b93f8..4bb9b13b429 100644
--- a/apps/web/src/components/chat/MessagesTimeline.test.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx
@@ -1093,6 +1093,62 @@ describe("MessagesTimeline", () => {
expect(markup).toContain("tool call failed");
});
+ it("renders trailing tool calls as part of the terminal assistant block", () => {
+ const turnId = TurnId.make("turn-trailing-tools");
+ const assistantMessageId = MessageId.make("assistant-trailing-tools");
+ const markup = renderToStaticMarkup(
+ <MessagesTimeline
+ {...buildProps()}
+ latestTurn={{
+ turnId,
+ state: "error",
+ startedAt: "2026-03-17T19:12:20.000Z",
+ completedAt: "2026-03-17T19:12:30.000Z",
+ }}
+ timelineEntries={[
+ {
+ id: "assistant-entry",
+ kind: "message",
+ createdAt: MESSAGE_CREATED_AT,
+ message: {
+ id: assistantMessageId,
+ role: "assistant",
+ text: "I’ll search for it now.",
+ turnId,
+ createdAt: MESSAGE_CREATED_AT,
+ updatedAt: "2026-03-17T19:12:29.000Z",
+ streaming: false,
+ },
+ },
+ {
+ id: "trailing-work-entry",
+ kind: "work",
+ createdAt: "2026-03-17T19:12:30.000Z",
+ entry: {
+ id: "trailing-work",
+ createdAt: "2026-03-17T19:12:30.000Z",
+ turnId,
+ label: "Ran command",
+ tone: "tool",
+ itemType: "command_execution",
+ toolLifecycleStatus: "completed",
+ },
+ },
+ ]}
+ />,
+ );
+
+ const messageIndex = markup.indexOf('data-timeline-row-id="assistant-entry"');
+ const toolIndex = markup.indexOf('data-timeline-row-id="trailing-work-entry"');
+ const metaIndex = markup.indexOf(
+ 'data-timeline-row-id="assistant-meta:assistant-trailing-tools"',
+ );
+ expect(messageIndex).toBeGreaterThanOrEqual(0);
+ expect(toolIndex).toBeGreaterThan(messageIndex);
+ expect(metaIndex).toBeGreaterThan(toolIndex);
+ expect(markup.match(/I’ll search for it now\./gu)).toHaveLength(1);
+ });
+
it("keeps mixed work logs neutral after a later tool call succeeds", () => {
const markup = renderToStaticMarkup(
<MessagesTimeline
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index ecb31bd7f90..98622b043f3 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -57,6 +57,7 @@ import {
workLogEntryIsToolLike,
} from "../../session-logic";
import {
+ type ChatMessage,
type ChatFileAttachment,
type ChatImageAttachment,
isBrowserPreviewAttachment,
@@ -731,6 +732,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
<LegendList<MessagesTimelineRow>
ref={listRef}
data={rows}
+ extraData={rows.length}
keyExtractor={keyExtractor}
getItemType={getItemType}
renderItem={renderItem}
@@ -1108,11 +1110,16 @@ const TimelineRowContent = memo(function TimelineRowContent({ row }: { row: Time
row.kind === "thinking"
? "pb-2"
: "pb-4",
- row.kind === "message" && row.message.role === "assistant" ? "group/assistant" : null,
+ (row.kind === "message" && row.message.role === "assistant") ||
+ row.kind === "assistant-meta"
+ ? "group/assistant"
+ : null,
)}
data-timeline-row-id={row.id}
data-timeline-row-kind={row.kind}
- data-message-id={row.kind === "message" ? row.message.id : undefined}
+ data-message-id={
+ row.kind === "message" || row.kind === "assistant-meta" ? row.message.id : undefined
+ }
data-message-role={row.kind === "message" ? row.message.role : undefined}
>
{row.kind === "work" ? (
@@ -1120,6 +1127,7 @@ const TimelineRowContent = memo(function TimelineRowContent({ row }: { row: Time
anchorKey={row.id}
groupedEntries={row.groupedEntries}
isExpandedToolGroup={row.isExpandedToolGroup}
+ displayLabel={row.displayLabel}
/>
) : null}
{row.kind === "work-live" ? <LiveWorkEntryTimelineRow row={row} /> : null}
@@ -1129,6 +1137,7 @@ const TimelineRowContent = memo(function TimelineRowContent({ row }: { row: Time
{row.kind === "message" && row.message.role === "assistant" ? (
<AssistantTimelineRow row={row} />
) : null}
+ {row.kind === "assistant-meta" ? <AssistantMetaTimelineRow row={row} /> : null}
{row.kind === "proposed-plan" ? <ProposedPlanTimelineRow row={row} /> : null}
{row.kind === "working" ? <WorkingTimelineRow row={row} /> : null}
{row.kind === "thinking" ? <ThinkingTimelineRow /> : null}
@@ -1453,32 +1462,93 @@ function AssistantTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "mess
onOpenTurnDiff={ctx.onOpenTurnDiff}
/>
{row.showAssistantMeta ? (
- <div className="mt-1.5 flex items-center gap-2 text-xs tabular-nums opacity-0 transition-opacity duration-200 focus-within:opacity-100 group-hover/assistant:opacity-100">
- <AssistantCopyButton row={row} />
- {!row.message.streaming && (
- <Tooltip>
- <TooltipTrigger
- render={<p className="text-muted-foreground text-xs tabular-nums" />}
- >
- {formatDayAwareTimestamp(row.message.updatedAt, ctx.timestampFormat)}
- </TooltipTrigger>
- <TooltipPopup>
- {formatChatTimestampTooltip(row.message.updatedAt, ctx.timestampFormat)}
- </TooltipPopup>
- </Tooltip>
- )}
- </div>
+ <AssistantMessageMeta
+ className="mt-1.5"
+ message={row.message}
+ showCopyButton={row.showAssistantCopyButton}
+ copyStreaming={row.assistantCopyStreaming}
+ />
) : null}
</div>
</>
);
}
-function AssistantCopyButton({ row }: { row: Extract<TimelineRow, { kind: "message" }> }) {
+function AssistantMetaTimelineRow({
+ row,
+}: {
+ row: Extract<TimelineRow, { kind: "assistant-meta" }>;
+}) {
+ return (
+ <div className="px-1">
+ <AssistantMessageMeta
+ className="mt-0.5"
+ message={row.message}
+ showCopyButton={row.showAssistantCopyButton}
+ copyStreaming={row.assistantCopyStreaming}
+ alwaysVisible
+ />
+ </div>
+ );
+}
+
+function AssistantMessageMeta({
+ className,
+ message,
+ showCopyButton,
+ copyStreaming,
+ alwaysVisible = false,
+}: {
+ className?: string;
+ message: ChatMessage;
+ showCopyButton: boolean;
+ copyStreaming: boolean;
+ alwaysVisible?: boolean;
+}) {
+ const ctx = use(TimelineRowCtx);
+
+ return (
+ <div
+ className={cn(
+ "flex items-center gap-2 text-xs tabular-nums transition-opacity duration-200",
+ alwaysVisible
+ ? "opacity-100"
+ : "opacity-0 focus-within:opacity-100 group-hover/assistant:opacity-100",
+ className,
+ )}
+ >
+ <AssistantCopyButton
+ message={message}
+ showCopyButton={showCopyButton}
+ streaming={copyStreaming}
+ />
+ {!message.streaming && (
+ <Tooltip>
+ <TooltipTrigger render={<p className="text-muted-foreground text-xs tabular-nums" />}>
+ {formatDayAwareTimestamp(message.updatedAt, ctx.timestampFormat)}
+ </TooltipTrigger>
+ <TooltipPopup>
+ {formatChatTimestampTooltip(message.updatedAt, ctx.timestampFormat)}
+ </TooltipPopup>
+ </Tooltip>
+ )}
+ </div>
+ );
+}
+
+function AssistantCopyButton({
+ message,
+ showCopyButton,
+ streaming,
+}: {
+ message: ChatMessage;
+ showCopyButton: boolean;
+ streaming: boolean;
+}) {
const assistantCopyState = resolveAssistantMessageCopyState({
- text: row.message.text ?? null,
- showCopyButton: row.showAssistantCopyButton,
- streaming: row.assistantCopyStreaming,
+ text: message.text ?? null,
+ showCopyButton,
+ streaming,
});
if (!assistantCopyState.visible) {
@@ -1583,10 +1653,12 @@ const WorkGroupSection = memo(function WorkGroupSection({
anchorKey,
groupedEntries,
isExpandedToolGroup,
+ displayLabel,
}: {
anchorKey: string;
groupedEntries: Extract<MessagesTimelineRow, { kind: "work" }>["groupedEntries"];
isExpandedToolGroup: boolean;
+ displayLabel?: string | undefined;
}) {
const { workspaceRoot, routeThreadKey } = use(TimelineRowCtx);
const nonEmptyEntries = useMemo(
@@ -1615,6 +1687,7 @@ const WorkGroupSection = memo(function WorkGroupSection({
workEntry={workEntry}
workspaceRoot={workspaceRoot}
isExpandedToolGroupEntry={false}
+ displayLabel={displayLabel}
/>
))}
</div>
@@ -2926,8 +2999,9 @@ const SimpleWorkEntryRow = memo(function SimpleWorkEntryRow(props: {
workEntry: TimelineWorkEntry;
workspaceRoot: string | undefined;
isExpandedToolGroupEntry: boolean;
+ displayLabel?: string | undefined;
}) {
- const { workEntry, workspaceRoot, isExpandedToolGroupEntry } = props;
+ const { workEntry, workspaceRoot, isExpandedToolGroupEntry, displayLabel } = props;
// Before any hooks: spawn CTA rows render their own component.
if (workEntry.agentSpawn) {
return <AgentSpawnCtaRow workEntry={workEntry} />;
@@ -2937,6 +3011,7 @@ const SimpleWorkEntryRow = memo(function SimpleWorkEntryRow(props: {
workEntry={workEntry}
workspaceRoot={workspaceRoot}
isExpandedToolGroupEntry={isExpandedToolGroupEntry}
+ displayLabel={displayLabel}
/>
);
});
@@ -2945,8 +3020,9 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {
workEntry: TimelineWorkEntry;
workspaceRoot: string | undefined;
isExpandedToolGroupEntry: boolean;
+ displayLabel?: string | undefined;
}) {
- const { workEntry, workspaceRoot, isExpandedToolGroupEntry } = props;
+ const { workEntry, workspaceRoot, isExpandedToolGroupEntry, displayLabel } = props;
const { threadRef, onImageExpand } = use(TimelineRowCtx);
const groupView = use(WorkGroupViewCtx);
const [expanded, setExpanded] = useState(
@@ -2970,7 +3046,7 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {
showWarningIndicator || (showFailedIndicator && !hasSpecialToolIcon)
? "circle-alert"
: workEntryIconName(workEntry);
- const previewText = workEntryDisplayLabel(workEntry, workspaceRoot);
+ const previewText = displayLabel ?? workEntryDisplayLabel(workEntry, workspaceRoot);
const displayText =
!toolPresentation && expanded && workEntry.command?.trim() ? "Command" : previewText;
const canExpand =