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): open the composer in Auto with the sidebar's sparkle icon (#9026)

Eric Hayesdc03b4f994df
diff --git a/apps/web/src/features/agents-view/primitives/workspace-mode.test.ts b/apps/web/src/features/agents-view/primitives/workspace-mode.test.ts
index a75c62c020..070ca40cea 100644
--- a/apps/web/src/features/agents-view/primitives/workspace-mode.test.ts
+++ b/apps/web/src/features/agents-view/primitives/workspace-mode.test.ts
@@ -8,47 +8,32 @@ vi.mock('@app/lib/analytics/posthog', () => ({
}));
beforeEach(() => {
- window.localStorage.clear();
flag.autoEnabled = true;
});
describe('workspace mode', () => {
- it('starts in Auto and remembers each choice per user', () => {
+ it('opens every composer in Auto, whatever was chosen before', () => {
createRoot((dispose) => {
- const workspace = createWorkspaceMode('user-a');
+ const workspace = createWorkspaceMode();
expect(workspace.mode()).toBe('auto');
workspace.setMode('code');
- dispose();
- });
- createRoot((dispose) => {
- const workspace = createWorkspaceMode('user-a');
expect(workspace.mode()).toBe('code');
- expect(createWorkspaceMode('user-b').mode()).toBe('auto');
- workspace.setMode('chat');
dispose();
});
createRoot((dispose) => {
- expect(createWorkspaceMode('user-a').mode()).toBe('chat');
+ expect(createWorkspaceMode().mode()).toBe('auto');
dispose();
});
});
it('reads Auto as Chat without the flag and keeps an explicit Code', () => {
flag.autoEnabled = false;
- window.localStorage.setItem('agents-view-mode-v1:user-b', 'code');
createRoot((dispose) => {
- const workspace = createWorkspaceMode('user-a');
+ const workspace = createWorkspaceMode();
expect(workspace.autoAvailable()).toBe(false);
expect(workspace.mode()).toBe('chat');
- expect(createWorkspaceMode('user-b').mode()).toBe('code');
- dispose();
- });
- });
-
- it('ignores unknown stored values', () => {
- window.localStorage.setItem('agents-view-mode-v1:user-a', 'agents');
- createRoot((dispose) => {
- expect(createWorkspaceMode('user-a').mode()).toBe('auto');
+ workspace.setMode('code');
+ expect(workspace.mode()).toBe('code');
dispose();
});
});
diff --git a/apps/web/src/features/agents-view/primitives/workspace-mode.ts b/apps/web/src/features/agents-view/primitives/workspace-mode.ts
index 6cf2684316..f813065594 100644
--- a/apps/web/src/features/agents-view/primitives/workspace-mode.ts
+++ b/apps/web/src/features/agents-view/primitives/workspace-mode.ts
@@ -1,37 +1,18 @@
import { useFeatureFlag } from '@app/lib/analytics/posthog';
-import { makePersistedState } from '@app/lib/persistence';
import { enableComposerAutoMode } from '@core/constant/featureFlags';
-import { createUserScopedStorage } from '@core/util/userScopedStorage';
import { createSignal } from 'solid-js';
import type { ComposerMode } from '../core/mode';
-const MODES: readonly ComposerMode[] = ['auto', 'chat', 'code'];
-
/**
* Whether the new-conversation composer picks the agent kind per prompt
* (Auto), or always starts chat agents (Chat) or coding agents (Code).
- * Scoped to the signed-in user; a new person starts in Auto, which reads as
- * Chat for anyone without {@link enableComposerAutoMode}.
+ * Every composer opens in Auto; a Chat or Code choice lasts only while it is
+ * mounted. Auto reads as Chat for anyone without {@link enableComposerAutoMode}.
*/
-export function createWorkspaceMode(userId: string | undefined) {
- const storage = createUserScopedStorage('agents-view-mode-v1');
+export function createWorkspaceMode() {
const autoFlag = useFeatureFlag(enableComposerAutoMode);
const autoAvailable = () => autoFlag().enabled;
- const [stored, setMode] = makePersistedState(
- createSignal<ComposerMode>('auto'),
- {
- storages: {
- restore: () => {
- if (!userId) return;
- const value = storage.read(userId);
- return MODES.find((mode) => mode === value);
- },
- write: (value) => {
- if (userId) storage.write(userId, value);
- },
- },
- }
- );
+ const [stored, setMode] = createSignal<ComposerMode>('auto');
const mode = (): ComposerMode => {
const value = stored();
return value === 'auto' && !autoAvailable() ? 'chat' : value;
diff --git a/apps/web/src/features/agents-view/views/AgentsView.tsx b/apps/web/src/features/agents-view/views/AgentsView.tsx
index abdc7ab100..c4e3d2e587 100644
--- a/apps/web/src/features/agents-view/views/AgentsView.tsx
+++ b/apps/web/src/features/agents-view/views/AgentsView.tsx
@@ -88,8 +88,8 @@ function AgentsWorkspace(props: { route?: AgentsRoute }) {
useWarmAgentSessionQuery(userId);
const notifications = useGlobalNotificationSource();
const mode = (): AgentsMode => props.route?.mode ?? 'chat';
- // The composer's Chat/Code choice; an open conversation keeps its own mode.
- const workspace = createWorkspaceMode(userId());
+ // The composer's Auto/Chat/Code choice; an open conversation keeps its own mode.
+ const workspace = createWorkspaceMode();
const listView = createConversationListView(userId());
const [creatingKind, setCreatingKind] = createSignal<AgentKind>();
const [localPage, setPage] = createSignal<AgentsPage>('new');
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
index 6b2cbb8da8..7789dfc657 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
@@ -234,10 +234,12 @@ vi.mock('../components/ChatComposer', () => ({
),
}));
+/** Most cases exercise an explicit Chat or Code choice; Auto has its own. */
+let startInChat = true;
+
beforeEach(() => {
localStorage.clear();
- // Most cases exercise an explicit Chat or Code choice; Auto has its own.
- localStorage.setItem('agents-view-mode-v1:user', 'chat');
+ startInChat = true;
mocks.userId = () => 'user';
mocks.chooseAgentMode.mockClear();
mocks.autoEnabled = true;
@@ -269,6 +271,8 @@ function page(
onOpenRoster={vi.fn()}
/>
));
+ const chat = screen.queryByRole('radio', { name: 'Chat' });
+ if (mode === undefined && startInChat && chat) fireEvent.click(chat);
return onStart;
}
function openAgents() {
@@ -434,8 +438,8 @@ describe('agent-led new conversation', () => {
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
}
});
- it('starts a new person in Auto without an agent, model, or effort to pick', () => {
- localStorage.clear();
+ it('starts in Auto without an agent, model, or effort to pick', () => {
+ startInChat = false;
page();
expect(
(screen.getByRole('radio', { name: 'Auto' }) as HTMLInputElement).checked
@@ -447,7 +451,6 @@ describe('agent-led new conversation', () => {
expect(screen.queryByRole('button', { name: 'Repository' })).toBeNull();
});
it('offers only Chat and Code without the Auto flag', () => {
- localStorage.clear();
mocks.autoEnabled = false;
const send = page();
expect(screen.queryByRole('radio', { name: 'Auto' })).toBeNull();
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.tsx b/apps/web/src/features/agents-view/views/NewChatPage.tsx
index d4468e32be..ab91d8c73d 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.tsx
@@ -20,7 +20,7 @@ import { fireAndForget } from '@core/util/fireAndForget';
import { uploadFile } from '@core/util/upload';
import ChatIcon from '@icon/system/regular/chat-circle.svg';
import CodeIcon from '@icon/system/regular/code.svg';
-import AutoIcon from '@icon/system/regular/magic-wand.svg';
+import AutoIcon from '@icon/system/regular/sparkle.svg';
import { useAgentCapabilitiesQuery } from '@queries/agents/capabilities';
import { chooseAgentMode } from '@queries/agents/mode-choice';
import { useAiBillingSummaryQuery } from '@queries/auth/ai-billing';
@@ -86,7 +86,7 @@ export function NewChatPage(props: {
roster: RosterAgent[];
/**
* Auto, Chat, or Code; Chat and Code also limit the agents offered.
- * Uncontrolled callers get the signed-in user's last choice.
+ * Uncontrolled callers start in Auto.
*/
mode?: ComposerMode;
onModeChange?: (mode: ComposerMode) => void;
@@ -103,7 +103,7 @@ export function NewChatPage(props: {
const recentAgents = createRecentAgentSelections(userId());
const repositories = createRecentRepositories(userId());
const preferredInmem = createPreferredInmemModel(userId());
- const ownMode = createWorkspaceMode(userId());
+ const ownMode = createWorkspaceMode();
const mode = () => props.mode ?? ownMode.mode();
const auto = () => mode() === 'auto';
/** Auto shows and prepares the chat agent; a prompt it sends to Code starts the coding agent. */
diff --git a/apps/web/src/features/local-runtime/local-runtime-setup.tsx b/apps/web/src/features/local-runtime/local-runtime-setup.tsx
index e022fe59df..c2c59a9029 100644
--- a/apps/web/src/features/local-runtime/local-runtime-setup.tsx
+++ b/apps/web/src/features/local-runtime/local-runtime-setup.tsx
@@ -1,5 +1,4 @@
import { openAgentComposer } from '@app/features/agents-view/primitives/open-composer';
-import { createWorkspaceMode } from '@app/features/agents-view/primitives/workspace-mode';
import { createRecentAgentSelections } from '@app/features/block-agent/context/recent-agent-selections';
import { useSplitLayout } from '@components/app/split-layout/layout';
import { useUserId } from '@core/context/user';
@@ -23,9 +22,8 @@ export function LocalRuntimeSetup(props: {
const layout = useSplitLayout();
const openSession = (agent: ReadyAgent) => {
- // The composer opens on the agent last chosen, in Code mode.
+ // The composer opens in Auto, with this agent as the usual coding agent.
createRecentAgentSelections(userId()).remember(agent.botId);
- createWorkspaceMode(userId()).setMode('code');
openAgentComposer(layout);
};
diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.md
index 1727e37650..f658a40503 100644
--- a/docs/agent-guide/ai-chat.md
+++ b/docs/agent-guide/ai-chat.md
@@ -413,11 +413,11 @@ the shimmer.
The selected segment glides for 250ms with
an ease-out curve. The greeting text flips vertically into place on each mode change
with the same duration; both animations respect reduced motion.
- Its bottom corners follow the toggle's curve. Chat and Code limit the offered agents; the choice is
- remembered per user, and a person with no saved choice starts in **Auto**. Auto is
+ Its bottom corners follow the toggle's curve. Chat and Code limit the offered agents; the choice
+ lasts only while the composer is mounted, and every composer opens in **Auto**. Auto is
behind the `enable-composer-auto-mode` PostHog flag (Macro employees only), which the
- agent harness checks too; without it the switch is Chat / Code and a saved Auto reads as Chat.
- **Auto** (magic wand) hides the agent, model, effort, and speed controls. On send, the
+ agent harness checks too; without it the switch is Chat / Code and Auto reads as Chat.
+ **Auto** (sparkle, the sidebar's Agents icon) hides the agent, model, effort, and speed controls. On send, the
input is briefly blocked (“Choosing Chat or Code…”) while `POST /agent-mode-choice` on the
agent harness asks Cloudflare's Clef Flash whether the prompt needs a coding agent. Code
starts the user's most recently used coding agent (else the first that can start) with its default model and
diff --git a/docs/agent-guide/settings.md b/docs/agent-guide/settings.md
index e9b4e00bf8..1cc5590a4d 100644
--- a/docs/agent-guide/settings.md
+++ b/docs/agent-guide/settings.md
@@ -668,7 +668,7 @@ New macrod sessions use the agent's saved model before sending the first prompt.
Changing that default applies to new sessions; existing sessions keep their selected model.
If the runtime rejects the saved model, the prompt fails instead of using a different model.
-The `Runtimes` section shows built-in Macro, Cursor, and Codex configuration, followed by paired macrod runtimes. Codex's card appears only within the agents and Codex rollouts. On the desktop app only, a “This computer” card appears above the built-in runtimes: the bundled macrod daemon is set up from here with one click. `Set up` scans the machine for installed agents and names the one it will use (Claude Code first, then Codex, OpenCode, OpenClaw, Hermes); `Options` changes the agent, workspace folder, and Full access. `Set up <agent>` then walks a three-step checklist — Find an agent, Connect this computer (start, install the connector, link to the account; the pairing is approved automatically, no code is typed), Create your agent (a private `@<agent>` coding agent bound to this runtime) — and ends on `@<agent> is ready` with `Start a session`, which opens the Agents composer in Code mode on that agent. A failed step shows its error and `Try again`, which resumes at the failed step. A desktop app that was never set up also shows a one-time “Run agents on this computer” prompt whose `Set up` runs the same flow in a dialog; closing the prompt sticks. A running runtime with no agent bound to it offers `Create agent`. The app then keeps the daemon up: it restarts after any unexpected exit (with backoff) and on every launch until the user presses `Stop`, and any re-pairing is approved from wherever the user is in the app, not only on this card. While running the card shows the bound agent and workspace with a `Stop` action; a stopped runtime offers `Start`. The web app never shows this card. The “Bring your own agent” card sits above the Agents / Runtimes navigation and is visible on both sections. It rotates Claude Code, OpenCode, OpenClaw, and Hermes; reduced motion keeps a static name. Its `New runtime` action opens the full-page pairing flow from either section: enter the code, look up the request, review the machine, name, sharing and permission consent, then Approve and Done. Back/Cancel returns to the runtime list. Destructive removal still requires confirmation. `/settings/runtimes` opens this section; legacy `/settings/harness?pair=…` links remain supported.
+The `Runtimes` section shows built-in Macro, Cursor, and Codex configuration, followed by paired macrod runtimes. Codex's card appears only within the agents and Codex rollouts. On the desktop app only, a “This computer” card appears above the built-in runtimes: the bundled macrod daemon is set up from here with one click. `Set up` scans the machine for installed agents and names the one it will use (Claude Code first, then Codex, OpenCode, OpenClaw, Hermes); `Options` changes the agent, workspace folder, and Full access. `Set up <agent>` then walks a three-step checklist — Find an agent, Connect this computer (start, install the connector, link to the account; the pairing is approved automatically, no code is typed), Create your agent (a private `@<agent>` coding agent bound to this runtime) — and ends on `@<agent> is ready` with `Start a session`, which opens the Agents composer in Auto with that agent as the usual coding agent. A failed step shows its error and `Try again`, which resumes at the failed step. A desktop app that was never set up also shows a one-time “Run agents on this computer” prompt whose `Set up` runs the same flow in a dialog; closing the prompt sticks. A running runtime with no agent bound to it offers `Create agent`. The app then keeps the daemon up: it restarts after any unexpected exit (with backoff) and on every launch until the user presses `Stop`, and any re-pairing is approved from wherever the user is in the app, not only on this card. While running the card shows the bound agent and workspace with a `Stop` action; a stopped runtime offers `Start`. The web app never shows this card. The “Bring your own agent” card sits above the Agents / Runtimes navigation and is visible on both sections. It rotates Claude Code, OpenCode, OpenClaw, and Hermes; reduced motion keeps a static name. Its `New runtime` action opens the full-page pairing flow from either section: enter the code, look up the request, review the machine, name, sharing and permission consent, then Approve and Done. Back/Cancel returns to the runtime list. Destructive removal still requires confirmation. `/settings/runtimes` opens this section; legacy `/settings/harness?pair=…` links remain supported.
Connection chips in agent replies open this page, including before any account is connected. Cursor's default-model picker uses
the same live model discovery and retains its existing save action.