Skip to content

Skip hidden command output and unify timeline expansion context - #3880

Open
ymichael wants to merge 3 commits into
mainfrom
bb/timeline-structural-selection
Open

ymichael wants to merge 3 commits into
mainfrom
bb/timeline-structural-selection

Conversation

@ymichael

@ymichael ymichael commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Collapsed timelines read and decode command-output bodies and parse shell commands even when the commands are hidden inside a summary. Summary expansion also used a separate partial-context path, so some valid summaries failed expansion or included rows from adjacent groups. Simply sharing the page loader made small expansions reconstruct unrelated work and introduced large regressions.

What changed

Omit hidden command-output bodies when building inactive collapsed pages, hydrate visible calls by event primary key before byte pagination, and parse command intents only for rendered command rows. Active, flat, nested, and unlimited-output requests retain full payload loading.

Use one context loader and row planner for pages and expansion. Expansion discovers item IDs belonging to the requested turn or parented children in the interval, follows their histories across turns, and retains assistant boundaries and shared control state. Other overlapping turns no longer pull in unrelated item histories. Preserve late completions, including child completions missing their parent-call field, and the endpoint's existing row-range expansion behavior.

Exclude already-loaded events from subsequent turn/child queries. Return primitive stored-event columns directly from SQLite to avoid a second row-mapping pass. Expansion skips unused whole-thread page-ordering work, resolves only referenced request IDs, and reuses the existing bounded decode cache. Remove the old partial-turn filtering/backfill path. No migration, public API, or host protocol change.

Rebased onto main after #3874 and #3876. Final before/after measurements compare main 0bb64f3789 with head 63fb6187d4, using the frozen main database and actual server routes.

Request Median before → after p95 before → after
Default cold open 12.09 → 9.23 ms 30.39 → 21.85 ms
Default repeat open 0.38 → 0.35 ms 1.42 → 1.41 ms
Unchanged update 0.29 → 0.28 ms 1.15 → 1.14 ms
Standalone cold expansion 4.25 → 4.45 ms 25.11 → 20.97 ms
Standalone repeat expansion 3.96 → 3.72 ms 24.50 → 17.06 ms
First expansion after default open 11.87 → 9.40 ms 34.53 → 25.50 ms

Default measurements cover all 2,385 threads (three measured rounds after warmup). Expansion covers all 6,183 latest-page summaries and follows every cursor; all candidate expansions succeed, including two that return 500 on main. Open-then-expand covers one top-level summary in each of 2,012 applicable threads. Broad expansion sweeps use one measured round after warmup; focused repeated checks are described below. All default response hashes match, with the same deleted-thread 404 in both versions.

Cold means application caches cleared; SQLite/OS caches are not flushed. Server-route timings include response-body consumption and exclude network/browser rendering. The standalone and open-then-expand populations differ, so their absolute medians are not a cache-effect comparison. Cold expansion is not universally faster: its corpus median increases by 0.19 ms. The old roughly 58 ms regression is eliminated, but some small cold expansions retain overhead.

Repeated 198 previously problematic cases for 15 measured rounds each, alternating version order. No repeated case crosses the preset regression threshold (>10% and >5 ms), but smaller regressions are real: the largest cold increase is 1.39 → 5.70 ms. The original identical-response problem case now measures 6.60 → 9.13 ms cold (previous draft ~58 ms), 5.88 → 6.87 ms repeat, and 6.45 → 7.50 ms after default open. Repeated the 24 cases with >2 ms standalone overhead after default open too; the largest remaining increase is 1.37 → 5.24 ms. These costs remain visible in the normal request path; the PR is an overall improvement with small expansion tradeoffs, not a universal speedup.

How you verified

  • Turbo: 128 server timeline tests, 580 database tests, and server/database typechecks pass. Previously verified unchanged thread-view/client-core portions with 406 and 297 tests respectively.
  • Regression tests cover unrelated overlapping work, late cross-turn completion, child completion without its parent call (both before and after parent completion), hidden output omission, visible hydration before byte pagination, and SQL index selection.
  • Frozen read-only main-database snapshot: 2,385 threads and 2,467,778 events. All 6,183 summaries on latest nested pages expand to the canonical renderer's children, accounting for retained previews expanding into full output. Three byte-clipped nested summaries use exact-ID full pre-change renderer oracles. Zero unexplained differences.
  • Nine archived full page walks: 315 pages, no cursor/route/schema errors, and all matching full nested rendering.
  • Final-source browser verification in an isolated synthetic store: a small group after 100 old commands expands only its own command/output; a 20,013-event thread expands four commands and output through line 4,999; a 140-turn thread pages backward twice, preserves the visible-message anchor, and expands an older summary.
  • Performance uses actual server routes, not renderer-only calls. Default requests retain production query defaults. Expansion benchmarks follow every detail cursor. Server-route timings exclude network/browser rendering; the browser checks above establish interaction correctness, not browser latency.

AGENT GENERATED

Base automatically changed from bb/timeline-head-state-context to main September 17, 2026 22:43
@ymichael
ymichael force-pushed the bb/timeline-structural-selection branch from ea132d8 to 6588971 Compare September 17, 2026 23:25
@ymichael
ymichael marked this pull request as ready for review September 18, 2026 01:25
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