Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 12 additions & 8 deletions SupacodeSettingsShared/App/AppShortcuts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SwiftUI

// Compile-time checkable shortcut identifier.
public nonisolated enum AppShortcutID: Codable, Hashable, Sendable, CodingKeyRepresentable {
case commandPalette, openSettings, checkForUpdates
case commandPalette, openSettings, checkForUpdates, showMainWindow
case toggleLeftSidebar, revealInSidebar
case newWorktree, refreshWorktrees, archivedWorktrees, archiveWorktree
case deleteWorktree, confirmWorktreeAction
Expand Down Expand Up @@ -38,6 +38,7 @@ public nonisolated enum AppShortcutID: Codable, Hashable, Sendable, CodingKeyRep
case .commandPalette: "commandPalette"
case .openSettings: "openSettings"
case .checkForUpdates: "checkForUpdates"
case .showMainWindow: "showMainWindow"
case .toggleLeftSidebar: "toggleLeftSidebar"
case .revealInSidebar: "revealInSidebar"
case .newWorktree: "newWorktree"
Expand Down Expand Up @@ -66,6 +67,7 @@ public nonisolated enum AppShortcutID: Codable, Hashable, Sendable, CodingKeyRep
"commandPalette": .commandPalette,
"openSettings": .openSettings,
"checkForUpdates": .checkForUpdates,
"showMainWindow": .showMainWindow,
"toggleLeftSidebar": .toggleLeftSidebar,
"revealInSidebar": .revealInSidebar,
"newWorktree": .newWorktree,
Expand Down Expand Up @@ -106,6 +108,7 @@ public nonisolated enum AppShortcutID: Codable, Hashable, Sendable, CodingKeyRep
case .commandPalette: "Command Palette"
case .openSettings: "Open Settings"
case .checkForUpdates: "Check For Updates"
case .showMainWindow: "Show Main Window"
case .toggleLeftSidebar: "Toggle Left Sidebar"
case .revealInSidebar: "Reveal in Sidebar"
case .newWorktree: "New Worktree"
Expand Down Expand Up @@ -286,6 +289,7 @@ public enum AppShortcuts {
public static let commandPalette = AppShortcut(id: .commandPalette, key: "p", modifiers: .command)
public static let openSettings = AppShortcut(id: .openSettings, key: ",", modifiers: .command)
public static let checkForUpdates = AppShortcut(id: .checkForUpdates, key: "u", modifiers: .command)
public static let showMainWindow = AppShortcut(id: .showMainWindow, key: "0", modifiers: .command)

public static let toggleLeftSidebar = AppShortcut(id: .toggleLeftSidebar, key: "[", modifiers: .command)
public static let revealInSidebar = AppShortcut(id: .revealInSidebar, key: "e", modifiers: [.command, .shift])
Expand Down Expand Up @@ -352,7 +356,10 @@ public enum AppShortcuts {
// MARK: - Groups.

public static let groups: [AppShortcutGroup] = [
AppShortcutGroup(category: .general, shortcuts: [commandPalette, openSettings, checkForUpdates]),
AppShortcutGroup(
category: .general,
shortcuts: [commandPalette, openSettings, checkForUpdates, showMainWindow]
),
AppShortcutGroup(category: .sidebar, shortcuts: [toggleLeftSidebar, revealInSidebar]),
AppShortcutGroup(
category: .worktrees,
Expand Down Expand Up @@ -434,12 +441,9 @@ public enum AppShortcuts {
// MARK: - View modifier.

extension View {
@ViewBuilder
// Always returns the same view type so menu-bar CommandGroups don't lose identity
// when the shortcut hydrates from disk; that flip strips Tahoe arrangement items.
public func appKeyboardShortcut(_ shortcut: AppShortcut?) -> some View {
if let shortcut {
self.keyboardShortcut(shortcut.keyEquivalent, modifiers: shortcut.modifiers)
} else {
self
}
keyboardShortcut(shortcut.map { KeyboardShortcut($0.keyEquivalent, modifiers: $0.modifiers) })
}
}
11 changes: 0 additions & 11 deletions supacode/App/DeeplinkReferenceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,6 @@ private struct DeeplinkSection: View {
}
}

struct DeeplinkReferenceMenuButton: View {
@Environment(\.openWindow) private var openWindow

var body: some View {
Button("Deeplink Reference") {
openWindow(id: WindowID.deeplinkReference)
}
.help("Open the deeplink reference.")
}
}

// MARK: - Deeplink → window bridge.

/// Opens the deeplink reference window when the reducer sets `isDeeplinkReferenceRequested`.
Expand Down
20 changes: 7 additions & 13 deletions supacode/App/supacodeApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -388,32 +388,26 @@ struct SupacodeApp: App {
TerminalCommands(ghosttyShortcuts: ghosttyShortcuts)
WindowCommands(ghosttyShortcuts: ghosttyShortcuts)
CommandGroup(after: .textEditing) {
let cmdPalette = AppShortcuts.commandPalette.effective(from: store.settings.shortcutOverrides)
Button("Command Palette") {
store.send(.commandPalette(.togglePresented))
}
.appKeyboardShortcut(cmdPalette)
.help("Command Palette (\(cmdPalette?.display ?? "none"))")
.appKeyboardShortcut(AppShortcuts.commandPalette.effective(from: store.settings.shortcutOverrides))
.help("Command Palette")
}
UpdateCommands(store: store.scope(state: \.updates, action: \.updates))
Group {
CommandGroup(replacing: .windowList) {}
CommandGroup(replacing: .singleWindowList) {
Button("Supacode") {
NSApplication.shared.surfaceMainWindow()
}
.keyboardShortcut("0")
.help("Show main window (⌘0)")
CommandGroup(replacing: .singleWindowList) {
Button("Supacode") {
NSApplication.shared.surfaceMainWindow()
}
.appKeyboardShortcut(AppShortcuts.showMainWindow.effective(from: store.settings.shortcutOverrides))
.help("Show Main Window")
}
CommandGroup(replacing: .appSettings) {
SettingsMenuButton(shortcutOverrides: store.settings.shortcutOverrides) {
store.send(.settings(.setSelection(.general)))
}
}
CommandGroup(replacing: .help) {
DeeplinkReferenceMenuButton()
Divider()
Button("Submit GitHub Issue") {
guard let url = URL(string: "https://github.com/supabitapp/supacode/issues/new") else { return }
NSWorkspace.shared.open(url)
Expand Down
Loading