Skip to content

fix(desktop): wheel-scroll codex transcripts via terminal scrollback#2499

Open
aprv10 wants to merge 3 commits into
AgentWrapper:mainfrom
aprv10:fix/codex-wheel-scroll
Open

fix(desktop): wheel-scroll codex transcripts via terminal scrollback#2499
aprv10 wants to merge 3 commits into
AgentWrapper:mainfrom
aprv10:fix/codex-wheel-scroll

Conversation

@aprv10

@aprv10 aprv10 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Resolves #2493

What

Mouse wheel (and PageUp/PageDown) did nothing when scrolling a codex pane on Windows. This makes the wheel scroll codex's transcript, the same way it already works in a raw terminal — without regressing the opencode scroll fix.

Root cause

The terminal was built on the assumption that every pane is a full-screen alt-buffer app under tmux (macOS/Linux): it set scrollback: 0 and synthesized SGR mouse reports so tmux copy-mode does the scrolling. The recent opencode fix layered on a blanket isWindowsPlatform() rule that force-fed PageUp/PageDown to every Windows pane.

Codex breaks all of those assumptions. Probing term.buffer/term.modes while wheel-scrolling a live codex session showed:

  • buf=normal — codex is a normal-buffer app, not alt-screen
  • mode=none — it does not track the mouse (SGR reports are ignored)
  • it ignores PageUp/PageDown (confirmed by hand)
  • len == rows, baseY ≈ 0 even after a long chat

Codex just prints its transcript and relies on the terminal's own scrollback (exactly what you see in raw PowerShell). But scrollback: 0 discarded every line that scrolled off, so there was nothing to scroll.

Fix

  • scrollback: 0 → 5000 so normal-buffer panes retain history. Alt-buffer panes (tmux, mouse-tracking TUIs) never feed this buffer, so they're unaffected.
  • Wheel handler now branches on buffer + mouse-tracking, in order: (1) paneScrollsByKeyboard → PageUp/PageDown (opencode — unchanged, kept first); (2) mouse-off + normal bufferterm.scrollLines() native scroll (codex, new); (3) mouse tracking on → SGR reports (tmux/zellij copy-mode); (4) alt-buffer fallback → page keys.
  • Removed the blanket isWindowsPlatform() branch; opencode is already covered by rule 1 on every platform.
  • Hid the .xterm-viewport scrollbar so the new scrollback doesn't reserve width and shift the grid; dropped the now-dead scrollbar-thumb CSS.

Testing

  • Manually verified on Windows: codex now wheel-scrolls its transcript; opencode scroll unchanged.
  • Updated XtermTerminal.test.tsx — added codex native-scroll and alt-buffer fallback cases; 31/31 pass, tsc --noEmit clean.

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new wheel-routing branch means Windows mouse-tracking panes now receive SGR wheel reports unless paneScrollsByKeyboard is true. TerminalPane only sets that hint for opencode, but kilocode is also a supported provider and the backend documents it as an OpenCode fork that shares the same TUI surface. This likely regresses Kilo Code wheel scrolling on Windows compared with the previous PageUp/PageDown fallback. Please add kilocode to KEYBOARD_SCROLL_PROVIDERS and cover that provider wiring.

@aprv10

aprv10 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Added kilocode to KEYBOARD_SCROLL_PROVIDERS, and extracted the mapping into providerScrollsByKeyboard() with a test covering both opencode and kilocode so the wiring can't silently regress again. Thanks!

@aprv10 aprv10 requested a review from illegalcall July 8, 2026 20:42
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.

Terminal cannot be scrolled when using Codex as agent in AO

2 participants