Skip to content

Commit 615b474

Browse files
committed
fix(web): keep separated tool runs visible
1 parent 2f6812a commit 615b474

2 files changed

Lines changed: 101 additions & 2 deletions

File tree

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,73 @@ describe("deriveMessagesTimelineRows", () => {
945945
});
946946
});
947947

948+
it("keeps separated in-progress tool runs visible", () => {
949+
const rows = deriveMessagesTimelineRows({
950+
timelineEntries: [
951+
{
952+
id: "first-running-entry",
953+
kind: "work",
954+
createdAt: "2026-01-01T00:00:05Z",
955+
entry: {
956+
id: "first-running",
957+
createdAt: "2026-01-01T00:00:05Z",
958+
turnId: "turn-1" as never,
959+
label: "Running first command",
960+
command: "rg first",
961+
requestKind: "command",
962+
tone: "tool" as const,
963+
toolLifecycleStatus: "inProgress" as const,
964+
},
965+
},
966+
{
967+
id: "assistant-commentary-entry",
968+
kind: "message",
969+
createdAt: "2026-01-01T00:00:06Z",
970+
message: {
971+
id: "assistant-commentary" as never,
972+
role: "assistant",
973+
text: "Starting another command.",
974+
turnId: "turn-1" as never,
975+
createdAt: "2026-01-01T00:00:06Z",
976+
updatedAt: "2026-01-01T00:00:06Z",
977+
streaming: false,
978+
},
979+
},
980+
{
981+
id: "second-running-entry",
982+
kind: "work",
983+
createdAt: "2026-01-01T00:00:07Z",
984+
entry: {
985+
id: "second-running",
986+
createdAt: "2026-01-01T00:00:07Z",
987+
turnId: "turn-1" as never,
988+
label: "Running second command",
989+
command: "rg second",
990+
requestKind: "command",
991+
tone: "tool" as const,
992+
toolLifecycleStatus: "inProgress" as const,
993+
},
994+
},
995+
],
996+
latestTurn: {
997+
turnId: "turn-1" as never,
998+
state: "running",
999+
startedAt: "2026-01-01T00:00:00Z",
1000+
completedAt: null,
1001+
},
1002+
isWorking: true,
1003+
activeTurnStartedAt: "2026-01-01T00:00:00Z",
1004+
turnDiffSummaryByAssistantMessageId: new Map(),
1005+
revertTurnCountByUserMessageId: new Map(),
1006+
});
1007+
1008+
expect(rows.map((row) => row.kind)).toEqual(["working", "work-live", "message", "work-live"]);
1009+
expect(rows.filter((row) => row.kind === "work-live").map((row) => row.entry.id)).toEqual([
1010+
"first-running",
1011+
"second-running",
1012+
]);
1013+
});
1014+
9481015
it("keeps the latest completed tool call live while the turn is running", () => {
9491016
const rows = deriveMessagesTimelineRows({
9501017
timelineEntries: [

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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,10 @@ export function deriveMessagesTimelineRows(input: {
704704
input.isWorking &&
705705
index >= activeTurnHeaderIndex &&
706706
(unsettledTurnId === null || timelineEntryTurnId(entry) === unsettledTurnId);
707+
const workEntryIsInActiveRun = (entry: WorkLogEntry) =>
708+
input.isWorking &&
709+
(entry.toolLifecycleStatus === "inProgress" || entry.sourceActivityKind === "task.progress") &&
710+
(unsettledTurnId === null || entry.turnId === unsettledTurnId);
707711
const isVisibleActiveToolEntry = (entry: WorkLogEntry) =>
708712
workLogEntryIsToolLike(entry) && workEntryIsVisibleInGroup(entry, true);
709713
const activeEntries = input.isWorking
@@ -837,7 +841,9 @@ export function deriveMessagesTimelineRows(input: {
837841
cursor += 1;
838842
}
839843
const visibleGroupedEntries = omitSupersededLifecycleMarkers(
840-
groupedEntries.filter((entry) => workEntryIsVisibleInGroup(entry)),
844+
groupedEntries.filter((entry) =>
845+
workEntryIsVisibleInGroup(entry, workEntryIsInActiveRun(entry)),
846+
),
841847
(entry) => entry,
842848
);
843849
if (visibleGroupedEntries.length > 0) {
@@ -847,7 +853,33 @@ export function deriveMessagesTimelineRows(input: {
847853
entry.agentSpawn === undefined &&
848854
entry.tone !== "error",
849855
);
850-
if (onlyToolEntries) {
856+
const activeInProgressToolEntries = visibleGroupedEntries.filter(workEntryIsInActiveRun);
857+
if (onlyToolEntries && activeInProgressToolEntries.length > 0) {
858+
const groupId = workGroupId(timelineEntry.id, timelineEntry.entry);
859+
const expanded = input.expandedWorkGroupIds?.has(groupId) ?? false;
860+
const latestActiveToolEntry = activeInProgressToolEntries.at(-1)!;
861+
nextRows.push({
862+
kind: "work-live",
863+
id: `work-live:${workGroupIdentity(timelineEntry.id, timelineEntry.entry)}`,
864+
createdAt: timelineEntry.createdAt,
865+
entry: latestActiveToolEntry,
866+
groupedEntries: visibleGroupedEntries,
867+
groupId,
868+
expanded,
869+
});
870+
if (expanded) {
871+
for (const [entryIndex, workEntry] of visibleGroupedEntries.entries()) {
872+
nextRows.push({
873+
kind: "work",
874+
id: workEntry.id,
875+
createdAt: workEntry.createdAt,
876+
groupedEntries: [workEntry],
877+
isExpandedToolGroupEntry: true,
878+
isLastExpandedToolGroupEntry: entryIndex === visibleGroupedEntries.length - 1,
879+
});
880+
}
881+
}
882+
} else if (onlyToolEntries) {
851883
const groupId = workGroupId(timelineEntry.id, timelineEntry.entry);
852884
const expanded = input.expandedWorkGroupIds?.has(groupId) ?? false;
853885
const summaryKind = toolGroupSummaryKind(visibleGroupedEntries);

0 commit comments

Comments
 (0)