mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-05 12:25:35 +08:00
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.
This commit is contained in:
@@ -143,6 +143,21 @@ const createFakeSubmitEvent = () => {
|
|||||||
return { preventDefault: () => undefined } as unknown as FormEvent<HTMLFormElement>;
|
return { preventDefault: () => undefined } as unknown as FormEvent<HTMLFormElement>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 = (
|
const getNotificationSessionSummary = (
|
||||||
selectedSession: ProjectSession | null,
|
selectedSession: ProjectSession | null,
|
||||||
fallbackInput: string,
|
fallbackInput: string,
|
||||||
@@ -204,7 +219,7 @@ export function useChatComposerState({
|
|||||||
const [uploadingImages, setUploadingImages] = useState<Map<string, number>>(new Map());
|
const [uploadingImages, setUploadingImages] = useState<Map<string, number>>(new Map());
|
||||||
const [imageErrors, setImageErrors] = useState<Map<string, string>>(new Map());
|
const [imageErrors, setImageErrors] = useState<Map<string, string>>(new Map());
|
||||||
const [isTextareaExpanded, setIsTextareaExpanded] = useState(false);
|
const [isTextareaExpanded, setIsTextareaExpanded] = useState(false);
|
||||||
const [thinkingMode, setThinkingMode] = useState('none');
|
const [thinkingMode, setThinkingMode] = useState(getInitialThinkingMode);
|
||||||
const [commandModalPayload, setCommandModalPayload] = useState<CommandModalPayload | null>(null);
|
const [commandModalPayload, setCommandModalPayload] = useState<CommandModalPayload | null>(null);
|
||||||
|
|
||||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
@@ -749,7 +764,6 @@ export function useChatComposerState({
|
|||||||
setUploadingImages(new Map());
|
setUploadingImages(new Map());
|
||||||
setImageErrors(new Map());
|
setImageErrors(new Map());
|
||||||
setIsTextareaExpanded(false);
|
setIsTextareaExpanded(false);
|
||||||
setThinkingMode('none');
|
|
||||||
|
|
||||||
if (textareaRef.current) {
|
if (textareaRef.current) {
|
||||||
textareaRef.current.style.height = 'auto';
|
textareaRef.current.style.height = 'auto';
|
||||||
@@ -795,6 +809,10 @@ export function useChatComposerState({
|
|||||||
inputValueRef.current = input;
|
inputValueRef.current = input;
|
||||||
}, [input]);
|
}, [input]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
safeLocalStorage.setItem(THINKING_MODE_STORAGE_KEY, thinkingMode);
|
||||||
|
}, [thinkingMode]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedProjectId) {
|
if (!selectedProjectId) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user