Repository navigation
feat(web): a running turn grows one summary row above the status line #521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4c6dab7
f9139af
0e66203
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1520,25 +1520,20 @@ export function liveAnswerPreview(entries: ReadonlyArray<TimelineEntry>): string | |
| } | ||
|
|
||
| /* fork:begin fork-quiet-live-turn — see .fork/customizations.yaml#fork-quiet-live-turn | ||
| The replies Zen holds back while answering, narrowed to the run still going; | ||
| The replies Zen holds back while answering, narrowed to the run still going, in order; | ||
| a guard (forkQuietLiveTurn) pins it to Zen's rule. */ | ||
| function forkHeldLiveReplyIds( | ||
| function forkLiveReplyIds( | ||
| input: Pick< | ||
| MessagesTimelineRowsInput, | ||
| | "timelineEntries" | ||
| | "isWorking" | ||
| | "latestRun" | ||
| | "runningRunId" | ||
| | "revealedMessageId" | ||
| | "forkShowLatestHeldReply" | ||
| "timelineEntries" | "isWorking" | "latestRun" | "runningRunId" | "revealedMessageId" | ||
| >, | ||
| ): ReadonlySet<string> { | ||
| const held = new Set<string>(); | ||
| ): ReadonlyArray<string> { | ||
| const replies: string[] = []; | ||
| const answeringRunId = | ||
| input.isWorking && input.latestRun?.turnEnded !== true | ||
| ? deriveUnsettledRunId(input.latestRun ?? null, input.runningRunId ?? null) | ||
| : null; | ||
| if (answeringRunId === null) return held; | ||
| if (answeringRunId === null) return replies; | ||
| const entries = input.timelineEntries; | ||
| const steerAnswerIds = deriveInFlightSteerAnswerIds(entries); | ||
| const retainedReplyIds = retainedAssistantReplyEntryIds(entries); | ||
|
|
@@ -1552,12 +1547,10 @@ function forkHeldLiveReplyIds( | |
| !steerAnswerIds.has(entry.message.id) && | ||
| !retainedReplyIds.has(entry.id) | ||
| ) { | ||
| held.add(entry.id); | ||
| replies.push(entry.id); | ||
| } | ||
| } | ||
| // While the turn waits on the user, the reply that led to the request explains it. | ||
| if (input.forkShowLatestHeldReply === true) held.delete([...held].at(-1) ?? ""); | ||
| return held; | ||
| return replies; | ||
| } | ||
| /* fork:end fork-quiet-live-turn */ | ||
|
|
||
|
|
@@ -1589,9 +1582,13 @@ function timelineRowEntries( | |
| /* fork:end fork-bots */ | ||
| /* fork:begin fork-quiet-live-turn — see .fork/customizations.yaml#fork-quiet-live-turn */ | ||
| | "forkHoldLiveReplies" | ||
| | "forkShowLatestHeldReply" | ||
| /* fork:end fork-quiet-live-turn */ | ||
| >, | ||
| /* fork:begin fork-quiet-live-turn — see .fork/customizations.yaml#fork-quiet-live-turn */ | ||
| forkLiveReplies: ReadonlyArray<string> = input.forkHoldLiveReplies === true | ||
| ? forkLiveReplyIds(input) | ||
| : [], | ||
| /* fork:end fork-quiet-live-turn */ | ||
| ) { | ||
| const visibility = input.toolCallVisibility ?? "showAll"; | ||
| const entries = input.timelineEntries; | ||
|
|
@@ -1643,9 +1640,11 @@ function timelineRowEntries( | |
| Zen's rule in every mode: a running turn's replies wait for it to end; the status line reads | ||
| them. Held after settling, so a thought followed only by a held reply still reads settled. */ | ||
| const settled = settleSupersededReasoning(shown); | ||
| const held = input.forkHoldLiveReplies === true ? forkHeldLiveReplyIds(input) : null; | ||
| // The newest stays in the entries: deriveMessagesTimelineRows draws no row for it, but it | ||
| // splits the turn, so the steps before it close into one summary row that grows each update. | ||
| const held = new Set(forkLiveReplies.slice(0, -1)); | ||
| return withoutSubagentDelegationRows( | ||
| held !== null && held.size > 0 ? settled.filter((entry) => !held.has(entry.id)) : settled, | ||
| held.size > 0 ? settled.filter((entry) => !held.has(entry.id)) : settled, | ||
| ); | ||
| /* fork:end fork-quiet-live-turn */ | ||
| } | ||
|
|
@@ -1708,15 +1707,22 @@ export function deriveMessagesTimelineRows( | |
| hideQuietBotWakes?: boolean; | ||
| /* fork:end fork-bots */ | ||
| /* fork:begin fork-quiet-live-turn — see .fork/customizations.yaml#fork-quiet-live-turn */ | ||
| /** Outside Zen, a running turn's replies stay out of the rows until it ends, as Zen's do. */ | ||
| /** Outside Zen, a running turn's replies stay out of the rows until it ends, as Zen's do; the newest still splits its steps. */ | ||
| forkHoldLiveReplies?: boolean; | ||
| /** While the turn waits on the user, the latest held reply shows. */ | ||
| forkShowLatestHeldReply?: boolean; | ||
| /* fork:end fork-quiet-live-turn */ | ||
| }, | ||
| resolve: MessageResolver = m, | ||
| ): MessagesTimelineRow[] { | ||
| const timelineEntries = timelineRowEntries(input); | ||
| /* fork:begin fork-quiet-live-turn — see .fork/customizations.yaml#fork-quiet-live-turn | ||
| Upstream: timelineRowEntries(input). While the turn waits on the user, the newest reply | ||
| shows, since it explains the request. */ | ||
| const forkLiveReplies = input.forkHoldLiveReplies === true ? forkLiveReplyIds(input) : []; | ||
| const timelineEntries = timelineRowEntries(input, forkLiveReplies); | ||
| const forkUnshownReplyId = | ||
| input.forkShowLatestHeldReply === true ? null : (forkLiveReplies.at(-1) ?? null); | ||
| /* fork:end fork-quiet-live-turn */ | ||
| const embeddedResultRunIds = new Set<RunId>(); | ||
| for (const entry of timelineEntries) { | ||
| if ((entry.kind === "html-render" || entry.kind === "mcp-app") && entry.runId !== null) { | ||
|
|
@@ -1878,7 +1884,14 @@ export function deriveMessagesTimelineRows( | |
| const activeWorkRow = | ||
| activeWorkAnchor && latestVisibleToolEntry && !latestToolFailed | ||
| ? (() => { | ||
| const groupId = workGroupId(activeWorkAnchor.id); | ||
| /* fork:begin fork-quiet-live-turn — see .fork/customizations.yaml#fork-quiet-live-turn | ||
| Upstream: workGroupId(activeWorkAnchor.id). Each newest reply moves the live | ||
| group's first step, so the run names it and an opened status line stays open. */ | ||
| const groupId = | ||
| input.forkHoldLiveReplies === true && unsettledRunId !== null | ||
| ? workGroupId(`fork-live:${unsettledRunId}`) | ||
| : workGroupId(activeWorkAnchor.id); | ||
| /* fork:end fork-quiet-live-turn */ | ||
| return { | ||
| kind: "work-live" as const, | ||
| id: latestToolKeepsActivityLive | ||
|
|
@@ -2374,6 +2387,9 @@ export function deriveMessagesTimelineRows( | |
| continue; | ||
| } | ||
|
|
||
| /* fork:begin fork-quiet-live-turn — see .fork/customizations.yaml#fork-quiet-live-turn */ | ||
| if (timelineEntry.id === forkUnshownReplyId) continue; | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds a fork
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm keeping this one as is. The unshown reply exists only while the run is unsettled. During that time the run is in |
||
| /* fork:end fork-quiet-live-turn */ | ||
| const compactionRunId = timelineEntry.message.runId; | ||
| const compactionRun = | ||
| compactionRunId !== null && isCompactionCommandMessage(timelineEntry.message); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the second derivation of the same newest reply:
timelineRowEntriesalready ranforkLiveReplyIdsto.slice(0, -1)it. Please derive it once, for example by returning it fromtimelineRowEntries, so the two calls can't drift apart and we don't pay the O(n) scans again on every streaming update.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0e66203, same change as the nit above: one
forkLiveReplyIdscall per row derive, passed totimelineRowEntries.