Skip to content

Commit 46e6e42

Browse files
committed
fix(web): Zen keeps the answer an agent finished before reading a steer
1 parent 8a2fafd commit 46e6e42

3 files changed

Lines changed: 51 additions & 12 deletions

File tree

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,12 @@ describe("v2 run and attempt history", () => {
26952695
it("hides tool calls or everything but the final answer", () => {
26962696
const runId = RunId.make("turn-1");
26972697
const at = (second: number) => `2026-01-01T00:00:${String(second).padStart(2, "0")}Z`;
2698-
const message = (id: string, role: "user" | "assistant", second: number): TimelineEntry => ({
2698+
const message = (
2699+
id: string,
2700+
role: "user" | "assistant",
2701+
second: number,
2702+
inputIntent?: "steer",
2703+
): TimelineEntry => ({
26992704
id,
27002705
kind: "message",
27012706
createdAt: at(second),
@@ -2707,6 +2712,7 @@ describe("v2 run and attempt history", () => {
27072712
createdAt: at(second),
27082713
updatedAt: at(second),
27092714
streaming: false,
2715+
...(inputIntent ? { inputIntent } : {}),
27102716
},
27112717
});
27122718
const command = (
@@ -2761,6 +2767,12 @@ describe("v2 run and attempt history", () => {
27612767
]);
27622768
expect(rows([user, failed, final], "hideAll")).toEqual(["user", "final"]);
27632769
expect(rows(turn, "zen")).toEqual(["user", "final"]);
2770+
const [steer, answer] = [
2771+
message("steer", "user", 4, "steer"),
2772+
message("answer", "assistant", 7),
2773+
];
2774+
expect(rows([user, steer, answer, final], "zen")).toEqual(["user", "steer", "answer", "final"]);
2775+
expect(rows([user, steer, step, passed, final], "zen")).toEqual(["user", "steer", "final"]);
27642776
expect(rows([user, step, passed], "zen", running)).toEqual([
27652777
"user",
27662778
"working-indicator-row",

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

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,27 @@ function workShownAsFinalAnswerOnly(
14031403
);
14041404
}
14051405

1406+
function deriveInFlightSteerAnswerIds(entries: ReadonlyArray<TimelineEntry>): ReadonlySet<string> {
1407+
const ids = new Set<string>();
1408+
let awaitingReply = false;
1409+
let candidate: string | null = null;
1410+
for (const entry of entries) {
1411+
if (entry.kind === "work" && entry.entry.itemType === "reasoning") continue;
1412+
const reply = entry.kind === "message" && entry.message.role === "assistant" ? entry : null;
1413+
if (candidate !== null && reply !== null) ids.add(candidate);
1414+
candidate = null;
1415+
if (timelineEntryIsSteer(entry)) {
1416+
awaitingReply = true;
1417+
} else if (entry.kind === "message" && entry.message.role === "user") {
1418+
awaitingReply = false;
1419+
} else if (reply !== null && awaitingReply) {
1420+
candidate = reply.message.id;
1421+
awaitingReply = false;
1422+
}
1423+
}
1424+
return ids;
1425+
}
1426+
14061427
export function liveAnswerPreview(entries: ReadonlyArray<TimelineEntry>): string | null {
14071428
const boundary = lastResponseBoundaryIndex(entries);
14081429
for (let index = entries.length - 1; index > boundary; index -= 1) {
@@ -1441,6 +1462,7 @@ function timelineRowEntries(
14411462
: null;
14421463
const answeringFrom = answering ? lastResponseBoundaryIndex(entries) + 1 : entries.length;
14431464
const terminalIds = deriveTerminalAssistantMessageIds(entries);
1465+
const steerAnswerIds = deriveInFlightSteerAnswerIds(entries);
14441466
shown = entries.filter((entry, index) => {
14451467
if (entry.kind !== "message") {
14461468
return workShownAsFinalAnswerOnly(entry, input.pendingApprovalRequestIds);
@@ -1449,7 +1471,7 @@ function timelineRowEntries(
14491471
return (
14501472
message.role !== "assistant" ||
14511473
message.id === input.revealedMessageId ||
1452-
(terminalIds.has(message.id) &&
1474+
((terminalIds.has(message.id) || steerAnswerIds.has(message.id)) &&
14531475
index < answeringFrom &&
14541476
(answeringRunId === null || message.runId !== answeringRunId))
14551477
);
@@ -1472,6 +1494,7 @@ function deriveTimelineTurnFolds(
14721494
| "revealedMessageId"
14731495
>,
14741496
) {
1497+
if (input.toolCallVisibility === "zen") return new Map<string, TurnFold>();
14751498
const timelineEntries = timelineRowEntries(input);
14761499
const unsettledRunId = deriveUnsettledRunId(input.latestRun ?? null, input.runningRunId ?? null);
14771500
const failedRunIds = failedTimelineRunIds(timelineEntries, input.latestRun ?? null);
@@ -1556,15 +1579,18 @@ export function deriveMessagesTimelineRows(input: {
15561579
isWorking: input.isWorking,
15571580
});
15581581
const runlessWorkActive = input.isWorking && input.runlessWorkActive === true;
1559-
const foldsByAnchorEntryId = deriveTurnFolds({
1560-
timelineEntries: timelineEntries,
1561-
terminalAssistantMessageIds,
1562-
latestRun: input.latestRun ?? null,
1563-
unfoldedRunIds: new Set([...activeVisualResponseRunIds, ...failedRunIds]),
1564-
runlessWorkActive,
1565-
liveSubagentEntryIds,
1566-
completeSupersededReplyEntryIds: completeSupersededReplyIds,
1567-
});
1582+
const foldsByAnchorEntryId =
1583+
input.toolCallVisibility === "zen"
1584+
? new Map<string, TurnFold>()
1585+
: deriveTurnFolds({
1586+
timelineEntries: timelineEntries,
1587+
terminalAssistantMessageIds,
1588+
latestRun: input.latestRun ?? null,
1589+
unfoldedRunIds: new Set([...activeVisualResponseRunIds, ...failedRunIds]),
1590+
runlessWorkActive,
1591+
liveSubagentEntryIds,
1592+
completeSupersededReplyEntryIds: completeSupersededReplyIds,
1593+
});
15681594
const timelineEntryById = new Map(timelineEntries.map((entry) => [entry.id, entry]));
15691595
const collapsedEntryIds = new Set<string>();
15701596
const collapsedFoldMemberIds = new Set<string>();

‎docs/user/activity-log.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ On web and desktop, **Settings → Labs → Tool calls in chat** hides commands,
2424
and MCP tool calls from the conversation. **Hide successful** shows a call while it runs and keeps
2525
it only if it fails. **Hide all** hides every call and shows **Thinking** while the agent works.
2626
**Zen** also hides the agent's in-between messages, so each turn shows your message
27-
and the agent's last reply, which appears when the turn ends. Find shows the in-between messages
27+
and the agent's last reply, which appears when the turn ends. If you steer while the agent is
28+
answering, the answer it finished before reading your steer stays too. Find shows the in-between messages
2829
while it is open. Approvals, questions, and errors always show. The setting applies to this browser
2930
or app only.

0 commit comments

Comments
 (0)