Skip to content

Desktop: Add Cmd+1..6 keyboard shortcuts for sidebar navigation - #5788

Closed
beastoin wants to merge 3 commits into
mainfrom
fix/desktop-keyboard-shortcuts
Closed

beastoin wants to merge 3 commits into
mainfrom
fix/desktop-keyboard-shortcuts

Conversation

@beastoin

Copy link
Copy Markdown
Collaborator

Summary

  • Adds keyboard shortcuts for sidebar navigation: Cmd+1 Dashboard, Cmd+2 Chat, Cmd+3 Memories, Cmd+4 Tasks, Cmd+5 Rewind, Cmd+6 Apps, Cmd+, Settings
  • Shortcuts appear in the macOS View menu (standard CommandGroup(after: .sidebar))
  • Uses a navigateToSidebarItem notification pattern matching existing navigation infrastructure

Fixes #5784 (friction #9)

Architecture

  • AppState.swift: New navigateToSidebarItem notification name
  • OmiApp.swift: CommandGroup(after: .sidebar) with 7 keyboard shortcuts that post the notification
  • DesktopHomeView.swift: .onReceive handler that reads rawValue from userInfo and animates to the target sidebar page

The order matches SidebarNavItem.mainItems (dashboard, chat, memories, tasks, rewind, apps). Cmd+, for Settings follows macOS convention.

Test plan

  • Build succeeds
  • Cmd+1 through Cmd+6 navigate to correct sidebar pages
  • Cmd+, opens Settings
  • Shortcuts appear in the View menu
  • Existing Cmd+/- font shortcuts still work

by AI for @beastoin

🤖 Generated with Claude Code

beastoin and others added 3 commits March 18, 2026 08:08
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-apps

greptile-apps Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds macOS keyboard shortcuts (Cmd+1 through Cmd+6 and Cmd+,) for sidebar navigation in the Omi desktop app, posting a new navigateToSidebarItem notification that DesktopHomeView receives to animate to the target page. The approach is a clean, minimal extension of the existing notification-based navigation infrastructure and the routing logic (rawValue → selectedIndex → PageContentView switch) is correct for all six main items and Settings.

Key changes:

  • AppState.swift: New navigateToSidebarItem Notification.Name with a clear doc-comment.
  • OmiApp.swift: CommandGroup(after: .sidebar) registers 7 shortcuts in the View menu.
  • DesktopHomeView.swift: onReceive handler mirrors the pattern of the existing navigateToChat/navigateToTasks handlers.

Issues found:

  • The shortcuts are registered unconditionally, including in Rewind launch mode where the sidebar is hidden; pressing them silently mutates selectedIndex with no visible result.
  • The onReceive handler does not call redirectIfPageHidden() after setting selectedIndex, so users on a restricted tier level can navigate to locked pages via keyboard (e.g. Cmd+2 for Chat, which requires tier 4).
  • Cmd+, for Settings is placed in the View menu (via CommandGroup(after: .sidebar)); the macOS convention is for this shortcut to live in the App menu.

Confidence Score: 4/5

  • Safe to merge; the shortcuts work correctly for the standard case, with two edge-case style concerns (Rewind mode and tier bypass) worth addressing as follow-ups.
  • The core routing logic is correct — SidebarNavItem.rawValue maps exactly to the PageContentView switch cases, the notification pattern mirrors existing handlers, and there are no conflicts with the existing Cmd+0/+/- shortcuts. Minor issues: shortcuts fire in Rewind mode (silent state mutation) and the handler skips tier-gating (consistent with existing handlers but user-facing). The non-standard Cmd+, menu placement is cosmetic.
  • desktop/Desktop/Sources/OmiApp.swift (Rewind-mode guard) and desktop/Desktop/Sources/MainWindow/DesktopHomeView.swift (tier check after navigation).

Important Files Changed

Filename Overview
desktop/Desktop/Sources/AppState.swift Adds a new navigateToSidebarItem notification name with a clear doc-comment; minimal, well-scoped change.
desktop/Desktop/Sources/OmiApp.swift Adds a CommandGroup(after: .sidebar) with 7 keyboard shortcuts (Cmd+1..6 and Cmd+,). Shortcuts remain active in Rewind launch mode and the Cmd+, placement in the View menu is non-standard; otherwise implementation is correct.
desktop/Desktop/Sources/MainWindow/DesktopHomeView.swift Adds an onReceive handler for the new notification that animates to the target selectedIndex; follows the exact pattern of existing navigateToChat/navigateToTasks handlers but does not check tier-gating before navigating.

Sequence Diagram

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

Last reviewed commit: "Add Cmd+1..6 sidebar..."

NotificationCenter.default.post(name: .navigateToSidebarItem, object: nil,
userInfo: ["rawValue": SidebarNavItem.settings.rawValue])
}
.keyboardShortcut(",", modifiers: .command)

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

Comment on lines +142 to +186
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)
}

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

Comment on lines +654 to +662
.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
}
}
}

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 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
    }
}

@github-actions

Copy link
Copy Markdown
Contributor

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:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our roadmap and vision

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! 💜

@undivisible
undivisible deleted the fix/desktop-keyboard-shortcuts branch August 20, 2026 11:34
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.

Desktop app: onboarding and local dev friction points

1 participant