diff --git a/frontend/src/components/chat/ChatPanel.tsx b/frontend/src/components/chat/ChatPanel.tsx index 927bcb4a..83276b92 100644 --- a/frontend/src/components/chat/ChatPanel.tsx +++ b/frontend/src/components/chat/ChatPanel.tsx @@ -687,11 +687,14 @@ export default function ChatPanel({ activeDoc, onCitationClick }: Props) { setShowExportMenu(false); } } + } // Shortcut 3: Ctrl/Cmd + K → Focus chat input from anywhere if (isCmdOrCtrl && (e.key === "k" || e.key === "K")) { e.preventDefault(); - textareaRef.current?.focus(); + setInput(""); + } else if (showHelpModal) { + setShowHelpModal(false); } // Shortcut 5: Ctrl/Cmd + Shift + C → Clear chat history @@ -724,8 +727,41 @@ export default function ChatPanel({ activeDoc, onCitationClick }: Props) { // eslint-disable-next-line react-hooks/exhaustive-deps }, [input, streaming, showExportMenu, messages]); // Dependencies updated to capture fresh state data + // Ctrl + Shift + C => Copy latest assistant response + if ( + isCmdOrCtrl && + e.shiftKey && + (e.key === "c" || e.key === "C") + ) { + e.preventDefault(); + + const latestAssistant = [...messages] + .reverse() + .find((msg) => msg.role === "assistant"); + + if (latestAssistant?.content) { + navigator.clipboard.writeText(latestAssistant.content); + } + } + }; + + window.addEventListener("keydown", handleGlobalKeyDown); + + return () => { + window.removeEventListener("keydown", handleGlobalKeyDown); + }; + }, [ + input, + streaming, + showHelpModal, + messages, + setInput, + handleSend, +]); + return (