From c825d342b381818ea609ccf23f4433367b877e68 Mon Sep 17 00:00:00 2001 From: Haileyesus <118998054+blackmammoth@users.noreply.github.com> Date: Thu, 4 Jun 2026 16:15:02 +0300 Subject: [PATCH] fix(chat): persist thinking mode selection Initialize the composer thinking mode from localStorage so reloads keep the user's selected mode instead of falling back to Standard. Keep the chosen mode after sending because the selector behaves like a preference, not a one-shot modifier for a single prompt. --- .../chat/hooks/useChatComposerState.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/chat/hooks/useChatComposerState.ts b/src/components/chat/hooks/useChatComposerState.ts index 6d3b93df..72cc2c97 100644 --- a/src/components/chat/hooks/useChatComposerState.ts +++ b/src/components/chat/hooks/useChatComposerState.ts @@ -143,6 +143,21 @@ const createFakeSubmitEvent = () => { return { preventDefault: () => undefined } as unknown as FormEvent; }; +const THINKING_MODE_STORAGE_KEY = 'chat-thinking-mode'; + +const getInitialThinkingMode = () => { + if (typeof window === 'undefined') { + return 'none'; + } + + const savedMode = safeLocalStorage.getItem(THINKING_MODE_STORAGE_KEY); + if (!savedMode) { + return 'none'; + } + + return thinkingModes.some((mode) => mode.id === savedMode) ? savedMode : 'none'; +}; + const getNotificationSessionSummary = ( selectedSession: ProjectSession | null, fallbackInput: string, @@ -204,7 +219,7 @@ export function useChatComposerState({ const [uploadingImages, setUploadingImages] = useState>(new Map()); const [imageErrors, setImageErrors] = useState>(new Map()); const [isTextareaExpanded, setIsTextareaExpanded] = useState(false); - const [thinkingMode, setThinkingMode] = useState('none'); + const [thinkingMode, setThinkingMode] = useState(getInitialThinkingMode); const [commandModalPayload, setCommandModalPayload] = useState(null); const textareaRef = useRef(null); @@ -749,7 +764,6 @@ export function useChatComposerState({ setUploadingImages(new Map()); setImageErrors(new Map()); setIsTextareaExpanded(false); - setThinkingMode('none'); if (textareaRef.current) { textareaRef.current.style.height = 'auto'; @@ -795,6 +809,10 @@ export function useChatComposerState({ inputValueRef.current = input; }, [input]); + useEffect(() => { + safeLocalStorage.setItem(THINKING_MODE_STORAGE_KEY, thinkingMode); + }, [thinkingMode]); + useEffect(() => { if (!selectedProjectId) { return;