Skip to content

Commit 52de062

Browse files
committed
fix: align thinking toggle with slider and drop extra state
1 parent 96987c2 commit 52de062

File tree

3 files changed

+10
-36
lines changed

3 files changed

+10
-36
lines changed

src/browser/components/ThinkingSlider.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import React, { useEffect, useId } from "react";
2-
import type { ThinkingLevel, ThinkingLevelOn } from "@/common/types/thinking";
2+
import type { ThinkingLevel } from "@/common/types/thinking";
33
import { useThinkingLevel } from "@/browser/hooks/useThinkingLevel";
44
import { TooltipWrapper, Tooltip } from "./Tooltip";
55
import { formatKeybind, KEYBINDS } from "@/browser/utils/ui/keybinds";
66
import { getThinkingPolicyForModel } from "@/browser/utils/thinking/policy";
7-
import { updatePersistedState } from "@/browser/hooks/usePersistedState";
8-
import { getLastActiveThinkingKey } from "@/common/constants/storage";
97

108
// Uses CSS variable --color-thinking-mode for theme compatibility
119
// Glow is applied via CSS using color-mix with the theme color
@@ -146,10 +144,6 @@ export const ThinkingSliderComponent: React.FC<ThinkingControlProps> = ({ modelS
146144
const handleThinkingLevelChange = (newLevel: ThinkingLevel) => {
147145
// ThinkingContext handles per-model persistence automatically
148146
setThinkingLevel(newLevel);
149-
// Also save active level for toggle keybind (Ctrl+Shift+T) to restore
150-
if (newLevel !== "off") {
151-
updatePersistedState(getLastActiveThinkingKey(modelString), newLevel as ThinkingLevelOn);
152-
}
153147
};
154148

155149
// Cycle through allowed thinking levels

src/browser/hooks/useAIViewKeybinds.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { useEffect } from "react";
22
import type { ChatInputAPI } from "@/browser/components/ChatInput";
33
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";
87
import { getThinkingPolicyForModel } from "@/browser/utils/thinking/policy";
98
import { getDefaultModel } from "@/browser/hooks/useModelLRU";
109
import type { StreamingMessageAggregator } from "@/browser/utils/messages/StreamingMessageAggregator";
@@ -109,23 +108,15 @@ export function useAIViewKeybinds({
109108
// Special-case: if model has single-option policy (e.g., gpt-5-pro only supports HIGH),
110109
// the toggle is a no-op to avoid confusing state transitions.
111110
const allowed = getThinkingPolicyForModel(modelToUse);
112-
if (allowed.length === 1) {
111+
if (allowed.length <= 1) {
113112
return; // No toggle for single-option policies
114113
}
115114

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);
129120
return;
130121
}
131122

src/common/constants/storage.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,6 @@ export function getThinkingLevelKey(modelName: string): string {
5959
return `thinkingLevel:${modelName}`;
6060
}
6161

62-
/**
63-
* Get the localStorage key for the last *active* thinking level used for a model.
64-
* Format: "lastActiveThinking:{modelName}"
65-
*
66-
* Used by the toggle keybind (Ctrl+Shift+T) to restore the previous non-off level.
67-
* Stores only active levels ("low" | "medium" | "high"), never "off".
68-
*/
69-
export function getLastActiveThinkingKey(modelName: string): string {
70-
return `lastActiveThinking:${modelName}`;
71-
}
72-
7362
/**
7463
* Get the localStorage key for the user's preferred model for a workspace
7564
*/

0 commit comments

Comments
 (0)