fix(cli): restore mouse wheel scrolling for TUI#2341
Conversation
Default historyScrollMode from 'native' to 'app' so CardStream captures wheel events in alt-screen terminals where native scrollback cannot scroll TUI content. - Apple Terminal and classic Windows console (conhost) stay on 'native' to avoid renderer crashes / missing wheel forwarding. - --no-mouse / mouseTracking:false now force 'native' as a hard override before the resolver runs. - Decode modified SGR wheel button codes (68/69/80 etc.) that some terminals (Windows Terminal previews) send with modifier bits set — the old exact-match on 64/65 silently dropped them. Fixes esengine#2260 (scroll wheel portion)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 315d9a46f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Default to app-managed scroll for all other terminals so the mouse | ||
| // wheel feeds into CardStream's scroll logic. Native scrollback | ||
| // cannot scroll TUI alt-screen content on most terminals. | ||
| return "app"; |
There was a problem hiding this comment.
Update stale auto-mode test expectation
Changing the auto-mode fall-through to "app" leaves tests/chat-scroll-wheel.test.ts:97-104 asserting that an unknown xterm/linux environment still resolves to "native"; any CI path that runs npm test/npm run verify will fail on that assertion even though this is now the intended default. Please update the test to match the new default or keep the old behavior for that environment.
Useful? React with 👍 / 👎.
The auto-mode fall-through now returns 'app' instead of 'native', so the test for unknown terminals must expect 'app'. Added two new test cases: - Apple Terminal stays on 'native' (renderer crash avoidance) - Classic Windows console (no TERM_PROGRAM) stays on 'native'
|
@chatgpt-codex-connector good catch — pushed
|
|
To use Codex here, create an environment for this repo. |
Summary
Fixes the scroll wheel portion of #2260 — mouse wheel not working in the CLI TUI after model finishes answering.
Root cause
src/cli/ui/history-scroll-mode.tsdefaulted to"native"for most terminals whenhistoryScrollModewas"auto". In"native"mode,mouse-mode.tssendsRESET_ALL(disabling all mouse tracking), relying on the terminal native scrollback. But in the TUI alt-screen buffer, there is nothing "above" the screen for native scrollback to scroll — wheel events produce no movement.Changes
1.
src/cli/ui/history-scroll-mode.ts— default to app-managed scroll"native"to"app"so CardStream captures wheel events"native"— it does not forward wheel events to the alt-screen2.
src/cli/commands/chat.tsx— honor opt-out flags--no-mouseandmouseTracking: falsenow force"native"as a hard override before the resolver runs3.
src/cli/ui/stdin-reader.ts— decode modified SGR wheel codesbtn === 64/btn === 65to bit maskingbtn & 64withbtn & 1for directionVerification
npm run typechecknpm run lint