From 1fc63b4e92e79d86d2defa0c13cd1ec190adcde7 Mon Sep 17 00:00:00 2001 From: Nicolas Varrot Date: Thu, 12 Feb 2026 19:08:00 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20add=20Alt+=E2=86=91/=E2=86=93=20keyboar?= =?UTF-8?q?d=20shortcuts=20to=20navigate=20between=20sessions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 15 +++++++++++++-- src/components/KeyboardShortcuts.tsx | 4 ++++ src/lib/i18n.ts | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 73b8d71..21f009f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -40,7 +40,7 @@ export default function App() { return () => setBaseTitle(undefined); }, [activeSession, sessions]); - // Close sidebar on Escape key, open shortcuts on ? + // Keyboard shortcuts: Escape, ?, Alt+↑/↓ for session navigation const handleKeyDown = useCallback((e: KeyboardEvent) => { if (e.key === 'Escape' && sidebarOpen) { setSidebarOpen(false); @@ -52,7 +52,18 @@ export default function App() { e.preventDefault(); setShortcutsOpen(true); } - }, [sidebarOpen, shortcutsOpen]); + // Alt+↑ / Alt+↓ — switch to previous/next session + if (e.altKey && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) { + e.preventDefault(); + if (sessions.length < 2) return; + const idx = sessions.findIndex(s => s.key === activeSession); + if (idx === -1) return; + const next = e.key === 'ArrowUp' + ? (idx - 1 + sessions.length) % sessions.length + : (idx + 1) % sessions.length; + switchSession(sessions[next].key); + } + }, [sidebarOpen, shortcutsOpen, sessions, activeSession, switchSession]); useEffect(() => { document.addEventListener('keydown', handleKeyDown); diff --git a/src/components/KeyboardShortcuts.tsx b/src/components/KeyboardShortcuts.tsx index 606214d..5e3a627 100644 --- a/src/components/KeyboardShortcuts.tsx +++ b/src/components/KeyboardShortcuts.tsx @@ -98,6 +98,10 @@ export function KeyboardShortcuts({ open, onClose }: Props) { keys={<>{mod}+K} label={t('shortcuts.search')} /> + Alt+/} + label={t('shortcuts.switchSession')} + /> Esc} label={t('shortcuts.closeSidebar')} diff --git a/src/lib/i18n.ts b/src/lib/i18n.ts index 4a29f03..cb74463 100644 --- a/src/lib/i18n.ts +++ b/src/lib/i18n.ts @@ -81,6 +81,7 @@ const en = { 'shortcuts.send': 'Send message', 'shortcuts.newline': 'New line', 'shortcuts.search': 'Search sessions', + 'shortcuts.switchSession': 'Previous / next session', 'shortcuts.closeSidebar': 'Close sidebar / search', 'shortcuts.stop': 'Stop generation', 'shortcuts.help': 'Show shortcuts', @@ -163,6 +164,7 @@ const fr: Record = { 'shortcuts.send': 'Envoyer le message', 'shortcuts.newline': 'Nouvelle ligne', 'shortcuts.search': 'Rechercher des sessions', + 'shortcuts.switchSession': 'Session précédente / suivante', 'shortcuts.closeSidebar': 'Fermer la barre / recherche', 'shortcuts.stop': 'Arrêter la génération', 'shortcuts.help': 'Afficher les raccourcis',