Skip to content

feat(tui): responsive layout tiers, panes, and a placed measure (L1) - #87

Merged
lg2m merged 2 commits into
feat/eng-844-u0-tui-goldensfrom
feat/eng-845-l1-tui-layout
Sep 21, 2026
Merged

lg2m merged 2 commits into
feat/eng-844-u0-tui-goldensfrom
feat/eng-845-l1-tui-layout

Conversation

@lg2m

@lg2m lg2m commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

L1: responsive layout tiers, panes, and a placed measure

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

Stacked on #86 (U0). Review the second commit only until U0 merges.

What changed

  • view/layout.rs (new): Tier::of(width) at 90 / 160 / 240 (Compact, Regular, Wide, Ultra); LayoutPrefs { rail, inspector } with PanePref::{Auto, Shown, Hidden} replaces app::Sidebar; compute_layout(width, height, chrome_rows, prefs, sessions) is a pure function returning Rects for the top row, body, transcript pane(s), inspector, and rail, plus strip and max_composer_rows. Ten unit tests at every breakpoint and bound.
  • view.rs::frame composes from the layout: pickers and the transcript take the pane width; side panes are blitted column-wise; rows pad to the terminal width so borders line up.
  • Render clamp 320×160 → 1024×512. A full-screen terminal on a large display is painted edge to edge; before, the right 160 columns of a 480-column terminal were blank.
  • Measure 120 → 100, placed one third across a wider pane's spare width. Line::indent carries the margin as a count so the width-keyed caches are untouched; write_line emits one MoveRight per row instead of spaces.
  • Inspector geometry is reserved (40–80 cols, carved only past the measure). Its Auto state resolves to hidden until slice L3 paints tool detail in it; PanePref::Shown opens it at any width today.
  • MAX_LIVE_MARKDOWN_ROWS fixed at 160 (was derived from the render height, so a tall terminal would have raised per-frame streaming work).
  • 21 of 35 goldens move (every size ≥ 90 columns); before/after visible in this diff. U0's pin that a 480-column terminal received a 320-wide frame is replaced by frames_fill_every_golden_size and prose_is_placed_at_the_measure_on_wide_terminals.
  • New docs/design/layout.md; one-sentence pointer in architecture.md; docs/README.md index entry.

How verified

  • cargo test --workspace green (qq-tui 255 lib + 5 goldens)
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test -p qq-tui --test gallery -- --ignored → inspected markdown-gallery-320x90.ans: 87 CSI 64 C moves, one per body row, content at the expected column.

Measurements

cargo bench -p qq-tui --bench render; raw under target/qq-perf/tui-L1-2026-09-20/final-{1,2}.txt vs the U0 baseline.

Gate Before (U0) After L1 (two runs) Budget
steady_state_frame median 24.2 µs 22.2 / 22.3 µs ±5 %
golden_path_first_minute median 37.2 µs 38.0 / 38.5 µs ±5 %
keystroke_to_frame median 28.2 µs 27.5 / 27.7 µs ±5 %
resize_horizontal median 35.2 µs 33.2 / 33.5 µs ±5 %
tool_calls_32_rows median 24.4 µs 22.8 / 22.8 µs ±5 %
streaming_run_on_32kb median 414.5 µs 442.0 / 450.8 µs ±5 % (U0 A/A spanned 414–445)
compact_80x24 (new) — 19.9 µs baseline
wide_160x48_full, inspector shown (new) — 35.1 µs baseline
resize_ultra_480x120 full repaint (new) — 123.8 µs baseline

Design note: the first implementation inserted a leading Span per row for the margin and cost +14 % on steady_state_frame (28.0 µs); the count form on Line brought it below baseline. An always-on empty inspector column cost ~3 µs of diff per frame for nothing, which is why Auto stays hidden until L3.

Docs

  • docs/design/layout.md (new), docs/design/architecture.md, docs/README.md, docs/plans/tui-redesign.md (D5 amended), docs/plans/progress/tui-redesign.md, docs/plans/progress/root.md

Compatibility

  • PROTOCOL / DESCRIPTOR / schema: unchanged. Ctrl-\ still toggles the rail; from Auto the first press hides.

Follow-ups / decisions needed

  • L2 (per-pane transcript state) next; U9 / L3 / L4 depend on it.
  • Deviation from plan: measure placed one third across rather than centered; rationale in layout.md, decision D5 amended.

Slice L1 of docs/plans/tui-redesign.md (ENG-845), stacked on U0.

The terminal's width now selects a layout tier (Compact < 90, Regular < 160,
Wide < 240, Ultra) and the tier selects the panes: one column with an agent
strip; a sessions rail beside the transcript; an inspector column reserved
for tool detail. view/layout.rs computes every pane's Rect once per frame as
a pure function of size, preferences, and session count; view.rs composes
from it. LayoutPrefs { rail, inspector } replaces app::Sidebar.

The render clamp rises from 320x160 to 1024x512, so a full-screen terminal
on a large display is painted edge to edge instead of leaving the right 160
columns blank. The transcript measure drops from 120 to 100 and is placed a
third of the way across a wider pane; Line::indent carries that margin as a
count so the width-keyed caches are untouched and the renderer emits one
cursor move per row. The inspector's Auto state stays hidden until slice L3
paints it.

21 of 35 goldens move (every size >= 90 columns) with the before/after in
this diff. Render bench: steady_state_frame 24.2 -> 22.2 us, golden_path
37.2 -> 38.0 us, resize_horizontal 35.2 -> 33.2 us; new scenes
compact_80x24 19.9 us, resize_ultra_480x120 123.8 us. New design doc
docs/design/layout.md.
@lg2m
lg2m force-pushed the feat/eng-845-l1-tui-layout branch from 5f1043c to 6f9dcd8 Compare September 21, 2026 00:15
@lg2m
lg2m merged commit 7585711 into main Sep 21, 2026
8 checks passed
@lg2m
lg2m deleted the feat/eng-845-l1-tui-layout branch September 21, 2026 00: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