Repository navigation
Conversation
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Listens for the notification and animates to the requested sidebar page by rawValue. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Cmd+1 Dashboard, Cmd+2 Chat, Cmd+3 Memories, Cmd+4 Tasks, Cmd+5 Rewind, Cmd+6 Apps, Cmd+, Settings. Uses standard macOS menu bar command group so shortcuts appear in the View menu. Fixes #5784 (friction #9) Co-Authored-By: Claude Opus 4.6 <[email protected]>
Greptile SummaryThis PR adds macOS keyboard shortcuts ( Key changes:
Issues found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant macOS as macOS Menu / Key Handler
participant OmiApp as OmiApp (CommandGroup)
participant NC as NotificationCenter
participant DHV as DesktopHomeView (onReceive)
participant PCV as PageContentView
User->>macOS: Press Cmd+1..6 or Cmd+,
macOS->>OmiApp: Button action fires
OmiApp->>NC: post(.navigateToSidebarItem, userInfo: ["rawValue": n])
NC->>DHV: publish notification
DHV->>DHV: unwrap rawValue → SidebarNavItem(rawValue:)
DHV->>DHV: withAnimation { selectedIndex = item.rawValue }
DHV->>PCV: selectedIndex changes → renders target page
Last reviewed commit: "Add Cmd+1..6 sidebar..." |
| NotificationCenter.default.post(name: .navigateToSidebarItem, object: nil, | ||
| userInfo: ["rawValue": SidebarNavItem.settings.rawValue]) | ||
| } | ||
| .keyboardShortcut(",", modifiers: .command) |
There was a problem hiding this comment.
Cmd+, placed in View menu (non-standard placement)
CommandGroup(after: .sidebar) inserts into the View menu. Cmd+, is the universal macOS shortcut for opening an app's Preferences/Settings, which by convention lives in the App (application name) menu — not the View menu. Placing it here means the "Settings" button appears under View → Settings rather than the expected AppMenu → Settings, which may surprise users browsing the menus.
Since the app doesn't have a SwiftUI Settings {} scene (so there's no auto-generated Cmd+, to conflict with), the shortcut itself will fire correctly. But if you want to match the standard macOS location you could add a separate CommandGroup(replacing: .appSettings) entry for Settings specifically, and keep only Cmd+1–6 in the .sidebar group.
| CommandGroup(after: .sidebar) { | ||
| Button("Dashboard") { | ||
| NotificationCenter.default.post(name: .navigateToSidebarItem, object: nil, | ||
| userInfo: ["rawValue": SidebarNavItem.dashboard.rawValue]) | ||
| } | ||
| .keyboardShortcut("1", modifiers: .command) | ||
|
|
||
| Button("Chat") { | ||
| NotificationCenter.default.post(name: .navigateToSidebarItem, object: nil, | ||
| userInfo: ["rawValue": SidebarNavItem.chat.rawValue]) | ||
| } | ||
| .keyboardShortcut("2", modifiers: .command) | ||
|
|
||
| Button("Memories") { | ||
| NotificationCenter.default.post(name: .navigateToSidebarItem, object: nil, | ||
| userInfo: ["rawValue": SidebarNavItem.memories.rawValue]) | ||
| } | ||
| .keyboardShortcut("3", modifiers: .command) | ||
|
|
||
| Button("Tasks") { | ||
| NotificationCenter.default.post(name: .navigateToSidebarItem, object: nil, | ||
| userInfo: ["rawValue": SidebarNavItem.tasks.rawValue]) | ||
| } | ||
| .keyboardShortcut("4", modifiers: .command) | ||
|
|
||
| Button("Rewind") { | ||
| NotificationCenter.default.post(name: .navigateToSidebarItem, object: nil, | ||
| userInfo: ["rawValue": SidebarNavItem.rewind.rawValue]) | ||
| } | ||
| .keyboardShortcut("5", modifiers: .command) | ||
|
|
||
| Button("Apps") { | ||
| NotificationCenter.default.post(name: .navigateToSidebarItem, object: nil, | ||
| userInfo: ["rawValue": SidebarNavItem.apps.rawValue]) | ||
| } | ||
| .keyboardShortcut("6", modifiers: .command) | ||
|
|
||
| Divider() | ||
|
|
||
| Button("Settings") { | ||
| NotificationCenter.default.post(name: .navigateToSidebarItem, object: nil, | ||
| userInfo: ["rawValue": SidebarNavItem.settings.rawValue]) | ||
| } | ||
| .keyboardShortcut(",", modifiers: .command) | ||
| } |
There was a problem hiding this comment.
Shortcuts remain active in Rewind launch mode
All seven shortcuts post navigateToSidebarItem unconditionally. When the app is launched with --mode=rewind (OMIApp.launchMode == .rewind), the sidebar and most content pages are hidden, but the CommandGroup is still registered. A user in Rewind mode who presses Cmd+1..6 or Cmd+, will mutate selectedIndex inside DesktopHomeView without any visible effect, silently corrupting the navigation state.
Consider guarding the command registration (or the notification handler) against Rewind mode:
if OMIApp.launchMode == .full {
CommandGroup(after: .sidebar) {
// ... shortcuts ...
}
}| .onReceive(NotificationCenter.default.publisher(for: .navigateToSidebarItem)) { notification in | ||
| if let rawValue = notification.userInfo?["rawValue"] as? Int, | ||
| let item = SidebarNavItem(rawValue: rawValue) | ||
| { | ||
| withAnimation(.easeInOut(duration: 0.2)) { | ||
| selectedIndex = item.rawValue | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Tier-gating not checked before navigating
The handler sets selectedIndex directly to the target item's rawValue without consulting the tier-locking system (isItemLocked / redirectIfPageHidden). For example, a user on tier 1 (who can only access Dashboard and Rewind) could press Cmd+3 (Memories, requires tier 2) or Cmd+2 (Chat, requires tier 4) and land on that locked page. redirectIfPageHidden() is only called on .onAppear and .onChange(of: currentTierLevel), not on selectedIndex changes, so there is no automatic correction.
This is consistent with the existing navigateToChat / navigateToTasks handlers (which also skip the tier check), but those are triggered programmatically from within the app, whereas these shortcuts are directly user-facing. It is worth at least calling redirectIfPageHidden() after setting selectedIndex here, or checking tier access before setting it:
.onReceive(NotificationCenter.default.publisher(for: .navigateToSidebarItem)) { notification in
if let rawValue = notification.userInfo?["rawValue"] as? Int,
let item = SidebarNavItem(rawValue: rawValue)
{
withAnimation(.easeInOut(duration: 0.2)) {
selectedIndex = item.rawValue
}
redirectIfPageHidden() // guard against tier-locked navigation
}
}|
Hey @beastoin 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! 💜 |
Summary
CommandGroup(after: .sidebar))navigateToSidebarItemnotification pattern matching existing navigation infrastructureFixes #5784 (friction #9)
Architecture
AppState.swift: NewnavigateToSidebarItemnotification nameOmiApp.swift:CommandGroup(after: .sidebar)with 7 keyboard shortcuts that post the notificationDesktopHomeView.swift:.onReceivehandler that readsrawValuefrom userInfo and animates to the target sidebar pageThe order matches
SidebarNavItem.mainItems(dashboard, chat, memories, tasks, rewind, apps). Cmd+, for Settings follows macOS convention.Test plan
by AI for @beastoin
🤖 Generated with Claude Code