Skip to content

Fix shortcut detection and floating bar memory usage#6394

Merged
kodjima33 merged 3 commits into
mainfrom
worktree-fix+onboarding-issues
Apr 7, 2026
Merged

Fix shortcut detection and floating bar memory usage#6394
kodjima33 merged 3 commits into
mainfrom
worktree-fix+onboarding-issues

Conversation

@kodjima33
Copy link
Copy Markdown
Collaborator

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

kodjima33 and others added 3 commits April 7, 2026 15:51
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>
@kodjima33 kodjima33 merged commit 8ec25c3 into main Apr 7, 2026
2 of 3 checks passed
@kodjima33 kodjima33 deleted the worktree-fix+onboarding-issues branch April 7, 2026 19:52
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 7, 2026

Greptile Summary

Fixes ⌘-key shortcut detection during onboarding by temporarily setting NSApp.mainMenu = nil, preventing NSMenu's performKeyEquivalent from consuming key events before the local NSEvent monitor sees them. The DispatchQueue.main.async deferral is intentional and correct — it ensures the save runs after both onAppear and onDisappear complete within the same run-loop cycle during SwiftUI's Group-based view swap. Also updates floatingBarSystemPromptPrefix in ChatProvider to direct the model to always check memories and respond without follow-up questions.

Confidence Score: 5/5

Safe 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

Filename Overview
desktop/Desktop/Sources/OnboardingFloatingBarShortcutStepView.swift Adds static savedMenu + NSApp.mainMenu nil pattern to fix ⌘-key detection; deferred via DispatchQueue.main.async; missing window-close safety net
desktop/Desktop/Sources/OnboardingVoiceShortcutStepView.swift Mirrors menu save/restore from FloatingBar step; savedMenu lacks doc comment; shares the same window-close edge case
desktop/Desktop/Sources/Providers/ChatProvider.swift Prompt-only change to floatingBarSystemPromptPrefix instructing always-check-memories and no follow-up questions

Sequence Diagram

sequenceDiagram
    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
Loading

Reviews (1): Last reviewed commit: "Fix floating bar to use memories and nev..." | Re-trigger Greptile

Comment on lines +263 to +268
// 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
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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.

Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
)

## 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)
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