Skip to content
Closed
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
51 changes: 51 additions & 0 deletions Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -9880,6 +9880,57 @@
}
}
},
"command.rightSidebarShow.title": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Show Right Sidebar"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "右サイドバーを表示"
}
}
}
},
"command.rightSidebarHide.title": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Hide Right Sidebar"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "右サイドバーを非表示"
}
}
}
},
"command.rightSidebarFocus.title": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Focus Right Sidebar"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "右サイドバーにフォーカス"
}
}
}
},
"command.openRightSidebarToolAsPane.subtitle": {
"extractionState": "manual",
"localizations": {
Expand Down
41 changes: 37 additions & 4 deletions Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5694,9 +5694,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent

func applyRightSidebarRemoteCommand(
_ command: RightSidebarRemoteCommand,
target: RightSidebarRemoteTarget = RightSidebarRemoteTarget()
target: RightSidebarRemoteTarget = RightSidebarRemoteTarget(),
preferredWindow: NSWindow? = nil
) -> RightSidebarRemoteApplyResult {
let context = rightSidebarRemoteContext(target: target)
let context = rightSidebarRemoteContext(target: target, preferredWindow: preferredWindow)
if !target.isActiveTarget, context == nil {
return .failure(String(localized: "rightSidebar.remote.error.targetNotFound", defaultValue: "ERROR: Right sidebar target not found"))
}
Expand Down Expand Up @@ -5779,7 +5780,28 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
}
}

private func rightSidebarRemoteContext(target: RightSidebarRemoteTarget) -> MainWindowContext? {
@discardableResult
func executeBuiltInRightSidebarAction(
_ action: CmuxSurfaceTabBarBuiltInAction,
preferredWindow: NSWindow? = nil,
onExecuted: (() -> Void)? = nil
) -> Bool {
guard let command = action.rightSidebarRemoteCommand else {
return false
}
switch applyRightSidebarRemoteCommand(command, preferredWindow: preferredWindow) {
case .ok:
onExecuted?()
return true
case .state, .failure:
return false
}
}

private func rightSidebarRemoteContext(
target: RightSidebarRemoteTarget,
preferredWindow: NSWindow? = nil
) -> MainWindowContext? {
if let windowId = target.windowId {
return mainWindowContexts.values.first(where: { $0.windowId == windowId })
}
Expand All @@ -5788,7 +5810,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
context.tabManager.tabs.contains(where: { $0.id == workspaceId })
}
}
return preferredRegisteredMainWindowContext()
return preferredRegisteredMainWindowContext(preferredWindow: preferredWindow)
}

@discardableResult
Expand Down Expand Up @@ -13065,6 +13087,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
) -> Bool {
switch action.action {
case .builtIn(let builtIn):
if executeBuiltInRightSidebarAction(
builtIn,
preferredWindow: preferredWindow,
onExecuted: onExecuted
) {
return true
}
switch builtIn {
case .newWorkspace:
context.tabManager.addWorkspace()
Expand Down Expand Up @@ -13117,6 +13146,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
)
if didSplit { onExecuted?() }
return didSplit
case .rightSidebarToggle, .rightSidebarShow, .rightSidebarHide, .rightSidebarFocus,
.rightSidebarFiles, .rightSidebarFind, .rightSidebarVault, .rightSidebarSessions,
.rightSidebarFeed, .rightSidebarDock:
return false
}
case .command, .agent, .workspaceCommand:
guard let cmuxConfigStore = context.cmuxConfigStore else {
Expand Down
27 changes: 2 additions & 25 deletions Sources/CmuxConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1499,34 +1499,11 @@ struct CmuxResolvedConfigAction: Identifiable, Sendable, Hashable {
}

static func builtIn(_ builtIn: CmuxSurfaceTabBarBuiltInAction) -> CmuxResolvedConfigAction {
let title: String
let keywords: [String]
switch builtIn {
case .newWorkspace:
title = String(localized: "command.newWorkspace.title", defaultValue: "New Workspace")
keywords = ["create", "new", "workspace"]
case .cloudVM:
title = String(localized: "command.cloudVM.title", defaultValue: "Start Cloud VM")
keywords = ["cloud", "vm", "virtual", "machine", "remote"]
case .newTerminal:
title = String(localized: "command.newTerminalTab.title", defaultValue: "New Terminal Tab")
keywords = ["new", "terminal", "tab", "surface"]
case .newBrowser:
title = String(localized: "command.newBrowserTab.title", defaultValue: "New Browser Tab")
keywords = ["new", "browser", "tab", "surface"]
case .splitRight:
title = String(localized: "command.terminalSplitRight.title", defaultValue: "Split Right")
keywords = ["terminal", "split", "right"]
case .splitDown:
title = String(localized: "command.terminalSplitDown.title", defaultValue: "Split Down")
keywords = ["terminal", "split", "down"]
}

return CmuxResolvedConfigAction(
id: builtIn.configID,
title: title,
title: builtIn.defaultTitle,
subtitle: String(localized: "command.cmuxConfig.builtInSubtitle", defaultValue: "cmux"),
keywords: keywords,
keywords: builtIn.defaultKeywords,
palette: true,
shortcut: nil,
icon: .symbol(builtIn.defaultIcon),
Expand Down
159 changes: 158 additions & 1 deletion Sources/CmuxSurfaceTabBarBuiltInAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@ enum CmuxSurfaceTabBarBuiltInAction: String, Codable, Sendable, CaseIterable, Ha
case newBrowser = "cmux.newBrowser"
case splitRight = "cmux.splitRight"
case splitDown = "cmux.splitDown"
case rightSidebarToggle = "cmux.rightSidebar.toggle"
case rightSidebarShow = "cmux.rightSidebar.show"
case rightSidebarHide = "cmux.rightSidebar.hide"
case rightSidebarFocus = "cmux.rightSidebar.focus"
case rightSidebarFiles = "cmux.rightSidebar.files"
case rightSidebarFind = "cmux.rightSidebar.find"
case rightSidebarVault = "cmux.rightSidebar.vault"
case rightSidebarSessions = "cmux.rightSidebar.sessions"
case rightSidebarFeed = "cmux.rightSidebar.feed"
case rightSidebarDock = "cmux.rightSidebar.dock"

static let rightSidebarActions: [CmuxSurfaceTabBarBuiltInAction] = [
.rightSidebarToggle,
.rightSidebarShow,
.rightSidebarHide,
.rightSidebarFocus,
.rightSidebarFiles,
.rightSidebarFind,
.rightSidebarVault,
.rightSidebarSessions,
.rightSidebarFeed,
.rightSidebarDock
]
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved

init?(configID: String) {
switch configID {
Expand All @@ -25,6 +48,26 @@ enum CmuxSurfaceTabBarBuiltInAction: String, Codable, Sendable, CaseIterable, Ha
self = .splitRight
case "cmux.splitDown", "splitDown":
self = .splitDown
case "cmux.rightSidebar.toggle", "rightSidebar.toggle":
self = .rightSidebarToggle
case "cmux.rightSidebar.show", "rightSidebar.show":
self = .rightSidebarShow
case "cmux.rightSidebar.hide", "rightSidebar.hide":
self = .rightSidebarHide
case "cmux.rightSidebar.focus", "rightSidebar.focus":
self = .rightSidebarFocus
case "cmux.rightSidebar.files", "rightSidebar.files":
self = .rightSidebarFiles
case "cmux.rightSidebar.find", "rightSidebar.find":
self = .rightSidebarFind
case "cmux.rightSidebar.vault", "rightSidebar.vault":
self = .rightSidebarVault
case "cmux.rightSidebar.sessions", "rightSidebar.sessions":
self = .rightSidebarSessions
case "cmux.rightSidebar.feed", "rightSidebar.feed":
self = .rightSidebarFeed
case "cmux.rightSidebar.dock", "rightSidebar.dock":
self = .rightSidebarDock
default:
return nil
}
Expand All @@ -48,12 +91,126 @@ enum CmuxSurfaceTabBarBuiltInAction: String, Codable, Sendable, CaseIterable, Ha
return "square.split.2x1"
case .splitDown:
return "square.split.1x2"
case .rightSidebarToggle, .rightSidebarShow, .rightSidebarHide:
return "rectangle.righthalf.inset.filled"
case .rightSidebarFocus:
return "scope"
case .rightSidebarFiles:
return RightSidebarMode.files.symbolName
case .rightSidebarFind:
return RightSidebarMode.find.symbolName
case .rightSidebarVault, .rightSidebarSessions:
return RightSidebarMode.sessions.symbolName
case .rightSidebarFeed:
return RightSidebarMode.feed.symbolName
case .rightSidebarDock:
return RightSidebarMode.dock.symbolName
}
}

var defaultTitle: String {
switch self {
case .newWorkspace:
return String(localized: "command.newWorkspace.title", defaultValue: "New Workspace")
case .cloudVM:
return String(localized: "command.cloudVM.title", defaultValue: "Start Cloud VM")
case .newTerminal:
return String(localized: "command.newTerminalTab.title", defaultValue: "New Terminal Tab")
case .newBrowser:
return String(localized: "command.newBrowserTab.title", defaultValue: "New Browser Tab")
case .splitRight:
return String(localized: "command.terminalSplitRight.title", defaultValue: "Split Right")
case .splitDown:
return String(localized: "command.terminalSplitDown.title", defaultValue: "Split Down")
case .rightSidebarToggle:
return String(localized: "shortcut.toggleRightSidebar.label", defaultValue: "Toggle Right Sidebar")
case .rightSidebarShow:
return String(localized: "command.rightSidebarShow.title", defaultValue: "Show Right Sidebar")
case .rightSidebarHide:
return String(localized: "command.rightSidebarHide.title", defaultValue: "Hide Right Sidebar")
case .rightSidebarFocus:
return String(localized: "command.rightSidebarFocus.title", defaultValue: "Focus Right Sidebar")
case .rightSidebarFiles:
return String(localized: "shortcut.switchRightSidebarToFiles.label", defaultValue: "Show Sidebar Files")
case .rightSidebarFind:
return String(localized: "shortcut.switchRightSidebarToFind.label", defaultValue: "Show Sidebar Find")
case .rightSidebarVault, .rightSidebarSessions:
return String(localized: "shortcut.switchRightSidebarToSessions.label", defaultValue: "Show Sidebar Vault")
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
case .rightSidebarFeed:
return String(localized: "shortcut.switchRightSidebarToFeed.label", defaultValue: "Show Sidebar Feed")
case .rightSidebarDock:
return String(localized: "shortcut.switchRightSidebarToDock.label", defaultValue: "Show Sidebar Dock")
}
}

var defaultKeywords: [String] {
switch self {
case .newWorkspace:
return ["create", "new", "workspace"]
case .cloudVM:
return ["cloud", "vm", "virtual", "machine", "remote"]
case .newTerminal:
return ["new", "terminal", "tab", "surface"]
case .newBrowser:
return ["new", "browser", "tab", "surface"]
case .splitRight:
return ["terminal", "split", "right"]
case .splitDown:
return ["terminal", "split", "down"]
case .rightSidebarToggle:
return ["right", "sidebar", "toggle"]
case .rightSidebarShow:
return ["right", "sidebar", "show"]
case .rightSidebarHide:
return ["right", "sidebar", "hide"]
case .rightSidebarFocus:
return ["right", "sidebar", "focus"]
case .rightSidebarFiles:
return ["right", "sidebar", "files"]
case .rightSidebarFind:
return ["right", "sidebar", "find", "search"]
case .rightSidebarVault:
return ["right", "sidebar", "vault", "sessions"]
case .rightSidebarSessions:
return ["right", "sidebar", "sessions", "vault"]
case .rightSidebarFeed:
return ["right", "sidebar", "feed"]
case .rightSidebarDock:
return ["right", "sidebar", "dock"]
}
}

var rightSidebarRemoteCommand: RightSidebarRemoteCommand? {
switch self {
case .rightSidebarToggle:
return .toggle
case .rightSidebarShow:
return .show
case .rightSidebarHide:
return .hide
case .rightSidebarFocus:
return .focus
case .rightSidebarFiles:
return .setMode(.files, focus: true)
case .rightSidebarFind:
return .setMode(.find, focus: true)
case .rightSidebarVault, .rightSidebarSessions:
return .setMode(.sessions, focus: true)
case .rightSidebarFeed:
return .setMode(.feed, focus: true)
case .rightSidebarDock:
return .setMode(.dock, focus: true)
case .newWorkspace, .cloudVM, .newTerminal, .newBrowser, .splitRight, .splitDown:
return nil
}
}

var bonsplitAction: BonsplitConfiguration.SplitActionButton.Action? {
switch self {
case .newWorkspace, .cloudVM:
case .newWorkspace, .cloudVM,
.rightSidebarToggle, .rightSidebarShow, .rightSidebarHide, .rightSidebarFocus,
.rightSidebarFiles, .rightSidebarFind, .rightSidebarVault, .rightSidebarSessions,
.rightSidebarFeed, .rightSidebarDock:
return nil
case .newTerminal:
return .newTerminal
Expand Down
6 changes: 5 additions & 1 deletion Sources/ContentView+RightSidebarCommandPalette.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ extension ContentView {
private static func commandPaletteRightSidebarModeShortcutAction(
forCommandID commandID: String
) -> KeyboardShortcutSettings.Action? {
commandPaletteRightSidebarMode(forCommandID: commandID)?.shortcutAction
}

static func commandPaletteRightSidebarMode(forCommandID commandID: String) -> RightSidebarMode? {
RightSidebarMode.availableModes().first { mode in
Self.commandPaletteRightSidebarModeCommandID(mode) == commandID
}?.shortcutAction
}
}
}
4 changes: 4 additions & 0 deletions Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5921,6 +5921,10 @@ struct ContentView: View {
}

private func commandPaletteConfigActionID(for commandId: String) -> String? {
if let rightSidebarMode = Self.commandPaletteRightSidebarMode(forCommandID: commandId) {
return rightSidebarMode.builtInAction.configID
}

switch commandId {
case "palette.newTerminalTab":
return CmuxSurfaceTabBarBuiltInAction.newTerminal.configID
Expand Down
10 changes: 10 additions & 0 deletions Sources/RightSidebarPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ nonisolated enum RightSidebarMode: String, CaseIterable, Codable, Sendable {
case .dock: return .switchRightSidebarToDock
}
}

var builtInAction: CmuxSurfaceTabBarBuiltInAction {
switch self {
case .files: return .rightSidebarFiles
case .find: return .rightSidebarFind
case .sessions: return .rightSidebarSessions
case .feed: return .rightSidebarFeed
case .dock: return .rightSidebarDock
}
}
}

extension RightSidebarMode {
Expand Down
Loading
Loading