Python
Effort slider keeps the thumb where it was let go
Rohit C Prasad1786ef652c34
diff --git a/surfaces/gui/e2e/session-model-settings.spec.ts b/surfaces/gui/e2e/session-model-settings.spec.tsindex 3bfcdaa2..642720e9 100644--- a/surfaces/gui/e2e/session-model-settings.spec.ts+++ b/surfaces/gui/e2e/session-model-settings.spec.ts@@ -50,8 +50,8 @@ test("reasoning effort: the pill shows the level; the slider marks the default aconst track = (await slider.boundingBox())!;await page.mouse.click(track.x + 4, track.y + track.height / 2);await expect(pill).toHaveText("Low");- const thumb = (await page.getByTestId("effort-thumb").boundingBox())!;- expect(thumb.x - track.x).toBeLessThanOrEqual(4);+ // The thumb slides into place; wait for it to settle at the left end.+ await expect.poll(async () => (await page.getByTestId("effort-thumb").boundingBox())!.x - track.x).toBeLessThanOrEqual(4);await expect(page.getByTestId("effort-reset")).toHaveText("Reset to High");await page.getByTestId("effort-reset").click();await expect(pill).toHaveText("High");@@ -71,8 +71,12 @@ test("reasoning effort: drag to the far right end, and the keys step and jump",await page.mouse.move(track.x + track.width + 40, y, { steps: 5 });await page.mouse.up();await expect(page.getByTestId("effort-pill")).toHaveText("Max");- const thumb = (await page.getByTestId("effort-thumb").boundingBox())!;- expect(track.x + track.width - (thumb.x + thumb.width)).toBeLessThanOrEqual(4);+ await expect+ .poll(async () => {+ const thumb = (await page.getByTestId("effort-thumb").boundingBox())!;+ return track.x + track.width - (thumb.x + thumb.width);+ })+ .toBeLessThanOrEqual(4);await slider.focus();await page.keyboard.press("ArrowLeft");await expect(page.getByTestId("effort-pill")).toHaveText("Extra high");diff --git a/surfaces/gui/src/components/Composer.tsx b/surfaces/gui/src/components/Composer.tsxindex 164021ef..ae00f105 100644--- a/surfaces/gui/src/components/Composer.tsx+++ b/surfaces/gui/src/components/Composer.tsx@@ -1176,7 +1176,12 @@ function SessionModelControls({const centre = (i: number) => `calc(18px + (100% - 36px) * ${frac(i)})`;const choose = (i: number) => {const lvl = levels[Math.max(0, Math.min(levels.length - 1, i))];- if (lvl && lvl !== level) apply({ reasoning_effort: lvl === reason?.default ? null : lvl });+ if (!lvl || lvl === level) return;+ const value = lvl === reason?.default ? null : lvl;+ // Show the new level at once, so the thumb stays where it was let go of instead of+ // sliding back to the old level until the server answers.+ setEffort(value);+ apply({ reasoning_effort: value });};// More than three levels crowd the row: name the ends, the current level and the// default; the rest show when the pointer is over their stop.