Skip to content

fix(tui): preserve Codex wheel locations - #261

Merged
senamakel merged 1 commit into
tinyhumansai:mainfrom
senamakel:fix-mouse-scroll-location
Aug 12, 2026
Merged

fix(tui): preserve Codex wheel locations#261
senamakel merged 1 commit into
tinyhumansai:mainfrom
senamakel:fix-mouse-scroll-location

Conversation

@senamakel

@senamakel senamakel commented Aug 12, 2026

Copy link
Copy Markdown
Member

Summary

  • forward Codex wheel input as pane-relative SGR mouse events
  • stop translating Codex wheel notches into prompt-history arrow keys
  • retain negotiated mouse, alternate-scroll, and emulator-history fallbacks for other harnesses

Root cause

Current Codex releases handle mouse events but do not negotiate terminal mouse reporting. Medulla therefore selected its Codex compatibility fallback, converted wheel notches into Up/Down keys, and necessarily discarded the pointer coordinates. Codex interpreted those keys as history/navigation input instead of scrolling the screen under the pointer.

Validation

  • cargo test
  • cargo test -p medulla-tui ui::harness_pane
  • cargo test -p medulla-tui --test feature_session_mouse
  • cargo fmt --check
  • cargo clippy --all-targets -- -D warnings

Summary by CodeRabbit

  • Bug Fixes
    • Improved wheel scrolling in Codex sessions by sending location-aware mouse events.
    • Preserved pane coordinates during scrolling and prevented unintended cursor-key history navigation.
    • Retained alternate-scroll behavior for compatible sessions and emulator history scrolling for inactive sessions.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Codex wheel scrolling now sends coordinate-aware SGR mouse reports when the input layer is ready. Alternate-scroll behavior remains unchanged for other sessions, and dead sessions still scroll emulator history.

Changes

Codex wheel forwarding

Layer / File(s) Summary
Add coordinate-aware SGR wheel encoding
src/tui/src/ui/harness_pane/mouse.rs
The mouse module adds sgr_wheel and uses it for SGR wheel encoding. Default and UTF-8 encodings remain unchanged.
Forward Codex wheel input
src/tui/src/ui/harness_pane/mod.rs, src/tui/src/ui/harness_pane/tests/session.rs
Running Codex sessions send pane-relative SGR wheel reports after bracketed paste is enabled. Tests verify coordinates (4,5) and reject cursor-key history navigation.

Estimated code review effort: 3 (Moderate) | ~15 minutes

Suggested reviewers: sanil-23

Poem

I’m a rabbit with wheels in my paws,
Sending SGR hops without flaws.
At (4,5) I spring,
No arrow keys sing—
Codex scrolls with precise applause.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving Codex wheel-event locations in the TUI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/tui/src/ui/harness_pane/tests/session.rs (1)

324-331: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the down-wheel branch.

This test sends only up = true, so it checks button 64 but not BUTTON_WHEEL_DOWN (65) or the ^[[B cursor-key fallback. Add a down-wheel assertion or equivalent coverage in the mouse tests.

As per coding guidelines, “Cover new branches with tests and maintain the repository's 80% line-coverage gate.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tui/src/ui/harness_pane/tests/session.rs` around lines 324 - 331, Extend
the mouse-event tests around the existing “Codex to receive a location-aware
wheel event” assertion to send a down-wheel event (`BUTTON_WHEEL_DOWN`/button
65) and verify it produces the expected location-aware sequence without falling
back to the `^[[B` cursor key or navigating history. Preserve the existing
up-wheel coverage and assertions.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/tui/src/ui/harness_pane/tests/session.rs`:
- Around line 324-331: Extend the mouse-event tests around the existing “Codex
to receive a location-aware wheel event” assertion to send a down-wheel event
(`BUTTON_WHEEL_DOWN`/button 65) and verify it produces the expected
location-aware sequence without falling back to the `^[[B` cursor key or
navigating history. Preserve the existing up-wheel coverage and assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3b4af7a5-8d89-4607-b642-4ca584b99c93

📥 Commits

Reviewing files that changed from the base of the PR and between 16b125f and dd8c9ef.

📒 Files selected for processing (3)
  • src/tui/src/ui/harness_pane/mod.rs
  • src/tui/src/ui/harness_pane/mouse.rs
  • src/tui/src/ui/harness_pane/tests/session.rs

@senamakel
senamakel merged commit 913350e into tinyhumansai:main Aug 12, 2026
9 checks 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