Skip to content

fix(session-ui): open a group of long Code Mode scripts without freezing the timeline - #65696

Merged
Hona merged 3 commits into
devfrom
used-group-expand
Nov 23, 2026
Merged

Hona merged 3 commits into
devfrom
used-group-expand

Conversation

@Hona

@Hona Hona commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Opening a long run of Code Mode scripts folded into one Used 46 Execute group 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 --check and strobe record --bench on an export of the session (single launches: discovery evidence, not results):

  • main.work 14,708 ms to open and close the group, main.style 11,703 ms of it.
  • Kobalte's Collapsible.Content reads its animation and size on every open and close: 63 forced style passes per open and close.
  • markdown.css matched a shell code block with :has(> pre:not([style*="background"])). A style attribute 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.
  • Every open decoded all 19,039 calls through Schema and gave each finished call a six-element TextShimmer.
flowchart LR
  click[Click Used 46 Execute] --> rows["46 scripts x every call\n19,039 rows"]
  rows --> forced["Kobalte content: forced style\nper collapsible"]
  forced --> resize[Virtualizer resizes the row]
  resize --> has["inline style change\n+ :has([style]) rule"]
  has --> again[Whole timeline restyled again]
Loading

Changes

  • Latest calls first: an Execute lists its latest 10 calls. A +N more button above them reveals 50 earlier calls per press, and focus moves to the first call when the button goes (tool-renderer.tsx).
  • Decode what shows: counting, the failed call and the subtitle read the raw list; only shown calls are decoded (current-tool-state.ts).
  • Plain collapsible content: Collapsible.Content mounts with the open state, without Kobalte's presence and measuring. Nothing in the app animates collapsible content (collapsible.tsx).
  • No [style] in :has(): the shell code block's toolbar background is matched from the toolbar after the code (markdown.css).
  • Shimmer only when live: a call or Execute title that never ran while shown renders plain text.

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 more above the rest.

Before After

Results

One launch each, the real 46-script session Before After
main.work, open and close 14,708 ms 222 ms
main.style, open and close 11,703 ms 87 ms
Click to frame, open ~14,200 ms 137-153 ms
Click to frame, close — 27-31 ms

The block below is the committed open a group of scripts case in packages/app/perf/timeline.bench.ts (fixtures/scripts.ts rebuilds 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.work per open: 16,679 ms → 149 ms (−99.1%).
  • Input response, p50: 7,285 ms → 69 ms (−99.05%).
  • DOM nodes after the open: 211,825 → 2,967. Renderer private memory: 4,488 MB → 752 MB.

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) read main.work +0.2% [−2% … +3%]: no change.

strobe · exp_6b22e5 · packages/app/perf/timeline.bench.ts · generated

2.3 pp more late frames, more in 2 of 2 pairs · not tested.

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

Metric origin/dev@562e55a048 a946e84 (dirty) Change Likely range Verdict
Main-thread work per run main 16,679,029 µs 148,765 µs −99.11%
−16,500,000 µs (warned)
−99.14% to −99.07%
−17,500,000 to −15,600,000 µs
stopped warned
Input response, p50 7,285,340 µs 68,923 µs −99.054%
−7,220,000 µs (warned)
−99.059% to −99.049%
−7,280,000 to −7,150,000 µs
not tested warned
Run time 16,845,475 µs 478,600 µs −97.16%
−16,400,000 µs (warned)
−97.24% to −97.07%
−17,200,000 to −15,600,000 µs
not tested warned
Style time per run 13,692,539 µs 62,479 µs −99.54%
−13,600,000 µs (warned)
−99.56% to −99.52%
−14,400,000 to −12,900,000 µs
not tested warned
Layout time per run 858,322 µs 6,371 µs −99.258%
−852,000 µs (warned)
−99.268% to −99.247%
−855,000 to −849,000 µs
not tested warned
JavaScript time per run 1,130,150 µs 59,447 µs −94.7%
−1,070,000 µs (warned)
−95.3% to −94.1%
−1,140,000 to −1,000,000 µs
not tested warned
Frame gap, p95 9,193 µs 12,148 µs +39%
+3,000 µs (warned)
−0.04% to +95%
0 to +6,000 µs
not tested warned
Dropped frames 86.5% 0.86% −99.005% −99.020% to −98.990% not tested warned
Main-thread busy time 98.4% 29.2% −70.3% −70.9% to −69.8% not tested warned
Input response, p95 — — — — skipped too few frames, 10 inputs of 20

Likely range: 50% confidence. Change: the pairs' typical change (Hodges–Lehmann: the median of the averages of every two pairs' changes).

Pairs

Pair Main-thread work per run, origin/dev@562e55a048 → a946e84 (dirty) Change Longest frame gap Other apps' CPU
1 AB 17,633,819 → 151,747 µs −99% 20,200,294 → 157,688 µs 299% → 719%
2 BA 15,724,238 → 145,784 µs −99% 21,315,502 → 121,255 µs 271% → 420%

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

165 Hz display origin/dev@562e55a048 a946e84 (dirty)
On time 93.95% 91.69%
One frame late 2.71% 3.56%
Two or more late 3.34% 4.75%
Frame gap, p50 6,062 µs 6,064 µs
Frame gap, p95 9,193 µs 12,148 µs
Frame gap, p99 — —
Longest frame gap 20,757,898 µs 139,472 µs

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

  • Base: origin/dev@562e55a048, fix(core): pin websearch in the Code Mode catalog
  • Head: a946e848e6 (dirty), fix(session-ui): open a group of long Code Mode scripts without freezing the timeline
  • Machine: Windows 11 26300 (26H2), Ryzen 9 9950X3D, NVIDIA GeForce RTX 5070 Ti, High performance power plan, Chrome 147.0.7727.15, 165 Hz display, pinned to CCD0 (96 MB L3, 16 CPUs), other processes kept off its 16 CPUs, window 1366×768
  • On screen: 'Timeline collapse state regression · OpenCode · Timeline collapse state regression'
  • Method: fresh launches in alternating pairs; Wilcoxon signed-rank test and Hodges–Lehmann interval; main metric checked at 8, 12, 18, 26, 40 pairs, others Holm-corrected; 13.3 min in all
  • Background load: 67% of all CPUs were busy before the run; close heavy apps for tighter intervals
  • Stale calibration: calibrated 2026-10-31T03:33:19Z (more than 7 days ago; strobe up recalibrates)
  • VariantPlacement: base runs in ~\AppData\Local\strobe\builds\13671da3556f and head in …/used-group-expand: they are on different filesystems (NTFS on volume 40dca54e…
  • EndedCpu: open a group of scripts · web: processes ended inside 2 of 5 measured runs; the CPU they used there (90.2 ms a run, median of those) is counted from…
  • OverheadBudget: open a group of scripts · web · origin/dev@562e55a048 block: the reserved-CPU sweep used 8.0% of a core, over its 5% budget (SPEC §19)
  • Throttled: open a group of scripts · web · a946e84 (dirty) block: the first speed check ran slow (Throttled: the speed check ran 2.01× slower than this device's…
  • OverheadBudget: open a group of scripts · web · a946e84 (dirty) block: strobe (besides its budgeted parts) and the runner used 25.1% of a core in the runs (122 ms/run over 488…
  • OverheadBudget: open a group of scripts · web · a946e84 (dirty) block: the sampler used 0.57% of a core, over its 0.5% budget (SPEC §19)
  • Unsteady warmup: 1 block(s) never did the same work twice in 10 warmup runs: the work swung from run to run without growing (jitter, not state): pin the target's CPUs…
  • Other load: other processes used 25% of a core or more in 4 of 4 timed blocks (kept; see Pairs)
  • Recorded with strobe 0.44.1, formatted with strobe 0.44.1+53da950254

Also measured, not tested

Metric origin/dev@562e55a048 a946e84 (dirty) Change Likely range
Frame gap, p50 6,062 µs 6,064 µs +0.033%
+2.0 µs (warned)
+0.016% to +0.049%
+1.0 to +3.0 µs
Frame latency, p50 12,119 µs 12,118 µs −0.008%
−1.0 µs (warned)
−0.017% to 0.000%
−2.0 to 0 µs
Frame latency, p95 13,949 µs 12,616 µs −9%
−1,300 µs (warned)
−16% to −1%
−2,500 to −100 µs
Paint time per run 206,575 µs 4,541 µs −97.8%
−200,000 µs (warned)
−98.0% to −97.5%
−220,000 to −180,000 µs
Layouts per run 7 6 −1 −1
Style recalculations per run 60 35 −25 −26 to −24
GPU use 0.05% 0.84% +1723% +1117% to +2631%
GPU memory 59.3 MB 91.6 MB +55%
+32 MB
+49% to +60%
+30 to +35 MB
Shared GPU memory 1.44 MB 1.57 MB +8%
+0.12 MB
+5% to +12%
+0.06 to +0.19 MB
App memory 4488 MB 752 MB −83.3%
−3,740 MB
−84.4% to −82.0%
−3,890 to −3,580 MB
JavaScript heap 416 MB 87.1 MB −79%
−329 MB
−81% to −77%
−344 to −314 MB
DOM nodes 211,825 2,967 −208,858 −208,858
Total CPU use 120% 131% +8% −0.1% to +17%
CPU time per run 20,603,804 µs 620,794 µs −97.0%
−20,000,000 µs (warned)
−97.3% to −96.7%
−21,100,000 to −18,900,000 µs
Rerun · command and recordings
strobe bench packages/app/perf/timeline.bench.ts \
  --base origin/dev \
  --head . \
  --filter "open a group of scripts"
  • Full report: strobe report experiment exp_6b22e5 --open
  • Kept launches: rec_bd6791 (origin/dev@562e55a048, pair 1), rec_061544 (a946e84 (dirty), pair 1)

strobe · exp_6b22e5 · end of generated report

@Hona
Hona force-pushed the used-group-expand branch from 18c7671 to 0bbf940 Compare November 23, 2026 03:34

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied in 072369d: callFailed now also requires tool: string, so it matches exactly the calls the rows decode.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 from visible.
  • executeToolFailed (line 54): a malformed entry no longer marks the script as failed.
  • executeToolSubtitle (line 107): this also uses callFailed, 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.

@Hona
Hona merged commit d84e1d7 into dev Nov 23, 2026
10 checks passed
@Hona
Hona deleted the used-group-expand branch November 23, 2026 03:44
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant