diff --git a/webapp/_webapp/src/views/chat/footer/index.tsx b/webapp/_webapp/src/views/chat/footer/index.tsx index 0cfc947d..994493a7 100644 --- a/webapp/_webapp/src/views/chat/footer/index.tsx +++ b/webapp/_webapp/src/views/chat/footer/index.tsx @@ -60,6 +60,8 @@ export function PromptInput() { const selectedText = useSelectionStore((s) => s.selectedText); const clearSelection = useSelectionStore((s) => s.clear); + const setSelectedText = useSelectionStore((s) => s.setSelectedText); + const setSurroundingText = useSelectionStore((s) => s.setSurroundingText); const { sendMessageStream } = useSendMessageStream(); const minimalistMode = useSettingStore((s) => s.minimalistMode); @@ -75,11 +77,26 @@ export function PromptInput() { userId: user?.id, }); setPrompt(""); - clearSelection(); + if (selectedText) { + setSelectedText(null); + setSurroundingText(null); + } else { + clearSelection(); + } setIsStreaming(true); await sendMessageStream(prompt, selectedText ?? ""); setIsStreaming(false); - }, [sendMessageStream, prompt, selectedText, user?.id, setIsStreaming, setPrompt, clearSelection]); + }, [ + sendMessageStream, + prompt, + selectedText, + user?.id, + setIsStreaming, + setPrompt, + clearSelection, + setSelectedText, + setSurroundingText, + ]); const handleKeyDown = useCallback( async (e: React.KeyboardEvent) => { // Check if IME composition is in progress to avoid submitting during Chinese input diff --git a/webapp/_webapp/tsconfig.app.json b/webapp/_webapp/tsconfig.app.json index 3512a469..9107c813 100644 --- a/webapp/_webapp/tsconfig.app.json +++ b/webapp/_webapp/tsconfig.app.json @@ -16,7 +16,7 @@ "jsx": "react-jsx", /* Type resolution */ - "types": ["bun", "vite/client", "node", "chrome", "react"], + "types": ["vite/client", "node", "chrome", "react"], "typeRoots": ["./node_modules/@types"], /* Linting */ @@ -26,5 +26,6 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, - "include": ["src"] + "include": ["src"], + "exclude": ["**/*.test.ts", "**/*.test.tsx"] }