Update remaining components to use customizable keyboard shortcuts

Co-authored-by: GTheMachine <156854865+GTheMachine@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-10 17:38:45 +00:00
committed by Kacper
parent 3a45970280
commit 857f46f86a
3 changed files with 20 additions and 17 deletions

View File

@@ -26,12 +26,13 @@ import { Markdown } from "@/components/ui/markdown";
import type { ImageAttachment } from "@/store/app-store"; import type { ImageAttachment } from "@/store/app-store";
import { import {
useKeyboardShortcuts, useKeyboardShortcuts,
ACTION_SHORTCUTS, useKeyboardShortcutsConfig,
KeyboardShortcut, KeyboardShortcut,
} from "@/hooks/use-keyboard-shortcuts"; } from "@/hooks/use-keyboard-shortcuts";
export function AgentView() { export function AgentView() {
const { currentProject, setLastSelectedSession, getLastSelectedSession } = useAppStore(); const { currentProject, setLastSelectedSession, getLastSelectedSession } = useAppStore();
const shortcuts = useKeyboardShortcutsConfig();
const [input, setInput] = useState(""); const [input, setInput] = useState("");
const [selectedImages, setSelectedImages] = useState<ImageAttachment[]>([]); const [selectedImages, setSelectedImages] = useState<ImageAttachment[]>([]);
const [showImageDropZone, setShowImageDropZone] = useState(false); const [showImageDropZone, setShowImageDropZone] = useState(false);
@@ -417,12 +418,12 @@ export function AgentView() {
// Keyboard shortcuts for agent view // Keyboard shortcuts for agent view
const agentShortcuts: KeyboardShortcut[] = useMemo(() => { const agentShortcuts: KeyboardShortcut[] = useMemo(() => {
const shortcuts: KeyboardShortcut[] = []; const shortcutsList: KeyboardShortcut[] = [];
// New session shortcut - only when in agent view with a project // New session shortcut - only when in agent view with a project
if (currentProject) { if (currentProject) {
shortcuts.push({ shortcutsList.push({
key: ACTION_SHORTCUTS.newSession, key: shortcuts.newSession,
action: () => { action: () => {
if (quickCreateSessionRef.current) { if (quickCreateSessionRef.current) {
quickCreateSessionRef.current(); quickCreateSessionRef.current();
@@ -432,8 +433,8 @@ export function AgentView() {
}); });
} }
return shortcuts; return shortcutsList;
}, [currentProject]); }, [currentProject, shortcuts]);
// Register keyboard shortcuts // Register keyboard shortcuts
useKeyboardShortcuts(agentShortcuts); useKeyboardShortcuts(agentShortcuts);

View File

@@ -19,7 +19,7 @@ import {
} from "lucide-react"; } from "lucide-react";
import { import {
useKeyboardShortcuts, useKeyboardShortcuts,
ACTION_SHORTCUTS, useKeyboardShortcutsConfig,
KeyboardShortcut, KeyboardShortcut,
} from "@/hooks/use-keyboard-shortcuts"; } from "@/hooks/use-keyboard-shortcuts";
import { import {
@@ -43,6 +43,7 @@ interface ContextFile {
export function ContextView() { export function ContextView() {
const { currentProject } = useAppStore(); const { currentProject } = useAppStore();
const shortcuts = useKeyboardShortcutsConfig();
const [contextFiles, setContextFiles] = useState<ContextFile[]>([]); const [contextFiles, setContextFiles] = useState<ContextFile[]>([]);
const [selectedFile, setSelectedFile] = useState<ContextFile | null>(null); const [selectedFile, setSelectedFile] = useState<ContextFile | null>(null);
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
@@ -63,12 +64,12 @@ export function ContextView() {
const contextShortcuts: KeyboardShortcut[] = useMemo( const contextShortcuts: KeyboardShortcut[] = useMemo(
() => [ () => [
{ {
key: ACTION_SHORTCUTS.addContextFile, key: shortcuts.addContextFile,
action: () => setIsAddDialogOpen(true), action: () => setIsAddDialogOpen(true),
description: "Add new context file", description: "Add new context file",
}, },
], ],
[] [shortcuts]
); );
useKeyboardShortcuts(contextShortcuts); useKeyboardShortcuts(contextShortcuts);
@@ -374,7 +375,7 @@ export function ContextView() {
className="ml-2 px-1.5 py-0.5 text-[10px] font-mono rounded bg-secondary border border-border" className="ml-2 px-1.5 py-0.5 text-[10px] font-mono rounded bg-secondary border border-border"
data-testid="shortcut-add-context-file" data-testid="shortcut-add-context-file"
> >
{ACTION_SHORTCUTS.addContextFile} {shortcuts.addContextFile}
</span> </span>
</Button> </Button>
</div> </div>

View File

@@ -9,7 +9,7 @@ import { Textarea } from "@/components/ui/textarea";
import { cn, modelSupportsThinking } from "@/lib/utils"; import { cn, modelSupportsThinking } from "@/lib/utils";
import { import {
useKeyboardShortcuts, useKeyboardShortcuts,
ACTION_SHORTCUTS, useKeyboardShortcutsConfig,
KeyboardShortcut, KeyboardShortcut,
} from "@/hooks/use-keyboard-shortcuts"; } from "@/hooks/use-keyboard-shortcuts";
import { import {
@@ -440,6 +440,7 @@ function ProfileForm({
export function ProfilesView() { export function ProfilesView() {
const { aiProfiles, addAIProfile, updateAIProfile, removeAIProfile, reorderAIProfiles } = const { aiProfiles, addAIProfile, updateAIProfile, removeAIProfile, reorderAIProfiles } =
useAppStore(); useAppStore();
const shortcuts = useKeyboardShortcutsConfig();
const [showAddDialog, setShowAddDialog] = useState(false); const [showAddDialog, setShowAddDialog] = useState(false);
const [editingProfile, setEditingProfile] = useState<AIProfile | null>(null); const [editingProfile, setEditingProfile] = useState<AIProfile | null>(null);
@@ -508,17 +509,17 @@ export function ProfilesView() {
// Build keyboard shortcuts for profiles view // Build keyboard shortcuts for profiles view
const profilesShortcuts: KeyboardShortcut[] = useMemo(() => { const profilesShortcuts: KeyboardShortcut[] = useMemo(() => {
const shortcuts: KeyboardShortcut[] = []; const shortcutsList: KeyboardShortcut[] = [];
// Add profile shortcut - when in profiles view // Add profile shortcut - when in profiles view
shortcuts.push({ shortcutsList.push({
key: ACTION_SHORTCUTS.addProfile, key: shortcuts.addProfile,
action: () => setShowAddDialog(true), action: () => setShowAddDialog(true),
description: "Create new profile", description: "Create new profile",
}); });
return shortcuts; return shortcutsList;
}, []); }, [shortcuts]);
// Register keyboard shortcuts for profiles view // Register keyboard shortcuts for profiles view
useKeyboardShortcuts(profilesShortcuts); useKeyboardShortcuts(profilesShortcuts);
@@ -549,7 +550,7 @@ export function ProfilesView() {
<Plus className="w-4 h-4 mr-2" /> <Plus className="w-4 h-4 mr-2" />
New Profile New Profile
<span className="hidden lg:flex items-center justify-center ml-2 px-2 py-0.5 text-[10px] font-mono rounded bg-primary-foreground/20 border border-primary-foreground/30 text-primary-foreground"> <span className="hidden lg:flex items-center justify-center ml-2 px-2 py-0.5 text-[10px] font-mono rounded bg-primary-foreground/20 border border-primary-foreground/30 text-primary-foreground">
{ACTION_SHORTCUTS.addProfile} {shortcuts.addProfile}
</span> </span>
</Button> </Button>
</div> </div>