|
1 | 1 | import { useEffect } from "react"; |
2 | 2 | import type { ChatInputAPI } from "@/browser/components/ChatInput"; |
3 | 3 | import { matchesKeybind, KEYBINDS, isEditableElement } from "@/browser/utils/ui/keybinds"; |
4 | | -import { getModelKey, getLastActiveThinkingKey } from "@/common/constants/storage"; |
5 | | -import { readPersistedState, updatePersistedState } from "@/browser/hooks/usePersistedState"; |
6 | | -import type { ThinkingLevel, ThinkingLevelOn } from "@/common/types/thinking"; |
7 | | -import { DEFAULT_THINKING_LEVEL } from "@/common/types/thinking"; |
| 4 | +import { getModelKey } from "@/common/constants/storage"; |
| 5 | +import { readPersistedState } from "@/browser/hooks/usePersistedState"; |
| 6 | +import type { ThinkingLevel } from "@/common/types/thinking"; |
8 | 7 | import { getThinkingPolicyForModel } from "@/browser/utils/thinking/policy"; |
9 | 8 | import { getDefaultModel } from "@/browser/hooks/useModelLRU"; |
10 | 9 | import type { StreamingMessageAggregator } from "@/browser/utils/messages/StreamingMessageAggregator"; |
@@ -109,23 +108,15 @@ export function useAIViewKeybinds({ |
109 | 108 | // Special-case: if model has single-option policy (e.g., gpt-5-pro only supports HIGH), |
110 | 109 | // the toggle is a no-op to avoid confusing state transitions. |
111 | 110 | const allowed = getThinkingPolicyForModel(modelToUse); |
112 | | - if (allowed.length === 1) { |
| 111 | + if (allowed.length <= 1) { |
113 | 112 | return; // No toggle for single-option policies |
114 | 113 | } |
115 | 114 |
|
116 | | - if (currentWorkspaceThinking !== "off") { |
117 | | - // Thinking is currently ON - save the active level and turn it off |
118 | | - const activeLevel: ThinkingLevelOn = currentWorkspaceThinking; |
119 | | - updatePersistedState(getLastActiveThinkingKey(modelToUse), activeLevel); |
120 | | - setThinkingLevel("off"); |
121 | | - } else { |
122 | | - // Thinking is currently OFF - restore last active level for this model |
123 | | - const lastActive = readPersistedState<ThinkingLevelOn>( |
124 | | - getLastActiveThinkingKey(modelToUse), |
125 | | - DEFAULT_THINKING_LEVEL |
126 | | - ); |
127 | | - setThinkingLevel(lastActive); |
128 | | - } |
| 115 | + // Cycle through the allowed levels (same order as the slider cycles) |
| 116 | + const currentIndex = allowed.indexOf(currentWorkspaceThinking); |
| 117 | + const nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % allowed.length; |
| 118 | + const nextLevel = allowed[nextIndex]; |
| 119 | + setThinkingLevel(nextLevel); |
129 | 120 | return; |
130 | 121 | } |
131 | 122 |
|
|
0 commit comments