Add tab and workspace rename keyboard shortcuts (macOS) (#3280)

Adds configurable macOS shortcuts for renaming the active terminal tab and active workspace, with review follow-up fixes for conflict detection, sidebar reveal, lineage child rename surfaces, and floating workspace focus scoping.
This commit is contained in:
Andrii Valenia
2026-06-03 19:29:20 -04:00
committed by GitHub
parent d9f2d4ac6c
commit 2ba6f00db4
19 changed files with 891 additions and 129 deletions
+36 -2
View File
@@ -63,6 +63,7 @@ import {
isFloatingWorkspaceTerminalInputTarget,
shouldMinimizeFloatingWorkspacePanelOnCloseShortcut
} from '@/lib/floating-workspace-terminal-actions'
import { requestScrollToCurrentWorkspaceRevealAndRename } from '@/lib/scroll-to-current-workspace-status'
import { DictationController } from './components/dictation/DictationController'
import { WorkspacePortScanner } from './components/ports/WorkspacePortScanner'
import { CrashReportDialog } from './components/crash-report/CrashReportDialog'
@@ -1283,7 +1284,8 @@ function App(): React.JSX.Element {
// app-level mod shortcuts (B, L, Shift+E/F/G) have no panel-level
// counterpart, so suppressing them here would silently no-op when
// focus lives inside the floating panel.
if (isFloatingWorkspacePanelFocused()) {
const floatingWorkspaceFocused = isFloatingWorkspacePanelFocused()
if (floatingWorkspaceFocused) {
if (
isFloatingWorkspacePanelShortcut(e, shortcutPlatform, null, keybindings, {
context,
@@ -1302,6 +1304,37 @@ function App(): React.JSX.Element {
return
}
// Why: rename the active terminal tab. Cmd+R is free in the app/terminal
// focus zone because the browser pane owns its own Cmd+R reload and that
// focus never reaches this renderer-window handler. Only terminal tabs
// have an inline title editor, so other active tab types fall through.
if (workspaceActive && !floatingWorkspaceFocused && matchShortcut('tab.rename')) {
const store = useAppStore.getState()
if (store.activeTabType === 'terminal' && store.activeTabId) {
e.preventDefault()
notifyTerminalCapture('tab.rename')
store.setRenamingTabId(store.activeTabId)
return
}
}
// Why: open the active worktree's inline title editor. Open/reveal it
// first so the card is mounted and visible even when sidebar filters or
// collapse state would otherwise hide it.
if (
workspaceActive &&
!floatingWorkspaceFocused &&
matchShortcut('workspace.rename') &&
activeWorktreeId
) {
e.preventDefault()
notifyTerminalCapture('workspace.rename')
const store = useAppStore.getState()
store.setSidebarOpen(true)
requestScrollToCurrentWorkspaceRevealAndRename()
return
}
// Why: Cmd/Ctrl+N is handled via the main-process before-input-event
// allowlist (see window-shortcut-policy.ts / useIpcEvents.ts) so it works
// globally — including when focus lives inside the markdown rich editor
@@ -1394,7 +1427,8 @@ function App(): React.JSX.Element {
floatingVisibleTabCount,
keybindings,
settings?.terminalShortcutPolicy,
setFloatingTerminalOpenWithFocus
setFloatingTerminalOpenWithFocus,
workspaceActive
])
useLayoutEffect(() => {
@@ -157,6 +157,8 @@ const WorktreeCard = React.memo(function WorktreeCard({
const openModal = useAppStore((s) => s.openModal)
const openTaskPage = useAppStore((s) => s.openTaskPage)
const updateWorktreeMeta = useAppStore((s) => s.updateWorktreeMeta)
const renamingWorktreeId = useAppStore((s) => s.renamingWorktreeId)
const setRenamingWorktreeId = useAppStore((s) => s.setRenamingWorktreeId)
const fetchHostedReviewForBranch = useAppStore((s) => s.fetchHostedReviewForBranch)
const settings = useAppStore((s) => s.settings)
const fetchIssue = useAppStore((s) => s.fetchIssue)
@@ -858,6 +860,8 @@ const WorktreeCard = React.memo(function WorktreeCard({
titleWrapper={titleDetailsWrapper}
onEditingChange={setTitleRenaming}
onRename={handleRenameTitle}
beginEditing={renamingWorktreeId === worktree.id}
onBeginEditingConsumed={() => setRenamingWorktreeId(null)}
/>
{worktree.pendingFirstAgentMessageRename === true && !titleRenaming ? (
@@ -1,13 +1,20 @@
/* eslint-disable max-lines -- Why: WorktreeList render tests share expensive mocks so focused sidebar regressions can exercise the real component boundary. */
import React from 'react'
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it, vi } from 'vitest'
import { beforeAll, describe, expect, it, vi } from 'vitest'
import type { ProjectGroup, Repo, Worktree, WorktreeLineage } from '../../../../shared/types'
const mockStore = vi.hoisted(() => ({
state: {} as Record<string, unknown>
}))
type WorktreeListComponent = React.ComponentType<{
scrollOffsetRef: React.RefObject<number>
scrollAnchorRef: React.RefObject<unknown>
}>
let WorktreeList: WorktreeListComponent
vi.mock('@/store', () => {
const useAppStore = ((selector: (state: Record<string, unknown>) => unknown) =>
selector(mockStore.state)) as ((
@@ -82,6 +89,15 @@ vi.mock('./WorktreeCardAgents', () => ({
)
}))
vi.mock('./WorktreeTitleInlineRename', () => ({
WorktreeTitleInlineRename: ({ displayName }: { displayName: string }) =>
React.createElement('span', { 'data-worktree-title-inline-rename': '' }, displayName)
}))
vi.mock('./WorktreeActivityStatusIndicator', () => ({
WorktreeActivityStatusIndicator: () => React.createElement('span', { 'data-status-dot': true })
}))
vi.mock('./WorktreeContextMenu', () => ({
default: ({ children }: { children: React.ReactNode }) =>
React.createElement(React.Fragment, null, children),
@@ -270,9 +286,11 @@ function setLineageFixtureState(
runtimePaneTitlesByTabId: {},
setFilterRepoIds: vi.fn(),
setHideDefaultBranchWorkspace: vi.fn(),
setRenamingWorktreeId: vi.fn(),
setShowSleepingWorkspaces: vi.fn(),
setSortBy: vi.fn(),
settings: null,
renamingWorktreeId: null,
showSleepingWorkspaces: true,
sortBy: 'manual',
sortEpoch: 0,
@@ -342,9 +360,11 @@ function setProjectGroupWithoutWorktreeRowsState(filterRepoIds: string[] = []):
runtimePaneTitlesByTabId: {},
setFilterRepoIds: vi.fn(),
setHideDefaultBranchWorkspace: vi.fn(),
setRenamingWorktreeId: vi.fn(),
setShowSleepingWorkspaces: vi.fn(),
setSortBy: vi.fn(),
settings: null,
renamingWorktreeId: null,
showSleepingWorkspaces: true,
sortBy: 'recent',
sortEpoch: 0,
@@ -366,8 +386,6 @@ function setProjectGroupWithoutWorktreeRowsState(filterRepoIds: string[] = []):
}
async function renderWorktreeListMarkup(): Promise<string> {
const { default: WorktreeList } = await import('./WorktreeList')
return renderToStaticMarkup(
React.createElement(WorktreeList, {
scrollOffsetRef: { current: 0 },
@@ -377,6 +395,10 @@ async function renderWorktreeListMarkup(): Promise<string> {
}
describe('WorktreeList lineage child card renderer', () => {
beforeAll(async () => {
WorktreeList = (await import('./WorktreeList')).default as WorktreeListComponent
}, 20_000)
it('renders project group headers when repos import before worktree rows load', async () => {
setProjectGroupWithoutWorktreeRowsState()
const markup = await renderWorktreeListMarkup()
@@ -408,6 +430,14 @@ describe('WorktreeList lineage child card renderer', () => {
expect(agentRowIndex).toBeLessThan(childToggleIndex)
})
it('renders nested child titles through the inline rename surface', async () => {
setLineageFixtureState()
const markup = await renderWorktreeListMarkup()
expect(markup).toContain('data-worktree-title-inline-rename=""')
expect(markup).toContain('lineage child with agent')
})
it('nests the first-level child workspace card surface under its parent', async () => {
setLineageFixtureState()
const markup = await renderWorktreeListMarkup()
@@ -32,6 +32,7 @@ import WorktreeCard from './WorktreeCard'
import WorktreeCardAgents, {
SUPPRESS_WORKTREE_LIST_SCROLL_ADJUSTMENT_EVENT
} from './WorktreeCardAgents'
import { WorktreeTitleInlineRename } from './WorktreeTitleInlineRename'
import { SshDisconnectedDialog } from './SshDisconnectedDialog'
import { WorktreeCardStatusSlot } from './WorktreeCardStatusSlot'
import { Button } from '@/components/ui/button'
@@ -119,7 +120,10 @@ import {
import { activateAndRevealWorktree } from '@/lib/worktree-activation'
import { activateWorktreeFromSidebar } from '@/lib/sidebar-worktree-activation'
import { getShortcutPlatform } from '@/lib/shortcut-platform'
import { SCROLL_TO_CURRENT_WORKSPACE_REVEAL_REQUEST_EVENT } from '@/lib/scroll-to-current-workspace-status'
import {
SCROLL_TO_CURRENT_WORKSPACE_REVEAL_REQUEST_EVENT,
type ScrollToCurrentWorkspaceRevealRequestDetail
} from '@/lib/scroll-to-current-workspace-status'
import { useRepoHeaderDrag } from './project-header-drag'
import WorktreeContextMenu from './WorktreeContextMenu'
import {
@@ -765,6 +769,9 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp
const [highlightedRevealWorktreeId, setHighlightedRevealWorktreeId] = useState<string | null>(
null
)
const renamingWorktreeId = useAppStore((s) => s.renamingWorktreeId)
const setRenamingWorktreeId = useAppStore((s) => s.setRenamingWorktreeId)
const updateWorktreeMeta = useAppStore((s) => s.updateWorktreeMeta)
const worktreeDragSessionRef = useRef<WorktreeSidebarDragSession | null>(null)
const worktreePointerDragRef = useRef<WorktreePointerDrag | null>(null)
const worktreePointerAutoscrollFrameIdRef = useRef<number | null>(null)
@@ -1265,6 +1272,9 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp
if (pendingRevealWorktree.highlight) {
flashRevealedWorktree(pendingRevealWorktree.worktreeId)
}
if (pendingRevealWorktree.beginRename) {
setRenamingWorktreeId(pendingRevealWorktree.worktreeId)
}
pendingRevealRetryRef.current = null
clearPendingRevealWorktreeId()
return
@@ -1320,6 +1330,7 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp
projectGroups,
pendingRevealRetryTick,
flashRevealedWorktree,
setRenamingWorktreeId,
schedulePendingRevealFrame,
cancelPendingRevealFrames
])
@@ -3274,9 +3285,15 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp
/>
</span>
<div className="min-w-0 flex-1">
<div className="truncate text-[12px] leading-tight text-foreground">
{child.worktree.displayName}
</div>
<WorktreeTitleInlineRename
displayName={child.worktree.displayName}
className="text-[12px]"
onRename={(displayName) =>
updateWorktreeMeta(child.worktree.id, { displayName })
}
beginEditing={renamingWorktreeId === child.worktree.id}
onBeginEditingConsumed={() => setRenamingWorktreeId(null)}
/>
<div className="mt-1 flex min-w-0 items-center gap-1.5">
{child.repo && groupBy !== 'repo' ? (
<span className="flex h-[16px] shrink-0 items-center gap-1.5 rounded-[4px] border border-border bg-accent px-1.5 text-[10px] font-semibold leading-none text-foreground dark:bg-accent/50 dark:border-border/60">
@@ -4532,21 +4549,32 @@ const WorktreeList = React.memo(function WorktreeList({
}
}, [setShowSleepingWorkspaces, setFilterRepoIds, setHideDefaultBranchWorkspace, filterState])
const handleRevealCurrentWorkspaceRequest = useCallback(() => {
if (!activeWorktreeId) {
return
}
const activeWorktree = worktreeMap.get(activeWorktreeId)
if (!activeWorktree || activeWorktree.isArchived) {
return
}
if (!worktrees.some((worktree) => worktree.id === activeWorktreeId)) {
// Why: the toolbar action promises to reveal the current workspace; when
// sidebar filters hide it, relax those filters before queuing the reveal.
clearFilters()
}
revealWorktreeInSidebar(activeWorktreeId, { behavior: 'smooth', highlight: true })
}, [activeWorktreeId, clearFilters, revealWorktreeInSidebar, worktreeMap, worktrees])
const handleRevealCurrentWorkspaceRequest = useCallback(
(event: Event) => {
const detail =
event instanceof CustomEvent
? (event.detail as ScrollToCurrentWorkspaceRevealRequestDetail | undefined)
: undefined
if (!activeWorktreeId) {
return
}
const activeWorktree = worktreeMap.get(activeWorktreeId)
if (!activeWorktree || activeWorktree.isArchived) {
return
}
if (!worktrees.some((worktree) => worktree.id === activeWorktreeId)) {
// Why: the toolbar action promises to reveal the current workspace; when
// sidebar filters hide it, relax those filters before queuing the reveal.
clearFilters()
}
revealWorktreeInSidebar(activeWorktreeId, {
behavior: 'smooth',
highlight: true,
beginRename: detail?.beginRename === true
})
},
[activeWorktreeId, clearFilters, revealWorktreeInSidebar, worktreeMap, worktrees]
)
useEffect(() => {
window.addEventListener(
@@ -0,0 +1,155 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const reactHookRuntime = vi.hoisted(() => ({
states: [] as unknown[],
index: 0
}))
vi.mock('react', async () => {
const actual = await vi.importActual<typeof import('react')>('react') // eslint-disable-line @typescript-eslint/consistent-type-imports -- vi.importActual requires inline import()
return {
...actual,
useCallback<T>(callback: T) {
return callback
},
useEffect(effect: () => void | (() => void)) {
effect()
},
useRef<T>(initial: T) {
return { current: initial }
},
useState<T>(initial: T | (() => T)) {
const stateIndex = reactHookRuntime.index++
if (!(stateIndex in reactHookRuntime.states)) {
reactHookRuntime.states[stateIndex] =
typeof initial === 'function' ? (initial as () => T)() : initial
}
const setState = (next: T | ((previous: T) => T)): void => {
reactHookRuntime.states[stateIndex] =
typeof next === 'function'
? (next as (previous: T) => T)(reactHookRuntime.states[stateIndex] as T)
: next
}
return [reactHookRuntime.states[stateIndex] as T, setState] as const
}
}
})
vi.mock('lucide-react', () => ({
LoaderCircle: function LoaderCircle(props: Record<string, unknown>) {
return { type: 'LoaderCircle', props }
}
}))
vi.mock('@/components/ui/input', () => ({
Input: function Input(props: Record<string, unknown>) {
return { type: 'input', props }
}
}))
vi.mock('@/components/ui/tooltip', () => ({
Tooltip: function Tooltip(props: { children?: unknown }) {
return { type: 'Tooltip', props }
},
TooltipContent: function TooltipContent(props: { children?: unknown }) {
return { type: 'TooltipContent', props }
},
TooltipTrigger: function TooltipTrigger(props: { children?: unknown }) {
return props.children
}
}))
type ReactElementLike = {
type: unknown
props: Record<string, unknown>
}
async function renderTitleRename(props: {
beginEditing: boolean
disabled?: boolean
onBeginEditingConsumed: () => void
}): Promise<unknown> {
reactHookRuntime.index = 0
const module = await import('./WorktreeTitleInlineRename')
return module.WorktreeTitleInlineRename({
displayName: 'Feature workspace',
onRename: vi.fn(),
...props
})
}
function expandNode(node: unknown): unknown {
if (node == null || typeof node === 'string' || typeof node === 'number') {
return node
}
if (Array.isArray(node)) {
return node.map(expandNode)
}
const el = node as ReactElementLike
if (typeof el.type === 'function') {
return expandNode(el.type(el.props))
}
return {
...el,
props: {
...el.props,
children: expandNode(el.props?.children)
}
}
}
function findElementsByType(node: unknown, typeName: string): ReactElementLike[] {
const results: ReactElementLike[] = []
const visit = (current: unknown): void => {
if (current == null || typeof current === 'string' || typeof current === 'number') {
return
}
if (Array.isArray(current)) {
for (const child of current) {
visit(child)
}
return
}
const el = current as ReactElementLike
if (el.type === typeName) {
results.push(el)
}
visit(el.props?.children)
}
visit(node)
return results
}
describe('WorktreeTitleInlineRename beginEditing', () => {
beforeEach(() => {
reactHookRuntime.states = []
reactHookRuntime.index = 0
})
it('opens the inline input and consumes the parent trigger once', async () => {
const onBeginEditingConsumed = vi.fn()
await renderTitleRename({ beginEditing: true, onBeginEditingConsumed })
const rerender = expandNode(
await renderTitleRename({ beginEditing: false, onBeginEditingConsumed })
)
const inputs = findElementsByType(rerender, 'input')
expect(onBeginEditingConsumed).toHaveBeenCalledTimes(1)
expect(inputs).toHaveLength(1)
expect(inputs[0].props.value).toBe('Feature workspace')
expect(inputs[0].props['data-worktree-title-rename-input']).toBe('true')
})
it('still consumes the trigger when the title is disabled', async () => {
const onBeginEditingConsumed = vi.fn()
await renderTitleRename({ beginEditing: true, disabled: true, onBeginEditingConsumed })
const rerender = expandNode(
await renderTitleRename({ beginEditing: false, disabled: true, onBeginEditingConsumed })
)
expect(onBeginEditingConsumed).toHaveBeenCalledTimes(1)
expect(findElementsByType(rerender, 'input')).toHaveLength(0)
})
})
@@ -1,4 +1,4 @@
import React, { useCallback, useRef, useState } from 'react'
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { LoaderCircle } from 'lucide-react'
import { toast } from 'sonner'
import { Input } from '@/components/ui/input'
@@ -34,6 +34,11 @@ type WorktreeTitleInlineRenameProps = {
titleWrapper?: (title: React.ReactElement) => React.ReactElement
onEditingChange?: (editing: boolean) => void
onRename: (displayName: string) => Promise<void> | void
// Why: lets a parent (e.g. the workspace.rename shortcut via WorktreeCard)
// open the editor imperatively. The parent clears its trigger in
// onBeginEditingConsumed so the request fires exactly once.
beginEditing?: boolean
onBeginEditingConsumed?: () => void
}
export function WorktreeTitleInlineRename({
@@ -45,7 +50,9 @@ export function WorktreeTitleInlineRename({
inputClassName,
titleWrapper,
onEditingChange,
onRename
onRename,
beginEditing = false,
onBeginEditingConsumed
}: WorktreeTitleInlineRenameProps): React.JSX.Element {
const editingRef = useRef(false)
const savingRef = useRef(false)
@@ -124,6 +131,21 @@ export function WorktreeTitleInlineRename({
input.select()
}, [])
// Why: open the editor when a parent requests it (the workspace.rename
// shortcut). Always consume the request so the parent's trigger can't linger;
// skip the actual open when disabled or already editing.
useEffect(() => {
if (!beginEditing) {
return
}
onBeginEditingConsumed?.()
if (disabled || editing) {
return
}
setValue(displayName)
setEditing(true)
}, [beginEditing, disabled, editing, displayName, onBeginEditingConsumed])
const stopCardEvent = useCallback((event: React.SyntheticEvent) => {
event.stopPropagation()
}, [])
@@ -0,0 +1,262 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const reactHookRuntime = vi.hoisted(() => ({
states: [] as unknown[],
index: 0
}))
const storeState = vi.hoisted(() => ({
agentStatusByPaneKey: {},
clearTabLaunchAgent: vi.fn(),
ptyIdsByTabId: {} as Record<string, string[]>,
renamingTabId: null as string | null,
repos: [],
setRenamingTabId: vi.fn((tabId: string | null) => {
storeState.renamingTabId = tabId
}),
terminalLayoutsByTabId: {},
worktreesByRepo: {},
unreadTerminalTabs: {} as Record<string, boolean>
}))
vi.mock('react', async () => {
const actual = await vi.importActual<typeof import('react')>('react') // eslint-disable-line @typescript-eslint/consistent-type-imports -- vi.importActual requires inline import()
return {
...actual,
useCallback<T>(callback: T) {
return callback
},
useEffect(effect: () => void | (() => void)) {
effect()
},
useRef<T>(initial: T) {
return { current: initial }
},
useState<T>(initial: T | (() => T)) {
const stateIndex = reactHookRuntime.index++
if (!(stateIndex in reactHookRuntime.states)) {
reactHookRuntime.states[stateIndex] =
typeof initial === 'function' ? (initial as () => T)() : initial
}
const setState = (next: T | ((previous: T) => T)): void => {
reactHookRuntime.states[stateIndex] =
typeof next === 'function'
? (next as (previous: T) => T)(reactHookRuntime.states[stateIndex] as T)
: next
}
return [reactHookRuntime.states[stateIndex] as T, setState] as const
}
}
})
vi.mock('@dnd-kit/sortable', () => ({
useSortable: () => ({
attributes: {},
listeners: { onPointerDown: vi.fn() },
setNodeRef: vi.fn()
})
}))
vi.mock('lucide-react', () => ({
Columns2: function Columns2(props: Record<string, unknown>) {
return { type: 'Columns2', props }
},
Minimize2: function Minimize2(props: Record<string, unknown>) {
return { type: 'Minimize2', props }
},
Pin: function Pin(props: Record<string, unknown>) {
return { type: 'Pin', props }
},
PinOff: function PinOff(props: Record<string, unknown>) {
return { type: 'PinOff', props }
},
Rows2: function Rows2(props: Record<string, unknown>) {
return { type: 'Rows2', props }
},
X: function X(props: Record<string, unknown>) {
return { type: 'X', props }
}
}))
vi.mock('@/components/ui/dropdown-menu', () => ({
DropdownMenu: function DropdownMenu(props: { children?: unknown }) {
return { type: 'DropdownMenu', props }
},
DropdownMenuContent: function DropdownMenuContent(props: { children?: unknown }) {
return { type: 'DropdownMenuContent', props }
},
DropdownMenuItem: function DropdownMenuItem(props: { children?: unknown }) {
return { type: 'DropdownMenuItem', props }
},
DropdownMenuSeparator: function DropdownMenuSeparator() {
return { type: 'DropdownMenuSeparator', props: {} }
},
DropdownMenuTrigger: function DropdownMenuTrigger(props: { children?: unknown }) {
return props.children
}
}))
vi.mock('@/components/ui/input', () => ({
Input: function Input(props: Record<string, unknown>) {
return { type: 'input', props }
}
}))
vi.mock('@/components/ui/tooltip', () => ({
Tooltip: function Tooltip(props: { children?: unknown }) {
return { type: 'Tooltip', props }
},
TooltipContent: function TooltipContent(props: { children?: unknown }) {
return { type: 'TooltipContent', props }
},
TooltipTrigger: function TooltipTrigger(props: { children?: unknown }) {
return props.children
}
}))
vi.mock('./shell-icons', () => ({
ShellIcon: function ShellIcon(props: Record<string, unknown>) {
return { type: 'ShellIcon', props }
}
}))
vi.mock('../sidebar/WorktreeCardHelpers', () => ({
FilledBellIcon: function FilledBellIcon(props: Record<string, unknown>) {
return { type: 'FilledBellIcon', props }
}
}))
vi.mock('./drop-indicator', () => ({
ACTIVE_TAB_INDICATOR_CLASSES: 'active-tab-indicator',
getDropIndicatorClasses: () => '',
getTabRootStateClasses: () => ''
}))
vi.mock('./middle-button-default-guard', () => ({
preventMiddleButtonDefault: vi.fn()
}))
vi.mock('@/store', () => ({
useAppStore: (selector: (state: typeof storeState) => unknown) => selector(storeState)
}))
type ReactElementLike = {
type: unknown
props: Record<string, unknown>
}
function makeTerminalTab() {
return {
id: 'terminal-tab-1',
title: 'Runtime terminal title',
customTitle: null,
type: 'terminal',
worktreeId: 'wt-1',
createdAt: 0
}
}
async function renderSortableTab(): Promise<unknown> {
reactHookRuntime.index = 0
const module = await import('./SortableTab')
return module.default({
tab: makeTerminalTab() as never,
tabCount: 1,
hasTabsToRight: false,
isActive: true,
isPinned: false,
isExpanded: false,
onActivate: vi.fn(),
onClose: vi.fn(),
onCloseOthers: vi.fn(),
onCloseToRight: vi.fn(),
onSetCustomTitle: vi.fn(),
onSetTabColor: vi.fn(),
onTogglePin: vi.fn(),
onToggleExpand: vi.fn(),
onSplitGroup: vi.fn(),
dragData: {
kind: 'tab',
worktreeId: 'wt-1',
groupId: 'group-1',
unifiedTabId: 'terminal-tab-1',
visibleTabId: 'terminal-tab-1',
tabType: 'terminal',
label: 'Runtime terminal title'
}
})
}
function expandNode(node: unknown): unknown {
if (node == null || typeof node === 'string' || typeof node === 'number') {
return node
}
if (Array.isArray(node)) {
return node.map(expandNode)
}
const el = node as ReactElementLike
if (typeof el.type === 'function') {
return expandNode(el.type(el.props))
}
return {
...el,
props: {
...el.props,
children: expandNode(el.props?.children)
}
}
}
function findElementsByType(node: unknown, typeName: string): ReactElementLike[] {
const results: ReactElementLike[] = []
const visit = (current: unknown): void => {
if (current == null || typeof current === 'string' || typeof current === 'number') {
return
}
if (Array.isArray(current)) {
for (const child of current) {
visit(child)
}
return
}
const el = current as ReactElementLike
if (el.type === typeName) {
results.push(el)
}
visit(el.props?.children)
}
visit(node)
return results
}
describe('SortableTab rename shortcut signal', () => {
beforeEach(() => {
reactHookRuntime.states = []
reactHookRuntime.index = 0
storeState.renamingTabId = 'terminal-tab-1'
storeState.unreadTerminalTabs = {}
storeState.clearTabLaunchAgent.mockClear()
storeState.setRenamingTabId.mockClear()
vi.stubGlobal('window', {
addEventListener: vi.fn(),
removeEventListener: vi.fn()
})
vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {
callback(0)
return 1
})
vi.stubGlobal('cancelAnimationFrame', vi.fn())
})
it('opens the inline rename input and consumes the matching store signal', async () => {
await renderSortableTab()
const rerender = expandNode(await renderSortableTab())
const inputs = findElementsByType(rerender, 'input')
expect(storeState.setRenamingTabId).toHaveBeenCalledWith(null)
expect(storeState.renamingTabId).toBeNull()
expect(inputs).toHaveLength(1)
expect(inputs[0].props.value).toBe('Runtime terminal title')
expect(inputs[0].props['data-tab-rename-input']).toBe('true')
})
})
@@ -1,17 +1,10 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { useSortable } from '@dnd-kit/sortable'
import { X, Minimize2, Columns2, Rows2, Pin, PinOff } from 'lucide-react'
import { X, Minimize2, Pin } from 'lucide-react'
import { ShellIcon } from './shell-icons'
import { AgentIcon } from '@/lib/agent-catalog'
import { stripLeadingAgentTitleDecoration } from '@/lib/agent-title-decoration'
import { useTabAgent } from '@/lib/use-tab-agent'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import { Input } from '@/components/ui/input'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import type { TerminalTab } from '../../../../shared/types'
@@ -25,6 +18,7 @@ import {
type DropIndicator
} from './drop-indicator'
import { preventMiddleButtonDefault } from './middle-button-default-guard'
import { SortableTabContextMenu } from './SortableTabContextMenu'
type SortableTabProps = {
tab: TerminalTab
@@ -46,19 +40,6 @@ type SortableTabProps = {
dropIndicator?: DropIndicator
}
export const TAB_COLORS = [
{ label: 'None', value: null },
{ label: 'Blue', value: '#3b82f6' },
{ label: 'Purple', value: '#a855f7' },
{ label: 'Pink', value: '#ec4899' },
{ label: 'Red', value: '#ef4444' },
{ label: 'Orange', value: '#f97316' },
{ label: 'Yellow', value: '#eab308' },
{ label: 'Green', value: '#22c55e' },
{ label: 'Teal', value: '#14b8a6' },
{ label: 'Gray', value: '#9ca3af' }
]
export const CLOSE_ALL_CONTEXT_MENUS_EVENT = 'orca-close-all-context-menus'
export default function SortableTab({
@@ -85,6 +66,8 @@ export default function SortableTab({
// map in TabBar would invalidate every SortableTab on every bell event
// because the slice returns a fresh object reference on each mark/clear.
const hasUnreadActivity = useAppStore((s) => s.unreadTerminalTabs[tab.id] === true)
const renamingTabId = useAppStore((s) => s.renamingTabId)
const setRenamingTabId = useAppStore((s) => s.setRenamingTabId)
// Why: createTab stamps the shell used at creation time, so changing the
// default shell later does not repaint existing tabs as a different shell.
@@ -170,6 +153,17 @@ export default function SortableTab({
})
}, [])
// Why: the tab.rename shortcut can't reach this component's local editing
// state directly, so it sets renamingTabId in the store; the matching tab
// opens its editor and immediately clears the flag so it fires once.
useEffect(() => {
if (renamingTabId !== tab.id) {
return
}
handleRenameOpen()
setRenamingTabId(null)
}, [renamingTabId, tab.id, handleRenameOpen, setRenamingTabId])
useEffect(() => {
const closeMenu = (): void => setMenuOpen(false)
window.addEventListener(CLOSE_ALL_CONTEXT_MENUS_EVENT, closeMenu)
@@ -425,85 +419,22 @@ export default function SortableTab({
)}
</div>
<DropdownMenu open={menuOpen} onOpenChange={setMenuOpen} modal={false}>
<DropdownMenuTrigger asChild>
<button
aria-hidden
tabIndex={-1}
className="pointer-events-none fixed size-px opacity-0"
style={{ left: menuPoint.x, top: menuPoint.y }}
/>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-48" sideOffset={0} align="start">
<DropdownMenuItem onSelect={() => onSplitGroup('up', tab.id)}>
<Rows2 className="mr-1.5 size-3.5" />
Split Up
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onSplitGroup('down', tab.id)}>
<Rows2 className="mr-1.5 size-3.5" />
Split Down
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onSplitGroup('left', tab.id)}>
<Columns2 className="mr-1.5 size-3.5" />
Split Left
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onSplitGroup('right', tab.id)}>
<Columns2 className="mr-1.5 size-3.5" />
Split Right
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={onTogglePin}>
{isPinned ? (
<PinOff className="mr-1.5 size-3.5" />
) : (
<Pin className="mr-1.5 size-3.5" />
)}
{isPinned ? 'Unpin Tab' : 'Pin Tab'}
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={() => !isPinned && onClose(tab.id)} disabled={isPinned}>
Close
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onCloseOthers(tab.id)} disabled={tabCount <= 1}>
Close Others
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onCloseToRight(tab.id)} disabled={!hasTabsToRight}>
Close Tabs To The Right
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={handleRenameOpen}>Change Title</DropdownMenuItem>
<div className="px-2 pt-1.5 pb-1">
<div className="text-xs font-medium text-muted-foreground mb-1.5">Tab Color</div>
<div className="flex flex-wrap gap-2">
{TAB_COLORS.map((color) => {
const isSelected = tab.color === color.value
return (
<DropdownMenuItem
key={color.label}
className={`relative h-4 w-4 min-w-4 p-0 rounded-full border ${
isSelected
? 'ring-1 ring-foreground/70 ring-offset-1 ring-offset-popover'
: ''
} ${
color.value
? 'border-transparent'
: 'border-muted-foreground/50 bg-transparent'
}`}
style={color.value ? { backgroundColor: color.value } : undefined}
onSelect={() => {
onSetTabColor(tab.id, color.value)
}}
>
{color.value === null && (
<span className="absolute block h-px w-3 rotate-45 bg-muted-foreground/80" />
)}
</DropdownMenuItem>
)
})}
</div>
</div>
</DropdownMenuContent>
</DropdownMenu>
<SortableTabContextMenu
tab={tab}
open={menuOpen}
point={menuPoint}
tabCount={tabCount}
hasTabsToRight={hasTabsToRight}
isPinned={isPinned}
onOpenChange={setMenuOpen}
onClose={onClose}
onCloseOthers={onCloseOthers}
onCloseToRight={onCloseToRight}
onRenameOpen={handleRenameOpen}
onSetTabColor={onSetTabColor}
onTogglePin={onTogglePin}
onSplitGroup={onSplitGroup}
/>
</>
)
}
@@ -0,0 +1,130 @@
import { Columns2, Pin, PinOff, Rows2 } from 'lucide-react'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import type { TerminalTab } from '../../../../shared/types'
const TAB_COLORS = [
{ label: 'None', value: null },
{ label: 'Blue', value: '#3b82f6' },
{ label: 'Purple', value: '#a855f7' },
{ label: 'Pink', value: '#ec4899' },
{ label: 'Red', value: '#ef4444' },
{ label: 'Orange', value: '#f97316' },
{ label: 'Yellow', value: '#eab308' },
{ label: 'Green', value: '#22c55e' },
{ label: 'Teal', value: '#14b8a6' },
{ label: 'Gray', value: '#9ca3af' }
] as const
type SortableTabContextMenuProps = {
tab: TerminalTab
open: boolean
point: { x: number; y: number }
tabCount: number
hasTabsToRight: boolean
isPinned: boolean
onOpenChange: (open: boolean) => void
onClose: (tabId: string) => void
onCloseOthers: (tabId: string) => void
onCloseToRight: (tabId: string) => void
onRenameOpen: () => void
onSetTabColor: (tabId: string, color: string | null) => void
onTogglePin: () => void
onSplitGroup: (direction: 'left' | 'right' | 'up' | 'down', sourceVisibleTabId: string) => void
}
export function SortableTabContextMenu({
tab,
open,
point,
tabCount,
hasTabsToRight,
isPinned,
onOpenChange,
onClose,
onCloseOthers,
onCloseToRight,
onRenameOpen,
onSetTabColor,
onTogglePin,
onSplitGroup
}: SortableTabContextMenuProps): React.JSX.Element {
return (
<DropdownMenu open={open} onOpenChange={onOpenChange} modal={false}>
<DropdownMenuTrigger asChild>
<button
aria-hidden
tabIndex={-1}
className="pointer-events-none fixed size-px opacity-0"
style={{ left: point.x, top: point.y }}
/>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-48" sideOffset={0} align="start">
<DropdownMenuItem onSelect={() => onSplitGroup('up', tab.id)}>
<Rows2 className="mr-1.5 size-3.5" />
Split Up
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onSplitGroup('down', tab.id)}>
<Rows2 className="mr-1.5 size-3.5" />
Split Down
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onSplitGroup('left', tab.id)}>
<Columns2 className="mr-1.5 size-3.5" />
Split Left
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onSplitGroup('right', tab.id)}>
<Columns2 className="mr-1.5 size-3.5" />
Split Right
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={onTogglePin}>
{isPinned ? <PinOff className="mr-1.5 size-3.5" /> : <Pin className="mr-1.5 size-3.5" />}
{isPinned ? 'Unpin Tab' : 'Pin Tab'}
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={() => !isPinned && onClose(tab.id)} disabled={isPinned}>
Close
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onCloseOthers(tab.id)} disabled={tabCount <= 1}>
Close Others
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onCloseToRight(tab.id)} disabled={!hasTabsToRight}>
Close Tabs To The Right
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={onRenameOpen}>Change Title</DropdownMenuItem>
<div className="px-2 pt-1.5 pb-1">
<div className="text-xs font-medium text-muted-foreground mb-1.5">Tab Color</div>
<div className="flex flex-wrap gap-2">
{TAB_COLORS.map((color) => {
const isSelected = tab.color === color.value
return (
<DropdownMenuItem
key={color.label}
className={`relative h-4 w-4 min-w-4 p-0 rounded-full border ${
isSelected ? 'ring-1 ring-foreground/70 ring-offset-1 ring-offset-popover' : ''
} ${
color.value ? 'border-transparent' : 'border-muted-foreground/50 bg-transparent'
}`}
style={color.value ? { backgroundColor: color.value } : undefined}
onSelect={() => {
onSetTabColor(tab.id, color.value)
}}
>
{color.value === null && (
<span className="absolute block h-px w-3 rotate-45 bg-muted-foreground/80" />
)}
</DropdownMenuItem>
)
})}
</div>
</div>
</DropdownMenuContent>
</DropdownMenu>
)
}
@@ -1,9 +1,25 @@
export const SCROLL_TO_CURRENT_WORKSPACE_REVEAL_REQUEST_EVENT =
'orca-scroll-to-current-workspace-reveal-request'
export function requestScrollToCurrentWorkspaceReveal(): void {
export type ScrollToCurrentWorkspaceRevealRequestDetail = {
beginRename?: boolean
}
function dispatchScrollToCurrentWorkspaceReveal(
detail?: ScrollToCurrentWorkspaceRevealRequestDetail
): void {
if (typeof window === 'undefined') {
return
}
window.dispatchEvent(new Event(SCROLL_TO_CURRENT_WORKSPACE_REVEAL_REQUEST_EVENT))
window.dispatchEvent(
new CustomEvent(SCROLL_TO_CURRENT_WORKSPACE_REVEAL_REQUEST_EVENT, { detail })
)
}
export function requestScrollToCurrentWorkspaceReveal(): void {
dispatchScrollToCurrentWorkspaceReveal()
}
export function requestScrollToCurrentWorkspaceRevealAndRename(): void {
dispatchScrollToCurrentWorkspaceReveal({ beginRename: true })
}
@@ -113,6 +113,14 @@ describe('TabsSlice', () => {
store = createTestStore()
})
it('setRenamingTabId sets and clears the tab rename signal', () => {
expect(store.getState().renamingTabId).toBeNull()
store.getState().setRenamingTabId('terminal-tab-1')
expect(store.getState().renamingTabId).toBe('terminal-tab-1')
store.getState().setRenamingTabId(null)
expect(store.getState().renamingTabId).toBeNull()
})
// ─── createUnifiedTab ───────────────────────────────────────────────
describe('createUnifiedTab', () => {
+9
View File
@@ -34,6 +34,9 @@ export type TabSplitDirection = 'left' | 'right' | 'up' | 'down'
export type TabsSlice = {
unifiedTabsByWorktree: Record<string, Tab[]>
// Why: signals the matching tab's inline title editor to open. A global
// keyboard shortcut (tab.rename) sets this; the tab clears it on consume.
renamingTabId: string | null
groupsByWorktree: Record<string, TabGroup[]>
activeGroupIdByWorktree: Record<string, string>
layoutByWorktree: Record<string, TabGroupLayoutNode>
@@ -83,6 +86,7 @@ export type TabsSlice = {
opts?: { recordInteraction?: boolean }
) => void
setUnifiedTabColor: (tabId: string, color: string | null) => void
setRenamingTabId: (tabId: string | null) => void
pinTab: (tabId: string) => void
unpinTab: (tabId: string) => void
closeOtherTabs: (tabId: string) => string[]
@@ -430,6 +434,7 @@ function buildActiveSurfacePatch(
export const createTabsSlice: StateCreator<AppState, [], [], TabsSlice> = (set, get) => ({
unifiedTabsByWorktree: {},
renamingTabId: null,
groupsByWorktree: {},
activeGroupIdByWorktree: {},
layoutByWorktree: {},
@@ -782,6 +787,10 @@ export const createTabsSlice: StateCreator<AppState, [], [], TabsSlice> = (set,
set((state) => patchTab(state.unifiedTabsByWorktree, tabId, { label }) ?? {})
},
setRenamingTabId: (tabId) => {
set({ renamingTabId: tabId })
},
setTabCustomLabel: (tabId, label, opts) => {
const exists = get().getTab(tabId) !== null
set((state) => patchTab(state.unifiedTabsByWorktree, tabId, { customLabel: label }) ?? {})
+17
View File
@@ -691,6 +691,23 @@ describe('createUISlice hydratePersistedUI', () => {
expect(store.getState().rightSidebarWidth).toBe(900)
})
it('stores pending sidebar reveal rename requests', () => {
const store = createUIStore()
store.getState().revealWorktreeInSidebar('repo1::/feature', {
behavior: 'smooth',
highlight: true,
beginRename: true
})
expect(store.getState().pendingRevealWorktree).toEqual({
worktreeId: 'repo1::/feature',
behavior: 'smooth',
highlight: true,
beginRename: true
})
})
it('falls back to existing sidebar widths when persisted values are not finite', () => {
const store = createUIStore()
+4 -1
View File
@@ -92,6 +92,7 @@ export type PendingSidebarWorktreeReveal = {
worktreeId: string
behavior: 'auto' | 'smooth'
highlight?: boolean
beginRename?: boolean
}
export type AgentSendPopoverTargetMode = {
@@ -777,6 +778,7 @@ export type UISlice = {
options?: {
behavior?: PendingSidebarWorktreeReveal['behavior']
highlight?: boolean
beginRename?: boolean
}
) => void
clearPendingRevealWorktreeId: () => void
@@ -1813,7 +1815,8 @@ export const createUISlice: StateCreator<AppState, [], [], UISlice> = (set, get)
pendingRevealWorktree: {
worktreeId,
behavior: options?.behavior ?? 'smooth',
...(options?.highlight ? { highlight: true } : {})
...(options?.highlight ? { highlight: true } : {}),
...(options?.beginRename ? { beginRename: true } : {})
}
}),
clearPendingRevealWorktreeId: () => set({ pendingRevealWorktree: null }),
@@ -37,6 +37,9 @@ export type WorktreeSlice = {
detectedWorktreesByRepo: Record<string, DetectedWorktreeListResult>
worktreeLineageById: Record<string, WorktreeLineage>
activeWorktreeId: string | null
// Why: signals the matching worktree card's inline title editor to open. The
// workspace.rename shortcut sets this; the card clears it on consume.
renamingWorktreeId: string | null
deleteStateByWorktreeId: Record<string, WorktreeDeleteState>
baseStatusByWorktreeId: Record<string, WorktreeBaseStatusEvent>
remoteBranchConflictByWorktreeId: Record<string, WorktreeRemoteBranchConflictEvent>
@@ -164,6 +167,7 @@ export type WorktreeSlice = {
*/
seedActiveWorktreeLastVisitedIfMissing: () => void
setActiveWorktree: (worktreeId: string | null) => void
setRenamingWorktreeId: (worktreeId: string | null) => void
allWorktrees: () => Worktree[]
getKnownWorktreeById: (worktreeId: string) => Worktree | DetectedWorktree | undefined
/**
@@ -3117,6 +3117,20 @@ describe('markWorktreeVisited', () => {
})
})
describe('setRenamingWorktreeId', () => {
it('sets and clears the workspace rename signal', () => {
const store = createTestStore()
expect(store.getState().renamingWorktreeId).toBeNull()
store.getState().setRenamingWorktreeId('repo1::/feature')
expect(store.getState().renamingWorktreeId).toBe('repo1::/feature')
store.getState().setRenamingWorktreeId(null)
expect(store.getState().renamingWorktreeId).toBeNull()
})
})
describe('setWorktreesPinnedAndReveal', () => {
beforeEach(() => {
vi.clearAllMocks()
@@ -690,6 +690,7 @@ export const createWorktreeSlice: StateCreator<AppState, [], [], WorktreeSlice>
detectedWorktreesByRepo: {},
worktreeLineageById: {},
activeWorktreeId: null,
renamingWorktreeId: null,
deleteStateByWorktreeId: {},
baseStatusByWorktreeId: {},
remoteBranchConflictByWorktreeId: {},
@@ -2014,6 +2015,10 @@ export const createWorktreeSlice: StateCreator<AppState, [], [], WorktreeSlice>
})
},
setRenamingWorktreeId: (worktreeId) => {
set({ renamingWorktreeId: worktreeId })
},
setActiveWorktree: (worktreeId) => {
if (worktreeId && shouldDeferActivationTerminalPrep()) {
markInputQuietSchedulerInput()
+56
View File
@@ -152,6 +152,62 @@ describe('keybindings', () => {
})
})
it('defines macOS-only rename shortcuts that stay conflict-free', () => {
expect(getEffectiveKeybindingsForAction('tab.rename', 'darwin')).toEqual(['Mod+R'])
expect(getEffectiveKeybindingsForAction('tab.rename', 'linux')).toEqual([])
expect(getEffectiveKeybindingsForAction('tab.rename', 'win32')).toEqual([])
expect(getEffectiveKeybindingsForAction('workspace.rename', 'darwin')).toEqual(['Mod+Alt+R'])
expect(getEffectiveKeybindingsForAction('workspace.rename', 'linux')).toEqual([])
expect(formatKeybindingList(['Mod+Alt+R'], 'darwin')).toBe('⌘⌥R')
expect(
keybindingMatchesAction(
'tab.rename',
{
key: 'r',
code: 'KeyR',
meta: true,
control: false,
alt: false,
shift: false
},
'darwin'
)
).toBe(true)
expect(
keybindingMatchesAction(
'tab.rename',
{
key: 'r',
code: 'KeyR',
meta: false,
control: true,
alt: false,
shift: false
},
'linux'
)
).toBe(false)
// Why: tab.rename (Mod+R) intentionally shares its binding with
// browser.reload, but the two live in different scopes (tabs vs browser),
// so customizing tab.rename to its default must not flag a conflict.
expect(findKeybindingConflicts('darwin', { 'tab.rename': ['Mod+R'] })).toEqual([])
// Why: tab/workspace rename share the same active workspace keydown path,
// so Settings must reject user overrides that make one shadow the other.
expect(findKeybindingConflicts('darwin', { 'workspace.rename': ['Mod+R'] })).toEqual([
{
binding: 'Mod+R',
actionIds: ['workspace.rename', 'tab.rename']
}
])
expect(findKeybindingConflicts('darwin', { 'tab.rename': ['Mod+Alt+R'] })).toEqual([
{
binding: 'Mod+Alt+R',
actionIds: ['workspace.rename', 'tab.rename']
}
])
})
it('keeps equalize pane sizes unassigned until users customize it', () => {
expect(getEffectiveKeybindingsForAction('terminal.equalizePaneSizes', 'darwin')).toEqual([])
expect(
+34
View File
@@ -31,6 +31,7 @@ export type KeybindingActionId =
| 'app.forceReload'
| 'file.exportPdf'
| 'workspace.create'
| 'workspace.rename'
| 'workspace.delete'
| 'voice.dictation'
| 'view.tasks'
@@ -53,6 +54,7 @@ export type KeybindingActionId =
| 'tab.newMarkdown'
| 'tab.openMarkdown'
| 'tab.close'
| 'tab.rename'
| 'tab.reopenClosed'
| 'tab.nextSameType'
| 'tab.previousSameType'
@@ -230,6 +232,22 @@ export const KEYBINDING_DEFINITIONS: readonly KeybindingDefinition[] = [
searchKeywords: ['shortcut', 'global', 'worktree', 'create', 'new workspace'],
defaultBindings: platformBindings(['Mod+N', 'Mod+Shift+N'])
},
{
id: 'workspace.rename',
title: 'Rename worktree',
group: 'Global',
scope: 'global',
conflictGroup: 'workspace-shell',
searchKeywords: ['shortcut', 'global', 'worktree', 'rename', 'workspace', 'title'],
// Why: macOS only. On Windows/Linux Ctrl+Alt+R has no safe default, and the
// chord families there (Ctrl+R reverse-search, Ctrl+Shift+R reload) are
// taken, so users bind it explicitly in Settings.
defaultBindings: {
darwin: ['Mod+Alt+R'],
linux: [],
win32: []
}
},
{
id: 'workspace.delete',
title: 'Delete Workspace',
@@ -425,6 +443,22 @@ export const KEYBINDING_DEFINITIONS: readonly KeybindingDefinition[] = [
searchKeywords: ['shortcut', 'close', 'tab', 'pane'],
defaultBindings: platformBindings(['Mod+W'])
},
{
id: 'tab.rename',
title: 'Rename active tab',
group: 'Tabs',
scope: 'tabs',
conflictGroup: 'workspace-shell',
searchKeywords: ['shortcut', 'tab', 'rename', 'title', 'label'],
// Why: macOS only. Cmd+R is free in the app/terminal focus zone (the
// browser pane owns its own Cmd+R reload). On Windows/Linux Ctrl+R is the
// shell reverse-search, so it is left unbound for explicit user binding.
defaultBindings: {
darwin: ['Mod+R'],
linux: [],
win32: []
}
},
{
id: 'tab.reopenClosed',
title: 'Reopen closed tab',