diff --git a/Sources/AppDelegate+DockShortcutRouting.swift b/Sources/AppDelegate+DockShortcutRouting.swift index ed78becb6d62..a783ed96e2c0 100644 --- a/Sources/AppDelegate+DockShortcutRouting.swift +++ b/Sources/AppDelegate+DockShortcutRouting.swift @@ -160,6 +160,23 @@ extension AppDelegate { ) } + /// Focuses the TextBox composer from a menu or command entrypoint. The + /// terminal panel owns the same focus toggle as the keyboard shortcut: + /// the first invocation reveals/focuses TextBox and the next returns focus + /// to the terminal. + @discardableResult + func performFocusTextBoxInputShortcut(preferredWindow: NSWindow? = nil) -> Bool { + let targetWindow = preferredWindow ?? shortcutRoutingActiveWindow + if let dock = focusedDockStoreForShortcut( + action: .focusTextBoxInput, + preferredWindow: targetWindow + ) { + return dock.performShortcutCommand(.focusTextBoxInput) + } + return activeTabManagerForCommands(preferredWindow: targetWindow)? + .focusFocusedTerminalTextBoxInputOrTerminal() ?? false + } + /// Creates a New Terminal / New Browser surface in the focused Dock pane. /// Returns the created Dock panel id when handled, or `nil` to fall through to /// the main-area creation path. diff --git a/Sources/cmuxApp.swift b/Sources/cmuxApp.swift index 095236a0f313..78f99ffac09a 100644 --- a/Sources/cmuxApp.swift +++ b/Sources/cmuxApp.swift @@ -1075,6 +1075,15 @@ struct cmuxApp: App { } } + splitCommandButton( + title: String(localized: "shortcut.focusTextBoxInput.label", defaultValue: "Focus TextBox Input"), + shortcut: menuShortcut(for: .focusTextBoxInput) + ) { + _ = AppDelegate.shared?.performFocusTextBoxInputShortcut( + preferredWindow: NSApp.keyWindow ?? NSApp.mainWindow + ) + } + splitCommandButton(title: String(localized: "menu.view.toggleRightSidebar", defaultValue: "Toggle Right Sidebar"), shortcut: menuShortcut(for: .toggleRightSidebar)) { if AppDelegate.shared?.toggleRightSidebarInActiveMainWindow( preferredWindow: NSApp.keyWindow ?? NSApp.mainWindow