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
5 changes: 3 additions & 2 deletions src/renderer/src/components/cmd-j/quick-action-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '@/components/native-chat/native-chat-layout-actions'
import type { NativeChatSplitDirection } from '@/components/native-chat/native-chat-split-shortcut'
import { selectWorktreesByRepo } from '@/store/workspace-record-selectors'
import type { TabSplitDirection } from '@/store/slices/tabs/tabs-slice-contract'

export type CmdJUnavailableReason =
| 'loading'
Expand Down Expand Up @@ -38,7 +39,7 @@ export type CmdJQuickActionContext = {
runtimeMode: 'local-desktop' | 'paired-web'
managedBrowserCreationEnabled?: boolean
activeGroupId: string | null
openNewBrowserTab: (groupId: string) => Promise<void>
openNewBrowserTab: (groupId: string, splitDirection?: TabSplitDirection) => Promise<void>
openBrowserUrl: (groupId: string, url: string) => Promise<void>
openNewMarkdownFile: (groupId: string) => Promise<void>
openNewTerminalTab: (groupId: string) => Promise<void>
Expand Down Expand Up @@ -152,7 +153,7 @@ export function getCurrentWorkspaceActionAvailability(
export function buildCmdJQuickActionContext(args: {
state: AppState
activeGroupSnapshot: CmdJActiveGroupSnapshot | null
openNewBrowserTab: (groupId: string) => Promise<void>
openNewBrowserTab: (groupId: string, splitDirection?: TabSplitDirection) => Promise<void>
openBrowserUrl: (groupId: string, url: string) => Promise<void>
openNewMarkdownFile: (groupId: string) => Promise<void>
openNewTerminalTab: (groupId: string) => Promise<void>
Expand Down
31 changes: 30 additions & 1 deletion src/renderer/src/components/cmd-j/quick-actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { FileText, FolderPlus, Globe, Play, SquareTerminal, Trash2 } from 'lucide-react'
import {
FileText,
FolderPlus,
Globe,
PanelRightClose,
Play,
SquareTerminal,
Trash2
} from 'lucide-react'
import type { LucideIcon } from 'lucide-react'
import type { CmdJQuickActionAvailability, CmdJQuickActionContext } from './quick-action-context'
import {
Expand Down Expand Up @@ -88,6 +96,27 @@ export const getCmdJQuickActions = createLocalizedCatalog((): CmdJQuickAction[]
isAvailable: getBrowserWorkspaceActionAvailability,
run: (ctx) => runBrowserWorkspaceAction(ctx, ctx.openNewBrowserTab)
},
{
id: 'new-browser-tab-split-right',
kind: 'action',
title: translate(
'auto.components.cmd.j.quick.actions.newBrowserTabSplitRight',
'New Browser Tab in Right Split'
),
description: translate(
'auto.components.cmd.j.quick.actions.newBrowserTabSplitRightDescription',
'Open a browser tab in a new split to the right.'
),
icon: PanelRightClose,
verbKeywords: [
translate('auto.components.cmd.j.quick.actions.verbs.browserRight', 'browser right'),
translate('auto.components.cmd.j.quick.actions.verbs.splitBrowser', 'split browser'),
translate('auto.components.cmd.j.quick.actions.verbs.browserSplit', 'browser split')
],
isAvailable: getBrowserWorkspaceActionAvailability,
run: (ctx) =>
runBrowserWorkspaceAction(ctx, (groupId) => ctx.openNewBrowserTab(groupId, 'right'))
},
{
id: 'new-markdown-file',
kind: 'action',
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/components/settings/keybinding-title-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const STATIC_TITLE_COPY = {
'tab.newTerminal': () => translate('keybindings.title.tabNewTerminal', 'New terminal tab'),
'tab.newAgent': () => translate('keybindings.title.tabNewAgent', 'New agent tab (default agent)'),
'tab.newBrowser': () => translate('keybindings.title.tabNewBrowser', 'New browser tab'),
'tab.newBrowserSplitRight': () =>
translate('keybindings.title.tabNewBrowserSplitRight', 'New browser tab in right split'),
'tab.newSimulator': () =>
translate('keybindings.title.tabNewSimulator', 'New mobile emulator tab'),
'tab.newMarkdown': () => translate('keybindings.title.tabNewMarkdown', 'New markdown tab'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export function buildShortcutRowVisibility(options: {
rows: group.items
.filter(
(item) =>
(options.managedBrowserCreationEnabled || item.id !== 'tab.newBrowser') &&
(options.managedBrowserCreationEnabled ||
(item.id !== 'tab.newBrowser' && item.id !== 'tab.newBrowserSplitRight')) &&
(options.mobileEmulatorCreationEnabled || item.id !== 'tab.newSimulator') &&
// Binding an experimental action while disabled would silently do nothing.
(options.agentDashboardEnabled || item.id !== 'dashboard.toggle')
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/components/settings/shortcuts-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export function getShortcutsPaneSearchEntries(options?: {
...getShortcutDefinitionSearchEntries()
.filter(
({ actionId }) =>
(includeManagedBrowser || actionId !== 'tab.newBrowser') &&
(includeManagedBrowser ||
(actionId !== 'tab.newBrowser' && actionId !== 'tab.newBrowserSplitRight')) &&
(includeMobileEmulator || actionId !== 'tab.newSimulator')
)
.map(({ searchEntry }) => searchEntry),
Expand Down
12 changes: 12 additions & 0 deletions src/renderer/src/components/terminal-workspace-keydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function handleTerminalWorkspaceKeyDown(
activeWorktreeId,
handleCloseAllFiles,
handleNewBrowserTab,
handleNewBrowserTabSplitRight,
handleNewFile,
handleNewSimulatorTab,
handleNewTab,
Expand Down Expand Up @@ -134,6 +135,17 @@ export function handleTerminalWorkspaceKeyDown(
handleNewBrowserTab()
return
}
if (!event.repeat && matchShortcut('tab.newBrowserSplitRight')) {
event.preventDefault()
notifyTerminalCapture('tab.newBrowserSplitRight')
if (
!floatingWorkspaceFocused &&
ensureClientCreationActionAllowed(activeWorktreeId, 'managed-browser')
) {
handleNewBrowserTabSplitRight()
}
return
}
if (!event.repeat && mobileEmulatorEnabled && matchShortcut('tab.newSimulator')) {
event.preventDefault()
notifyTerminalCapture('tab.newSimulator')
Expand Down
82 changes: 48 additions & 34 deletions src/renderer/src/components/use-terminal-create-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { openTabBarEntry, type TabCreateEntryArgs } from './tab-bar/tab-create-e
import { translate } from '@/i18n/i18n'
import { getActiveWorktreeRuntimeEnvironmentId } from './terminal-workspace-model'
import type { TerminalColdActivationController } from './terminal-cold-activation'
import type { TabSplitDirection } from '@/store/slices/tabs/tabs-slice-contract'

export function useTerminalCreateActions(controller: TerminalColdActivationController) {
const {
Expand Down Expand Up @@ -75,41 +76,53 @@ export function useTerminalCreateActions(controller: TerminalColdActivationContr
}).catch(showClientCreationActionError)
}, [activeWorktreeId])

const openNewBrowserTab = useCallback(
(splitDirection?: TabSplitDirection) => {
if (!activeWorktreeId) {
return
}
const targetGroupId =
useAppStore.getState().activeGroupIdByWorktree[activeWorktreeId] ??
useAppStore.getState().groupsByWorktree[activeWorktreeId]?.[0]?.id
if (targetGroupId) {
void openNewBrowserTabInActiveWorkspace(targetGroupId, splitDirection).catch(
showClientCreationActionError
)
return
}
const state = useAppStore.getState()
const browserAvailability = getClientCreationActionPolicy(state, activeWorktreeId)[
'managed-browser'
]
if (browserAvailability.state !== 'enabled') {
toast.error(browserAvailability.reason)
return
}
const defaultUrl = state.browserDefaultUrl ?? 'about:blank'
const runtimeEnvironmentId = getActiveWorktreeRuntimeEnvironmentId(activeWorktreeId)
if (browserAvailability.provider === 'paired-runtime' && runtimeEnvironmentId) {
void createWebRuntimeSessionBrowserTab({
worktreeId: activeWorktreeId,
environmentId: runtimeEnvironmentId,
url: defaultUrl
}).catch(showClientCreationActionError)
return
}
createBrowserTab(activeWorktreeId, defaultUrl, {
title: translate('auto.components.Terminal.37da0d736f', 'New Browser Tab'),
focusAddressBar: true,
...(runtimeEnvironmentId ? { browserRuntimeEnvironmentId: null } : {})
})
},
[activeWorktreeId, createBrowserTab, openNewBrowserTabInActiveWorkspace]
)
// Why wrappers: menus pass their select event as the first argument.
const handleNewBrowserTab = useCallback(() => {
if (!activeWorktreeId) {
return
}
const targetGroupId =
useAppStore.getState().activeGroupIdByWorktree[activeWorktreeId] ??
useAppStore.getState().groupsByWorktree[activeWorktreeId]?.[0]?.id
if (targetGroupId) {
void openNewBrowserTabInActiveWorkspace(targetGroupId).catch(showClientCreationActionError)
return
}
const state = useAppStore.getState()
const browserAvailability = getClientCreationActionPolicy(state, activeWorktreeId)[
'managed-browser'
]
if (browserAvailability.state !== 'enabled') {
toast.error(browserAvailability.reason)
return
}
const defaultUrl = state.browserDefaultUrl ?? 'about:blank'
const runtimeEnvironmentId = getActiveWorktreeRuntimeEnvironmentId(activeWorktreeId)
if (browserAvailability.provider === 'paired-runtime' && runtimeEnvironmentId) {
void createWebRuntimeSessionBrowserTab({
worktreeId: activeWorktreeId,
environmentId: runtimeEnvironmentId,
url: defaultUrl
}).catch(showClientCreationActionError)
return
}
createBrowserTab(activeWorktreeId, defaultUrl, {
title: translate('auto.components.Terminal.37da0d736f', 'New Browser Tab'),
focusAddressBar: true,
...(runtimeEnvironmentId ? { browserRuntimeEnvironmentId: null } : {})
})
}, [activeWorktreeId, createBrowserTab, openNewBrowserTabInActiveWorkspace])
openNewBrowserTab()
}, [openNewBrowserTab])
const handleNewBrowserTabSplitRight = useCallback(() => {
openNewBrowserTab('right')
}, [openNewBrowserTab])

const handleOpenEntry = useCallback(async (args: TabCreateEntryArgs) => {
await openTabBarEntry(args)
Expand Down Expand Up @@ -178,6 +191,7 @@ export function useTerminalCreateActions(controller: TerminalColdActivationContr
handleNewTab,
handleNewSimulatorTab,
handleNewBrowserTab,
handleNewBrowserTabSplitRight,
handleOpenEntry,
handleDuplicateBrowserTab,
handleNewFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export function useTerminalKeyboardShortcuts(controller: TerminalActivationContr
activeWorktreeId,
handleCloseAllFiles,
handleNewBrowserTab,
handleNewBrowserTabSplitRight,
handleNewFile,
handleNewSimulatorTab,
handleNewTab,
Expand All @@ -34,6 +35,7 @@ export function useTerminalKeyboardShortcuts(controller: TerminalActivationContr
}, [
activeWorktreeId,
handleNewBrowserTab,
handleNewBrowserTabSplitRight,
handleNewSimulatorTab,
handleNewFile,
handleNewTab,
Expand Down
12 changes: 9 additions & 3 deletions src/renderer/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17148,12 +17148,17 @@
"chatPaneRight": "chat pane right",
"splitChatDown": "split chat down",
"newChatBelow": "new chat below",
"chatPaneBelow": "chat pane below"
"chatPaneBelow": "chat pane below",
"browserRight": "browser right",
"splitBrowser": "split browser",
"browserSplit": "browser split"
},
"splitChatRight": "Split Chat Right",
"splitChatRightDescription": "Open a new chat in a split pane to the right.",
"splitChatDown": "Split Chat Down",
"splitChatDownDescription": "Open a new chat in a split pane below."
"splitChatDownDescription": "Open a new chat in a split pane below.",
"newBrowserTabSplitRight": "New Browser Tab in Right Split",
"newBrowserTabSplitRightDescription": "Open a browser tab in a new split to the right."
}
},
"palette": {
Expand Down Expand Up @@ -22332,7 +22337,8 @@
"terminalSplitRight": "Split terminal right",
"terminalSplitDown": "Split terminal down",
"terminalSwitchInputSource": "Switch input source / language (native)",
"newAgentTab": "New {{agent}} tab"
"newAgentTab": "New {{agent}} tab",
"tabNewBrowserSplitRight": "New browser tab in right split"
},
"group": {
"global": "Global",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,26 @@ describe('browser tab creation placement', () => {
expect(group(store, G1)?.tabOrder).toEqual(['A', 'B', 'C', n.id, m.id])
})

it('opens Group New Browser Tab in a new split beside the invoking group', async () => {
seedSplit(store)
await drawFromMain()
await store.getState().openNewBrowserTabInActiveWorkspace(G1, 'right')
await settled()
const n = store
.getState()
.unifiedTabsByWorktree[WT]!.find((tab) => !['A', 'B', 'C', 'X'].includes(tab.id))!
expect(group(store, G1)?.tabOrder).toEqual(['A', 'B', 'C'])
expect(store.getState().layoutByWorktree[WT]).toMatchObject({
first: {
type: 'split',
direction: 'horizontal',
first: { type: 'leaf', groupId: G1 },
second: { type: 'leaf', groupId: n.groupId }
},
second: { type: 'leaf', groupId: G2 }
})
})

it('uses the invoking group workspace instead of the globally selected one', async () => {
seedSplit(store)
store.setState({ activeWorktreeId: 'repo1::/elsewhere' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import type {
} from '@/runtime/client-hosted-browser-close-intents'
import type { WorkspaceSessionHydrationOptions } from '@/lib/workspace-session-hydration-keys'
import type { ExecutionHostId } from '../../../../../shared/execution-host'
import type { TabSplitTarget } from '../tabs/tabs-slice-contract'
import type { TabSplitDirection, TabSplitTarget } from '../tabs/tabs-slice-contract'
import type { RuntimeBrowserPlacement } from '../../../../../shared/runtime-browser-placement'

export type CreateBrowserTabOptions = {
Expand Down Expand Up @@ -146,7 +146,10 @@ export type BrowserSlice = {
url: string,
options?: CreateBrowserTabOptions
) => BrowserWorkspace
openNewBrowserTabInActiveWorkspace: (groupId: string) => Promise<void>
openNewBrowserTabInActiveWorkspace: (
groupId: string,
splitDirection?: TabSplitDirection
) => Promise<void>
/** `profileId: null` uses the workspace default profile. */
openBrowserProfileTabInActiveWorkspace: (
url: string,
Expand Down
14 changes: 9 additions & 5 deletions src/renderer/src/store/slices/browser/browser-tab-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { findGroupAndWorktree } from '../tab-group-state'
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../../shared/layout-owner-switch'
import { openBrowserTabThroughLayoutOwner } from './browser-tab-open-through-layout-owner'
import { browserTabOpenView } from './browser-tab-open-view'
import { resolveWebRuntimeBrowserClientTargetGroup } from '@/runtime/web-runtime-browser-client-target-group'

export function createBrowserTabActions(
set: BrowserSliceSet,
Expand Down Expand Up @@ -175,7 +176,7 @@ export function createBrowserTabActions(
return browserTab
},

openNewBrowserTabInActiveWorkspace: async (groupId) => {
openNewBrowserTabInActiveWorkspace: async (groupId, splitDirection) => {
const state = get()
// Why: the invoking group owns its workspace; global selection may already point elsewhere.
const worktreeId =
Expand All @@ -190,6 +191,7 @@ export function createBrowserTabActions(
throw new Error(browserAvailability.reason)
}
const defaultUrl = state.browserDefaultUrl ?? 'about:blank'
const split = splitDirection ? { sourceGroupId: groupId, splitDirection } : undefined
const runtimeEnvironmentId = runtimeEnvironmentIdOrLocalUnlessTwin(state, worktreeId)
if (browserAvailability.provider === 'paired-runtime') {
if (!runtimeEnvironmentId) {
Expand All @@ -203,9 +205,11 @@ export function createBrowserTabActions(
worktreeId,
environmentId: runtimeEnvironmentId,
url: defaultUrl,
// Desktop reconciliation honors clientTargetGroupId; targetGroupId steers snapshot-driven clients instead.
targetGroupId: groupId,
clientTargetGroupId: groupId
...resolveWebRuntimeBrowserClientTargetGroup(
get(),
{ workspaceId: worktreeId, targetGroupId: groupId, split },
runtimeEnvironmentId
)
})
if (created) {
get().recordFeatureInteraction('browser-tab-created')
Expand All @@ -225,7 +229,7 @@ export function createBrowserTabActions(
title: translate('auto.store.slices.browser.d175274b6d', 'New Browser Tab'),
focusAddressBar: true,
browserRuntimeEnvironmentId: null,
targetGroupId: groupId
...(split ? { split } : { targetGroupId: groupId })
})
get().recordFeatureInteraction('browser-tab-created')
},
Expand Down
13 changes: 13 additions & 0 deletions src/shared/keybindings/definitions-core-2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ export const KEYBINDING_DEFINITION_CORE_2: readonly KeybindingDefinition[] = [
searchKeywords: ['shortcut', 'tab', 'browser', 'new'],
defaultBindings: platformBindings(['Mod+Shift+B'])
},
{
id: 'tab.newBrowserSplitRight',
title: 'New browser tab in right split',
group: 'Tabs',
scope: 'tabs',
searchKeywords: ['shortcut', 'tab', 'browser', 'new', 'split', 'right', 'side', 'pane'],
// Why: macOS only — Ctrl+Alt+letter is AltGr text input on Windows/Linux.
defaultBindings: {
darwin: ['Mod+Alt+B'],
linux: [],
win32: []
}
},
{
id: 'tab.newSimulator',
title: 'New mobile emulator tab',
Expand Down
1 change: 1 addition & 0 deletions src/shared/keybindings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type KeybindingActionId =
| 'tab.newAgent'
| AgentTabActionId
| 'tab.newBrowser'
| 'tab.newBrowserSplitRight'
| 'tab.newSimulator'
| 'tab.newMarkdown'
| 'tab.openMarkdown'
Expand Down
Loading