Repository navigation
fix(session-ui): drive markdown readiness, steer grow-in and tool status titles through state machines - #61977
Conversation
…atus titles through state machines
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
There was a problem hiding this comment.
The three lifecycles look right to me, and the Markdown readiness and hidden-tab title fixes check out. I ran the new component specs on the base, where all 4 fail and show the bugs described. With this PR, the three Markdown readiness specs pass. Session-ui unit tests (494), tsc -b and 100 existing session-ui component tests (markdown, timeline, lifecycle, tool groups) also pass. I didn't run steer grow-in in a browser; I checked it through its unit tests and the existing timeline component tests.
The public API is unchanged. data-markdown-ready keeps its meaning; only when it toggles changes.
One blocker: the new tool-status-title.spec.ts fails every time on this branch (see the inline comment). CI runs test:components, so it will go red.
These are browser-only animation and timing changes, so a short before/after video of a steer growing in and of a history page loading above would help reviewers.
There was a problem hiding this comment.
The failing test is fixed: the done title is now found by its slot. With this branch, the tool status title and Markdown readiness component specs pass on repeated runs (3 runs each). On the base, the updated spec still catches the 0px width bug. Nothing new to raise. The public API is unchanged.
Three Session UI lifecycles that run while a reply streams now each live in one explicit state machine: Markdown readiness, steer grow-in, and the tool status title animation.
Bugs fixed
data-markdown-readyremoved and re-added: 2 mutations per<Markdown>on the timeline'sMutationObserverstreaming→false)localFileExistsnever settlesINLINE_PATH_CHECK_TIMEOUT_MS(2 s); the path stays plain codestreamingflips before thehtmlfetcher runslet streamed, not the mode of its own sourcemode0px→ natural)activeflips in a hidden tab (display: none)"0px", pinnedwidth: 0px+overflow: hiddenfor 600 ms: the title was invisible if the tab showed in that windowdoneTextwhile active)suffixandswapState
stateDiagram-v2 direction LR state "Markdown" as md { pending --> ready: rendered, no checks (or streaming) pending --> checking: rendered, checks pending checking --> ready: checks.settled / checks.timed-out (same attempt) checking --> checking: new blocks → attempt + 1 ready --> pending: render stale / stream ends checking --> pending: render stale / stream starts } state "Tool status title" as tool { idle --> measuring: sync with a width idle --> idle: hidden, reduced motion, mode switch measuring --> animating: measured (same attempt) measuring --> idle: measured 0px or same width without crossfade animating --> idle: settled (same attempt) measuring --> measuring: reversal → attempt + 1 }Steer arrivals: a user message is a steer only when it lands below the last row already seen while the session works. Rows are keyed by message ID (user, shell, assistant), so a prepended page lands above every seen row and a first page has no seen row at all.
Deleted
markdown.tsx:let streamed, every directdataset.markdownReadywrite, thePromise.all(pending)guard.session-timeline-row.tsx: the mutableseenobject, thearrivalsmemo that mutated it, andarrivals().delete(...)during render.tool-status-title.tsx:createStore({ active, animating, width })and thefinish()/animate()pair.Hot path
dom.rendered; states without a started check are frozen singletons, so a steady stream allocates nothing in the machine. The driver reuses its event objects.transition*returns the state; drivers derive timers, frames and the worker projection cleanup from the state change (thepaced-text-machinepattern), so no effect arrays are allocated.data-markdown-readyusestoggleAttribute(name, ready), which records no mutation when unchanged.sessionID,rowsandbusydid not change.Benchmark
stream a replyrun (packages/app/perf/stream.bench.ts) on an Apple M4, comparing base5ea5c5e610(this branch's merge base) with head; strobe's block is at the end. The Windows machine was locked.main.work) came out 16% lower, with an interval of −47% to +13%. The device was loaded (29% background CPU, 43–49% run-to-run variation), so the run shows no sign of a regression but proves no win.Product calls
activesettles at once; anactiveflip at the same width still crossfades for 600 ms.dev, which checked status at render time).Deviations from the design
message-content.tsx) stays as is: already one 3-value union ("grace" | "now" | undefined) with one monotonic transition and no flags.loadingvariant. "No seen row above" covers a first page, a leading notice, and rows replaced wholesale.markdownMode/markdownReadyselectors instead of an allocatingview()object, because the effect reads them on every delta.Visual
strobe ┬╖ exp_0fc370 ┬╖ packages/app/perf/stream.bench.ts ┬╖ generated
No answer yet
Stream a reply: Main-thread work per 4.2 s run: no answer, stopped after 17 pairs; unsteady case: its work grew each run.
Stopped early: the results cover only the pairs that finished.
Details ┬╖ metrics, pairs, profiles, method
Metrics
Likely range: 98.5% confidence for the main metric, 95.5% for the others. Change: the median of the pairs' own changes.
Pairs
Each pair launched both builds fresh, in alternating order (AB or BA). Change: the main metric.
Frame pacing
Shares of all 18,664 and 20,148 gaps between frames; a frame is late from 1.5 frame times. Gap percentiles: each launch's own, median across launches.
How it was measured
5ea5c5e610, fix(gui-plugins): drive the Pierre file tree through one state machineorigin/sessionui-lows-one@ed28f79726, test(session-ui): locate the done title by its slotAlso measured, not tested
Unchanged: DOM nodes (1176), frame gap, p50 (16.7 ms). Uneven pairs: renderer CPU use read 16.6–60.6% before and 19.8–60.5% with this PR and JavaScript heap read 32.5–117 MB before and 32.6–106 MB with this PR; the medians' change (beside it) and the pairs' own point different ways, as when a few launches read far from the rest, so read neither as the change.
Rerun ┬╖ command and recordings
strobe bench packages/app/perf/stream.bench.ts \ --base 5ea5c5e610 \ --head origin/sessionui-lows-one \ --filter "stream a reply"strobe report experiment exp_0fc370 --openrec_8eb2ef(before, pair 1),rec_b329a1(this PR, pair 1)strobe ┬╖ exp_0fc370 ┬╖ end of generated report