diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx index eae9e43459f4..f8bbda418d9b 100644 --- a/apps/web/src/components/BranchToolbar.tsx +++ b/apps/web/src/components/BranchToolbar.tsx @@ -72,6 +72,7 @@ import { observeResize } from "~/lib/observeResize"; export interface BranchToolbarHandle { openBranchPicker: () => void; usePreviousWorktree: () => void; + selectNewWorktree: () => void; } interface BranchToolbarProps { @@ -652,10 +653,17 @@ export const BranchToolbar = memo(function BranchToolbar({ onUsePreviousWorktree(); onComposerFocusRequest?.(); }, + selectNewWorktree: () => { + if (!showGitControls || envModeLocked || forceNewWorktree) return; + onEnvModeChange("worktree"); + }, }), [ canUsePreviousWorktree, + envModeLocked, + forceNewWorktree, onComposerFocusRequest, + onEnvModeChange, onUsePreviousWorktree, previousWorktreeSeed, showGitControls, diff --git a/apps/web/src/components/chat/composerShortcuts.ts b/apps/web/src/components/chat/composerShortcuts.ts index 30beb9771968..fb5f52854f4a 100644 --- a/apps/web/src/components/chat/composerShortcuts.ts +++ b/apps/web/src/components/chat/composerShortcuts.ts @@ -34,5 +34,8 @@ export function composerShortcutCommands( "composer.previousWorktree": ({ event }) => { if (!event.repeat) branchToolbarRef.current?.usePreviousWorktree(); }, + "composer.newWorktree": ({ event }) => { + if (!event.repeat) branchToolbarRef.current?.selectNewWorktree(); + }, } satisfies ChatShortcutCommands; } diff --git a/docs/user/keybindings.md b/docs/user/keybindings.md index 308d7d934c1f..cc77178b2b0e 100644 --- a/docs/user/keybindings.md +++ b/docs/user/keybindings.md @@ -37,6 +37,8 @@ Use `mod+shift+e` for effort, `mod+shift+a` for permissions, `mod+shift+x` for t workspace, and `mod+shift+g` for the Git branch. The workspace menu includes the current checkout, a new worktree, and the previous worktree when available. Use `mod+shift+l` to reuse the previous worktree directly. +To select a new worktree directly, bind **Composer: New Worktree** in Keybindings. +It has no default shortcut and uses the same rules as the workspace menu. To change effort one step without opening the picker, bind **Composer: Increase Effort** and **Composer: Decrease Effort** in Keybindings. diff --git a/packages/contracts/src/keybindings.ts b/packages/contracts/src/keybindings.ts index eda5138b760b..12b40878c85f 100644 --- a/packages/contracts/src/keybindings.ts +++ b/packages/contracts/src/keybindings.ts @@ -100,6 +100,7 @@ export const STATIC_KEYBINDING_COMMANDS = [ "composer.decreaseEffort", "composer.mode", "composer.workspace", + "composer.newWorktree", "composer.previousWorktree", "composer.branch", "chat.new",