Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(agents): apply effort slider choice when the selector closes (#8509)

Jacob Beckerman1b23bbc653fb
diff --git a/apps/web/src/features/block-agent/component/EffortSelector.test.tsx b/apps/web/src/features/block-agent/component/EffortSelector.test.tsx
index d6f3c65b50..bea6fc4f39 100644
--- a/apps/web/src/features/block-agent/component/EffortSelector.test.tsx
+++ b/apps/web/src/features/block-agent/component/EffortSelector.test.tsx
@@ -8,6 +8,7 @@ import {
screen,
waitFor,
} from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
import type { SelectSessionConfigOption } from '../state/session-config';
import { EffortSelector } from './EffortSelector';
@@ -116,10 +117,17 @@ it('returns focus to the composer when the mobile chooser closes', async () => {
await waitFor(() => expect(document.activeElement).toBe(input));
});
-it('adjusts desktop effort with the speedometer slider and retains the popup', async () => {
+it('stages desktop slider effort and commits it when the popup closes', async () => {
vi.mocked(isTouchDevice).mockReturnValue(false);
const change = vi.fn();
- render(() => <EffortSelector config={config} onChange={change} />);
+ const openChange = vi.fn();
+ render(() => (
+ <EffortSelector
+ config={config}
+ onChange={change}
+ onOpenChange={openChange}
+ />
+ ));
fireEvent.keyDown(screen.getByRole('button', { name: 'Effort: Low' }), {
key: 'Enter',
});
@@ -129,10 +137,67 @@ it('adjusts desktop effort with the speedometer slider and retains the popup', a
await waitFor(() => expect(document.activeElement).toBe(slider));
expect(screen.queryByRole('menuitem', { name: 'Choose model' })).toBeNull();
fireEvent.keyDown(slider, { key: 'ArrowRight' });
+ expect(change).not.toHaveBeenCalled();
+ expect(screen.getByRole('menu')).toBeTruthy();
+ expect(
+ screen.getByRole('button', { name: 'Effort: High', hidden: true })
+ ).toBeTruthy();
+ fireEvent.keyDown(slider, { key: 'Escape' });
+ await waitFor(() => expect(openChange).toHaveBeenLastCalledWith(false));
expect(change).toHaveBeenCalledExactlyOnceWith({
configId: 'effort',
value: 'high',
name: 'High',
});
- expect(screen.getByRole('menu')).toBeTruthy();
+});
+
+it('does not commit when the desktop slider returns to the current effort', async () => {
+ vi.mocked(isTouchDevice).mockReturnValue(false);
+ const change = vi.fn();
+ const openChange = vi.fn();
+ render(() => (
+ <EffortSelector
+ config={config}
+ onChange={change}
+ onOpenChange={openChange}
+ />
+ ));
+ fireEvent.keyDown(screen.getByRole('button', { name: 'Effort: Low' }), {
+ key: 'Enter',
+ });
+ const slider = await screen.findByRole('slider', {
+ name: 'Reasoning effort',
+ });
+ await waitFor(() => expect(document.activeElement).toBe(slider));
+ fireEvent.keyDown(slider, { key: 'ArrowRight' });
+ fireEvent.keyDown(slider, { key: 'ArrowLeft' });
+ fireEvent.keyDown(slider, { key: 'Escape' });
+ await waitFor(() => expect(openChange).toHaveBeenLastCalledWith(false));
+ expect(change).not.toHaveBeenCalled();
+});
+
+it('drops a staged desktop effort when the config changes before close', async () => {
+ vi.mocked(isTouchDevice).mockReturnValue(false);
+ const change = vi.fn();
+ const openChange = vi.fn();
+ const [current, setCurrent] = createSignal(config);
+ render(() => (
+ <EffortSelector
+ config={current()}
+ onChange={change}
+ onOpenChange={openChange}
+ />
+ ));
+ fireEvent.keyDown(screen.getByRole('button', { name: 'Effort: Low' }), {
+ key: 'Enter',
+ });
+ const slider = await screen.findByRole('slider', {
+ name: 'Reasoning effort',
+ });
+ await waitFor(() => expect(document.activeElement).toBe(slider));
+ fireEvent.keyDown(slider, { key: 'ArrowRight' });
+ setCurrent({ ...config, id: 'other-effort' });
+ fireEvent.keyDown(slider, { key: 'Escape' });
+ await waitFor(() => expect(openChange).toHaveBeenLastCalledWith(false));
+ expect(change).not.toHaveBeenCalled();
});
diff --git a/apps/web/src/features/block-agent/component/EffortSelector.tsx b/apps/web/src/features/block-agent/component/EffortSelector.tsx
index 18c5ed4289..253a8b27e6 100644
--- a/apps/web/src/features/block-agent/component/EffortSelector.tsx
+++ b/apps/web/src/features/block-agent/component/EffortSelector.tsx
@@ -19,13 +19,28 @@ export function EffortSelector(props: {
onCloseAutoFocus?: (event: Event) => void;
}) {
const [open, setOpen] = createSignal(false);
+ // The desktop slider stages its choice here and commits it when the menu closes.
+ const [pending, setPending] = createSignal<EffortChoice>();
let content: HTMLElement | undefined;
const changeOpen = (value: boolean) => {
setOpen(value);
+ if (!value) {
+ const choice = pending();
+ setPending(undefined);
+ if (
+ choice &&
+ choice.configId === props.config?.id &&
+ choices().some((option) => option.value === choice.value) &&
+ choice.value !== committed() &&
+ !props.disabled
+ )
+ props.onChange(choice);
+ }
props.onOpenChange?.(value);
};
const choices = () => props.config?.options ?? [];
- const value = () => props.value ?? props.config?.currentValue;
+ const committed = () => props.value ?? props.config?.currentValue;
+ const value = () => pending()?.value ?? committed();
const index = () =>
Math.max(
0,
@@ -113,7 +128,7 @@ export function EffortSelector(props: {
(choice) => choice.value === next
);
if (props.config && choice)
- props.onChange({
+ setPending({
configId: props.config.id,
value: choice.value,
name: choice.name,
diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.md
index cc8eb0edae..47b9c23422 100644
--- a/docs/agent-guide/ai-chat.md
+++ b/docs/agent-guide/ai-chat.md
@@ -511,7 +511,8 @@ the shimmer.
the catalog in place with a Back action. Search includes every model.
- Desktop keeps the model selector and speedometer as separate controls. The
speedometer opens a slider with a stop for each advertised effort level. Arrow keys
- adjust the level; pointer drags commit on release. The popover stays open, and
+ and drags preview the level; it is applied once, when the popover closes, and
+ only if it differs from the current level. The popover stays open, and
the model selector opens the full catalog independently. On mobile, the **speedometer-style
effort** button opens its own sheet after the input expands. Choosing a level
applies it and closes the sheet. Models with fewer than two effort choices
@@ -1769,7 +1770,7 @@ There is no periodic PR lookup polling.
On desktop, open the speedometer beside the model selector to adjust the
current model with the **Reasoning effort** slider. The header and accessible value announce the
selected level. Arrow keys move between supported levels; the menu stays open
-until dismissed. The model selector opens the full catalog independently; other
+until dismissed, and the chosen level is applied when it closes. The model selector opens the full catalog independently; other
models still offer their own effort submenu with Right Arrow. On mobile, tap a model
to select it, then use the adjacent effort button to adjust effort.
Cursor and Macro's in-memory agent load the hovered model's own advertised
@@ -2015,7 +2016,7 @@ creating an event is a real action, including from a local app connected to dev.
On desktop, open the speedometer beside the model selector to adjust the
current model with the **Reasoning effort** slider. The header and accessible value announce the
selected level. Arrow keys move between supported levels; the menu stays open
-until dismissed. The model selector opens the full catalog independently; other
+until dismissed, and the chosen level is applied when it closes. The model selector opens the full catalog independently; other
models still offer their own effort submenu with Right Arrow. On mobile, tap a model
to select it, then use the adjacent effort button to adjust effort.
Cursor and Macro's in-memory agent load the hovered model's own advertised