Skip to content

Fix BUG-026: forward mouse wheel to full-screen agents#812

Merged
anutron merged 4 commits into
masterfrom
argus/bugbash-3
Jun 25, 2026
Merged

Fix BUG-026: forward mouse wheel to full-screen agents#812
anutron merged 4 commits into
masterfrom
argus/bugbash-3

Conversation

@anutron

@anutron anutron commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

In the Hera panes and the Tasks-tab agent view, the mouse wheel did nothing on a freshly-started agent session — you couldn't scroll up. Older sessions scrolled fine.

Root cause (not an argus regression): Claude Code (and Codex) recently default to a fullscreen mode — the alternate screen (ESC[?1049h) with in-place cursor-home redraws. A full-screen TUI has no terminal scrollback by definition (sbLen=0, maxScroll=0), so the pane's wheel-scroll had nothing to reveal. This is faithful terminal behavior — you can't wheel-scroll a full-screen TUI in any terminal. Old sessions scrolled only because they had accumulated main-buffer scrollback (a bug-bash-2 coordinator measured sbLen≈2791 vs a fresh worker's sbLen=0, both on the alternate screen). The "recent regression" was the upstream Claude Code default change, not an argus commit.

Fix

TerminalPane.MouseHandler now forwards the wheel to a live, alternate-screen agent as SGR mouse frames (ESC[<64;Cx;Cy M wheel-up, 65 wheel-down) over the session input, so the agent scrolls its own view — exactly how a real terminal hands the wheel to a foreground full-screen app (mirrors the plugin-view forwarder, #681). Agents enable SGR mouse reporting (1000h/1002h/1003h/1006h), so the frames are understood.

  • Main-screen agents and finished/replay sessions are unchanged — they keep the pane's own terminal scrollback.
  • Diff mode is unaffected.
  • Shared TerminalPane, so this fixes both the Hera coord/agent panes and the Tasks-tab agent view.
  • Mouse-only — no keybinding/help/README-key changes.

Verification

  • Live dogfood confirmed: wheel-up scrolls a fullscreen Claude agent's own view — and renders better than the old default-mode pane scrollback, which mangled the alternate-screen redraw frames.
  • New tests: forward_wheel_test.go (forwards-when-alt-screen, scrolls-scrollback-when-not) + Hera routing regression tests.
  • make pre-pr: build / vet / fmt-check / lint-pr (0 issues) / test-cover-gate (89.5% ≥ 88 floor) all green. The vuln gate flags two Go stdlib CVEs (net/textproto, crypto/x509; fixed in go1.26.4) — toolchain-only, not this change, and advisory (continue-on-error) in CI.

Spec

OpenSpec terminal-rendering capability gains a "Mouse wheel forwarded to full-screen agents" requirement (change fix-bug-026, archived into base specs in this PR).

Merge note: this branch carries one bug's fix on top of a master merge — prefer a merge/rebase over squash to preserve the Fix BUG-026 commit history.

🤖 Generated with Claude Code

anutron and others added 4 commits June 24, 2026 21:56
The native Hera view's mouse-wheel scroll routes through HeraPage.MouseHandler
-> regionAt -> the pane under the cursor. If a wheel event misses the pane
rects it falls through to FocusRail, where the rail has no MouseHandler, so
Box.MouseHandler does not consume it and tview never redraws (Application
redraws a mouse event only when consumed) -- scroll-up silently does nothing.

The existing TestPanes_MouseRoutingByRegion scrolls over the agent region but
never asserts the scroll landed. Add two assertions that close that gap:

- TestPanes_MouseScrollRoutesToWorkerPane: wheel over the agent region scrolls
  the selected live worker's TerminalPane (consumed + scrollOffset increases).
- TestPanes_MouseScrollRoutesToCoordPane: with a coordinator selected (Details
  mode), wheel over the coord region scrolls the coordinator pane.

Investigation note: the BUG-026 report (cannot mouse-scroll-up in new/active
Hera sessions) could not be reproduced on this base -- routing and scrollback
both behave correctly for live worker and coordinator panes. These tests pin
that correct behavior as a regression guard while a precise repro is gathered.

Test-only; no behavioral change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ty scrollback

Agents like Claude Code / Codex run as full-screen TUIs: they take the
alternate screen (ESC[?1049h) and redraw in place via cursor-home (ESC[H)
instead of emitting scrolling output, so the terminal pane's own scrollback
stays near-empty. The native Hera coord/agent panes (and the shared Tasks-tab
agent view) scroll that scrollback on the mouse wheel, so wheel-up was a silent
no-op whenever the agent rendered in place -- maxScroll clamps to 0 with no
history to reveal.

Confirmed by feeding two real session logs through the replay emulator: a
coordinator that emitted scrolling output yielded ~2791 scrollback lines
(scrollable); a worker that redrew in place yielded 0. Both were on the
alternate screen, so alt-screen presence is not the discriminator -- committed
scrollback depth is. NOT a routing/click-to-focus bug: the wheel reaches the
pane (scroll-down visibly redrew); there was simply nothing in scrollback.

Fix (matches how a real terminal hands the wheel to the foreground full-screen
app, and the existing plugin-view forwarder #681): when the live agent is on the
alternate screen, TerminalPane.MouseHandler forwards wheel events to the agent
as SGR mouse frames (ESC[<64|65;Cx;Cy M) via sess.WriteInput so the agent scrolls
its own view. Main-screen agents and finished/replay sessions keep the pane's
own terminal scrollback unchanged. Mouse-only -- no keybinding/help changes.

Specs: openspec/changes/fix-bug-026 (terminal-rendering delta).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ding to full-screen agents)

Base spec updated atomically with the merged fix per CLAUDE.md. The lone incomplete task (6.1 live dogfood) is the pending runtime verification on Aaron's relaunch.
@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/drn/argus/internal/tui/hera 92.14% (ø)
github.com/drn/argus/internal/tui/terminal 95.26% (-0.01%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/drn/argus/internal/tui/terminal/terminalpane.go 95.37% (-0.02%) 735 (+19) 701 (+18) 34 (+1) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/drn/argus/internal/tui/hera/panes_cover_test.go
  • github.com/drn/argus/internal/tui/terminal/forward_wheel_test.go

@anutron anutron merged commit 5a28710 into master Jun 25, 2026
1 check passed
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.

1 participant