Repository navigation
fix(session-ui): open a group of long Code Mode scripts without freezing the timeline - #65696
Conversation
18c7671 to
0bbf940
Compare
There was a problem hiding this comment.
The change looks sound, but I couldn't run it: the session-ui component tests need a Chromium that can't launch here, so I didn't check the reveal behaviour or the timings myself. tsc passes for session-ui and ui, and the current-tool-state unit tests pass. A before/after screenshot or short clip of opening the group would help.
The public API is unchanged: these are web timeline UI internals only.
One case is worth fixing: when the failing call is among the hidden earlier calls, the script's error isn't shown anywhere until the user reveals it (inline comment).
| // latest and reveals earlier ones on request. | ||
| const [shown, setShown] = createSignal(executeCallsShown) | ||
| const hidden = createMemo(() => Math.max(0, count() - shown())) | ||
| const visible = createMemo(() => executeToolCalls(props.metadata, hidden())) |
There was a problem hiding this comment.
The runtime error is still attached to owner(), the last failed call, but that call may now be outside the latest 10. Picture a script that catches a failed call, makes 10 or more further calls, then fails. The fallback row only renders when owner() === -1, so the error isn't shown anywhere until the user presses +N more. Two options: show the error row on its own when owner() < hidden(), or always include the owning call in visible.
There was a problem hiding this comment.
Fixed in 05e504e: the error row now shows on its own while its call is among the hidden ones (owner() < hidden()), and moves onto the call once it is revealed.
There was a problem hiding this comment.
Yes, 05e504e fixes it. At tool-renderer.tsx:2203, owner() < hidden() covers both cases: a failure with no call (-1), and a failing call that is still hidden. When +N more reveals the call, owner() >= hidden() becomes true, the standalone row goes away, and the error renders on the call through item().index === owner(). owner and hidden both index the raw toolCalls list, and executeToolCalls keeps start + offset, so the indexes match.
One small leftover gap: executeToolErrorIndex checks the raw list for status: "error" only, but a row renders only if decodeExecuteCall succeeds, which also requires tool: string (current-tool-state.ts:57-63, 81, 93). If the last failed entry has no valid tool but sits in the visible range, it is dropped from the rows, and the standalone row is skipped because owner() >= hidden(), so the error shows nowhere. Before this PR, owner searched the decoded list, so that couldn't happen. This only matters for malformed metadata. A one-line fix keeps the two checks in sync:
const callFailed = Schema.is(Schema.Struct({ tool: Schema.String, status: Schema.Literal("error") }))I only read the diff and the code at pr/head; I didn't run the UI or the tests. I changed nothing in the checkout. The bun.lock change in git status isn't mine, and I left it in place.
There was a problem hiding this comment.
Applied in 072369d: callFailed now also requires tool: string, so it matches exactly the calls the rows decode.
There was a problem hiding this comment.
072369d fixes the gap. callFailed (current-tool-state.ts:94) now checks tool and status the same way decodeExecuteCall does, so the error is always on a row that renders.
executeToolErrorIndex/owner: the error can no longer be attached to a call that is dropped fromvisible.executeToolFailed(line 54): a malformed entry no longer marks the script as failed.executeToolSubtitle(line 107): this also usescallFailed, so the collapsed subtitle names the same calls the rows can show. It names the first failed call while the row error goes on the last one, but the base branch already did that, so it isn't new.
The checks still differ in one case: decodeExecuteCall also rejects an input that is present but isn't a record, and callFailed doesn't check input. That only happens with metadata that is broken in that specific way, so I'd leave it.
I only read the diff and the code at pr/head; I didn't run anything. I changed nothing in the checkout, and the bun.lock change isn't mine, so I left it in place.
Opening a long run of Code Mode scripts folded into one
Used 46 Executegroup froze the app for about 15 s. Each script opens by default inside a group, and the six that walked a source tree listed all of their 19,039 calls.Discovery
From
strobe bench --checkandstrobe record --benchon an export of the session (single launches: discovery evidence, not results):main.work14,708 ms to open and close the group,main.style11,703 ms of it.Collapsible.Contentreads its animation and size on every open and close: 63 forced style passes per open and close.markdown.cssmatched a shell code block with:has(> pre:not([style*="background"])). Astyleattribute inside:has()makes Chromium recheck every:has()above each element whose inline style changes. The timeline positions its rows inline, so the virtualizer's scroll adjustment after the open restyled the whole timeline a second time (3,314 then 3,673 elements). Dropping that one rule in the page removed the second pass.Schemaand gave each finished call a six-elementTextShimmer.Changes
+N morebutton above them reveals 50 earlier calls per press, and focus moves to the first call when the button goes (tool-renderer.tsx).current-tool-state.ts).Collapsible.Contentmounts with the open state, without Kobalte's presence and measuring. Nothing in the app animates collapsible content (collapsible.tsx).[style]in:has(): the shell code block's toolbar background is matched from the toolbar after the code (markdown.css).Before and after
The same opened group, scrolled up the same distance: before, one script's thousands of calls fill the view; after, each script lists its latest calls, with
+76 moreabove the rest.Results
main.work, open and closemain.style, open and closeThe block below is the committed
open a group of scriptscase inpackages/app/perf/timeline.bench.ts(fixtures/scripts.tsrebuilds the session's 46 scripts and 19,039 calls). Other work kept the machine's CPUs busy, so it was stopped after 2 pairs, before strobe's first look at pair 8: its headline says "No answer yet". Both pairs moved the same way, by about 99%:main.workper open: 16,679 ms → 149 ms (−99.1%).Its "late frames" caution counts the frames that did present: base presented almost none while frozen (86.5% of vsyncs dropped, against 0.86% here).
The same comparison on
scroll history(35 pairs, stopped before its last look) readmain.work+0.2% [−2% … +3%]: no change.strobe · exp_6b22e5 · packages/app/perf/timeline.bench.ts · generated
No answer yet
Caution
Regression: late frames rose from 6.1% to 8.3% (2 of 2 pairs)
Open a group of scripts: Main-thread work per 17 s run: no answer, stopped after 2 pairs; unsteady case: its work grew each run.
Stopped early: the results cover only the pairs that finished.
Details · metrics, pairs, profiles, method
Metrics
−16,500,000 µs (warned)
−17,500,000 to −15,600,000 µs
−7,220,000 µs (warned)
−7,280,000 to −7,150,000 µs
−16,400,000 µs (warned)
−17,200,000 to −15,600,000 µs
−13,600,000 µs (warned)
−14,400,000 to −12,900,000 µs
−852,000 µs (warned)
−855,000 to −849,000 µs
−1,070,000 µs (warned)
−1,140,000 to −1,000,000 µs
+3,000 µs (warned)
0 to +6,000 µs
Likely range: 50% confidence. Change: the pairs' typical change (Hodges–Lehmann: the median of the averages of every two pairs' changes).
Pairs
Each pair launched both builds fresh, in alternating order (AB or BA). Change: the main metric. Other apps' CPU: other processes on the measured CPUs, % of one core, bold from 25%; 2 other processes ≥ 5%, busiest 147% of a core.
Frame pacing
Shares of all 479 and 421 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
origin/dev@562e55a048, fix(core): pin websearch in the Code Mode cataloga946e848e6 (dirty), fix(session-ui): open a group of long Code Mode scripts without freezing the timelineAlso measured, not tested
+2.0 µs (warned)
+1.0 to +3.0 µs
−1.0 µs (warned)
−2.0 to 0 µs
−1,300 µs (warned)
−2,500 to −100 µs
−200,000 µs (warned)
−220,000 to −180,000 µs
+32 MB
+30 to +35 MB
+0.12 MB
+0.06 to +0.19 MB
−3,740 MB
−3,890 to −3,580 MB
−329 MB
−344 to −314 MB
−20,000,000 µs (warned)
−21,100,000 to −18,900,000 µs
Rerun · command and recordings
strobe report experiment exp_6b22e5 --openrec_bd6791(origin/dev@562e55a048, pair 1),rec_061544(a946e84 (dirty), pair 1)strobe · exp_6b22e5 · end of generated report