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.

feat(desktop): make local agent setup discoverable (#8399)

Eric Hayes6bf3b923e5aa
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index cb13631aee..9633229194 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -325,6 +325,10 @@ Connect can close without reporting success (an OAuth provider severs its
consent popup's opener) even though Pipedream created the account. Every close
without success, on web and native, asks `/pipedream/mcp/recover` to register
the user's newest account for that app from the last fifteen minutes.
+Desktop Home and Agents new-conversation and active-session composers show the shared **Run agents
+on this computer** invitation until this installation is paired or the current
+user dismisses it locally. Keep the invitation tied to bundled macrod support,
+not to account-wide paired runtime count; a user can pair several computers.
### General
diff --git a/apps/web/src/features/agents-view/components/AgentPickerIdentity.tsx b/apps/web/src/features/agents-view/components/AgentPickerIdentity.tsx
index cb3693f6cd..7a928e8145 100644
--- a/apps/web/src/features/agents-view/components/AgentPickerIdentity.tsx
+++ b/apps/web/src/features/agents-view/components/AgentPickerIdentity.tsx
@@ -1,5 +1,7 @@
+import { AgentOfflineBadge } from '@core/component/AgentOfflineBadge';
import { modelLabel } from '@core/component/AI/constant/model-label';
import Check from '@icon/system/regular/check.svg';
+import { cn } from '@ui';
import { Show } from 'solid-js';
import type { RosterAgent } from '../core/roster';
import { AgentIcon } from './AgentGlyph';
@@ -29,11 +31,18 @@ export function AgentPickerIdentity(props: {
<AgentIcon agent={props.agent} class="size-[18px]" />
</span>
<span class="min-w-0 flex-1 text-left">
- <span
- class="block truncate text-sm font-medium leading-5"
- title={props.agent.name}
- >
- {props.agent.name}
+ <span class="flex min-w-0 items-center gap-2">
+ <span
+ class={cn('block min-w-0 truncate text-sm font-medium leading-5', {
+ 'text-ink-muted': props.agent.offline,
+ })}
+ title={props.agent.name}
+ >
+ {props.agent.name}
+ </span>
+ <Show when={props.agent.offline}>
+ <AgentOfflineBadge />
+ </Show>
</span>
<span
class="block truncate text-xs leading-4 text-ink-muted"
diff --git a/apps/web/src/features/agents-view/components/AgentSessionPane.tsx b/apps/web/src/features/agents-view/components/AgentSessionPane.tsx
index f31d923216..39510002ee 100644
--- a/apps/web/src/features/agents-view/components/AgentSessionPane.tsx
+++ b/apps/web/src/features/agents-view/components/AgentSessionPane.tsx
@@ -22,6 +22,7 @@ import {
ReviewNotesDock,
} from '@app/features/changes/changes';
import { useBlockEntityCommands } from '@app/features/next-soup/actions';
+import { LocalRuntimePrompt } from '@app/features/settings/components/local-runtime-prompt';
import { SidePanel } from '@components/app/side-panel';
import { SplitFileMenu } from '@components/app/split-layout/components/SplitFileMenu';
import {
@@ -291,6 +292,7 @@ function SessionContent(props: {
>
<ChangesHandoff />
<ReviewNotesDock />
+ <LocalRuntimePrompt />
<AgentComposer
autofocus={!searchTarget()}
input={ChatSessionInput}
diff --git a/apps/web/src/features/agents-view/core/roster.test.ts b/apps/web/src/features/agents-view/core/roster.test.ts
index f3f3b78827..7683a68225 100644
--- a/apps/web/src/features/agents-view/core/roster.test.ts
+++ b/apps/web/src/features/agents-view/core/roster.test.ts
@@ -101,6 +101,8 @@ describe('buildAgentRoster', () => {
});
expect(saved[2]?.unavailableReason).toBe('Its runtime is disconnected');
expect(saved[2]?.connectLabel).toBe('Reconnect runtime');
+ expect(saved[2]?.offline).toBe(true);
+ expect(saved[1]?.offline).toBeFalsy();
expect(saved[3]?.runtime.label).toBe('Disconnected runtime');
});
diff --git a/apps/web/src/features/agents-view/core/roster.ts b/apps/web/src/features/agents-view/core/roster.ts
index aee19ae97f..9511086cb1 100644
--- a/apps/web/src/features/agents-view/core/roster.ts
+++ b/apps/web/src/features/agents-view/core/roster.ts
@@ -66,6 +66,12 @@ export type RosterAgent = {
ownerId?: string;
/** Why it cannot be started from the composer right now, when it cannot. */
unavailableReason?: string;
+ /**
+ * Its paired machine is not connected. Distinct from an unconfigured
+ * built-in runtime: there is nothing to set up, the computer is just away,
+ * so surfaces mark it "Offline" rather than offering a connect flow.
+ */
+ offline?: boolean;
/** An unavailable agent with a setup action stays clickable. */
connectLabel?: string;
/** The persisted record behind a user-made agent; absent for system ones. */
@@ -153,6 +159,7 @@ function persistedAgent(
agent.bot.owner?.type === 'user'
? agent.bot.owner.user_id
: (agent.bot.created_by ?? undefined),
+ offline: agent.harness === 'macrod' && !connected,
connectLabel:
agent.harness === 'cursor' && input.cursorNeedsConnection
? 'Connect Cursor'
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.tsx b/apps/web/src/features/agents-view/views/NewChatPage.tsx
index 4ab0d0c425..f4e33a5a4b 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.tsx
@@ -1,5 +1,6 @@
import { promptActionOf } from '@app/features/block-agent/component/prompt-action';
import { createRecentAgentSelections } from '@app/features/block-agent/context/recent-agent-selections';
+import { LocalRuntimePrompt } from '@app/features/settings/components/local-runtime-prompt';
import {
createInputAttachmentTracker,
type InputAttachmentData,
@@ -601,6 +602,7 @@ export function NewChatPage(props: {
data-agent-new-composer={props.workspaceId}
class="agents-view-portal touch:px-(--mobile-chrome-gutter) pointer-events-auto min-w-0"
>
+ <LocalRuntimePrompt />
{composer()}
</div>
</FloatRegionOrInline>
diff --git a/apps/web/src/features/channel/use-channel-bot-mention-users.test.ts b/apps/web/src/features/channel/use-channel-bot-mention-users.test.ts
index cfd009e9f5..10d33b4fb6 100644
--- a/apps/web/src/features/channel/use-channel-bot-mention-users.test.ts
+++ b/apps/web/src/features/channel/use-channel-bot-mention-users.test.ts
@@ -9,6 +9,7 @@ import {
} from './use-channel-bot-mention-users';
const flags = vi.hoisted(() => ({ cursor: (): boolean => false }));
+const offline = vi.hoisted(() => ({ ids: new Set<string>() }));
vi.mock('@core/constant/featureFlags', () => ({
enableCursorAgents: { key: 'enable-cursor-agents' },
}));
@@ -28,6 +29,9 @@ vi.mock('@queries/agents/agents', () => ({
],
}),
}));
+vi.mock('@queries/agents/offline-runtimes', () => ({
+ useOfflineAgentBotIds: () => () => offline.ids,
+}));
const timestamp = '2026-08-27T12:00:00Z';
@@ -65,6 +69,25 @@ function agent(
describe('availableBotMentionUsers', () => {
beforeEach(() => {
flags.cursor = () => false;
+ offline.ids = new Set<string>();
+ });
+
+ it('marks an agent whose runtime is offline', () => {
+ createRoot((dispose) => {
+ flags.cursor = () => true;
+ offline.ids = new Set(['codex-agent']);
+ const users = useMessageBotMentionUsers(() => ({
+ type: 'channel',
+ id: 'channel-1',
+ }));
+ expect(
+ users().find((user) => user.id === 'bot|codex-agent')?.offline
+ ).toBe(true);
+ expect(
+ users().find((user) => user.id === `bot|${CURSOR_BOT_ID}`)?.offline
+ ).toBeUndefined();
+ dispose();
+ });
});
it('updates Cursor mention visibility when the rollout changes', () => {
diff --git a/apps/web/src/features/channel/use-channel-bot-mention-users.ts b/apps/web/src/features/channel/use-channel-bot-mention-users.ts
index 3a96ab02b3..fd1cf13637 100644
--- a/apps/web/src/features/channel/use-channel-bot-mention-users.ts
+++ b/apps/web/src/features/channel/use-channel-bot-mention-users.ts
@@ -2,6 +2,7 @@ import { isCursorBotId } from '@core/constant/cursorAgent';
import { useCursorAgentsAccess } from '@core/cursor/flag';
import type { IUser } from '@core/user/types';
import { useAgentsQuery } from '@queries/agents/agents';
+import { useOfflineAgentBotIds } from '@queries/agents/offline-runtimes';
import { useChannelBotsQuery } from '@queries/channel/channel-bots';
import { queryReadyGate } from '@queries/gate';
import type { Agent } from '@service-storage/generated/schemas/agent';
@@ -9,12 +10,13 @@ import type { Bot } from '@service-storage/generated/schemas/bot';
import type { MessageParent } from '@service-storage/messages';
import { type Accessor, createMemo } from 'solid-js';
-function mentionUser(bot: Bot): IUser {
+function mentionUser(bot: Bot, offline: boolean): IUser {
return {
id: `bot|${bot.id}`,
name: bot.name,
email: bot.name,
photoUrl: bot.avatar_url ?? undefined,
+ offline: offline || undefined,
};
}
@@ -23,12 +25,17 @@ function mentionUser(bot: Bot): IUser {
* agents. Account setup does not hide a mention: the harness answers with
* a connection prompt in the thread when setup is needed. The built-in
* Cursor entry follows the Cursor rollout flag.
+ *
+ * A disconnected macrod runtime is different from unfinished setup, and is
+ * marked: no harness is listening, so the mention would go unanswered rather
+ * than prompt for anything.
*/
export function availableBotMentionUsers(
channelBots: readonly Bot[],
agents: readonly Agent[],
cursorEnabled: boolean,
- surface: MessageParent['type'] = 'channel'
+ surface: MessageParent['type'] = 'channel',
+ offlineBotIds: ReadonlySet<string> = new Set()
): IUser[] {
const globalAgents = agents.filter(
(agent) =>
@@ -39,7 +46,7 @@ export function availableBotMentionUsers(
return [...channelBots, ...globalAgents.map((agent) => agent.bot)]
.filter((bot) => cursorEnabled || !isCursorBotId(bot.id))
- .map(mentionUser)
+ .map((bot) => mentionUser(bot, offlineBotIds.has(bot.id)))
.filter((user) => {
if (seen.has(user.id)) return false;
seen.add(user.id);
@@ -62,13 +69,15 @@ export function useMessageBotMentionUsers(
);
const agents = useAgentsQuery();
const canUseCursor = useCursorAgentsAccess();
+ const offlineBotIds = useOfflineAgentBotIds();
return createMemo(() =>
availableBotMentionUsers(
queryReadyGate(channelBots) ? channelBots.data : [],
queryReadyGate(agents) ? agents.data : [],
canUseCursor(),
- parent().type
+ parent().type,
+ offlineBotIds()
)
);
}
diff --git a/apps/web/src/features/home/components/HomeChatStart.test.tsx b/apps/web/src/features/home/components/HomeChatStart.test.tsx
index 77da2b719a..fb5aa3f346 100644
--- a/apps/web/src/features/home/components/HomeChatStart.test.tsx
+++ b/apps/web/src/features/home/components/HomeChatStart.test.tsx
@@ -31,6 +31,9 @@ vi.mock('@app/lib/analytics/posthog', () => ({
useFeatureFlag: () => () => ({ enabled: mocks.agentsEnabled }),
}));
vi.mock('@core/constant/featureFlags', () => ({ enableChatV3Agents: {} }));
+vi.mock('@app/features/settings/components/local-runtime-prompt', () => ({
+ LocalRuntimePrompt: () => null,
+}));
vi.mock('@core/component/AI/component/DragDrop', () => ({
DragDropWrapper: (props: ChildrenProps & { class?: string }) => (
<div data-testid="home-composer-frame" class={props.class}>
diff --git a/apps/web/src/features/home/components/HomeChatStart.tsx b/apps/web/src/features/home/components/HomeChatStart.tsx
index ff7824fd09..314d689f36 100644
--- a/apps/web/src/features/home/components/HomeChatStart.tsx
+++ b/apps/web/src/features/home/components/HomeChatStart.tsx
@@ -3,6 +3,7 @@ import {
ViewShell,
ViewSidebar,
} from '@app/components/view-shell';
+import { LocalRuntimePrompt } from '@app/features/settings/components/local-runtime-prompt';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { DragDropWrapper } from '@core/component/AI/component/DragDrop';
import { ChatInputProvider } from '@core/component/AI/context';
@@ -62,11 +63,16 @@ export function HomeChatStart() {
</div>
</Show>
</div>
- <HomeChatInput
- variant="default"
- placeholder="Type @ to reference / for skills"
- autoFocusOnMount={false}
- />
+ <div class="min-w-0">
+ <Show when={!agents().enabled}>
+ <LocalRuntimePrompt />
+ </Show>
+ <HomeChatInput
+ variant="default"
+ placeholder="Type @ to reference / for skills"
+ autoFocusOnMount={false}
+ />
+ </div>
<div class="min-h-0 min-w-0 pb-8">
<HomeRecommendedActions />
</div>
diff --git a/apps/web/src/features/local-runtime/views/local-runtime-setup-panel.tsx b/apps/web/src/features/local-runtime/views/local-runtime-setup-panel.tsx
index a155f1f905..ef273d3225 100644
--- a/apps/web/src/features/local-runtime/views/local-runtime-setup-panel.tsx
+++ b/apps/web/src/features/local-runtime/views/local-runtime-setup-panel.tsx
@@ -5,7 +5,7 @@ import CaretDownIcon from '@icon/system/regular/caret-down.svg';
import CheckCircleIcon from '@icon/system/regular/check-circle.svg';
import SpinnerIcon from '@icon/system/regular/spinner-gap.svg';
import type { MacrodStatus } from '@macro/tauri/macrod';
-import { Button, cn } from '@ui';
+import { Button, cn, ToggleSwitch } from '@ui';
import { createSignal, Match, onMount, Show, Switch } from 'solid-js';
import { match } from 'ts-pattern';
import {
@@ -342,27 +342,29 @@ function SetupOptions(props: {
{t('localRuntime.workspaceHint')}
</p>
</div>
- <label class="flex w-full items-start gap-3 rounded-lg border border-edge-muted p-4 text-sm text-ink">
- <input
- type="checkbox"
- class="mt-0.5 size-5 shrink-0 accent-accent"
+ <div class="w-full rounded-lg border border-edge-muted p-4">
+ <ToggleSwitch
+ size="md"
+ class="w-full items-start"
+ controlClass="mt-0.5 shrink-0"
+ labelClass="text-sm text-ink"
checked={props.fullAccess}
- onChange={(event) =>
- props.onFullAccess(event.currentTarget.checked)
+ onChange={props.onFullAccess}
+ label={
+ <span>
+ <span class="flex flex-wrap items-center gap-2 font-semibold">
+ {t('localRuntime.fullAccess')}
+ <span class="rounded-full bg-ink/6 px-2 py-0.5 text-xs font-medium text-ink-muted">
+ {t('localRuntime.suggested')}
+ </span>
+ </span>
+ <span class="mt-1 block text-sm text-ink-muted">
+ {t('localRuntime.fullAccessHint')}
+ </span>
+ </span>
}
/>
- <span>
- <span class="flex flex-wrap items-center gap-2 font-semibold">
- {t('localRuntime.fullAccess')}
- <span class="rounded-full bg-ink/6 px-2 py-0.5 text-xs font-medium text-ink-muted">
- {t('localRuntime.suggested')}
- </span>
- </span>
- <span class="mt-1 block text-sm text-ink-muted">
- {t('localRuntime.fullAccessHint')}
- </span>
- </span>
- </label>
+ </div>
<Show when={props.needsInstall}>
<p class="text-xs text-ink-extra-muted">
{t('localRuntime.connectorHint')}
diff --git a/apps/web/src/features/settings/Agents.tsx b/apps/web/src/features/settings/Agents.tsx
index c7f0ffff3b..aa15b056a6 100644
--- a/apps/web/src/features/settings/Agents.tsx
+++ b/apps/web/src/features/settings/Agents.tsx
@@ -206,10 +206,15 @@ export function Agents(props: {
);
return {
id: target.harnessId ?? '',
- name:
- harness?.owner.type === 'team'
- ? `${harness.name} · Team`
- : (harness?.name ?? 'macrod'),
+ // Offline runtimes stay selectable: binding an agent to a machine
+ // that is merely asleep is normal, and the label says what to expect.
+ name: [
+ harness?.name ?? 'macrod',
+ harness?.owner.type === 'team' ? 'Team' : undefined,
+ harness && !harness.connected ? 'Offline' : undefined,
+ ]
+ .filter(Boolean)
+ .join(' · '),
kind: 'macrod',
allowPermissionBypass: harness?.allow_permission_bypass ?? false,
target,
diff --git a/apps/web/src/features/settings/Harness.test.tsx b/apps/web/src/features/settings/Harness.test.tsx
index 309969ff6d..4750c16b21 100644
--- a/apps/web/src/features/settings/Harness.test.tsx
+++ b/apps/web/src/features/settings/Harness.test.tsx
@@ -370,7 +370,7 @@ describe('Harness', () => {
expect(screen.queryByText('No paired runtimes yet')).toBeNull();
expect(
- screen.queryByRole('heading', { name: 'Paired runtimes' })
+ screen.queryByRole('heading', { name: 'Connected runtimes' })
).toBeNull();
expect(
screen.queryByRole('button', { name: 'Enter pairing code' })
@@ -400,6 +400,9 @@ describe('Harness', () => {
render(() => <Harness />);
+ expect(
+ screen.getByRole('heading', { name: 'Connected runtimes' })
+ ).toBeTruthy();
expect(screen.getByText('Dev box')).toBeTruthy();
expect(screen.getByText('Team')).toBeTruthy();
expect(screen.getByRole('img', { name: 'Connected' })).toBeTruthy();
@@ -407,11 +410,32 @@ describe('Harness', () => {
expect(screen.queryByText('Never connected')).toBeNull();
});
- it('shows a disconnected private harness that never connected', () => {
+ it('lists an offline runtime below the connected ones', () => {
+ const offline = {
+ ...REGISTERED_HARNESS,
+ id: 'harness-offline',
+ name: 'Old laptop',
+ owner: { type: 'user' as const, user_id: 'macro|[email protected]' },
+ connected: false,
+ last_connected_at: null,
+ };
+ harnessMocks.query.data = [offline, REGISTERED_HARNESS];
+
+ render(() => <Harness />);
+
+ expect(screen.getByText('Private')).toBeTruthy();
+ expect(screen.getByRole('img', { name: 'Offline' })).toBeTruthy();
+ expect(screen.getByText('Never connected')).toBeTruthy();
+ const names = screen
+ .getAllByText(/Dev box|Old laptop/)
+ .map((node) => node.textContent);
+ expect(names).toEqual(['Dev box', 'Old laptop']);
+ });
+
+ it('hides the section when every runtime is offline', () => {
harnessMocks.query.data = [
{
...REGISTERED_HARNESS,
- owner: { type: 'user', user_id: 'macro|[email protected]' },
connected: false,
last_connected_at: null,
},
@@ -419,9 +443,10 @@ describe('Harness', () => {
render(() => <Harness />);
- expect(screen.getByText('Private')).toBeTruthy();
- expect(screen.getByRole('img', { name: 'Disconnected' })).toBeTruthy();
- expect(screen.getByText('Never connected')).toBeTruthy();
+ expect(
+ screen.queryByRole('heading', { name: 'Connected runtimes' })
+ ).toBeNull();
+ expect(screen.queryByText('Dev box')).toBeNull();
});
it('confirms before removing a harness', async () => {
diff --git a/apps/web/src/features/settings/Harness.tsx b/apps/web/src/features/settings/Harness.tsx
index d936e1bdc7..a52c335b41 100644
--- a/apps/web/src/features/settings/Harness.tsx
+++ b/apps/web/src/features/settings/Harness.tsx
@@ -18,8 +18,9 @@ import {
import type { Harness as RegisteredHarness } from '@service-storage/client';
import { useSearchParams } from '@solidjs/router';
import { ApiKeyInput, Button, confirmDialog, Dialog, Panel } from '@ui';
-import { createSignal, For, onMount, Show } from 'solid-js';
+import { createSignal, onMount, Show } from 'solid-js';
import { CodexHarness } from './codex/views/CodexHarness';
+import { ConnectedRuntimesSection } from './components/connected-runtimes-section';
import { CursorDefaultModel } from './components/cursor-default-model';
import { LocalRuntimeCard } from './components/local-runtime-card';
import {
@@ -27,7 +28,7 @@ import {
CURSOR_KEY_PREFIX,
isCursorApiKey,
} from './core/cursor-api-key';
-import { ConnectAction, HarnessIcon, StatusDot } from './integration-ui';
+import { HarnessIcon } from './integration-ui';
import { SettingsCard, SettingsPage } from './primitives';
import { RuntimePairingPage } from './RuntimePairingPage';
@@ -35,12 +36,6 @@ function failureMessage(error: unknown, fallback: string): string {
return (error instanceof ThrownResultError && error.message) || fallback;
}
-function lastConnectedText(harness: RegisteredHarness): string {
- return harness.last_connected_at
- ? `Last connected ${new Date(harness.last_connected_at).toLocaleString()}`
- : 'Never connected';
-}
-
/** Settings UI for choosing and configuring the available agent harnesses. */
export function Harness(
props: { onBack?: () => void; backLabel?: string } = {}
@@ -143,6 +138,11 @@ export function Harness(
</Button>
}
>
+ <ConnectedRuntimesSection
+ harnesses={harnessesQuery.isSuccess ? harnessesQuery.data : []}
+ error={harnessesQuery.isError}
+ onRemove={setRemovingHarness}
+ />
<LocalRuntimeCard />
<div>
<h2 class="mb-3 px-6 text-sm font-semibold text-ink">
@@ -286,68 +286,6 @@ export function Harness(
</Show>
</SettingsCard>
</div>
-
- <Show
- when={!harnessesQuery.isSuccess || harnessesQuery.data.length > 0}
- >
- <div>
- <h2 class="mb-3 px-6 text-sm font-semibold text-ink">
- Paired runtimes
- </h2>
- <SettingsCard>
- <For
- each={harnessesQuery.isSuccess ? harnessesQuery.data : []}
- fallback={
- <div class="flex flex-col items-center py-6 text-center">
- <p class="text-sm text-ink">
- {harnessesQuery.isError
- ? 'Could not load runtimes.'
- : 'Loading runtimes…'}
- </p>
- </div>
- }
- >
- {(harness) => (
- <div class="flex items-center justify-between gap-4 px-4 py-3">
- <div class="min-w-0 flex-1">
- <div class="flex min-w-0 items-center gap-2">
- <p class="min-w-0 flex-1 truncate text-sm text-ink">
- {harness.name}
- </p>
- <span class="inline-flex h-5 shrink-0 items-center whitespace-nowrap rounded-md border border-edge-muted px-2 text-xxs/none font-medium uppercase text-ink-extra-muted">
- {harness.owner.type === 'team' ? 'Team' : 'Private'}
- </span>
- <StatusDot
- state={
- harness.connected ? 'connected' : 'disconnected'
- }
- label={
- harness.connected ? 'Connected' : 'Disconnected'
- }
- />
- </div>
- <p class="mt-0.5 truncate text-xs text-ink-extra-muted">
- {lastConnectedText(harness)}
- </p>
- </div>
- <div class="shrink-0">
- <ConnectAction
- label="Remove"
- variant="danger"
- onClick={() => setRemovingHarness(harness)}
- />
- </div>
- </div>
- )}
- </For>
- <Show when={harnessesQuery.isError}>
- <p class="px-4 py-3 text-xs text-negative">
- Could not load your runtimes. Try refreshing this page.
- </p>
- </Show>
- </SettingsCard>
- </div>
- </Show>
</SettingsPage>
</Show>
diff --git a/apps/web/src/features/settings/components/connected-runtimes-section.tsx b/apps/web/src/features/settings/components/connected-runtimes-section.tsx
new file mode 100644
index 0000000000..8ce36bbeec
--- /dev/null
+++ b/apps/web/src/features/settings/components/connected-runtimes-section.tsx
@@ -0,0 +1,82 @@
+import type { Harness as RegisteredHarness } from '@service-storage/client';
+import { For, Show } from 'solid-js';
+import { ConnectAction, StatusDot } from '../integration-ui';
+import { SettingsCard } from '../primitives';
+
+function lastConnectedText(harness: RegisteredHarness): string {
+ return harness.last_connected_at
+ ? `Last connected ${new Date(harness.last_connected_at).toLocaleString()}`
+ : 'Never connected';
+}
+
+/**
+ * The machines paired to this account, connected ones first.
+ *
+ * Nothing is shown until at least one runtime is connected: with none, the
+ * setup cards above are the only useful thing on the page, and a list of
+ * machines that cannot run anything reads as a fault. Disconnected runtimes
+ * stay listed once any sibling is connected, because removing a stale pairing
+ * is the reason to come here.
+ */
+export function ConnectedRuntimesSection(props: {
+ harnesses: readonly RegisteredHarness[];
+ /** The runtimes could not be loaded; say so rather than show an empty page. */
+ error: boolean;
+ onRemove: (harness: RegisteredHarness) => void;
+}) {
+ const connectedCount = () =>
+ props.harnesses.filter((harness) => harness.connected).length;
+ const ordered = () => [
+ ...props.harnesses.filter((harness) => harness.connected),
+ ...props.harnesses.filter((harness) => !harness.connected),
+ ];
+
+ return (
+ <Show when={connectedCount() > 0 || props.error}>
+ <div>
+ <Show when={connectedCount() > 0}>
+ <h2 class="mb-3 px-6 text-sm font-semibold text-ink">
+ Connected runtimes
+ </h2>
+ </Show>
+ <SettingsCard>
+ <For each={ordered()}>
+ {(harness) => (
+ <div class="flex items-center justify-between gap-4 px-4 py-3">
+ <div class="min-w-0 flex-1">
+ <div class="flex min-w-0 items-center gap-2">
+ <p class="min-w-0 flex-1 truncate text-sm text-ink">
+ {harness.name}
+ </p>
+ <span class="inline-flex h-5 shrink-0 items-center whitespace-nowrap rounded-md border border-edge-muted px-2 text-xxs/none font-medium uppercase text-ink-extra-muted">
+ {harness.owner.type === 'team' ? 'Team' : 'Private'}
+ </span>
+ <StatusDot
+ state={harness.connected ? 'connected' : 'disconnected'}
+ label={harness.connected ? 'Connected' : 'Offline'}
+ />
+ </div>
+ <p class="mt-0.5 truncate text-xs text-ink-extra-muted">
+ {lastConnectedText(harness)}
+ </p>
+ </div>
+ <div class="shrink-0">
+ <ConnectAction
+ label="Remove"
+ variant="danger"
+ onClick={() => props.onRemove(harness)}
+ />
+ </div>
+ </div>
+ )}
+ </For>
+ <Show when={props.error}>
+ <p class="px-4 py-3 text-xs text-negative">
+ Could not load your runtimes. Try refreshing this page.
+ </p>
+ </Show>
+ </SettingsCard>
+ </div>
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/settings/components/local-runtime-prompt.test.tsx b/apps/web/src/features/settings/components/local-runtime-prompt.test.tsx
new file mode 100644
index 0000000000..d6af3daff4
--- /dev/null
+++ b/apps/web/src/features/settings/components/local-runtime-prompt.test.tsx
@@ -0,0 +1,161 @@
+/** @vitest-environment jsdom */
+
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { LocalRuntimePrompt } from './local-runtime-prompt';
+
+const mocks = vi.hoisted(() => ({
+ desktop: true,
+ supported: true,
+ paired: false,
+ statusPhase: 'stopped',
+ inspect: undefined as Promise<{ paired: boolean }> | undefined,
+ listen: undefined as Promise<() => void> | undefined,
+ openSettings: vi.fn(),
+ onStatus: undefined as ((status: { phase: string }) => void) | undefined,
+ unlisten: vi.fn(),
+}));
+
+vi.mock('@core/util/platform', () => ({
+ isDesktopPlatform: () => mocks.desktop,
+}));
+vi.mock('@core/constant/SettingsState', () => ({
+ useSettingsState: () => ({ openSettings: mocks.openSettings }),
+}));
+let currentUser: () => string | undefined = () => 'user-1';
+vi.mock('@core/context/user', () => ({ useUserId: () => currentUser }));
+vi.mock('@macro/tauri/macrod', () => ({
+ macrodSupport: async () => ({ supported: mocks.supported }),
+ macrodInspect: () =>
+ mocks.inspect ?? Promise.resolve({ paired: mocks.paired }),
+ macrodStatus: async () => ({ phase: mocks.statusPhase }),
+ onMacrodStatus: (callback: (status: { phase: string }) => void) => {
+ mocks.onStatus = callback;
+ return mocks.listen ?? Promise.resolve(mocks.unlisten);
+ },
+}));
+
+beforeEach(() => {
+ mocks.desktop = true;
+ mocks.supported = true;
+ mocks.paired = false;
+ mocks.statusPhase = 'stopped';
+ mocks.inspect = undefined;
+ mocks.listen = undefined;
+ mocks.openSettings.mockClear();
+ mocks.unlisten.mockClear();
+ mocks.onStatus = undefined;
+ currentUser = () => 'user-1';
+});
+afterEach(() => {
+ cleanup();
+ localStorage.clear();
+});
+
+describe('local runtime invitation', () => {
+ it('opens local setup from both mounted composer prompts and dismisses both on this computer', async () => {
+ render(() => (
+ <>
+ <LocalRuntimePrompt />
+ <LocalRuntimePrompt />
+ </>
+ ));
+ await waitFor(() =>
+ expect(
+ screen.getAllByRole('button', { name: /Run agents on this computer/ })
+ ).toHaveLength(4)
+ );
+
+ fireEvent.click(screen.getAllByText('Set up')[0]);
+ expect(mocks.openSettings).toHaveBeenCalledWith('Harness');
+
+ fireEvent.click(
+ screen.getAllByRole('button', {
+ name: 'Dismiss Run agents on this computer',
+ })[0]
+ );
+ expect(screen.queryByText('Run agents on this computer')).toBeNull();
+ expect(
+ localStorage.getItem('macro:local-runtime-prompt:dismissed:user-1')
+ ).toBe('1');
+ });
+
+ it('keeps dismissal scoped to the signed-in user and this desktop installation', async () => {
+ const [user, setUser] = createSignal<string | undefined>('user-1');
+ currentUser = user;
+ render(() => <LocalRuntimePrompt />);
+ await screen.findByText('Run agents on this computer');
+ fireEvent.click(
+ screen.getByRole('button', {
+ name: 'Dismiss Run agents on this computer',
+ })
+ );
+ expect(screen.queryByText('Run agents on this computer')).toBeNull();
+
+ setUser('user-2');
+ expect(screen.getByText('Run agents on this computer')).toBeTruthy();
+ setUser('user-1');
+ expect(screen.queryByText('Run agents on this computer')).toBeNull();
+ });
+
+ it('does not invite unsupported or already paired installations', async () => {
+ mocks.paired = true;
+ render(() => <LocalRuntimePrompt />);
+ await waitFor(() => expect(mocks.onStatus).toBeTypeOf('function'));
+ expect(screen.queryByText('Run agents on this computer')).toBeNull();
+ cleanup();
+
+ mocks.supported = false;
+ render(() => <LocalRuntimePrompt />);
+ expect(screen.queryByText('Run agents on this computer')).toBeNull();
+ });
+
+ it('shows the invitation even while the status listener is pending', async () => {
+ mocks.listen = new Promise(() => {});
+ render(() => <LocalRuntimePrompt />);
+ expect(await screen.findByText('Run agents on this computer')).toBeTruthy();
+ });
+
+ it('hides a stale invitation when pairing finishes before the listener registers', async () => {
+ let finishListening: (stop: () => void) => void = () => {};
+ mocks.listen = new Promise((resolve) => {
+ finishListening = resolve;
+ });
+ render(() => <LocalRuntimePrompt />);
+ await screen.findByText('Run agents on this computer');
+
+ mocks.paired = true;
+ mocks.statusPhase = 'running';
+ finishListening(mocks.unlisten);
+ await waitFor(() =>
+ expect(screen.queryByText('Run agents on this computer')).toBeNull()
+ );
+ });
+
+ it('hides the invitation once this machine finishes pairing', async () => {
+ render(() => <LocalRuntimePrompt />);
+ await screen.findByText('Run agents on this computer');
+ mocks.onStatus?.({ phase: 'running' });
+ expect(screen.queryByText('Run agents on this computer')).toBeNull();
+ });
+
+ it('does not show an older unpaired inspection after the runtime connects', async () => {
+ let finishInspect: (value: { paired: boolean }) => void = () => {};
+ mocks.inspect = new Promise((resolve) => {
+ finishInspect = resolve;
+ });
+ render(() => <LocalRuntimePrompt />);
+ await waitFor(() => expect(mocks.onStatus).toBeTypeOf('function'));
+ mocks.onStatus?.({ phase: 'running' });
+ finishInspect({ paired: false });
+ await mocks.inspect;
+ expect(screen.queryByText('Run agents on this computer')).toBeNull();
+ });
+});
diff --git a/apps/web/src/features/settings/components/local-runtime-prompt.tsx b/apps/web/src/features/settings/components/local-runtime-prompt.tsx
new file mode 100644
index 0000000000..f4c253d99c
--- /dev/null
+++ b/apps/web/src/features/settings/components/local-runtime-prompt.tsx
@@ -0,0 +1,144 @@
+import { useSettingsState } from '@core/constant/SettingsState';
+import { useUserId } from '@core/context/user';
+import { fireAndForget } from '@core/util/fireAndForget';
+import { isDesktopPlatform } from '@core/util/platform';
+import { createUserScopedStorage } from '@core/util/userScopedStorage';
+import {
+ macrodInspect,
+ macrodStatus,
+ macrodSupport,
+ onMacrodStatus,
+} from '@macro/tauri/macrod';
+import LaptopIcon from '@phosphor/laptop.svg';
+import XIcon from '@phosphor/x.svg';
+import type { UnlistenFn } from '@tauri-apps/api/event';
+import { createSignal, onCleanup, onMount, Show } from 'solid-js';
+
+const dismissal = createUserScopedStorage(
+ 'macro:local-runtime-prompt:dismissed'
+);
+const dismissalEvent = 'macro:local-runtime-prompt:dismissed';
+
+/** Invite each desktop installation to set up its own bundled local runtime. */
+export function LocalRuntimePrompt() {
+ if (!isDesktopPlatform()) return null;
+
+ const userId = useUserId();
+ const { openSettings } = useSettingsState();
+ const [available, setAvailable] = createSignal(false);
+ const [dismissalVersion, setDismissalVersion] = createSignal(0);
+
+ const refreshDismissal = () => {
+ setDismissalVersion((version) => version + 1);
+ };
+ const onStorage = (event: StorageEvent) => {
+ if (event.key?.startsWith('macro:local-runtime-prompt:dismissed:')) {
+ refreshDismissal();
+ }
+ };
+ const dismissed = () => {
+ dismissalVersion();
+ const id = userId();
+ return Boolean(id && dismissal.read(id) === '1');
+ };
+
+ onMount(() => {
+ let disposed = false;
+ let runningObserved = false;
+ let unlisten: UnlistenFn | undefined;
+ let refreshVersion = 0;
+ window.addEventListener(dismissalEvent, refreshDismissal);
+ window.addEventListener('storage', onStorage);
+
+ const refresh = async () => {
+ const version = ++refreshVersion;
+ try {
+ const [config, status] = await Promise.all([
+ macrodInspect(),
+ macrodStatus(),
+ ]);
+ if (!disposed && !runningObserved && version === refreshVersion) {
+ setAvailable(!config.paired && status.phase !== 'running');
+ }
+ } catch (error) {
+ console.error('could not inspect the local agent runtime', error);
+ }
+ };
+
+ const inspect = async () => {
+ try {
+ const support = await macrodSupport();
+ if (!support.supported || disposed) return;
+ fireAndForget(refresh(), 'local-runtime-prompt.refresh');
+ fireAndForget(
+ (async () => {
+ try {
+ const stop = await onMacrodStatus((status) => {
+ if (status.phase === 'running') {
+ runningObserved = true;
+ setAvailable(false);
+ }
+ });
+ if (disposed) {
+ stop();
+ return;
+ }
+ unlisten = stop;
+ await refresh();
+ } catch (error) {
+ console.error('could not watch the local agent runtime', error);
+ }
+ })(),
+ 'local-runtime-prompt.watch'
+ );
+ } catch (error) {
+ console.error('could not check local agent support', error);
+ }
+ };
+ fireAndForget(inspect(), 'local-runtime-prompt.inspect');
+
+ onCleanup(() => {
+ disposed = true;
+ unlisten?.();
+ window.removeEventListener(dismissalEvent, refreshDismissal);
+ window.removeEventListener('storage', onStorage);
+ });
+ });
+
+ const dismiss = () => {
+ const id = userId();
+ if (id) dismissal.write(id, '1');
+ window.dispatchEvent(new Event(dismissalEvent));
+ };
+
+ return (
+ <Show when={available() && !dismissed()}>
+ <div class="mb-3 flex items-center gap-1 rounded-xl border border-edge-muted bg-surface p-1.5 text-ink">
+ <button
+ type="button"
+ class="flex min-w-0 flex-1 items-center gap-3 rounded-lg px-2 py-1.5 text-left transition-colors hover:bg-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
+ onClick={() => openSettings('Harness')}
+ >
+ <LaptopIcon class="size-5 shrink-0 text-accent" aria-hidden="true" />
+ <span class="min-w-0 flex-1">
+ <span class="block text-sm font-medium">
+ Run agents on this computer
+ </span>
+ <span class="block text-xs text-ink-muted">
+ Use your installed agents and local files in Macro.
+ </span>
+ </span>
+ <span class="shrink-0 text-xs font-medium text-accent">Set up</span>
+ </button>
+ <button
+ type="button"
+ class="flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-muted hover:bg-hover hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
+ aria-label="Dismiss Run agents on this computer"
+ onClick={dismiss}
+ >
+ <XIcon class="size-4" aria-hidden="true" />
+ </button>
+ </div>
+ </Show>
+ );
+}
diff --git a/apps/web/src/lib/core/component/AgentOfflineBadge.tsx b/apps/web/src/lib/core/component/AgentOfflineBadge.tsx
new file mode 100644
index 0000000000..f8a61e333f
--- /dev/null
+++ b/apps/web/src/lib/core/component/AgentOfflineBadge.tsx
@@ -0,0 +1,12 @@
+/**
+ * Marks an agent whose paired runtime is not connected. One component so the
+ * composer picker, the mobile picker, and the `@` menu all say the same word
+ * for the same state.
+ */
+export function AgentOfflineBadge() {
+ return (
+ <span class="inline-flex shrink-0 items-center rounded-sm bg-hover px-1.5 py-0.5 text-[10px] font-medium leading-none text-ink-muted">
+ Offline
+ </span>
+ );
+}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.test.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.test.tsx
index 1a095bd9b4..774f719732 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.test.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.test.tsx
@@ -565,3 +565,31 @@ it("offers the viewer's routines to share by mention, only in channel composers"
));
expect(screen.queryByText('Routines')).toBeNull();
});
+
+it('marks an offline agent and refuses to mention it', () => {
+ Element.prototype.scrollIntoView = vi.fn();
+ const offlineAgent: IUser = {
+ id: 'bot|agent-1',
+ name: 'Dev box agent',
+ email: 'Dev box agent',
+ offline: true,
+ };
+ const menu = createMenuOperations();
+ menu.openMenu();
+ const onPick = vi.fn();
+ render(() => (
+ <MentionsMenu
+ menu={menu}
+ entities={() => []}
+ users={() => [offlineAgent]}
+ sources={['users']}
+ anchor={document.createElement('div')}
+ onPick={onPick}
+ />
+ ));
+
+ expect(screen.getByText('Offline')).toBeTruthy();
+ fireEvent.click(screen.getByTitle('Dev box agent — offline'));
+ expect(onPick).not.toHaveBeenCalled();
+ expect(menu.isOpen()).toBe(true);
+});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx
index 14700d40f5..15efa62e3f 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx
@@ -597,7 +597,17 @@ function MentionsMenuInner(props: MentionsMenuProps) {
})
: undefined;
+ /**
+ * Agents whose runtime is away are listed but not pickable: a mention
+ * inserted here would sit in the message unanswered until the machine comes
+ * back, which reads as the agent ignoring you. The flag rides on the user
+ * entry so this menu needs no view of runtimes.
+ */
+ const isOffline = (item: MentionItem) =>
+ item.kind === 'user' && item.data.offline === true;
+
const itemAction = async (item: MentionItem) => {
+ if (isOffline(item)) return;
analytics.track('mentions_menu_use', { itemType: item.kind });
if (props.onPick) props.onPick(item);
else await itemActionHandler?.(item);
@@ -653,6 +663,9 @@ function MentionsMenuInner(props: MentionsMenuProps) {
},
onSelect: () => {
const selectedItem = controller.selectedItem();
+ // Keep the menu open on an offline agent so Enter reads as "not that
+ // one" rather than silently dismissing with nothing inserted.
+ if (selectedItem && isOffline(selectedItem)) return;
if (selectedItem) {
itemAction(selectedItem).catch((error) =>
Telemetry.error(error, {
@@ -873,6 +886,7 @@ function MentionsMenuInner(props: MentionsMenuProps) {
itemAction={itemAction}
setIndex={setSelectedIndexFromMouse}
setOpen={setMenuOpen}
+ offline={isOffline(item())}
/>
)}
</Key>
@@ -918,6 +932,7 @@ function MentionsMenuInner(props: MentionsMenuProps) {
items={controller.combinedItems()}
selectedIndex={controller.selectedIndex()}
itemAction={itemAction}
+ offline={isOffline}
setIndex={setSelectedIndexFromMouse}
setOpen={setMenuOpen}
maxHeight={contentMaxHeight()}
@@ -944,6 +959,8 @@ function VirtualizedItemList(props: {
items: MentionItem[];
selectedIndex: number;
itemAction: (item: MentionItem) => void;
+ /** Whether an item's agent runtime is away; such rows are not pickable. */
+ offline: (item: MentionItem) => boolean;
setIndex: (index: number) => void;
setOpen: (open: boolean) => void;
maxHeight?: number;
@@ -1018,6 +1035,7 @@ function VirtualizedItemList(props: {
itemAction={props.itemAction}
setIndex={props.setIndex}
setOpen={props.setOpen}
+ offline={props.offline(currentItem())}
disableScrollIntoView
/>
</div>
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
index ccb78d9f97..0cd6a084da 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
@@ -1,3 +1,4 @@
+import { AgentOfflineBadge } from '@core/component/AgentOfflineBadge';
import { EntityIcon } from '@core/component/EntityIcon';
import { TaskStatusIcon } from '@core/component/TaskStatusIcon';
import { UserIcon } from '@core/component/UserIcon';
@@ -26,6 +27,8 @@ export function MentionsMenuItem(props: {
setOpen: (open: boolean) => void;
/** When true, disables the internal scrollIntoView behavior (used when list is virtualized) */
disableScrollIntoView?: boolean;
+ /** The agent's runtime is not connected, so mentioning it would go nowhere. */
+ offline?: boolean;
actions?: JSX.Element;
}) {
let itemRef: HTMLDivElement | undefined;
@@ -144,11 +147,15 @@ export function MentionsMenuItem(props: {
e.stopPropagation();
}}
on:click={(e) => {
+ e.stopPropagation();
+ // An offline agent stays visible so its absence is explained, but
+ // picking it would insert a mention nothing will answer.
+ if (props.offline) return;
props.itemAction(props.item);
props.setOpen(false);
- e.stopPropagation();
}}
on:mousemove={() => props.setIndex(props.index)}
+ aria-disabled={props.offline ? 'true' : undefined}
class={cn('group flex items-center p-1.5 mx-1.5 rounded-md', {
'bg-ink/5': props.selected,
})}
@@ -156,8 +163,11 @@ export function MentionsMenuItem(props: {
<div class="mr-2 flex items-center">{icon()}</div>
<div class="flex min-w-0 grow items-center gap-2">
<span
- class="ph-no-capture min-w-0 max-w-full overflow-hidden text-nowrap text-ink text-xs sm:text-sm font-medium"
- title={name()}
+ class={cn(
+ 'ph-no-capture min-w-0 max-w-full overflow-hidden text-nowrap text-xs sm:text-sm font-medium',
+ props.offline ? 'text-ink-muted' : 'text-ink'
+ )}
+ title={props.offline ? `${name()} — offline` : name()}
style={{ 'text-overflow': 'ellipsis' }}
>
{labelParts().name}
@@ -170,6 +180,9 @@ export function MentionsMenuItem(props: {
Agent
</span>
</Show>
+ <Show when={props.offline}>
+ <AgentOfflineBadge />
+ </Show>
</div>
{props.actions}
</div>
diff --git a/apps/web/src/lib/core/constant/settingsTabsConfig.tsx b/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
index abfe32aacb..7afc32e5a9 100644
--- a/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
+++ b/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
@@ -28,7 +28,7 @@ import { useHasPermission } from '../context/user';
import { isMobile } from '../mobile/isMobile';
import { isNativeMobilePlatform } from '../mobile/isNativeMobilePlatform';
import { isTouchDevice } from '../mobile/isTouchDevice';
-import { isPlatform } from '../util/platform';
+import { isDesktopPlatform, isPlatform } from '../util/platform';
import {
botManagement,
DEV_MODE_ENV,
@@ -388,10 +388,10 @@ export const useSettingsTabAvailable = () => {
);
case 'Agent':
return !isNativeMobilePlatform();
- // Configurable agents are still rolling out; keep both tabs behind the
- // same enable-chat-v3-agents gate as the channel mention surfaces, so
- // settings never advertises agents to a user who cannot mention one.
+ // The bundled desktop runtime can be set up from Home even while the
+ // configurable Agents view is still rolling out.
case 'Harness':
+ return isDesktopPlatform() || chatV3AgentsFlag().enabled;
case 'Agents':
return chatV3AgentsFlag().enabled;
// Touch hides the Agents sidebar that lists Routines on desktop, so
diff --git a/apps/web/src/lib/core/user/types.ts b/apps/web/src/lib/core/user/types.ts
index 0ac8f6d140..a636725f97 100644
--- a/apps/web/src/lib/core/user/types.ts
+++ b/apps/web/src/lib/core/user/types.ts
@@ -10,6 +10,12 @@ export type IUser = {
name: string;
photoUrl?: string;
lastInteraction?: DateValue;
+ /**
+ * Set on agent principals whose runtime is paired but not connected. The
+ * mention menu marks them "Offline" and refuses to insert them, since the
+ * machine that would answer is away.
+ */
+ offline?: boolean;
};
type BaseUserName = {
diff --git a/apps/web/src/lib/queries/agents/offline-runtimes.test.ts b/apps/web/src/lib/queries/agents/offline-runtimes.test.ts
new file mode 100644
index 0000000000..505717f438
--- /dev/null
+++ b/apps/web/src/lib/queries/agents/offline-runtimes.test.ts
@@ -0,0 +1,50 @@
+import { describe, expect, it } from 'vitest';
+import { offlineAgentBotIds } from './offline-runtimes';
+
+function agent(botId: string, harness: string, harnessId?: string) {
+ return { bot: { id: botId }, harness, harness_id: harnessId ?? null };
+}
+
+describe('offlineAgentBotIds', () => {
+ it('marks macrod agents whose runtime is disconnected', () => {
+ const offline = offlineAgentBotIds(
+ [agent('away', 'macrod', 'h1'), agent('here', 'macrod', 'h2')],
+ [
+ { id: 'h1', connected: false },
+ { id: 'h2', connected: true },
+ ]
+ );
+
+ expect(offline.has('away')).toBe(true);
+ expect(offline.has('here')).toBe(false);
+ });
+
+ it('leaves built-in and cloud runtimes alone', () => {
+ const offline = offlineAgentBotIds(
+ [
+ agent('macro', 'in-memory'),
+ agent('cursor', 'cursor'),
+ agent('codex', 'codex-cloud'),
+ ],
+ []
+ );
+
+ expect(offline.size).toBe(0);
+ });
+
+ it('counts an agent bound to a runtime it cannot see as offline', () => {
+ const offline = offlineAgentBotIds(
+ [agent('orphan', 'macrod', 'removed'), agent('unbound', 'macrod')],
+ [{ id: 'h1', connected: true }]
+ );
+
+ expect(offline.has('orphan')).toBe(true);
+ expect(offline.has('unbound')).toBe(true);
+ });
+
+ it('has no opinion without agents', () => {
+ expect(offlineAgentBotIds([], [{ id: 'h1', connected: true }]).size).toBe(
+ 0
+ );
+ });
+});
diff --git a/apps/web/src/lib/queries/agents/offline-runtimes.ts b/apps/web/src/lib/queries/agents/offline-runtimes.ts
new file mode 100644
index 0000000000..dba6f0de36
--- /dev/null
+++ b/apps/web/src/lib/queries/agents/offline-runtimes.ts
@@ -0,0 +1,62 @@
+import { queryReadyGate } from '@queries/gate';
+import { useHarnessesQuery } from '@queries/harnesses/harnesses';
+import type { Harness } from '@service-storage/client';
+import { type Accessor, createMemo } from 'solid-js';
+import { useAgentsQuery } from './agents';
+
+/** The agent fields the lookup reads; structural so tests need no wire type. */
+type AgentLike = {
+ bot: { id: string };
+ harness: string;
+ harness_id?: string | null;
+};
+
+/** The runtime fields the lookup reads. */
+type RuntimeLike = Pick<Harness, 'id' | 'connected'>;
+
+/**
+ * The bot ids whose runtime is paired but not currently connected.
+ *
+ * Only macrod agents can be offline: a built-in or cloud runtime has no
+ * paired machine behind it, and Cursor reports its own setup state. An agent
+ * bound to a harness that is gone entirely (removed, or never visible to this
+ * user) counts as offline too — starting it would hang the same way.
+ */
+export function offlineAgentBotIds(
+ agents: readonly AgentLike[],
+ runtimes: readonly RuntimeLike[]
+): ReadonlySet<string> {
+ const connected = new Set(
+ runtimes.filter((runtime) => runtime.connected).map((runtime) => runtime.id)
+ );
+ return new Set(
+ agents
+ .filter(
+ (agent) =>
+ agent.harness === 'macrod' &&
+ !(agent.harness_id && connected.has(agent.harness_id))
+ )
+ .map((agent) => agent.bot.id)
+ );
+}
+
+/**
+ * Live view of {@link offlineAgentBotIds}. Both queries are shared by key, so
+ * every surface that calls this rides the harness list's existing poll rather
+ * than adding one.
+ */
+export function useOfflineAgentBotIds(): Accessor<ReadonlySet<string>> {
+ const agentsQuery = useAgentsQuery();
+ const harnessesQuery = useHarnessesQuery();
+ return createMemo(() => {
+ // Until the runtimes are known, nothing is offline. Treating a pending
+ // list as empty would flash "Offline" across a healthy roster on load.
+ if (!queryReadyGate(harnessesQuery)) return EMPTY;
+ return offlineAgentBotIds(
+ queryReadyGate(agentsQuery) ? agentsQuery.data : [],
+ harnessesQuery.data
+ );
+ });
+}
+
+const EMPTY: ReadonlySet<string> = new Set();
diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.md
index 5e86b27b17..f11583d729 100644
--- a/docs/agent-guide/ai-chat.md
+++ b/docs/agent-guide/ai-chat.md
@@ -550,6 +550,10 @@ the shimmer.
A checkmark identifies the selected model,
including when it is the agent’s configured default; there is no separate default row.
Disconnected Cursor offers **Connect Cursor**, opening Settings → Agents → Runtimes.
+ An agent whose paired machine is away is greyed out, carries an **Offline**
+ badge, and offers **Reconnect runtime** instead of a model submenu; the same
+ badge appears in the `@` menu, where offline agents cannot be mentioned at all
+ (clicking or pressing Enter leaves the menu open and inserts nothing).
The built-in sandbox and paired macrod runtimes are not offered here.
- With the `enable-agent-updates` flag, the New conversation page shows a stack
of pending updates from your coding sessions under the composer: one card per
@@ -677,12 +681,23 @@ the shimmer.
field focused on open, and a default model picker that enables once the key is
saved. Connected, the same page shows the saved date, **Disconnect**, and
**Done**. **Manage** on a paired machine opens **Runtimes** (Back returns to
- Agents): built-in providers, **New runtime**, and the **Paired runtimes** list,
- which appears once you have a paired runtime.
+ Agents): **Connected runtimes** (shown only once a paired machine is connected;
+ it then lists every paired machine, connected ones first, each with
+ **Connected** or **Offline** and **Remove**), built-in providers, and
+ **New runtime**.
On the desktop app, **Runtimes** opens with a **This computer** card that sets
up the bundled macrod daemon in one click: **Set up** detects installed agents,
then **Start running agents here** configures, pairs (auto-approved, no code),
- and starts it. The manual flow below remains for pairing other machines.
+ and starts it. Before this computer is paired, a dismissible **Run agents on
+ this computer** invitation appears above the Home input and the Agents
+ new-conversation and active-session inputs. Clicking it opens Runtimes;
+ dismissing it affects only this desktop installation and signed-in user.
+ Runtimes is available on desktop even when the newer Agents view is still
+ rolling out. Each paired computer keeps its own runtime identity and appears
+ separately under Connected runtimes. The manual flow below remains for pairing
+ other machines. In the agent form, a runtime whose machine is away is labelled
+ **· Offline** but stays selectable: binding an agent to a sleeping computer is
+ normal.
**New runtime** shows three steps: install macrod with the shown `curl … |
sh` (macOS, Linux) or `irm … | iex` (Windows) command, run `macrod` and
configure your agent in Quickstart, then enter your pairing
diff --git a/docs/agent-guide/settings.md b/docs/agent-guide/settings.md
index 5d3cb49c27..9a3d782b0d 100644
--- a/docs/agent-guide/settings.md
+++ b/docs/agent-guide/settings.md
@@ -717,7 +717,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 a larger Full access choice labeled Suggested (unchecked until explicitly selected). `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.
+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 a larger Full access choice labeled Suggested (unchecked until explicitly selected). `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. Before this computer is paired, a dismissible “Run agents on this computer” invitation also appears above the Home input and the Agents new-conversation and active-session inputs; it opens Runtimes, and dismissal applies only to this user on this computer. The Runtimes settings tab stays available in the desktop app even if the newer Agents view is disabled. 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.