Repository navigation
Fix terminal input during window drags - #4281
austinywang wants to merge 11 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR implements reference-counted terminal input suppression during window move and drag operations. A new suppression system prevents mouse event forwarding to Ghostty while windows are being dragged, fixing spurious "CC" character insertion into terminal input. The suppression mechanism is integrated into drag handlers and guards mouse event forwarding conditionally. ChangesTerminal Input Suppression During Window Drag
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning, 1 inconclusive)
✅ Passed checks (13 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR fixes a terminal-input pollution bug where performing an explicit titlebar window drag could write mouse-report escape sequences into the shell prompt. It introduces a per-window, reference-counted suppression counter (via
Confidence Score: 4/5Safe to merge after confirming the missing @mainactor on the test class does not cause a compile error in this project's concurrency configuration. The production suppression logic is well-scoped and correct. FolderWindowMoveSuppressionTests lacks @mainactor while every sibling test class in the file carries it, and the two new test methods call functions that require main-actor isolation. If the project's test target uses Swift 6 strict concurrency, those tests will fail to compile. The fix is a one-line annotation. cmuxTests/WindowAndDragTests.swift — FolderWindowMoveSuppressionTests needs @mainactor to match all sibling test classes and to legally call the new @mainactor suppression functions. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant DragHandle as "DragHandle / TitlebarAccessory"
participant Suppressor as withWindowMoveTerminalInputSuppression
participant NSWindow
participant GhosttyNSView
User->>DragHandle: mouseDown on titlebar drag area
DragHandle->>Suppressor: beginWindowMoveTerminalInputSuppression
Note over Suppressor: depth becomes 1
Suppressor->>NSWindow: performDrag nested event loop
NSWindow-->>GhosttyNSView: mouseMoved / mouseDragged / mouseUp
GhosttyNSView->>GhosttyNSView: shouldForwardTerminalMouseEventToGhostty returns false
Note over GhosttyNSView: Events dropped, no bytes written to terminal
NSWindow-->>DragHandle: performDrag returns
DragHandle->>Suppressor: endWindowMoveTerminalInputSuppression via defer
Note over Suppressor: depth back to 0
Note over GhosttyNSView: Normal mouse reporting resumes
|
…-4125-window-move-cc
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit dfe70c8. Configure here.
|
Greptile high-priority note checked: this is already satisfied at PR head af7ddb8. |

Closes #4125.
Suppresses terminal mouse reporting while cmux performs explicit titlebar window drags so moving the app window cannot write mouse-report bytes into the shell prompt.
Note
Medium Risk
Touches low-level AppKit mouse/drag event routing and terminal input forwarding; regressions could break window dragging or terminal mouse interactions in edge cases.
Overview
Prevents terminal mouse reporting from firing while the app is performing an explicit
window.performDrag(with:), avoiding mouse-report bytes being written into the terminal during window moves.Adds a per-window, reference-counted terminal-input suppression state in
WindowDragHandleView.swift(withwithWindowMoveTerminalInputSuppression), wraps titlebar drag initiators inUpdateTitlebarAccessory/WindowDragHandleView, and gates multipleGhosttyTerminalViewmouse handlers (down/up/right/other/move/enter/exit/drag/menu) behindshouldForwardTerminalMouseEventToGhostty.Adds unit tests covering suppression toggling and reference counting.
Reviewed by Cursor Bugbot for commit dfe70c8. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Prevents terminal mouse and scroll input from leaking into the shell during explicit titlebar window drags. Input reporting is fully suppressed while dragging so escape bytes aren’t sent.
withWindowMoveTerminalInputSuppression.window.performDrag(with:)in the titlebar accessory and drag handle; gated allGhosttyTerminalViewhandlers viashouldForwardTerminalMouseEventToGhostty(mouse down/up/right/other, move/enter/exit/drag, context menu, and scrollWheel).Written for commit af7ddb8. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests