Repository navigation
Description
Problem
When Codex runs in the default alternate-screen TUI, a terminal that is not a
local terminal emulator cannot give the reader reliable scrollback. This shows
up consistently under Vogt (web + Capacitor mobile app), where one PTY is shared
by several viewers, but it is not Vogt-specific: any browser terminal,
multiplexer or remote-console front end hits the same three things.
1. Wheel scrolling only works when the pointer is inside the transcript rect
TranscriptView::handle_mouse_with_mode drops the event when the pointer is
outside the transcript's area:
// codex-rs/tui/src/transcript_view/input.rs:248-257
let inside = self
.area
.contains(ScreenPosition::new(event.column, event.row));
let dragging = self
.selection
.as_ref()
.is_some_and(|selection| selection.dragging);
if !inside && !dragging {
return None;
}A front end that translates a touch/trackpad gesture into a wheel report has to
invent coordinates. Vogt dispatches the wheel at the touch point
(web/src/Terminal.tsx:831-841). A swipe that starts over the composer/footer,
or after a soft keyboard has shifted the layout, lands outside the rect and the
scroll is silently dropped. That matches the observed ~80% failure rate: the
same gesture works when it happens to start over the transcript.
Suggested: for ScrollUp/ScrollDown, scroll the transcript regardless of
whether the pointer is inside it (or at least accept a wheel that started in the
terminal's screen area). Rejecting wheel input outside a rect is the right rule
for selection, not for scrolling.
Related: a wheel whose accumulated delta rounds to zero rows is dropped
(input.rs:282-286), and scroll() returns early when the position does not
move while following (transcript_view.rs:421-427). That leaves the view in the
"following" state, so the next repaint re-pins it to the tail. A partially
delivered gesture should not leave the reader following.
2. "Following" is re-asserted by streaming output
is_following() is position == Latest (transcript_view.rs:380-382). While a
turn streams, the transcript mutates continuously; if a scroll did not change
the position (dropped/zero-row wheel above), the view stays at Latest and the
next mutation repaints at the bottom. Interrupting the turn (Esc) stops the
mutations, which is why "press Esc and then scroll" sometimes works.
3. One alternate-screen viewport, no scrollback, no per-viewer position
The alternate buffer has no scrollback by design. Codex's transcript lives in
one in-process viewport, so every attached viewer that scrolls sends input into
the same viewport. With multiple devices on one PTY (desktop + phone) the last
device to act moves it for everyone, and a repaint moves it back. No client can
hold its own position, because no per-client copy of the output exists.
Inline mode (tui.alternate_screen = "never" / --no-alt-screen) writes the
transcript to the normal buffer. Verified in a real PTY capture:
- default: alternate screen on,
state_formattedhas?1003h/?1006hbut no
?1049h,scrollback = 0 --no-alt-screen: no?1049h, no mouse-tracking sequences at all, so the
terminal emulator owns the wheel and each viewer scrolls its own buffer
Why this matters for Vogt
Vogt attaches several clients to one PTY and already translates swipes into
wheel reports in the alternate buffer (web/src/terminalTouch.ts:99,
web/src/Terminal.tsx:826-841). That path works when the event survives the
gate above, but it can only move the shared TUI viewport. Vogt's snapshot
replay also cannot restore ?1049h (vt100::state_formatted omits the
alternate-screen mode), so a reloaded client and the process disagree about
which buffer is active.
Vogt can mitigate by launching Codex inline, but that is a workaround that gives
up the alternate-screen UX. The durable fixes belong here:
- Accept wheel scrolling regardless of pointer position inside the screen.
- Do not leave
position == Latestafter a scroll that was partially applied. - Offer a first-class "shared / remote viewer" or inline output mode that is
safe for multi-viewer terminals (basically what--no-alt-screendoes), and
document it as the supported mode for multiplexed/web terminals.
Repro
- Run Codex in a PTY with mouse tracking on, in alternate mode.
- Send an SGR wheel-up (
ESC[<64;20;10M) with row/column inside the transcript
→ the transcript scrolls. - Send the same wheel with coordinates over the footer/composer rows → no
movement, and the next streamed token repaints at the bottom. - Repeat during a streaming turn: the view returns to the tail after each
mutation unless a scroll actually movedposition.
Acceptance criteria
- A wheel event delivered anywhere over the terminal screen scrolls the
transcript (selection still respects the rect). - A scroll gesture that ends at a non-Latest position stays there while output
streams; new output shows the "new activity" affordance instead of moving the
viewport. - A documented mode exists for terminals with no local scrollback or with
multiple viewers, and it produces ordinary append-only output.
Activity
thedancingdeveloper commentedon Nov 19, 2026
Fix pushed to branch
fix/wi-tui-43-44(4beebbd7be, based on fork/main), no PR opened. Wheel up/down now scrolls the transcript anywhere on screen (selection still respects the rect); newtui.mouse_capture = falseconfig (also-c tui.mouse_capture=falseor envCODEX_TUI_MOUSE_CAPTURE=0) turns off mouse reporting in the alt screen so front ends keep text selection. Documented in FORK.md. Not changed: a fractional-speed wheel that rounds to zero rows still leaves the view following (an existing test asserts that). Tests: new wheel-outside-rect and policy tests; clippy clean; nextest shows only unrelated version/status snapshot and analytics stack-overflow failures.thedancingdeveloper commentedon Nov 19, 2026
Review follow-up on
fix/wi-tui-43-44(4beebbd7be, unchanged): (1) withtranscript_view/input.rsreverted to origin/fork/main,wheel_scrolls_transcript_when_pointer_is_outside_its_areaFAILS (assertion failed: !view.is_following()) and passes with the fix.config_and_env_resolve_mouse_capturetests a function the fix adds, so without the fix it does not compile rather than fails. (2) On origin/fork/main with RUST_MIN_STACK=16MiB: 6508 tests, 39 failed; with the fix: 6510 tests (the 2 new), 39 failed. Same count, so the 39 failures (version/status snapshots, others) are pre-existing, not caused by this change.thedancingdeveloper commentedon Nov 21, 2026
Fixed by PR #47 (codex batch), shipped in release fork-6ef285b4 and pinned in vogt (live on vogt-dev).