Skip to content

Commit 8a2fafd

Browse files
committed
fix(web): Zen keeps wake cards and the Working row for a queued follow-up
1 parent d73cc15 commit 8a2fafd

2 files changed

Lines changed: 45 additions & 31 deletions

File tree

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

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,20 +2734,18 @@ describe("v2 run and attempt history", () => {
27342734
command("failed", "failed", 9),
27352735
message("final", "assistant", 20),
27362736
];
2737+
const running = { runId, status: "running" as const, startedAt: at(0), completedAt: null };
2738+
const ended = { ...running, turnEnded: true };
27372739
const rows = (
27382740
timelineEntries: ReadonlyArray<TimelineEntry>,
2739-
toolCallVisibility: "hideSuccessful" | "hideAll" | "finalAnswersOnly",
2740-
isWorking = false,
2741+
toolCallVisibility: "hideSuccessful" | "hideAll" | "zen",
2742+
latestRun?: typeof ended | typeof running,
27412743
) =>
27422744
deriveMessagesTimelineRows({
27432745
timelineEntries,
27442746
expandedRunIds: new Set([runId]),
2745-
isWorking,
2746-
...(isWorking
2747-
? {
2748-
latestRun: { runId, status: "running" as const, startedAt: at(0), completedAt: null },
2749-
}
2750-
: {}),
2747+
isWorking: latestRun !== undefined,
2748+
...(latestRun ? { latestRun } : {}),
27512749
turnDiffSummaries: [],
27522750
supportsConversationRollback: false,
27532751
toolCallVisibility,
@@ -2762,29 +2760,41 @@ describe("v2 run and attempt history", () => {
27622760
"final",
27632761
]);
27642762
expect(rows([user, failed, final], "hideAll")).toEqual(["user", "final"]);
2765-
expect(rows(turn, "finalAnswersOnly")).toEqual(["user", "final"]);
2766-
expect(rows([user, step, passed], "finalAnswersOnly", true)).toEqual([
2763+
expect(rows(turn, "zen")).toEqual(["user", "final"]);
2764+
expect(rows([user, step, passed], "zen", running)).toEqual([
27672765
"user",
27682766
"working-indicator-row",
27692767
"live-activity-row",
27702768
]);
27712769
expect(liveAnswerPreview([user, step, passed])).toBe("step");
2772-
expect(
2773-
deriveMessagesTimelineRows({
2774-
timelineEntries: turn,
2775-
isWorking: true,
2776-
latestRun: {
2777-
runId,
2778-
status: "running",
2779-
startedAt: at(0),
2780-
completedAt: null,
2781-
turnEnded: true,
2782-
},
2783-
turnDiffSummaries: [],
2784-
supportsConversationRollback: false,
2785-
toolCallVisibility: "finalAnswersOnly",
2786-
}).map((row) => row.id),
2787-
).toEqual(["user", "final"]);
2770+
expect(rows(turn, "zen", ended)).toEqual(["user", "final"]);
2771+
const followUp = message("follow-up", "user", 30);
2772+
expect(rows([...turn, followUp], "zen", ended)).toEqual([
2773+
"user",
2774+
"final",
2775+
"follow-up",
2776+
"working-indicator-row",
2777+
]);
2778+
const wake: TimelineEntry = {
2779+
id: "wake",
2780+
kind: "work",
2781+
createdAt: at(30),
2782+
entry: {
2783+
id: "wake",
2784+
createdAt: at(30),
2785+
runId: RunId.make("wake"),
2786+
label: "Task finished",
2787+
tone: "info",
2788+
itemType: "notification",
2789+
},
2790+
};
2791+
expect(rows([user, final, wake], "zen", { ...running, runId: RunId.make("wake") })).toEqual([
2792+
"user",
2793+
"final",
2794+
"wake",
2795+
"working-indicator-row",
2796+
"live-activity-row",
2797+
]);
27882798
});
27892799
it("collapses only output from a superseded V2 attempt within the active logical run", () => {
27902800
const runId = "run-steered" as never;

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,7 @@ function workShownAsFinalAnswerOnly(
13961396
pendingApprovalRequestIds?.has(item.requestId) === true) ||
13971397
work.questionAnswer !== undefined ||
13981398
timelineEntryIsCompaction(entry) ||
1399+
timelineEntryStartsResponse(entry) ||
13991400
work.tone === "error" ||
14001401
work.sourceActivityKind === "runtime.error" ||
14011402
(work.itemType === "error" && work.toolLifecycleStatus !== "completed")
@@ -1433,7 +1434,7 @@ function timelineRowEntries(
14331434
const visibility = input.toolCallVisibility ?? "showAll";
14341435
const entries = input.timelineEntries;
14351436
let shown = entries;
1436-
if (visibility === "finalAnswersOnly") {
1437+
if (visibility === "zen") {
14371438
const answering = input.isWorking && input.latestRun?.turnEnded !== true;
14381439
const answeringRunId = answering
14391440
? deriveUnsettledRunId(input.latestRun ?? null, input.runningRunId ?? null)
@@ -1752,11 +1753,14 @@ export function deriveMessagesTimelineRows(input: {
17521753
const activeCompactionRunId = compactsOnReturn
17531754
? runningCompactionRunId
17541755
: (resumeCompactionEntry?.entry.runId ?? null);
1756+
const endedRunId = input.latestRun?.turnEnded === true ? input.latestRun.runId : null;
1757+
const zenAnswerLanded =
1758+
input.toolCallVisibility === "zen" &&
1759+
endedRunId !== null &&
1760+
timelineEntries.findLastIndex((entry) => timelineEntryRunId(entry) === endedRunId) >=
1761+
activeTurnHeaderIndex;
17551762
const appendWorkingRow = () => {
1756-
if (compactionOnlyRunFinished) return;
1757-
if (input.toolCallVisibility === "finalAnswersOnly" && input.latestRun?.turnEnded === true) {
1758-
return;
1759-
}
1763+
if (compactionOnlyRunFinished || zenAnswerLanded) return;
17601764
if (runningCompactionRunId !== null && activeCompactionRunId === null) return;
17611765
nextRows.push({
17621766
kind: "working",

0 commit comments

Comments
 (0)