From c78f0e78aae2e540eaf7f86cf8cb194e53ec6980 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 20 Mar 2026 20:33:43 +0200 Subject: [PATCH] feat(web): wire Composer to pre-fill clipboard content from Electron tray --- surfsense_web/components/assistant-ui/thread.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/surfsense_web/components/assistant-ui/thread.tsx b/surfsense_web/components/assistant-ui/thread.tsx index b7a5bcf0e..b6bbea2f4 100644 --- a/surfsense_web/components/assistant-ui/thread.tsx +++ b/surfsense_web/components/assistant-ui/thread.tsx @@ -314,6 +314,16 @@ const Composer: FC = () => { const composerRuntime = useComposerRuntime(); const hasAutoFocusedRef = useRef(false); + // Clipboard content from Electron tray (pre-filled into composer) + const [clipboardText, setClipboardText] = useState(); + useEffect(() => { + const api = (window as { electronAPI?: { getClipboardContent?: () => Promise } }).electronAPI; + if (!api?.getClipboardContent) return; + api.getClipboardContent().then((text) => { + if (text) setClipboardText(text); + }); + }, []); + const isThreadEmpty = useAssistantState(({ thread }) => thread.isEmpty); const isThreadRunning = useAssistantState(({ thread }) => thread.isRunning); @@ -520,6 +530,7 @@ const Composer: FC = () => { onDocumentRemove={handleDocumentRemove} onSubmit={handleSubmit} onKeyDown={handleKeyDown} + initialText={clipboardText} className="min-h-[24px]" />