Skip to content

[Bug]: Mouse wheel sends arrow keys to a normal-buffer CLI without mouse reporting, cycling its input history #8563

Open

Description

@lcorncream

Operating system

Windows

Orca version

v1.4.137 (Windows 11, win32 10.0.26200)

Details

Short summary:
Scrolling the mouse wheel over a pane running an inline (non-alt-screen) CLI TUI cycles the app's prompt/input history instead of scrolling the terminal scrollback — wheel-up behaves like repeated Up-arrow presses delivered to the PTY.

What happened?

The hosted app (GJC, a CLI coding agent):

  • never enables mouse reporting (no CSI ?1000h / ?1006h; it even writes ?1000l/?1006l on exit),
  • never enters the alternate screen (no CSI ?1049h) — it renders inline on the normal buffer,
  • only pushes the kitty keyboard protocol (CSI > 7 u).

Per xterm.js MouseService._handlePassiveWheel, wheel-to-arrow synthesis should only fire when !buffer.hasScrollback (i.e. the alt buffer), and Orca's scrollback policy floor is 1,000 rows (default 5,000), so the normal buffer always has scrollback. Orca's own wheel multiplier (pane-terminal-mouse-wheel.ts) is also gated on the enable-mouse-events class, which never applies here. So no code path should be synthesizing arrows for this app, yet arrows arrive: the app maps Up/Down on an empty editor to prompt-history navigation, which matches the observed history cycling exactly.

Possible suspects: the TUI wheel-report changes merged in #7179 (synthetic wheel report replay/burst logic), or the patched-viewport work in #7450.

How can we reproduce it?

  1. Run any inline (non-alt-screen) TUI that maps Up/Down to input history and does not enable mouse reporting — e.g. a CLI agent REPL.
  2. Type a few prompts so history exists, leave the input empty.
  3. Scroll the wheel up over the pane.
  4. Expected: terminal scrollback scrolls. Actual: the app's input history cycles (arrow keys are delivered to the PTY).

Anything else that might help:
Shift+wheel and dragging the scrollbar still scroll the real scrollback, so the viewport itself is fine; only the plain wheel path misroutes.

Activity

  1. changed the title [-]Mouse wheel sends arrow keys to a normal-buffer CLI without mouse reporting, cycling its input history[/-] [+][Bug]: Mouse wheel sends arrow keys to a normal-buffer CLI without mouse reporting, cycling its input history[/+] on Jul 13, 2026
  2. added
    bug
    on Jul 16, 2026
  3. added
    pending_repro
    on Jul 16, 2026
  4. OrcaWin commented on Jul 17, 2026

    @OrcaWin
    Collaborator

    Agent reproduction package (Windows orchestration 2026-07-16)

    Host context: Windows 11 / Orca 1.4.143.0 / repo path used: docs/bug-reproductions/
    Labels applied: see issue labels (has_repro or cannot_repro).
    Security: Do not run user-uploaded binaries from issue attachments. Recreate fixtures from the steps/scripts below.


    Issue 8563 — Mouse wheel sends arrow keys to normal-buffer CLI without mouse reporting

    Status: needs_setup (code path confirmed; interactive UI repro not run)
    Host: Windows 11, Orca 1.4.143, xterm @xterm/[email protected]
    Label: (none — interactive symptom not exercised headful)

    Summary

    Reporter: wheel over a pane running an inline (normal buffer) CLI that does not enable mouse reporting cycles input history (as if Up/Down were typed), instead of scrolling terminal scrollback. Shift+wheel and scrollbar still scroll correctly.

    Code path analysis

    1. xterm is the arrow synthesizer

    node_modules/@xterm/xterm/src/browser/services/MouseService.ts — _handlePassiveWheel:

    • If mouse protocol does not own wheel, and !buffer.hasScrollback, xterm sends:
    ESC + (applicationCursorKeys ? 'O' : '[') + (deltaY < 0 ? 'A' : 'B')
    

    i.e. Up/Down arrow sequences into the PTY (triggerDataEvent).

    2. hasScrollback definition

    Buffer.ts:

    public get hasScrollback(): boolean {
      return this._hasScrollback && this.lines.maxLength > this._rows;
    }

    False for the alt buffer, or if scrollback max length ≤ rows.

    3. Orca #7179 multiplier is not the synthesizer for this case

    pane-terminal-mouse-wheel.ts — shouldMultiplyTerminalMouseWheel requires class enable-mouse-events. Unit test “leaves normal terminal scrollback alone” passes (no multiply without that class). Multiplier only replays wheel events for TUI mouse reporting; it does not emit CSI A/B itself.

    So the reporter’s “no mouse reporting + normal buffer” case should use xterm passive wheel → viewport scroll unless hasScrollback is unexpectedly false.

    Repro (another agent)

    Logic probe (no GUI)

    cd <repo>
    powershell -NoProfile -ExecutionPolicy Bypass -File docs/bug-reproductions/scripts/repro-8563-wheel-arrow-logic.ps1
    # exit 3 = code path confirmed; interactive still needs headful

    Interactive (needs headful Orca)

    1. Open Orca terminal pane; run an inline REPL that maps Up/Down to history and does not emit CSI ?1000h / alt-screen (?1049h).
    2. Enter a few prompts; leave input empty.
    3. Wheel up over the pane.
    4. Expected: scrollback moves. Actual (reporter): history cycles (arrows to PTY).
    5. Compare Shift+wheel (should still scroll).

    Optional instrumentation: log terminal.buffer.active.type, hasScrollback, element.classList, and PTY writes on wheel.

    Expected vs actual

    Expected Normal buffer + scrollback ≥ 1000 → wheel scrolls viewport; no arrows
    Actual (reporter) Wheel delivers Up/Down to CLI history
    Actual (this host) Confirmed synthesizer + gates in source/tests; no headful confirmation

    Evidence

    • docs/bug-reproductions/evidence/8563-20260716-023012-meta.json
    • docs/bug-reproductions/evidence/8563-20260716-023012-xterm-wheel-lines.txt
    • docs/bug-reproductions/evidence/8563-20260716-023012-wheel-tests.log
    • Interactive attempts 2026-07-16: evidence/8563-20260716-023109.*, evidence/8563-20260716-023344.* — orca computer scroll over window coords did not yield KEY lines (probe/terminal-create flaky under load; no headful confirmation of arrows).

    Next steps / fix directions

    1. Headful repro with logging of buffer.active.hasScrollback at wheel time (is normal buffer incorrectly reporting no scrollback?).
    2. If hasScrollback is true but arrows still appear, search other sendData paths.
    3. If false on normal buffer, fix scrollback option / buffer selection / xterm beta regression.
    4. Hardening: custom wheel handler could block arrow synthesis when buffer.type === 'normal' and scrollback > 0, even if xterm disagrees.

    Repro script: repro-8563-wheel-arrow-logic.ps1

    # Repro #8563 (logic probe): document xterm wheel->arrow gate + Orca multiplier gate
    # Full interactive repro requires headful Orca + inline non-alt-screen CLI.
    # Usage: powershell -NoProfile -ExecutionPolicy Bypass -File docs/bug-reproductions/scripts/repro-8563-wheel-arrow-logic.ps1
    $ErrorActionPreference = "Continue"
    $repo = Resolve-Path (Join-Path $PSScriptRoot "..\..\..")
    Set-Location $repo
    $evDir = Join-Path $repo "docs\bug-reproductions\evidence"
    New-Item -ItemType Directory -Path $evDir -Force | Out-Null
    $stamp = Get-Date -Format "yyyyMMdd-HHmmss"
    
    $mouseService = "node_modules\@xterm\xterm\src\browser\services\MouseService.ts"
    $bufferTs = "node_modules\@xterm\xterm\src\common\buffer\Buffer.ts"
    $orcaWheel = "src\renderer\src\lib\pane-manager\pane-terminal-mouse-wheel.ts"
    
    $ms = Get-Content $mouseService -Raw
    $buf = Get-Content $bufferTs -Raw
    $ow = Get-Content $orcaWheel -Raw
    
    $hasPassiveArrow = $ms -match 'applicationCursorKeys' -and $ms -match "deltaY < 0 \? 'A' : 'B'"
    $hasScrollbackGate = $ms -match '!this\._bufferService\.buffer\.hasScrollback'
    $hasScrollbackDef = $buf -match 'return this\._hasScrollback && this\.lines\.maxLength > this\._rows'
    $orcaGated = $ow -match "enable-mouse-events" -and $ow -match 'shouldMultiplyTerminalMouseWheel'
    
    # Run unit tests proving Orca does not multiply without mouse reporting class
    $log = Join-Path $evDir "8563-$stamp-wheel-tests.log"
    pnpm exec vitest run --config config/vitest.config.ts `
      src/renderer/src/lib/pane-manager/pane-terminal-mouse-wheel.test.ts `
      -t "leaves normal terminal scrollback alone" --maxWorkers=1 2>&1 | Tee-Object $log
    $testsOk = ($LASTEXITCODE -eq 0)
    
    $meta = @{
      issue = 8563
      stamp = $stamp
      xtermSynthesizesArrowsWhenNoScrollback = $hasPassiveArrow
      xtermGatedOnHasScrollback = $hasScrollbackGate
      hasScrollbackDefinition = "hasScrollback && lines.maxLength > rows"
      hasScrollbackDefFound = $hasScrollbackDef
      orcaMultiplierGatedOnEnableMouseEvents = $orcaGated
      unitTestNoMultiplyWithoutMouseClass = $testsOk
      interactiveRepro = "needs headful Orca + inline CLI without mouse reporting / alt-screen"
      bugReproducedInteractive = $false
      codePathConfirmed = ($hasPassiveArrow -and $hasScrollbackGate -and $orcaGated -and $testsOk)
      notes = "Reporter symptom (normal buffer arrows) implies hasScrollback was false unexpectedly, or another input path. Orca #7179 multiplier is correctly gated and is not the primary synthesizer."
    }
    $path = Join-Path $evDir "8563-$stamp-meta.json"
    $meta | ConvertTo-Json -Depth 5 | Set-Content $path -Encoding utf8
    # Also extract the critical lines for evidence
    Select-String -Path $mouseService -Pattern "hasScrollback|applicationCursorKeys|deltaY < 0" |
      ForEach-Object { "$($_.LineNumber):$($_.Line)" } |
      Set-Content (Join-Path $evDir "8563-$stamp-xterm-wheel-lines.txt") -Encoding utf8
    Write-Host ($meta | ConvertTo-Json -Depth 4)
    if ($meta.codePathConfirmed) { exit 3 } else { exit 2 }
    
    

    How another agent should use this

    1. Read this comment fully (status, expected vs actual, blockers).
    2. If a script is included above, copy it to a temp file and run it on a Windows 11 host with Orca installed (prefer production install under %LOCALAPPDATA%\Programs\orca).
    3. Capture evidence (CLI --json, screenshots, logs) under a local folder; optionally comment results back here.
    4. If status is cannot_repro / needs_setup, satisfy the listed prerequisites first, then re-attempt and flip labels: remove cannot_repro, add has_repro when conclusive.
  5. AmethystLiang commented on Aug 14, 2026

    @AmethystLiang
    Contributor

    Also reported from Discord as #14165 (Claude Code and Cursor agent sessions). Symptom match: mouse wheel over a long agent answer cycles input history instead of scrolling the transcript. User asked whether a focus shortcut exists; Shift+wheel / scrollbar still scroll, same as this issue.

  6. paulkarayan commented on Sep 2, 2026

    @paulkarayan

    having the same issue on a macbook pro. orca with claude.

  7. nwparker commented on Sep 10, 2026

    @nwparker
    Contributor

    Looking at this now just not reproducing it... odd

  8. nwparker commented on Sep 11, 2026

    @nwparker
    Contributor

    Dug into this properly. Short version: it's alternate-screen only, and Orca already behaves like most terminals.

    When an app is on the alternate screen and hasn't enabled mouse reporting, the terminal turns the wheel into Up/Down. That's deliberate — it's how less and vim scroll. If the app maps arrows to input history instead, you get this.

    Verified on macOS with real wheel events, watching the bytes actually reach the pty:

    pane bytes sent to pty result
    inline agent CLI (normal buffer, mouse off) focus reports only scrollback scrolled fine
    tmux (alt screen, mouse off) ESC O A shell history cycled

    So a normal-buffer CLI can't produce it, which is why this was so hard to reproduce — the original report's "never enters alt screen" case doesn't happen. tmux reproduces it in one command.

    The knob that controls this is DECSET 1007. Where everyone lands:

    terminal mode 1007 default
    xterm yes (alternateScroll) off
    iTerm2 yes, plus profile settings off
    GNOME Terminal / VTE yes on
    Alacritty / Ghostty / WezTerm / Warp yes on
    kitty not implemented always on
    Orca (xterm.js) not implemented always on

    Turning it off globally would cost everyone wheel scrolling in less, man and vim, so it isn't a free win.

    One more thing worth knowing: Claude Code's agent view sends ?1007h — it asks for arrow keys on purpose, and warns "Scroll wheel is sending arrow keys · use PgUp/PgDn to scroll" when it detects it. That one isn't ours to fix.

    So before changing anything — what do you expect the wheel to do here? Keep today's behaviour and have tmux users run set -g mouse on? A setting? Something else? And if you're hitting this outside tmux, tell us the exact app and we'll chase it.

  9. nwparker commented on Sep 11, 2026

    @nwparker
    Contributor

    @paulkarayan @lcorncream -- what type of behavior are you trying to mimic?
    Can you point to the terminal you are using that exhibits the 'correct' behavior?

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

Metadata

Metadata

Assignees

Labels

bugos:Windowspending-user-responsepending_repro

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions