From 9a6e6ea59414604dd69686171623c15a411ae199 Mon Sep 17 00:00:00 2001 From: Cody Seibert Date: Tue, 9 Dec 2025 08:56:58 -0500 Subject: [PATCH] Add keyboard shortcut 'W' for creating new agent session MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added newSession shortcut to ACTION_SHORTCUTS in use-keyboard-shortcuts.ts - Updated SessionManager to expose quick create function via ref - Updated AgentView to register the shortcut and trigger new session creation - Display shortcut key indicator (W) on the New session button - Updated feature_list.json to mark feature as verified 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .automaker/feature_list.json | 4 +-- app/src/components/session-manager.tsx | 19 ++++++++++++++ app/src/components/views/agent-view.tsx | 34 ++++++++++++++++++++++++- app/src/hooks/use-keyboard-shortcuts.ts | 10 ++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/.automaker/feature_list.json b/.automaker/feature_list.json index 2a75a39e..b8750afd 100644 --- a/.automaker/feature_list.json +++ b/.automaker/feature_list.json @@ -54,6 +54,6 @@ "category": "Agent Runner", "description": "Can you please add a shortcut for starting a new session?", "steps": [], - "status": "backlog" + "status": "verified" } -] \ No newline at end of file +] diff --git a/app/src/components/session-manager.tsx b/app/src/components/session-manager.tsx index acff1edd..2b8df243 100644 --- a/app/src/components/session-manager.tsx +++ b/app/src/components/session-manager.tsx @@ -24,6 +24,7 @@ import { } from "lucide-react"; import { cn } from "@/lib/utils"; import type { SessionListItem } from "@/types/electron"; +import { ACTION_SHORTCUTS } from "@/hooks/use-keyboard-shortcuts"; // Random session name generator const adjectives = [ @@ -50,6 +51,7 @@ interface SessionManagerProps { onSelectSession: (sessionId: string | null) => void; projectPath: string; isCurrentSessionThinking?: boolean; + onQuickCreateRef?: React.MutableRefObject<(() => Promise) | null>; } export function SessionManager({ @@ -57,6 +59,7 @@ export function SessionManager({ onSelectSession, projectPath, isCurrentSessionThinking = false, + onQuickCreateRef, }: SessionManagerProps) { const [sessions, setSessions] = useState([]); const [activeTab, setActiveTab] = useState<"active" | "archived">("active"); @@ -118,6 +121,18 @@ export function SessionManager({ } }; + // Expose the quick create function via ref for keyboard shortcuts + useEffect(() => { + if (onQuickCreateRef) { + onQuickCreateRef.current = handleQuickCreateSession; + } + return () => { + if (onQuickCreateRef) { + onQuickCreateRef.current = null; + } + }; + }, [onQuickCreateRef, projectPath]); + // Rename session const handleRenameSession = async (sessionId: string) => { if (!editingName.trim() || !window.electronAPI?.sessions) return; @@ -192,9 +207,13 @@ export function SessionManager({ size="sm" onClick={handleQuickCreateSession} data-testid="new-session-button" + title={`New Session (${ACTION_SHORTCUTS.newSession})`} > New + + {ACTION_SHORTCUTS.newSession} + )} diff --git a/app/src/components/views/agent-view.tsx b/app/src/components/views/agent-view.tsx index c4b48874..514a1200 100644 --- a/app/src/components/views/agent-view.tsx +++ b/app/src/components/views/agent-view.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState, useCallback, useRef, useEffect } from "react"; +import { useState, useCallback, useRef, useEffect, useMemo } from "react"; import { useAppStore } from "@/store/app-store"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; @@ -23,6 +23,11 @@ import { cn } from "@/lib/utils"; import { useElectronAgent } from "@/hooks/use-electron-agent"; import { SessionManager } from "@/components/session-manager"; import type { ImageAttachment } from "@/store/app-store"; +import { + useKeyboardShortcuts, + ACTION_SHORTCUTS, + KeyboardShortcut, +} from "@/hooks/use-keyboard-shortcuts"; export function AgentView() { const { currentProject } = useAppStore(); @@ -41,6 +46,9 @@ export function AgentView() { // Input ref for auto-focus const inputRef = useRef(null); + // Ref for quick create session function from SessionManager + const quickCreateSessionRef = useRef<(() => Promise) | null>(null); + // Use the Electron agent hook (only if we have a session) const { messages, @@ -369,6 +377,29 @@ export function AgentView() { } }, [currentSessionId]); + // Keyboard shortcuts for agent view + const agentShortcuts: KeyboardShortcut[] = useMemo(() => { + const shortcuts: KeyboardShortcut[] = []; + + // New session shortcut - only when in agent view with a project + if (currentProject) { + shortcuts.push({ + key: ACTION_SHORTCUTS.newSession, + action: () => { + if (quickCreateSessionRef.current) { + quickCreateSessionRef.current(); + } + }, + description: "Create new session", + }); + } + + return shortcuts; + }, [currentProject]); + + // Register keyboard shortcuts + useKeyboardShortcuts(agentShortcuts); + if (!currentProject) { return (
)} diff --git a/app/src/hooks/use-keyboard-shortcuts.ts b/app/src/hooks/use-keyboard-shortcuts.ts index b563211d..b234a92a 100644 --- a/app/src/hooks/use-keyboard-shortcuts.ts +++ b/app/src/hooks/use-keyboard-shortcuts.ts @@ -100,10 +100,20 @@ export const NAV_SHORTCUTS: Record = { settings: "S", // S for Settings }; +/** + * Shortcut definitions for UI controls + */ +export const UI_SHORTCUTS: Record = { + toggleSidebar: "`", // Backtick to toggle sidebar +}; + /** * Shortcut definitions for add buttons */ export const ACTION_SHORTCUTS: Record = { addFeature: "N", // N for New feature addContextFile: "F", // F for File (add context file) + startNext: "Q", // Q for Queue (start next features from backlog) + newSession: "W", // W for new session (in agent view) + openProject: "O", // O for Open project (navigate to welcome view) };