Skip to content

TUI: establish release-grade cross-platform QA and defect remediation #459

Backlog

Description

@gaobrian

Goal

Establish a release-grade quality baseline for the complete BSH TUI, not just the reported macOS two-finger scroll defect. The TUI must remain a thin client of the standalone Runtime Host and must not change GUI behavior or the Multi-Interface architecture.

"Bug-free" cannot be proven absolutely. The engineering target is zero known P0/P1 defects, deterministic regression coverage for every confirmed defect, and passing platform + PTY + manual acceptance gates.

Current baseline

  • TUI implementation: crates/bsh/src/tui/{app,board,editor,export,menu,mod,nav,picker,prefs,shell,skin,term}.rs.
  • The largest concentration of state transitions is app.rs (~21k lines); event acquisition/terminal lifecycle is in term.rs; event loop and rendering dispatch are in mod.rs.
  • Existing unit coverage is substantial in app/board/editor/menu/nav/picker/prefs/shell/skin/export, but mod.rs has only a wheel-direction mapping test and term.rs tests do not currently prove fragmented terminal input at the BSH integration boundary.
  • PR fix(tui): preserve fragmented terminal mouse reports #457 fixed the fragmented Unix SGR input read issue by pinning a Crossterm revision and was merged. Its Ubuntu PTY gate failed before compiling BSH because Zig was missing from .github/workflows/tui-release-gate.yml.
  • PR ci(tui): install Zig in PTY release gate #458 adds Zig 0.16.0 setup to that gate; CI must confirm the correction.

Audit workstreams and acceptance

P0 — Input protocol and terminal lifecycle

  • SGR mouse reports fragmented at every byte boundary must never become composer text or Escape key events.
  • Test rapid vertical trackpad scroll, direction reversal, top/bottom boundary reversal, horizontal wheel reports, resize interleaving, and scroll during live streaming.
  • Verify mouse capture, SGR mode, bracketed paste, raw mode, alternate screen, cursor visibility and stderr redirection are restored on normal exit, setup failure, editor handover failure and panic.
  • Verify standalone Escape remains responsive and is not confused with a partial CSI/SS3/OSC/DCS sequence.
  • Verify keyboard press/repeat/release behavior on macOS, Linux and Windows; Ctrl/Alt/Shift combinations; Unicode; paste; focus/resize events.

P0 — Event loop and responsiveness

  • No blocking Host/store/network operation on the UI thread.
  • Bound event draining and rendering work; event floods must not starve paint or input.
  • Test queued direction reversals, resize floods, input bursts, disconnected event channels and slow Host responses.
  • Instrument event-read → dispatch → state update → frame draw latency; define p50/p95/p99 budgets.

P1 — Transcript and history

  • Scroll offset remains valid after streaming updates, commits, compaction, resize, width reflow, session switching and older-page loading.
  • History page merge preserves message/tool-call relationships and reader viewport anchoring.
  • Test concurrent refresh + older-page fetch + session switch; stale replies must never land in the wrong session.
  • Test the 512-message held-window limit and repeated attempts at the oldest page.

P1 — Composer, menu and navigation

  • Cursor and selection correctness for UTF-8 grapheme clusters, combining marks, emoji/ZWJ sequences and wide characters.
  • Multiline editing, word movement, home/end, delete/backspace, history recall, paste and editor round-trip.
  • Slash/mention completion, popup clipping, pointer/keyboard parity, stale candidate handling and command argument parsing.
  • Keymap conflicts and remapping precedence must be deterministic and visible.

P1 — Shell pane and PTY

  • Reader thread termination, child reaping, writer errors, shell exit, resize races and close semantics.
  • Verify shell input encoding and paste behavior across Unix PTY and Windows ConPTY.
  • Ensure closing TUI or switching sessions does not leave orphan shells or reader threads.

P1 — Rendering and layout

  • Narrow/tall terminal sizes, repeated resize, no out-of-bounds cursor, clipping or panic.
  • Markdown, long tool output, control characters, ANSI-like/untrusted content, Unicode width and no-color terminals.
  • Mouse hit targets must correspond to the exact frame painted; stale hit maps must not trigger actions after resize/state change.

P2 — Export, preferences and recovery

  • Export path resolution, atomic replacement, permissions and failure reporting.
  • Preference corruption, partial writes, draft persistence and session-key isolation.
  • Host restart/disconnect, subscription replay, slow consumer recovery and uncertain send idempotency.

Cross-platform CI

  • macOS PTY + TUI tests.
  • Linux PTY + TUI tests.
  • Windows compile + TUI tests.
  • cargo fmt --check, cargo clippy -p bsh --all-targets -- -D warnings, relevant unit tests, and deterministic PTY integration tests.
  • CI must install all native build prerequisites (including Zig for Ghostty) and must run when Cargo.toml/Cargo.lock or terminal dependencies change.

Execution rules

  • Every finding must include severity, reproduction, root cause evidence, affected platforms, fix, regression test and validation result.
  • Do not refactor unrelated code while fixing defects.
  • Do not merge a fix solely because it compiles; require the relevant regression test and platform gate.
  • Keep GUI and Runtime Host contracts unchanged unless a separate ADR explicitly approves a change.
  • Manual macOS Ghostty two-finger trackpad acceptance is required; CI cannot fully emulate physical gesture timing.

Initial concrete follow-ups

  1. Finish CI verification for merged PR fix(tui): preserve fragmented terminal mouse reports #457 and PR ci(tui): install Zig in PTY release gate #458.
  2. Add deterministic BSH-level terminal input regression tests around fragmented SGR mouse reports.
  3. Add event-loop tests for bounded draining, direction reversals and boundary clamping.
  4. Add lifecycle tests for terminal mode restoration and editor handover.
  5. Audit asynchronous load cancellation/stale response handling and PTY child/reader lifecycle.
  6. Produce a reviewed defect register with P0/P1/P2 classification before broad refactoring.

Activity

  1. gaobrian commented on Dec 1, 2026

    @gaobrian
    ContributorAuthor

    Correction to my earlier 20 ms timeout assessment

    I re-checked the upstream reproduction and the merged dependency update more carefully. My earlier statement that the 20 ms deadline necessarily lets a queued continuation leak into Composer was too strong and is not supported by the reader behavior.

    The relevant distinction is that the Unix readers use the parser's pending-Escape deadline while also checking for readable input; an available continuation is preferred over expiring the pending Escape. The deterministic regression in openai/codex#60814 covers a continuation queued after the deadline, plus every split position and standalone Escape. The candidate reader change is the use of buffer_external_input() in both Unix backends.

    BSH's current pinned revision 37ca4a27a9424ec5dbe6451f48c339d7b45f8d63 is the revision selected by merged openai/codex#62139, which advances from the older affected revision ed1cdab.... So we should not treat the 20 ms timeout itself as a confirmed remaining defect, nor add a decoded-character quarantine based on that assumption.

    What remains unproven is the BSH integration/manual Ghostty trackpad path. The correct next step is to bring the deterministic fragmented-input regression into the exact dependency/backend configuration BSH builds, then reproduce at the BSH PTY/terminal boundary.

  2. gaobrian commented on Dec 1, 2026

    @gaobrian
    ContributorAuthor

    Follow-up: verify the patched Crossterm path at the BSH integration boundary

    I re-checked the current main dependency state:

    • Cargo.toml patches crates.io Crossterm to openai-oss-forks/crossterm revision 37ca4a27a9424ec5dbe6451f48c339d7b45f8d63.
    • This is the same revision selected by the merged Codex PR openai/codex#62139, whose stated purpose is to prevent split Unix SGR mouse reports from becoming composer keystrokes.
    • term.rs::Terminal::next_key still returns a decoded KeyCode::Esc immediately and has no BSH-level assertion/test that a fragmented SGR report cannot surface as subsequent KeyCode::Char events.

    This changes the next investigation: simply advancing the Crossterm pin again is not evidence-based. We need a deterministic BSH integration regression that drives fragmented SGR bytes through the exact event source used by Terminal::next_key (both Unix backends where feasible), and asserts:

    1. one wheel report yields one wheel event;
    2. no Escape or printable tail reaches the composer;
    3. standalone Escape still works;
    4. split positions and delayed continuations are covered;
    5. the test exercises the same dependency feature/backend combination as the shipped BSH binary.

    The existing PR #458 release-gate run 46572027560 is still building on macOS, Linux and Windows at the time of this note; it has not yet passed. This follow-up is intentionally a test-first investigation, not a claim that the reported trackpad issue is fixed.

  3. gaobrian commented on Dec 1, 2026

    @gaobrian
    ContributorAuthor

    CI result and Linux gate follow-up

    The completed TUI release-gate run 46572027560 reports:

    • macOS PTY gate: passed (build and attach/render/exit/Host-survival steps passed).
    • Windows compile and TUI tests: passed.
    • Linux PTY gate: failed during final linking, before the PTY lifecycle step. The linker could not find -lc++ and -lxkbcommon-x11.

    I opened PR #460 to install the missing Ubuntu development packages (libc++-dev and libxkbcommon-x11-dev) in the TUI release-gate workflow. This is a CI environment correction, not a runtime scroll fix.

    The macOS CI gate passing is useful, but it does not emulate physical two-finger trackpad timing in Ghostty. Manual acceptance and a deterministic dependency-level regression remain required before closing the original report.

  4. gaobrian commented on Dec 1, 2026

    @gaobrian
    ContributorAuthor

    BSH PTY regression added — PR #461

    I have added an integration test to the existing Unix PTY release gate:

    • injects wheel-up and wheel-down SGR reports split at every byte boundary;
    • sends a queued 128-event alternating-direction burst to cross the per-frame drain budget;
    • strips terminal CSI output and checks that printable report tails never appear in the terminal output;
    • sends a standalone Escape, then verifies the existing Ctrl-D exit and Host-survival lifecycle.

    This exercises the real BSH process and Crossterm reader, not a mocked key queue. It is intentionally test-first: no runtime filtering or speculative Crossterm changes were added.

    PR: #461

    CI is running. Passing this gate will validate the PTY integration path, but physical two-finger trackpad acceptance in Ghostty remains a separate manual check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions