Repository navigation
fix(terminal): forward key events in panel host container to fix Esc key - #1692
BillionClaw wants to merge 1 commit into
Conversation
The HostContainerView in GhosttyTerminalView now forwards key events to the hosted terminal surface view. This ensures that keys like Escape work properly inside panels by routing events from the SwiftUI anchor view to the actual terminal view hosted in the portal window layer. Changes: - Added key event forwarding methods (keyDown, keyUp, flagsChanged, performKeyEquivalent) - Added acceptsFirstResponder override to enable key event reception - Added becomeFirstResponder override to transfer focus to terminal view - Added public terminalSurfaceView accessor on GhosttySurfaceScrollView - Connected hostedView reference in HostContainerView during updateNSView Fixes manaflow-ai#1610
|
@BillionClaw is attempting to deploy a commit to the Manaflow Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughHostContainerView now forwards keyboard events (keyDown, keyUp, flagsChanged, performKeyEquivalent) to the underlying Ghostty terminal surface, enabling proper event handling within panel-hosted terminals. A weak reference to hostedView and a public accessor terminalSurfaceView are added to support this event routing mechanism. Changes
Sequence DiagramsequenceDiagram
actor User
participant Panel as SwiftUI Panel
participant HCV as HostContainerView
participant ScrollView as GhosttySurfaceScrollView
participant Terminal as GhosttyNSView
User->>Panel: Press Escape key
Panel->>HCV: keyDown event
HCV->>HCV: canBecomeFirstResponder?
HCV->>ScrollView: Forward keyDown via hostedView
ScrollView->>Terminal: Pass to terminal surface
Terminal->>Terminal: Process Escape input
Terminal->>User: Dialog closes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
|
Closing per repository blocklist: maintainer threatened to ban. All submissions to this repo have been suspended. |
Summary
Fixes #1610 - Esc key not working inside panels.
Problem
When a terminal is embedded in a panel (via the bonsplit layout system), key events were not being properly routed to the terminal view. This was because the HostContainerView (the SwiftUI anchor for the portal-hosted terminal) did not forward key events to the actual GhosttyNSView that handles terminal input.
Solution
Modified HostContainerView in GhosttyTerminalView.swift to forward key events to the hosted terminal surface view:
Added key event forwarding methods: keyDown, keyUp, flagsChanged, and performKeyEquivalent now forward events to the terminal surface view.
Added acceptsFirstResponder override: Returns true so the container can receive key events.
Added becomeFirstResponder override: Transfers focus directly to the terminal view when the container becomes first responder.
Added public terminalSurfaceView accessor: Exposes the underlying GhosttyNSView from GhosttySurfaceScrollView for event forwarding.
Connected hostedView reference: Sets the hosted view on HostContainerView during updateNSView so it can forward events.
Testing
This fix ensures that keys like Escape are properly routed to the terminal when using panels, allowing terminal applications (like vim, less, etc.) to receive Esc key input correctly.
Related
Summary by cubic
Forward key events from the panel host container to the terminal surface view so Esc and other keys work when the terminal is embedded in panels. Fixes #1610.
terminalSurfaceViewaccessor and wireshostedViewduringupdateNSViewfor event routing.Written for commit d9cb478. Summary will update on new commits.
Summary by CodeRabbit