Skip to content

Commit ca0fb2d

Browse files
committed
fix: enforce minimum thinking tokens of 1024 in UI slider
- Set minimum value to 1024 for thinking tokens slider to match backend validation - Update tests to reflect the new minimum constraint - This prevents users from setting thinking tokens below the required minimum
1 parent 1e76736 commit ca0fb2d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ 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={0}
66+
min={1024}
6767
max={modelMaxThinkingTokens}
6868
step={256}
6969
value={[Math.min(customMaxThinkingTokens, modelMaxThinkingTokens)]}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ describe("ThinkingBudget", () => {
9696
})
9797

9898
it("should allow max thinking tokens up to 80% of max output tokens", () => {
99-
render(<ThinkingBudget {...defaultProps} apiConfiguration={{ modelMaxTokens: 1000 }} />)
99+
render(<ThinkingBudget {...defaultProps} apiConfiguration={{ modelMaxTokens: 5000 }} />)
100100

101101
const slider = screen.getByTestId("slider")
102-
// Max should be 80% of 1000 = 800
103-
expect(slider.getAttribute("max")).toBe("800")
102+
// Max should be 80% of 5000 = 4000
103+
expect(slider.getAttribute("max")).toBe("4000")
104104
})
105105

106106
it("should use default thinking tokens if not provided", () => {
@@ -111,23 +111,23 @@ describe("ThinkingBudget", () => {
111111
expect(slider).toHaveValue("8000") // 80% of 10000
112112
})
113113

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

117117
const slider = screen.getByTestId("slider")
118-
expect(slider.getAttribute("min")).toBe("0")
118+
expect(slider.getAttribute("min")).toBe("1024")
119119
})
120120

121121
it("should cap displayed value at 80% even if stored value is higher", () => {
122122
render(
123123
<ThinkingBudget
124124
{...defaultProps}
125-
apiConfiguration={{ modelMaxTokens: 1000, modelMaxThinkingTokens: 8192 }}
125+
apiConfiguration={{ modelMaxTokens: 5000, modelMaxThinkingTokens: 8192 }}
126126
/>,
127127
)
128128

129129
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")
130+
// Value should be capped at 4000 (80% of 5000) even though stored value is 8192
131+
expect(slider).toHaveValue("4000")
132132
})
133133
})

0 commit comments

Comments
 (0)