Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/web/src/components/chat/MessagesTimeline.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,9 @@ describe("deriveMessagesTimelineRows", () => {
});

it("reuses one activity row for initial thinking and the latest tool", () => {
const deriveRows = (toolLifecycleStatus: "inProgress" | "completed" | "declined" | null) =>
const deriveRows = (
toolLifecycleStatus: "inProgress" | "completed" | "failed" | "declined" | null,
) =>
deriveMessagesTimelineRows({
timelineEntries:
toolLifecycleStatus === null
Expand Down Expand Up @@ -1235,6 +1237,7 @@ describe("deriveMessagesTimelineRows", () => {
const initialRows = deriveRows(null);
const runningRows = deriveRows("inProgress");
const completedRows = deriveRows("completed");
const failedRows = deriveRows("failed");
const declinedRows = deriveRows("declined");
const initialActivityRow = initialRows.find((row) => row.id === "live-activity-row");
const runningActivityRow = runningRows.find((row) => row.id === "live-activity-row");
Expand All @@ -1243,11 +1246,14 @@ describe("deriveMessagesTimelineRows", () => {
expect(initialActivityRow).toMatchObject({ kind: "thinking" });
expect(runningActivityRow).toMatchObject({ kind: "work-live", active: true });
expect(completedActivityRow).toMatchObject({ kind: "work-live", active: true });
expect(failedRows.some((row) => row.kind === "work-live")).toBe(false);
expect(failedRows.at(-1)).toMatchObject({ kind: "thinking", id: "live-activity-row" });
expect(declinedRows.find((row) => row.kind === "work-live")).toMatchObject({ active: false });
expect(declinedRows.at(-1)).toMatchObject({ kind: "thinking", id: "live-activity-row" });
expect(initialRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
expect(runningRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
expect(completedRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
expect(failedRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
expect(declinedRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
});

Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/components/chat/MessagesTimeline.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,17 @@ export function deriveMessagesTimelineRows(input: {
const latestRunningToolEntry = visibleActiveToolEntries.findLast((entry) =>
workEntryIsActiveTurnActivity(entry.entry),
);
const latestToolFailed =
latestVisibleToolEntry !== undefined &&
latestVisibleToolEntry.entry.toolLifecycleStatus !== "declined" &&
workEntryDisplayIndicatesToolFailure(latestVisibleToolEntry.entry);
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
const latestToolKeepsActivityLive =
latestRunningToolEntry !== undefined ||
(latestVisibleToolEntry !== undefined &&
workEntryIndicatesToolSuccess(latestVisibleToolEntry.entry));
const activeWorkPlacementEntryId = latestVisibleToolEntry?.id;
const activeWorkRow =
activeWorkAnchor && latestVisibleToolEntry
activeWorkAnchor && latestVisibleToolEntry && !latestToolFailed
Comment thread
cursor[bot] marked this conversation as resolved.
? (() => {
const groupId = workGroupId(activeWorkAnchor.id, activeWorkAnchor.entry);
return {
Expand All @@ -625,7 +629,7 @@ export function deriveMessagesTimelineRows(input: {
})()
: null;
const activeWorkEntryIds = new Set(
activeWorkRow === null ? [] : activeToolEntries.map((entry) => entry.id),
activeWorkRow !== null || latestToolFailed ? activeToolEntries.map((entry) => entry.id) : [],
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
);
const appendWorkingRow = () => {
nextRows.push({
Expand Down
Loading