feat: add auto-create worktree setting and related UI components

This commit is contained in:
Bohdan Triapitsyn
2026-01-07 23:37:32 +02:00
parent b6646b6b3e
commit c7700d5384
11 changed files with 144 additions and 14 deletions
+10 -3
View File
@@ -6,6 +6,7 @@ import { useAssistantStatus } from '@/hooks/useAssistantStatus';
import { getRegisteredRuntimeAPIs } from '@/contexts/runtimeAPIRegistry';
import { hasModifier } from '@/lib/utils';
import { createWorktreeSession } from '@/lib/worktreeSessionCreator';
import { useConfigStore } from '@/stores/useConfigStore';
export const useKeyboardShortcuts = () => {
const { openNewSessionDraft, abortCurrentOperation, armAbortPrompt, clearAbortPrompt, currentSessionId } = useSessionStore();
@@ -81,14 +82,20 @@ export const useKeyboardShortcuts = () => {
if (hasModifier(e) && e.key.toLowerCase() === 'n') {
e.preventDefault();
if (e.shiftKey) {
// Shift+Cmd/Ctrl+N creates a new session with auto-generated worktree
const autoWorktree = useConfigStore.getState().settingsAutoCreateWorktree;
// If autoWorktree is true: Cmd+N -> Worktree, Cmd+Shift+N -> Standard
// If autoWorktree is false: Cmd+N -> Standard, Cmd+Shift+N -> Worktree
const shouldCreateWorktree = autoWorktree ? !e.shiftKey : e.shiftKey;
if (shouldCreateWorktree) {
// Create new session with auto-generated worktree
setActiveMainTab('chat');
setSessionSwitcherOpen(false);
createWorktreeSession();
return;
}
// Cmd/Ctrl+N opens a new session without worktree
// Open a new session without worktree
setActiveMainTab('chat');
setSessionSwitcherOpen(false);
openNewSessionDraft();