Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ extension ShortcutAction {
case .closeTab: return ShortcutStroke(key: "w", command: true)
case .closeOtherTabsInPane: return ShortcutStroke(key: "t", command: true, option: true)
case .closeWorkspace: return ShortcutStroke(key: "w", command: true, shift: true)
// Unbound by default: "Pin Workspace" is reachable through the context
// menu and command palette. Shipping it unbound avoids colliding with an
// existing default; users can bind it (e.g. ⌘⇧F) in Settings.
case .togglePinnedWorkspace: return nil
case .newWorkspaceGroup: return ShortcutStroke(key: "g", command: true, control: true)
case .groupSelectedWorkspaces: return ShortcutStroke(key: "g", command: true, shift: true)
case .toggleFocusedWorkspaceGroupCollapsed: return ShortcutStroke(key: ".", command: true, control: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public enum ShortcutAction: String, CaseIterable, Sendable, Hashable, SettingCod
case closeTab
case closeOtherTabsInPane
case closeWorkspace
/// Toggles the pinned state of the focused workspace.
case togglePinnedWorkspace
/// Creates a new empty workspace group.
case newWorkspaceGroup
/// Groups the selected workspaces in the workspace list.
Expand Down Expand Up @@ -187,6 +189,7 @@ extension ShortcutAction {
.prevSidebarTab, .focusHistoryBack, .focusHistoryForward,
.selectWorkspaceByNumber, .renameTab, .renameWorkspace,
.editWorkspaceDescription, .closeTab, .closeOtherTabsInPane, .closeWorkspace,
.togglePinnedWorkspace,
.newWorkspaceGroup, .groupSelectedWorkspaces, .toggleFocusedWorkspaceGroupCollapsed,
.reopenClosedBrowserPanel, .newSurface, .toggleTerminalCopyMode,
.focusTextBoxInput, .cycleTextBoxSubmitAction, .attachTextBoxFile, .sendCtrlFToTerminal,
Expand Down Expand Up @@ -375,6 +378,8 @@ extension ShortcutAction {
case .closeTab: return "Close Tab"
case .closeOtherTabsInPane: return "Close Other Tabs in Pane"
case .closeWorkspace: return "Close Workspace"
case .togglePinnedWorkspace:
return String(localized: "shortcut.togglePinnedWorkspace.label", defaultValue: "Pin or Unpin Focused Workspace")
case .newWorkspaceGroup:
return String(localized: "shortcut.newWorkspaceGroup.label", defaultValue: "New Workspace Group")
case .groupSelectedWorkspaces:
Expand Down
23 changes: 23 additions & 0 deletions Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13728,6 +13728,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
}
}

if matchConfiguredShortcut(event: event, action: .togglePinnedWorkspace) {
// Only consume the event when a focused workspace was resolved and
// toggled. Otherwise fall through so a rebinding that shares this
// chord with another action still works.
if handleTogglePinnedWorkspaceShortcut(
preferredWindow: commandPaletteTargetWindow ?? event.window ?? shortcutRoutingActiveWindow
) {
return true
}
}

if matchConfiguredShortcut(event: event, action: .editWorkspaceDescription) {
#if DEBUG
cmuxDebugLog(
Expand Down Expand Up @@ -14928,6 +14939,18 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
return true
}

func handleTogglePinnedWorkspaceShortcut(preferredWindow: NSWindow? = nil) -> Bool {
let targetWindow = preferredWindow ?? shortcutRoutingActiveWindow
let resolvedTabManager: TabManager? = contextForMainWindow(targetWindow)?.tabManager ?? self.tabManager
Comment thread
teamleaderleo marked this conversation as resolved.
Resolved
Comment thread
teamleaderleo marked this conversation as resolved.
Resolved
guard let tabManager = resolvedTabManager else { return false }
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
// Don't consume the event when there is no focused workspace — let the
// matched chord propagate, consistent with the group shortcuts'
// fall-through policy.
guard let focusedId = tabManager.selectedTabId else { return false }
tabManager.togglePin(tabId: focusedId)
return true
Comment thread
teamleaderleo marked this conversation as resolved.
Resolved
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

@discardableResult
func createEmptyWorkspaceGroup(tabManager explicitTabManager: TabManager? = nil, preferredWindow: NSWindow? = nil) -> Bool {
let targetWindow = preferredWindow ?? shortcutRoutingActiveWindow
Expand Down
7 changes: 7 additions & 0 deletions Sources/KeyboardShortcutSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ enum KeyboardShortcutSettings {
case closeTab
case closeOtherTabsInPane
case closeWorkspace
case togglePinnedWorkspace
case newWorkspaceGroup
case groupSelectedWorkspaces
case toggleFocusedWorkspaceGroupCollapsed
Expand Down Expand Up @@ -234,6 +235,7 @@ enum KeyboardShortcutSettings {
case .closeTab: return String(localized: "menu.file.closeTab", defaultValue: "Close Tab")
case .closeOtherTabsInPane: return String(localized: "menu.file.closeOtherTabs", defaultValue: "Close Other Tabs in Pane")
case .closeWorkspace: return String(localized: "shortcut.closeWorkspace.label", defaultValue: "Close Workspace")
case .togglePinnedWorkspace: return String(localized: "shortcut.togglePinnedWorkspace.label", defaultValue: "Pin or Unpin Focused Workspace")
Comment thread
teamleaderleo marked this conversation as resolved.
Resolved
case .newWorkspaceGroup: return String(localized: "shortcut.newWorkspaceGroup.label", defaultValue: "New Workspace Group")
case .groupSelectedWorkspaces: return String(localized: "shortcut.groupSelectedWorkspaces.label", defaultValue: "Group Selected Workspaces")
case .toggleFocusedWorkspaceGroupCollapsed: return String(localized: "shortcut.toggleFocusedWorkspaceGroupCollapsed.label", defaultValue: "Toggle Focused Workspace's Group Collapse")
Expand Down Expand Up @@ -409,6 +411,11 @@ enum KeyboardShortcutSettings {
return StoredShortcut(key: "t", command: true, shift: false, option: true, control: false)
case .closeWorkspace:
return StoredShortcut(key: "w", command: true, shift: true, option: false, control: false)
case .togglePinnedWorkspace:
// Unbound by default: reachable through the context menu and
// command palette. Ships unbound to avoid colliding with an
// existing default; users can bind it (e.g. Cmd+Shift+F).
return .unbound
case .newWorkspaceGroup:
return StoredShortcut(key: "g", command: true, shift: false, option: false, control: true)
case .groupSelectedWorkspaces:
Expand Down
1 change: 1 addition & 0 deletions web/data/cmux-shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export const shortcutCategories: ShortcutCategory[] = [
{ id: "selectWorkspaceByNumber", combos: [["⌘", "1…9"]], description: { en: "Select workspace 1…9", ja: "ワークスペース1…9を選択" } },
{ id: "renameWorkspace", combos: [["⌘", "⇧", "R"]], description: { en: "Rename workspace", ja: "ワークスペース名を変更" } },
{ id: "editWorkspaceDescription", combos: [["⌥", "⌘", "E"]], description: { en: "Edit workspace description", ja: "ワークスペースの説明を編集" } },
{ id: "togglePinnedWorkspace", combos: [], description: { en: "Pin or unpin the focused workspace", ja: "フォーカス中のワークスペースをピン留め/解除" } },
Comment thread
teamleaderleo marked this conversation as resolved.
Resolved
{ id: "newWorkspaceGroup", combos: [["⌃", "⌘", "G"]], description: { en: "New empty workspace group", ja: "空のワークスペースグループを作成" } },
{ id: "groupSelectedWorkspaces", combos: [["⌘", "⇧", "G"]], description: { en: "Group selected workspaces", ja: "選択したワークスペースをグループ化" } },
{
Expand Down
1 change: 1 addition & 0 deletions web/data/cmux.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,7 @@
"closeTab",
"closeOtherTabsInPane",
"closeWorkspace",
"togglePinnedWorkspace",
"newWorkspaceGroup",
"groupSelectedWorkspaces",
"toggleFocusedWorkspaceGroupCollapsed",
Expand Down