Skip to content

TUI: alternate-screen mouse capture blocks client-side text selection in browser terminals and mobile #44

Closed

Description

@thedancingdeveloper

Problem

The fullscreen transcript enables SGR mouse tracking whenever it owns the alternate screen:

  • codex-rs/tui/src/tui/alternate_screen.rs:57 emits ESC[?1000h ESC[?1002h ESC[?1003h
  • :115 emits ESC[?1006h
  • gated by capture_mouse, set from OverlayInput::captures_mouse in codex-rs/tui/src/tui.rs:650

In a terminal emulator that is not the local console, that capture takes the selection away from the front end. xterm.js only forces a local selection on a mouse drag when Shift or Alt is held (shouldForceSelection); a plain drag is sent to the PTY as a mouse report instead. The visible result in Vogt (#/t/<session>, web and Capacitor mobile app) is that click-drag select, the Copy shortcut, the Copy chip and right-click copy all see an empty selection.

A phone has no Shift escape hatch, and xterm.js does not synthesise a selection for touch. A long-press therefore sends nothing at all: no local selection and no useful mouse report. This reproduces deterministically in a PTY probe of codex-cli 0.167.0+fork.02fc9bcab; the ~80% intermittent failure operators see also has a focus/keyboard component, but mouse capture is sufficient on its own.

Related to #43 (scrollback in multi-viewer terminals), but this is a separate defect: even with working scrollback, a PTY front end cannot select or copy text while the program holds mouse tracking.

Requested direction

One of:

  1. A first-class knob for terminals whose selection belongs to the front end, e.g. tui.mouse_capture = "never" / tui.shared_terminal = true, which keeps mouse reporting off while retaining the fullscreen transcript.
  2. Document tui.alternate_screen = "never" / --no-alt-screen as the supported mode for browser, multiplexer and multi-viewer front ends, alongside a clear statement that the fullscreen transcript captures the pointer.

A per-session/per-viewer policy would be better than a global one where practical, since a native terminal and a browser viewer can be attached to the same PTY at the same time.

Acceptance criteria

  • A browser/multiplexer front end can select and copy transcript text without requiring Shift/Alt or a program-specific workaround.
  • A touch front end has a supported path to select text (either the program leaves selection to the front end, or it documents that it does not).
  • The chosen mode is documented for shared/multi-viewer PTYs.

Workaround in use downstream

Vogt launches the fork with -c tui.alternate_screen="never" (TheDancingDeveloper-org/vogt, engine/server/src/agent_cli.rs, WI-4392) and adds a mobile long-press fallback. That fixes the product but gives up the alternate-screen UX, so it is a mitigation rather than the durable answer.

Activity

  1. thedancingdeveloper commented on Nov 19, 2026

    @thedancingdeveloper
    Author

    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); new tui.mouse_capture = false config (also -c tui.mouse_capture=false or env CODEX_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.

  2. thedancingdeveloper commented on Nov 19, 2026

    @thedancingdeveloper
    Author

    Review follow-up on fix/wi-tui-43-44 (4beebbd7be, unchanged): (1) with transcript_view/input.rs reverted to origin/fork/main, wheel_scrolls_transcript_when_pointer_is_outside_its_area FAILS (assertion failed: !view.is_following()) and passes with the fix. config_and_env_resolve_mouse_capture tests 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.

  3. thedancingdeveloper commented on Nov 21, 2026

    @thedancingdeveloper
    Author

    Fixed by PR #47 (codex batch), shipped in release fork-6ef285b4 and pinned in vogt (live on vogt-dev).

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