Skip to content

Commit 9c2fb52

Browse files
committed
fix: allow thinking tokens slider to go from 0 to 80% of max tokens
- Removed the 1024 minimum from the thinking tokens slider UI - Slider now goes from 0 to 80% of max output tokens - Changed step size from 1024 to 256 for finer control - Backend still enforces the 1024 minimum when needed - This fixes the issue where the slider was unusable when max tokens < 1280
1 parent 3a527b7 commit 9c2fb52

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

webview-ui/src/components/settings/ThinkingBudget.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export const ThinkingBudget = ({ apiConfiguration, setApiConfigurationField, mod
6363
<div className="font-medium">{t("settings:thinkingBudget.maxThinkingTokens")}</div>
6464
<div className="flex items-center gap-1" data-testid="reasoning-budget">
6565
<Slider
66-
min={1024}
66+
min={0}
6767
max={modelMaxThinkingTokens}
68-
step={1024}
69-
value={[customMaxThinkingTokens]}
68+
step={256}
69+
value={[Math.min(customMaxThinkingTokens, modelMaxThinkingTokens)]}
7070
onValueChange={([value]) => setApiConfigurationField("modelMaxThinkingTokens", value)}
7171
/>
7272
<div className="w-12 text-sm text-center">{customMaxThinkingTokens}</div>

webview-ui/src/components/settings/__tests__/ThinkingBudget.spec.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ describe("ThinkingBudget", () => {
9595
expect(setApiConfigurationField).toHaveBeenCalledWith("modelMaxThinkingTokens", 8000) // 80% of 10000
9696
})
9797

98+
it("should allow max thinking tokens up to 80% of max output tokens", () => {
99+
render(<ThinkingBudget {...defaultProps} apiConfiguration={{ modelMaxTokens: 1000 }} />)
100+
101+
const slider = screen.getByTestId("slider")
102+
// Max should be 80% of 1000 = 800
103+
expect(slider.getAttribute("max")).toBe("800")
104+
})
105+
98106
it("should use default thinking tokens if not provided", () => {
99107
render(<ThinkingBudget {...defaultProps} apiConfiguration={{ modelMaxTokens: 10000 }} />)
100108

@@ -103,10 +111,23 @@ describe("ThinkingBudget", () => {
103111
expect(slider).toHaveValue("8000") // 80% of 10000
104112
})
105113

106-
it("should use min thinking tokens of 1024", () => {
114+
it("should use min thinking tokens of 0", () => {
107115
render(<ThinkingBudget {...defaultProps} apiConfiguration={{ modelMaxTokens: 1000 }} />)
108116

109117
const slider = screen.getByTestId("slider")
110-
expect(slider.getAttribute("min")).toBe("1024")
118+
expect(slider.getAttribute("min")).toBe("0")
119+
})
120+
121+
it("should cap displayed value at 80% even if stored value is higher", () => {
122+
render(
123+
<ThinkingBudget
124+
{...defaultProps}
125+
apiConfiguration={{ modelMaxTokens: 1000, modelMaxThinkingTokens: 8192 }}
126+
/>,
127+
)
128+
129+
const slider = screen.getByTestId("slider")
130+
// Value should be capped at 800 (80% of 1000) even though stored value is 8192
131+
expect(slider).toHaveValue("800")
111132
})
112133
})

0 commit comments

Comments
 (0)