Skip to content

Commit a257603

Browse files
committed
🤖 Fix Cmd+Shift+T keybind failing in new chats
The toggle thinking keybind (Cmd+Shift+T) would fail in new chats because it checked message history for the current model, which is null until the first message is sent. However, users can see and select a model in the UI immediately (stored in localStorage). Root cause: State source mismatch - UI shows: selectedModel from localStorage (always available) - Keybind checked: currentModel from message history (null in new chats) Fix: Read the selected model from localStorage and fall back to message history model if not set. This matches what the user sees in the UI. Now the keybind works immediately in new chats, matching user expectations. _Generated with `cmux`_
1 parent 1bd73d6 commit a257603

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/hooks/useAIViewKeybinds.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect } from "react";
22
import type { ChatInputAPI } from "@/components/ChatInput";
33
import { matchesKeybind, KEYBINDS, isEditableElement } from "@/utils/ui/keybinds";
4-
import { getLastThinkingByModelKey } from "@/constants/storage";
4+
import { getLastThinkingByModelKey, getModelKey } from "@/constants/storage";
55
import { updatePersistedState, readPersistedState } from "@/hooks/usePersistedState";
66
import type { ThinkingLevel, ThinkingLevelOn } from "@/types/thinking";
77
import { DEFAULT_THINKING_LEVEL } from "@/types/thinking";
@@ -64,17 +64,22 @@ export function useAIViewKeybinds({
6464
if (matchesKeybind(e, KEYBINDS.TOGGLE_THINKING)) {
6565
e.preventDefault();
6666

67-
// Skip if no model set (workspace has no messages yet)
68-
if (!currentModel) {
67+
// Get selected model from localStorage (what user sees in UI)
68+
// Fall back to message history model if not set
69+
const selectedModel = readPersistedState<string | null>(getModelKey(workspaceId), null);
70+
const modelToUse = selectedModel ?? currentModel;
71+
72+
// Skip if no model set at all
73+
if (!modelToUse) {
6974
return;
7075
}
7176

7277
// Storage key for remembering this model's last-used active thinking level
73-
const lastThinkingKey = getLastThinkingByModelKey(currentModel);
78+
const lastThinkingKey = getLastThinkingByModelKey(modelToUse);
7479

7580
// Special-case: if model has single-option policy (e.g., gpt-5-pro only supports HIGH),
7681
// the toggle is a no-op to avoid confusing state transitions.
77-
const allowed = getThinkingPolicyForModel(currentModel);
82+
const allowed = getThinkingPolicyForModel(modelToUse);
7883
if (allowed.length === 1) {
7984
return; // No toggle for single-option policies
8085
}

0 commit comments

Comments
 (0)