Fix shortcut detection and floating bar memory usage#6394
Conversation
macOS menu system consumes ⌘-key combos (⌘O, ⌘J, ⌘Return) via performKeyEquivalent before NSEvent local monitors fire. Strip the main menu while the shortcut test step is active, restore on leave. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Same fix as floating bar shortcut step: strip main menu so ⌘-key combos reach the event monitor instead of being consumed by NSMenu. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Updated floating bar system prompt to always check user memories before answering, give direct personalized answers, and never ask clarifying questions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryFixes ⌘-key shortcut detection during onboarding by temporarily setting Confidence Score: 5/5Safe to merge — fix is correct for the normal onboarding flow and all remaining findings are P2 The DispatchQueue.main.async pattern correctly handles SwiftUI Group navigation ordering. The only concern is a window-close edge case (P2) that doesn't affect the primary onboarding path. No P0/P1 issues found. OnboardingFloatingBarShortcutStepView.swift and OnboardingVoiceShortcutStepView.swift share a window-close edge case worth hardening Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant SW as SwiftUI
participant KM as installKeyMonitor
participant M as NSApp.mainMenu
U->>SW: navigate to shortcut step
SW->>KM: onAppear()
KM->>KM: addLocalMonitor
KM->>KM: addGlobalMonitor
KM-->>M: DispatchQueue.main.async (next run-loop)
M->>M: savedMenu = mainMenu
M->>M: mainMenu = nil
U->>SW: press ⌘ key
SW->>SW: localMonitor fires (not swallowed by NSMenu)
SW->>SW: shortcutDetected = true
U->>SW: click Continue
SW->>KM: onDisappear()
KM->>KM: removeMonitor(local + global)
KM->>M: mainMenu = savedMenu
M->>M: savedMenu = nil
Note over U,M: ⚠️ P2: if window closes via red-X,
onDisappear is skipped → mainMenu stays nil
Reviews (1): Last reviewed commit: "Fix floating bar to use memories and nev..." | Re-trigger Greptile |
| // Temporarily strip the main menu so ⌘-key combos (⌘O, ⌘J, ⌘Return, etc.) aren't | ||
| // swallowed by NSMenu's performKeyEquivalent before our monitor sees them. | ||
| DispatchQueue.main.async { | ||
| Self.savedMenu = NSApp.mainMenu | ||
| NSApp.mainMenu = nil | ||
| } |
There was a problem hiding this comment.
No safety net if
onDisappear is skipped
NSApp.mainMenu is set to nil here and only restored in removeKeyMonitors(), which is called from onDisappear. If the onboarding window is closed via the red-X button (or any code path that doesn't trigger onDisappear), the menu is never restored — permanently removing Quit, Preferences, Edit, and all menu-bar actions for the session. Consider adding a NSWindow.willCloseNotification observer as a fallback when the menu is nil'd, and removing it when removeKeyMonitors() runs normally. The same gap exists in OnboardingVoiceShortcutStepView lines 274–277.
) ## Summary - **Fix shortcut detection in onboarding**: ⌘-key combos (⌘O, ⌘J, ⌘Return) were consumed by NSMenu's `performKeyEquivalent` before the event monitor could detect them. Temporarily strip the main menu during the shortcut test steps, restore on leave. - **Fix floating bar not using memories**: Updated system prompt to always check user memories before answering, give direct personalized answers, and never ask follow-up questions. ## Test plan - [ ] On shortcut step, press ⌘O / ⌘J / ⌘Return — buttons should light up - [ ] On voice shortcut step, press and hold Option — button should light up - [ ] Ask floating bar "which computer should I buy?" — should give personalized answer using memories 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
performKeyEquivalentbefore the event monitor could detect them. Temporarily strip the main menu during the shortcut test steps, restore on leave.Test plan
🤖 Generated with Claude Code