Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
62 changes: 40 additions & 22 deletions .fork/customizations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6586,6 +6586,16 @@
fork-quiet-live-turn), the running tool, and the thinking word. A new
tool or thought takes the line at once; otherwise it turns every 4s,
skipping voices with nothing to say, and the word changes each lap. A
tool that ends between beats hands the line back to the thought, not on
to the word, and each new label stays up at least 1.5s (a thought still
streaming grows through on its first deadline), so a burst of reply,
tool and settle never flickers three texts through the line in a few
frames; the dwell rules are pure functions beside the rotation's. The
list reuses the line across threads, so WorkingTimelineRow keys it by
thread. The line swaps a div for a button when a group appears, which
remounts its shimmer, so each mount is phased to the clock by the
animation's own duration (--fork-shimmer-phase) and a change never
starts a second sweep right after one. A
provider startup or "Waiting on N subagents" holds the line alone and
stops the clock. The thinking word comes from
@t3tools/shared/forkThinkingWords: the seed is what last landed (the row
Expand Down Expand Up @@ -6629,33 +6639,41 @@

- id: fork-quiet-live-turn
intent: >
A running turn reads as one status line in every tool-call mode, the way
Zen reads. Outside Zen upstream streams each reply as it lands, so a
turn grew a column of command, reply, command rows that the turn fold
swallowed into "Worked for …" the moment it ended. The fork holds a
running turn's replies (Zen's rule: everything after the response
boundary, except a revealed message, a steer's answer and a final-answer
reply) until the turn ends, so its steps join one stretch that folds into
the status line (fork-working-row-last), and the line reads Zen's
preview of them. MessagesTimeline opts in with forkHoldLiveReplies,
except while Find is open, which searches reply text, and the guest share
page opts out (forkStreamLiveReplies), so a guest still watches replies
stream as upstream shows them. While the turn waits on the user (an
approval or a question), the latest held reply shows, since it usually
explains the request (forkShowLatestHeldReply); unlike Zen. The hold runs
after settleSupersededReasoning, so a thought followed only by a held
reply still reads settled. Upstream's logic
tests derive without the flag and keep upstream's shapes. The guard runs
one fixture through Zen and through the hold and requires the same
replies, so a sync that adds a Zen exemption fails it. The no3y iOS app
is unchanged.
A running turn reads calmly in every tool-call mode: one summary row
that grows as the turn goes, then the status line. Outside Zen upstream
streams each reply as it lands, so a turn grew a column of command,
reply, command rows that the turn fold swallowed into "Worked for …" the
moment it ended. The fork holds a running turn's replies (Zen's rule:
everything after the response boundary, except a revealed message, a
steer's answer and a final-answer reply) until the turn ends, except the
newest, which stays in the entries but draws no row
(deriveMessagesTimelineRows skips it). It still splits the turn, so the
steps before it close into one summary row whose counts climb with each
update, and the steps since it fold into the status line
(fork-working-row-last), which reads Zen's preview of it. Only the status
line ever carries the agent's words. Each split moves the live group's
first step, so the live group is named for the run, and a status line
the user opened stays open across updates, as it did when the whole turn
was one stretch. The held replies are worked out once per derive. MessagesTimeline opts in with
forkHoldLiveReplies, except while Find is open, which searches reply
text, and the guest share page opts out (forkStreamLiveReplies), so a
guest still watches replies stream as upstream shows them. While the turn
waits on the user (an approval or a question), the newest reply shows,
since it usually explains the request (forkShowLatestHeldReply); unlike
Zen. The hold runs after settleSupersededReasoning, so a thought followed
only by a held reply still reads settled. Upstream's logic tests derive
without the flag and keep upstream's shapes. The guard runs one fixture
through Zen and through the hold and requires the same replies, so a sync
that adds a Zen exemption fails it. The no3y iOS app is unchanged.
tier: 3
files:
- apps/web/src/__fork_guards__/forkQuietLiveTurn.test.ts
shadows: []
watch:
# Fenced: the forkHoldLiveReplies input, forkHeldLiveReplyIds and the
# filter in timelineRowEntries after the visibility filters.
# Fenced: the forkHoldLiveReplies input, forkLiveReplyIds, the filter in
# timelineRowEntries after the visibility filters (and its
# forkLiveReplies parameter), the skipped row for the newest reply in
# deriveMessagesTimelineRows, and the live group's run-named id.
- apps/web/src/components/chat/MessagesTimeline.logic.ts
# Fenced: passes forkHoldLiveReplies, the forkStreamLiveReplies prop, and
# reads liveAnswerPreview in every mode (upstream gates it to Zen).
Expand Down
58 changes: 37 additions & 21 deletions apps/web/src/components/chat/MessagesTimeline.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
}
Expand Down Expand Up @@ -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 =

Copy link
Copy Markdown
Owner Author

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: timelineRowEntries already ran forkLiveReplyIds to .slice(0, -1) it. Please derive it once, for example by returning it from timelineRowEntries, so the two calls can't drift apart and we don't pay the O(n) scans again on every streaming update.

Copy link
Copy Markdown
Owner Author

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 forkLiveReplyIds call per row derive, passed to timelineRowEntries.

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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a fork continue in the middle of upstream's main row loop, so that an entry every earlier derivation already counted never becomes a row. Can we hold this reply like the others and build the summary row explicitly in one fenced helper, so no ghost entry exists at all? See review point 1.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The 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 activeVisualResponseRunIds (so no turn fold applies), it has no row (so terminal-message meta isn't drawn), and when the turn ends the hold lifts and it renders as before. A hand-built summary row would duplicate upstream's grouping for the summary, which means work-toggle ids, forkTrailSummary, expansion and continuation, and that's more fork surface than this three-line fenced skip. The lone-tool-row quirk is listed in the PR body as a known once-per-turn shape. I also moved the newest-reply derivation to one place (see the reply on L1724).

/* fork:end fork-quiet-live-turn */
const compactionRunId = timelineEntry.message.runId;
const compactionRun =
compactionRunId !== null && isCompactionCommandMessage(timelineEntry.message);
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/components/chat/TimelineWorkGroupRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,12 @@ export function WorkingTimelineRow({ row }: { row: Extract<TimelineRow, { kind:
const forkTasks = use(ForkLiveTasksCtx);
/* fork:end fork-live-task-list */
/* fork:begin fork-working-row-last — see .fork/customizations.yaml#fork-working-row-last */
const { routeThreadKey } = use(TimelineRowCtx);
if (isForkStatusLine(row)) {
return (
<ForkLiveStatusLine
// The list reuses this row across threads; a new thread starts its own rotation and dwell.
key={routeThreadKey}
row={row}
timer={row.createdAt ? <WorkingTimer createdAt={row.createdAt} /> : null}
trailing={
Expand Down
44 changes: 42 additions & 2 deletions apps/web/src/custom/ForkLiveStatusLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { ForkLiveTaskList } from "./ForkLiveTaskList";
import { ForkLiveTasksCtx } from "./forkLiveTasks";
import {
forkStatusLineAdvance,
forkStatusLineDwellEnd,
forkStatusLineDwellReconcile,
forkStatusLineDwellStart,
forkStatusLineReconcile,
forkStatusLineRotates,
forkStatusLineStart,
Expand All @@ -23,6 +26,40 @@ import {
} from "./forkWorkingRowLast";

const BEAT_MS = 4000;
const DWELL_MS = 1500;

/**
* The line swaps a div for a button when a group appears, which remounts the shimmer and
* would start a sweep at once. Phasing each mount to the clock keeps the sweeps a cycle apart.
*/
function shimmerLineRef(element: HTMLSpanElement | null) {
const shimmer = element?.querySelector<HTMLElement>(".live-activity-focus");
const cycleMs = shimmer
? Number.parseFloat(getComputedStyle(shimmer).animationDuration) * 1000
: 0;
if (element && cycleMs > 0) {
element.style.setProperty("--fork-shimmer-phase", `${-(performance.now() % cycleMs)}ms`);
}
return observeVisibleAnimation(element);
}

/** Holds each new label for DWELL_MS; forkWorkingRowLast holds the rules, this hook only the clock. */
function useDwelledLabel(label: string, thought: boolean): string {
const [shown, setShown] = useState(() => forkStatusLineDwellStart(label, thought));
const next = forkStatusLineDwellReconcile(shown, label, thought);
if (next !== shown) setShown(next);
const { dwelling, arrival } = next;
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- a wall-clock dwell, started by each label that takes the line
useEffect(() => {
if (!dwelling) return;
const id = window.setTimeout(
() => setShown((current) => forkStatusLineDwellEnd(current, arrival)),
DWELL_MS,
);
return () => window.clearTimeout(id);
}, [dwelling, arrival]);
return next.label;
}

/** The rotation's state; forkWorkingRowLast holds the rules, this hook only the clock. */
function useStatusLineState(voices: ForkStatusLineVoices) {
Expand Down Expand Up @@ -62,7 +99,10 @@ export function ForkLiveStatusLine({
const groupId = live?.groupId;
const voices = forkStatusLineVoices(live, use(TimelineRowActivityCtx), ctx.workspaceRoot, m);
const rotation = useStatusLineState(voices);
const label = forkStatusLineText(voices, rotation, row.forkWordSeed);
const label = useDwelledLabel(
forkStatusLineText(voices, rotation, row.forkWordSeed),
voices.pinned === null && rotation.voice === "thought",
);
const text = (
<>
<span className="min-w-0 truncate">{label}</span>
Expand All @@ -73,7 +113,7 @@ export function ForkLiveStatusLine({
<>
<SidebarV2WorkingMark seed={row.id} />
<span
ref={observeVisibleAnimation}
ref={shimmerLineRef}
data-fork-status-line
className="relative flex min-w-0 items-center gap-2 overflow-hidden whitespace-nowrap"
>
Expand Down
Loading
Loading