Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Sources/GhosttyTerminalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4878,18 +4878,17 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
return false
}

if let lastPerformKeyEvent {
self.lastPerformKeyEvent = nil
if lastPerformKeyEvent == event.timestamp {
equivalent = event.characters ?? ""
break
}
}

lastPerformKeyEvent = event.timestamp
return false
// For unbound Command-modified keys (e.g., Cmd+Shift+K with no binding),
// forward directly to the terminal rather than relying on AppKit's redispatch.
// AppKit may drop the event if no menu item matches, preventing the key from
// reaching the terminal via the kitty keyboard protocol.
// See: https://github.com/manaflow-ai/cmux/issues/1718
lastPerformKeyEvent = nil
keyDown(with: event)
return true
Comment on lines +4881 to +4888

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Exclude `Cmd+`` from the new unbound-Command forwarding path.

Line 4881 currently forwards all unbound Command keys to keyDown(with:). That also catches `Cmd+`` (keyCode 50), which should remain on AppKit/window-menu routing for window cycling.

🔧 Proposed fix
-            lastPerformKeyEvent = nil
-            keyDown(with: event)
-            return true
+            // Keep Cmd+` on AppKit/window-menu routing (window cycling).
+            if event.keyCode == 50 {
+                lastPerformKeyEvent = nil
+                return false
+            }
+
+            lastPerformKeyEvent = nil
+            keyDown(with: event)
+            return true

Based on learnings Repo: manaflow-ai/cmux — Command-backtick (Cmd+, keyCode 50) is intentionally excluded from direct menu routing; do not add a bypass for Cmd+.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/GhosttyTerminalView.swift` around lines 4881 - 4888, The new
unbound-Command forwarding path in GhosttyTerminalView.swift unconditionally
clears lastPerformKeyEvent and calls keyDown(with: event), which incorrectly
forwards Cmd+` (keyCode 50) and breaks AppKit/window-menu routing; update the
handler to detect the Command-modified backtick (check event.keyCode == 50 and
event.modifierFlags contains .command) and skip the forwarding for that combo
(leave lastPerformKeyEvent intact and allow normal AppKit/menu routing), while
continuing to forward other unbound Command keys via lastPerformKeyEvent = nil;
keyDown(with: event).

@cubic-dev-ai cubic-dev-ai Bot Mar 18, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Unbound Command key equivalents are now always consumed in performKeyEquivalent, which can block app/menu shortcuts from routing through AppKit.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Sources/GhosttyTerminalView.swift, line 4888:

<comment>Unbound Command key equivalents are now always consumed in `performKeyEquivalent`, which can block app/menu shortcuts from routing through AppKit.</comment>

<file context>
@@ -4878,18 +4878,17 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
+            // See: https://github.com/manaflow-ai/cmux/issues/1718
+            lastPerformKeyEvent = nil
+            keyDown(with: event)
+            return true
         }
 
</file context>
Fix with Cubic

}

// Handle \r and / cases by creating a modified event and forwarding to keyDown.
let finalEvent = NSEvent.keyEvent(
with: .keyDown,
location: event.locationInWindow,
Expand Down