mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-05 09:33:07 +00:00
Add keyboard shortcut 'W' for creating new agent session
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -54,6 +54,6 @@
|
|||||||
"category": "Agent Runner",
|
"category": "Agent Runner",
|
||||||
"description": "Can you please add a shortcut for starting a new session?",
|
"description": "Can you please add a shortcut for starting a new session?",
|
||||||
"steps": [],
|
"steps": [],
|
||||||
"status": "backlog"
|
"status": "verified"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import type { SessionListItem } from "@/types/electron";
|
import type { SessionListItem } from "@/types/electron";
|
||||||
|
import { ACTION_SHORTCUTS } from "@/hooks/use-keyboard-shortcuts";
|
||||||
|
|
||||||
// Random session name generator
|
// Random session name generator
|
||||||
const adjectives = [
|
const adjectives = [
|
||||||
@@ -50,6 +51,7 @@ interface SessionManagerProps {
|
|||||||
onSelectSession: (sessionId: string | null) => void;
|
onSelectSession: (sessionId: string | null) => void;
|
||||||
projectPath: string;
|
projectPath: string;
|
||||||
isCurrentSessionThinking?: boolean;
|
isCurrentSessionThinking?: boolean;
|
||||||
|
onQuickCreateRef?: React.MutableRefObject<(() => Promise<void>) | null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SessionManager({
|
export function SessionManager({
|
||||||
@@ -57,6 +59,7 @@ export function SessionManager({
|
|||||||
onSelectSession,
|
onSelectSession,
|
||||||
projectPath,
|
projectPath,
|
||||||
isCurrentSessionThinking = false,
|
isCurrentSessionThinking = false,
|
||||||
|
onQuickCreateRef,
|
||||||
}: SessionManagerProps) {
|
}: SessionManagerProps) {
|
||||||
const [sessions, setSessions] = useState<SessionListItem[]>([]);
|
const [sessions, setSessions] = useState<SessionListItem[]>([]);
|
||||||
const [activeTab, setActiveTab] = useState<"active" | "archived">("active");
|
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
|
// Rename session
|
||||||
const handleRenameSession = async (sessionId: string) => {
|
const handleRenameSession = async (sessionId: string) => {
|
||||||
if (!editingName.trim() || !window.electronAPI?.sessions) return;
|
if (!editingName.trim() || !window.electronAPI?.sessions) return;
|
||||||
@@ -192,9 +207,13 @@ export function SessionManager({
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={handleQuickCreateSession}
|
onClick={handleQuickCreateSession}
|
||||||
data-testid="new-session-button"
|
data-testid="new-session-button"
|
||||||
|
title={`New Session (${ACTION_SHORTCUTS.newSession})`}
|
||||||
>
|
>
|
||||||
<Plus className="w-4 h-4 mr-1" />
|
<Plus className="w-4 h-4 mr-1" />
|
||||||
New
|
New
|
||||||
|
<span className="ml-1.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20 text-white/80">
|
||||||
|
{ACTION_SHORTCUTS.newSession}
|
||||||
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useCallback, useRef, useEffect } from "react";
|
import { useState, useCallback, useRef, useEffect, useMemo } from "react";
|
||||||
import { useAppStore } from "@/store/app-store";
|
import { useAppStore } from "@/store/app-store";
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -23,6 +23,11 @@ import { cn } from "@/lib/utils";
|
|||||||
import { useElectronAgent } from "@/hooks/use-electron-agent";
|
import { useElectronAgent } from "@/hooks/use-electron-agent";
|
||||||
import { SessionManager } from "@/components/session-manager";
|
import { SessionManager } from "@/components/session-manager";
|
||||||
import type { ImageAttachment } from "@/store/app-store";
|
import type { ImageAttachment } from "@/store/app-store";
|
||||||
|
import {
|
||||||
|
useKeyboardShortcuts,
|
||||||
|
ACTION_SHORTCUTS,
|
||||||
|
KeyboardShortcut,
|
||||||
|
} from "@/hooks/use-keyboard-shortcuts";
|
||||||
|
|
||||||
export function AgentView() {
|
export function AgentView() {
|
||||||
const { currentProject } = useAppStore();
|
const { currentProject } = useAppStore();
|
||||||
@@ -41,6 +46,9 @@ export function AgentView() {
|
|||||||
// Input ref for auto-focus
|
// Input ref for auto-focus
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
// Ref for quick create session function from SessionManager
|
||||||
|
const quickCreateSessionRef = useRef<(() => Promise<void>) | null>(null);
|
||||||
|
|
||||||
// Use the Electron agent hook (only if we have a session)
|
// Use the Electron agent hook (only if we have a session)
|
||||||
const {
|
const {
|
||||||
messages,
|
messages,
|
||||||
@@ -369,6 +377,29 @@ export function AgentView() {
|
|||||||
}
|
}
|
||||||
}, [currentSessionId]);
|
}, [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) {
|
if (!currentProject) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -413,6 +444,7 @@ export function AgentView() {
|
|||||||
onSelectSession={setCurrentSessionId}
|
onSelectSession={setCurrentSessionId}
|
||||||
projectPath={currentProject.path}
|
projectPath={currentProject.path}
|
||||||
isCurrentSessionThinking={isProcessing}
|
isCurrentSessionThinking={isProcessing}
|
||||||
|
onQuickCreateRef={quickCreateSessionRef}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -100,10 +100,20 @@ export const NAV_SHORTCUTS: Record<string, string> = {
|
|||||||
settings: "S", // S for Settings
|
settings: "S", // S for Settings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut definitions for UI controls
|
||||||
|
*/
|
||||||
|
export const UI_SHORTCUTS: Record<string, string> = {
|
||||||
|
toggleSidebar: "`", // Backtick to toggle sidebar
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortcut definitions for add buttons
|
* Shortcut definitions for add buttons
|
||||||
*/
|
*/
|
||||||
export const ACTION_SHORTCUTS: Record<string, string> = {
|
export const ACTION_SHORTCUTS: Record<string, string> = {
|
||||||
addFeature: "N", // N for New feature
|
addFeature: "N", // N for New feature
|
||||||
addContextFile: "F", // F for File (add context file)
|
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)
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user