Skip to content

refactor(tui): per-pane transcript state behind one visible pane (L2) - #94

Merged
lg2m merged 1 commit into
mainfrom
feat/eng-846-l2-pane-state
Sep 21, 2026
Merged

lg2m merged 1 commit into
mainfrom
feat/eng-846-l2-pane-state

Conversation

@lg2m

@lg2m lg2m commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

L2: per-pane transcript state behind one visible pane

Spec: docs/plans/tui-redesign.md#responsive-model Linear: ENG-846 (parent ENG-843)

Follows #87 (L1, merged). Structural slice: no user-visible change, goldens unchanged. It gives each transcript pane its own scroll and live-row state so L4 can show two or three sessions side by side, each independently scrollable.

What changed

  • viewport.rs: TranscriptPane { view, viewport, live_message_ranges }, MAX_PANES = 3.
  • app.rs: panes: Vec<TranscriptPane> + focused_pane replace the single view/viewport; accessors view(), set_view(), viewport(), pane(). Every scroll path (wheel, PageUp/Down, Shift-arrows, Ctrl-Home/End) goes through the focused pane; set_focus / Refocus / ResetSnapshot route through set_view. panes.len() == 1 in this slice.
  • view/transcript.rs: TranscriptCache holds only state shared across panes (completed layouts keyed by width, tool rows, settled-prefix layouts). body(pane, …) returns a PaneUpdate; retain_visible(app, shown) prunes once per frame across all shown sessions; eviction bound raised to MAX_VISIBLE_MESSAGES × MAX_PANES so a second pane cannot thrash the first.
  • view.rs: frame zips layout slots with the pane window around focus, collects pane_updates, commit writes them back. Overlays render into the focused slot only.
  • view/layout.rs: the geometry struct is renamed TranscriptSlot to leave TranscriptPane for state.
  • docs/design/layout.md: "Panes and state" section.

How verified

  • cargo test --workspace green (qq-tui 258 lib + 5 goldens; goldens byte-identical)
  • fmt / clippy -D warnings / cargo check --workspace --all-targets
  • New tests: panes_on_different_sessions_scroll_independently, a_non_zero_pane_keeps_its_tail_anchor_when_its_live_message_settles, a_pane_following_a_deleted_session_shows_the_empty_prompt

Measurements

target/qq-perf/tui-L2-2026-09-20/{baseline,after-3}.txt, same session:

Gate Before After Budget
steady_state_frame 23.5 µs 22.0 µs ±5 %
streaming_focused 37.8 36.5 ±5 %
streaming_run_on_32kb 472.6 428.0 ±5 %
golden_path 40.0 38.5 ±5 %
keystroke 29.2 26.9 ±5 %
wheel_scroll 34.2 32.6 ±5 %
resize_horizontal 34.7 32.9 ±5 %
tool_calls_32_folded 13.6 13.1 ±5 %

Design notes / deviations

  • No preserve_tail_anchor field on the pane: derived each frame from the pane's stored ranges and viewport, so it cannot go stale.
  • tool_rows pruning is a scan over the shown sessions' calls rather than a per-frame HashSet (the set cost +1 µs on tool_calls_32_folded).
  • Two panes on one session at different content widths would fight over the message-keyed caches; the layout gives every slot the same content width, and the invariant is documented on TranscriptCache for L4.

Docs

  • docs/design/layout.md, docs/plans/progress/tui-redesign.md. Root request: architecture.md's qq-tui bullet still says one cache "for the shown session".

Compatibility

  • PROTOCOL / DESCRIPTOR / schema: unchanged.

Slice L2 of docs/plans/tui-redesign.md (ENG-846). Structural only: the
layout still produces one transcript slot, so frames and goldens do not
move.

- viewport::TranscriptPane owns a pane's View, Viewport, and live-row
  anchors; MAX_PANES = 3. App.panes + focused_pane replace App.view and
  App.viewport, reached through view()/set_view()/viewport()/pane().
- TranscriptCache keeps only what panes share (completed layouts, tool
  rows, live settled prefixes). body() takes the pane and returns a
  PaneUpdate; retain_visible prunes once per frame across every shown
  session; the layout bound is MAX_VISIBLE_MESSAGES * MAX_PANES so panes
  never evict each other.
- FrameRenderer::frame zips the layout's slots with the pane window
  around the focus and commit writes every reconciled pane back;
  overlays paint into the focused slot. A pane following a deleted
  session renders the empty prompt.
- The layout geometry struct is renamed TranscriptSlot.
- docs/design/layout.md gains "Panes and state"; the ledger records the
  receipt and a root request for architecture.md.

Tests: three new pane tests; 258 lib + 5 golden green. Bench within
noise of L1 (steady_state_frame 22.0 us, resize_horizontal 32.9 us).
@lg2m

lg2m commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

Linear: ENG-846. Stacked PR #95 (U1) targets this branch; retarget to main after merge.

@lg2m
lg2m added this pull request to stack #96 September 21, 2026 03:55
@lg2m
lg2m merged commit e511ce4 into main Sep 21, 2026
4 checks passed
@lg2m
lg2m deleted the feat/eng-846-l2-pane-state branch September 21, 2026 03:57
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