Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(agents): remember the last picked effort for new conversations (#9560)
Eric Hayes21c662ea332d
diff --git a/apps/web/src/features/agents-view/primitives/preferred-effort.test.ts b/apps/web/src/features/agents-view/primitives/preferred-effort.test.tsnew file mode 100644index 0000000000..bd6c701e3b--- /dev/null+++ b/apps/web/src/features/agents-view/primitives/preferred-effort.test.ts@@ -0,0 +1,38 @@+import { createRoot } from 'solid-js';+import { beforeEach, describe, expect, it } from 'vitest';+import { createPreferredEffort } from './preferred-effort';++beforeEach(() => window.localStorage.clear());++const ULTRA = { configId: 'effort', value: 'ultra', name: 'Ultra' };+const HIGH = { configId: 'effort', value: 'high', name: 'High' };++describe('preferred effort', () => {+ it('remembers the last effort per target across composer mounts', () => {+ createRoot((dispose) => {+ const preferred = createPreferredEffort('user-a');+ preferred.remember('cursor:gpt-5', ULTRA);+ preferred.remember('in-memory:kimi', HIGH);+ dispose();+ });+ createRoot((dispose) => {+ const preferred = createPreferredEffort('user-a');+ expect(preferred.effort('cursor:gpt-5')).toEqual(ULTRA);+ expect(preferred.effort('in-memory:kimi')).toEqual(HIGH);+ expect(+ createPreferredEffort('user-b').effort('cursor:gpt-5')+ ).toBeUndefined();+ dispose();+ });+ });++ it('ignores malformed stored values', () => {+ window.localStorage.setItem('agents-view-effort-v1:user-a', '{"x":1');+ window.localStorage.setItem('agents-view-effort-v1:user-b', '{"x":1}');+ createRoot((dispose) => {+ expect(createPreferredEffort('user-a').effort('x')).toBeUndefined();+ expect(createPreferredEffort('user-b').effort('x')).toBeUndefined();+ dispose();+ });+ });+});diff --git a/apps/web/src/features/agents-view/primitives/preferred-effort.ts b/apps/web/src/features/agents-view/primitives/preferred-effort.tsnew file mode 100644index 0000000000..094149a356--- /dev/null+++ b/apps/web/src/features/agents-view/primitives/preferred-effort.ts@@ -0,0 +1,59 @@+import type { EffortChoice } from '@app/features/block-agent/state/session-config';+import { makePersistedState } from '@app/lib/persistence';+import { createUserScopedStorage } from '@core/util/userScopedStorage';+import { createSignal } from 'solid-js';+import { z } from 'zod';++const PREFERRED_EFFORTS_SCHEMA = z.record(+ z.string(),+ z.object({ configId: z.string(), value: z.string(), name: z.string() })+);++type PreferredEfforts = z.infer<typeof PREFERRED_EFFORTS_SCHEMA>;++/**+ * The last effort chosen in the New conversation composer for each agent+ * runtime and model. Scoped to the signed-in user so new conversations keep+ * starting on that effort until another one is picked.+ */+export function createPreferredEffort(userId: string | undefined) {+ const storage = createUserScopedStorage('agents-view-effort-v1');+ const [efforts, setEfforts] = makePersistedState(+ createSignal<PreferredEfforts>({}),+ {+ storages: {+ restore: () => {+ if (!userId) return;+ const stored = storage.read(userId);+ if (!stored) return;+ try {+ const parsed = PREFERRED_EFFORTS_SCHEMA.safeParse(+ JSON.parse(stored)+ );+ return parsed.success ? parsed.data : undefined;+ } catch {+ return undefined;+ }+ },+ write: (value) => {+ if (!userId) return;+ storage.write(userId, JSON.stringify(value));+ },+ },+ }+ );++ return {+ /** The remembered effort for one `target` (a serialized runtime and model). */+ effort: (target: string): EffortChoice | undefined => efforts()[target],+ remember: (target: string, choice: EffortChoice) =>+ setEfforts((current) => ({+ ...current,+ [target]: {+ configId: choice.configId,+ value: choice.value,+ name: choice.name,+ },+ })),+ };+}diff --git a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx b/apps/web/src/features/agents-view/views/NewChatPage.test.tsxindex 68b86b41ba..fcdf478372 100644--- a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx+++ b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx@@ -1388,6 +1388,49 @@ describe('agent-led new conversation', () => {expect.objectContaining({ effortOverride: undefined }));});+ it('keeps the last picked effort as the default for that model', async () => {+ const pickGpt5 = async () => {+ const models = await hoverAgent('Cursor');+ fireEvent.keyDown(models.getByRole('menuitem', { name: /^GPT-5/ }), {+ key: 'Enter',+ });+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());+ };+ const send = page(true, [], false, [], 'code');+ await pickGpt5();+ fireEvent.keyDown(screen.getByRole('button', { name: 'Effort: Low' }), {+ key: 'ArrowDown',+ });+ fireEvent.keyDown(await screen.findByRole('menuitem', { name: 'Ultra' }), {+ key: 'Enter',+ });+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));+ expect(send).toHaveBeenLastCalledWith(+ expect.objectContaining({+ effortOverride: { configId: 'cursor_effort', value: 'ultra' },+ })+ );++ await pickGpt5();+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));+ expect(send).toHaveBeenLastCalledWith(+ expect.objectContaining({+ effortOverride: { configId: 'cursor_effort', value: 'ultra' },+ })+ );++ cleanup();+ const remounted = page(true, [], false, [], 'code');+ await pickGpt5();+ expect(screen.getByRole('button', { name: 'Effort: Ultra' })).toBeTruthy();+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));+ expect(remounted).toHaveBeenLastCalledWith(+ expect.objectContaining({+ effortOverride: { configId: 'cursor_effort', value: 'ultra' },+ })+ );+ });});it('starts a conversation with an uploaded image and no text', () => {diff --git a/apps/web/src/features/agents-view/views/NewChatPage.tsx b/apps/web/src/features/agents-view/views/NewChatPage.tsxindex b7136057f0..9b0803b2a4 100644--- a/apps/web/src/features/agents-view/views/NewChatPage.tsx+++ b/apps/web/src/features/agents-view/views/NewChatPage.tsx@@ -52,6 +52,7 @@ import {createPersistedComposerDraft,NEW_CONVERSATION_ATTACHMENTS_KEY,} from '../primitives/composer-draft';+import { createPreferredEffort } from '../primitives/preferred-effort';import { createPreferredInmemModel } from '../primitives/preferred-inmem-model';import { createPreferredRepository } from '../primitives/preferred-repository';import { createRecentRepositories } from '../primitives/recent-repositories';@@ -114,6 +115,7 @@ export function NewChatPage(props: {const recentAgents = createRecentAgentSelections(userId());const repositories = createRecentRepositories(userId());const preferredInmem = createPreferredInmemModel(userId());+ const preferredEffort = createPreferredEffort(userId());const ownMode = createWorkspaceMode();const mode = () => props.mode ?? ownMode.mode();const auto = () => mode() === 'auto';@@ -194,20 +196,24 @@ export function NewChatPage(props: {effortConfigOption(capabilities.isSuccess ? capabilities.data.configOptions : []);- const [effortSelection, setEffortSelection] = createSignal<{- target: string;- configId: string;- value: string;- name: string;- }>();+ /** The last effort picked for the selected runtime and model, while it is still offered. */const selectedEffort = () => {- const selection = effortSelection();- return selection?.target === JSON.stringify(capabilityTarget())- ? selection+ const target = capabilityTarget();+ if (!target) return;+ const choice = preferredEffort.effort(JSON.stringify(target));+ const config = effort();+ // Retain it while the selected model's discovery refreshes; startup+ // revalidates against the runtime.+ if (!choice || !config) return choice;+ return config.id === choice.configId &&+ config.options.some((option) => option.value === choice.value)+ ? choice: undefined;};- // The submenu already validated this choice. Retain it while the selected- // model's discovery refreshes; startup revalidates against the runtime.+ const rememberEffort = (choice: EffortChoice) => {+ const target = capabilityTarget();+ if (target) preferredEffort.remember(JSON.stringify(target), choice);+ };const effortOverride = () => {const config = effort();const minimum =@@ -393,9 +399,9 @@ export function NewChatPage(props: {}: {}),});- // Macro's preferred model stays; coding-agent submenu picks are one-shot.+ // Macro's preferred model and the picked efforts stay; coding-agent model+ // picks are one-shot.setModelOverride(undefined);- setEffortSelection(undefined);};const selectAgent = (@@ -412,11 +418,7 @@ export function NewChatPage(props: {} else {setModelOverride(model);}- setEffortSelection(- selection- ? { ...selection, target: JSON.stringify(capabilityTarget()) }- : undefined- );+ if (selection) rememberEffort(selection);};let focusInput: (() => void) | undefined;@@ -454,9 +456,8 @@ export function NewChatPage(props: {);const setMode = (next: ComposerMode) => {- // A model or effort picked for the other mode's agent does not carry over.+ // A model picked for the other mode's agent does not carry over.setModelOverride(undefined);- setEffortSelection(undefined);if (props.onModeChange) props.onModeChange(next);else ownMode.setMode(next);};@@ -532,12 +533,7 @@ export function NewChatPage(props: {config={effort()}value={effortOverride()?.value}disabled={Boolean(blocked())}- onChange={(choice) =>- setEffortSelection({- ...choice,- target: JSON.stringify(capabilityTarget()),- })- }+ onChange={rememberEffort}/><Showwhen={['macro-inmem', 'in-memory'].includes(diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.mdindex 5eeee9bad8..983d5bc956 100644--- a/docs/agent-guide/ai-chat.md+++ b/docs/agent-guide/ai-chat.md@@ -515,7 +515,7 @@ the shimmer.without asking; any failure or a 3s timeout also falls back to Chat. The session opensunder Chat or Code like one started from that mode.Switching modes preserves the draft and attachments and- clears model and effort overrides from the previous mode. It does not filter+ clears the model override from the previous mode. It does not filterthe conversation sidebar. Session composers start at one line and grow withlonger prompts or Shift+Enter. Lists, quotes, headings, and other non-paragraphblocks expand immediately, even with short text. The editor takes the full width@@ -658,8 +658,10 @@ the shimmer.the catalog in place with a Back action. Search includes every model.- A compact **speedometer-style effort** button with a simple arc and needle beside the model selector opens a simple list of effort levels with a check beside the current choice: a popover centered below the button on desktop, or its own bottom sheet on mobile. Choosing a level applies it and closes the menu. Mobile shows it alongside the model control after the input expands. It is hidden when the model has fewer than two effort choices.Model-specific effort choices remain available in desktop model submenus.- Free and Pro users start new conversations at the lowest advertised level,- unless they explicitly choose another. Existing sessions keep their current setting.+ New conversations remember the last effort picked for each runtime and model,+ per signed-in user, across sends, mode switches, and reloads, while that model+ still offers it. Without one, Free and Pro users start at the lowest advertised+ level. Existing sessions keep their current setting.- On desktop, chat agents' empty input shows the static hint **Type @ to mentiondocs, people, or channels, / for skills** immediately, without typing or cyclingthrough other hints. Clearing a draft restores the same hint.