Skip to content

Commit 60fb030

Browse files
committed
fix(chat): preserve concurrent tool activity
1 parent f1bc202 commit 60fb030

4 files changed

Lines changed: 32 additions & 23 deletions

File tree

‎apps/web/src/components/chat/MessagesTimeline.logic.test.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -887,18 +887,18 @@ describe("deriveMessagesTimelineRows", () => {
887887
const rows = deriveMessagesTimelineRows({
888888
timelineEntries: [
889889
{
890-
id: "completed-command-entry",
890+
id: "running-command-entry",
891891
kind: "work",
892892
createdAt: "2026-01-01T00:00:05Z",
893893
entry: {
894-
id: "completed-command",
894+
id: "running-command",
895895
createdAt: "2026-01-01T00:00:05Z",
896896
turnId: "turn-1" as never,
897-
label: "Ran rg",
897+
label: "Running rg",
898898
command: "rg toolCall",
899899
requestKind: "command",
900900
tone: "tool" as const,
901-
toolLifecycleStatus: "completed" as const,
901+
toolLifecycleStatus: "inProgress" as const,
902902
},
903903
},
904904
{
@@ -917,18 +917,18 @@ describe("deriveMessagesTimelineRows", () => {
917917
},
918918
},
919919
{
920-
id: "running-command-entry",
920+
id: "completed-command-entry",
921921
kind: "work",
922922
createdAt: "2026-01-01T00:00:07Z",
923923
entry: {
924-
id: "running-command",
924+
id: "completed-command",
925925
createdAt: "2026-01-01T00:00:07Z",
926926
turnId: "turn-1" as never,
927-
label: "Running tests",
927+
label: "Ran tests",
928928
command: "vp test run",
929929
requestKind: "command",
930930
tone: "tool" as const,
931-
toolLifecycleStatus: "inProgress" as const,
931+
toolLifecycleStatus: "completed" as const,
932932
},
933933
},
934934
],
@@ -949,9 +949,9 @@ describe("deriveMessagesTimelineRows", () => {
949949
expect(rows.find((row) => row.kind === "work-live")).toMatchObject({
950950
entry: { id: "running-command" },
951951
groupedEntries: [
952-
{ id: "completed-command" },
953-
{ id: "completed-edit" },
954952
{ id: "running-command" },
953+
{ id: "completed-edit" },
954+
{ id: "completed-command" },
955955
],
956956
});
957957
});

‎apps/web/src/components/chat/MessagesTimeline.logic.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -733,21 +733,25 @@ export function deriveMessagesTimelineRows(input: {
733733
(entry) => entry.entry,
734734
);
735735
const activeWorkAnchor = activeToolEntries[0];
736-
const latestActiveToolEntry = visibleActiveToolEntries.at(-1);
737-
const activeWorkPlacementEntryId = latestActiveToolEntry?.id;
736+
const latestVisibleToolEntry = visibleActiveToolEntries.at(-1);
737+
const latestRunningToolEntry = visibleActiveToolEntries.findLast((entry) =>
738+
workEntryIsActiveTurnActivity(entry.entry),
739+
);
740+
const displayedToolEntry = latestRunningToolEntry ?? latestVisibleToolEntry;
741+
const activeWorkPlacementEntryId = latestVisibleToolEntry?.id;
738742
const activeWorkRow =
739-
activeWorkAnchor && latestActiveToolEntry
743+
activeWorkAnchor && displayedToolEntry
740744
? (() => {
741745
const groupId = workGroupId(activeWorkAnchor.id, activeWorkAnchor.entry);
742746
return {
743747
kind: "work-live" as const,
744748
id: `work-live:${workGroupIdentity(activeWorkAnchor.id, activeWorkAnchor.entry)}`,
745749
createdAt: activeWorkAnchor.createdAt,
746-
entry: latestActiveToolEntry.entry,
750+
entry: displayedToolEntry.entry,
747751
groupedEntries: visibleActiveToolEntries.map((entry) => entry.entry),
748752
groupId,
749753
expanded: input.expandedWorkGroupIds?.has(groupId) ?? false,
750-
active: workEntryIsActiveTurnActivity(latestActiveToolEntry.entry),
754+
active: latestRunningToolEntry !== undefined,
751755
};
752756
})()
753757
: null;

‎apps/web/src/components/chat/MessagesTimeline.test.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ describe("MessagesTimeline", () => {
13081308
expect(markup).not.toContain("tool call failed");
13091309
});
13101310

1311-
it("keeps terminal command copy visible while thinking continues", () => {
1311+
it("keeps declined command copy visible while thinking continues", () => {
13121312
const turnId = TurnId.make("turn-live");
13131313
const markup = renderToStaticMarkup(
13141314
<MessagesTimeline
@@ -1324,26 +1324,26 @@ describe("MessagesTimeline", () => {
13241324
runningTurnId={turnId}
13251325
timelineEntries={[
13261326
{
1327-
id: "entry-failed",
1327+
id: "entry-declined",
13281328
kind: "work",
13291329
createdAt: MESSAGE_CREATED_AT,
13301330
entry: {
1331-
id: "work-failed",
1331+
id: "work-declined",
13321332
createdAt: MESSAGE_CREATED_AT,
13331333
turnId,
1334-
toolCallId: "call-failed",
1334+
toolCallId: "call-declined",
13351335
label: "Run lint",
13361336
tone: "tool",
13371337
itemType: "command_execution",
13381338
command: "pnpm lint",
1339-
toolLifecycleStatus: "failed",
1339+
toolLifecycleStatus: "declined",
13401340
},
13411341
},
13421342
]}
13431343
/>,
13441344
);
13451345

1346-
expect(markup).toContain("Ran pnpm");
1346+
expect(markup).toContain("Declined pnpm");
13471347
expect(markup).toContain("Thinking");
13481348
expect(markup).toContain("tool call failed");
13491349
});

‎apps/web/src/components/chat/MessagesTimeline.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,8 +2224,13 @@ function liveWorkEntryLabel(
22242224
const command = workEntry.command?.trim();
22252225
if (command) {
22262226
const program = commandProgramName(command);
2227-
if (program) return `${active ? "Running" : "Ran"} ${program}`;
2228-
return active ? "Running command" : "Ran command";
2227+
const verb = active
2228+
? "Running"
2229+
: workEntry.toolLifecycleStatus === "declined"
2230+
? "Declined"
2231+
: "Ran";
2232+
if (program) return `${verb} ${program}`;
2233+
return `${verb} command`;
22292234
}
22302235

22312236
return workEntryPreview(workEntry, workspaceRoot) ?? toolWorkEntryHeading(workEntry);

0 commit comments

Comments
 (0)