From 9b1538324f6a2c44921a0548d569ac7455dd1f03 Mon Sep 17 00:00:00 2001 From: BVS Rao <112616081+bvsr365@users.noreply.github.com> Date: Sun, 15 Nov 2026 21:17:20 +0530 Subject: [PATCH 1/2] feat(devices): a person sets which threads another device's agents may change here MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Settings → Devices → Limits gets "Agents on may change: Nothing / Threads they started / All threads", carried through bridge.policy, its validator, the bridge.nodes policy view and `mousse-cli bridge limits --agent-reach`. bridge.policy stays a local method of this computer's windows and command line, so a device cannot change its own reach. The device's activity list marks the calls its agents made ("by an agent"). Refs #1160 Co-Authored-By: Claude Opus 5.5 --- src/cli/commands/net.ts | 22 ++- src/mms/bridge/deviceActivity.ts | 2 + src/mms/net/NetService.ts | 10 +- src/mms/net/registerMethods.ts | 8 +- src/mms/net/store/nodePolicy.ts | 6 +- .../components/devices/DeviceActivityRows.tsx | 1 + .../components/devices/DeviceLimitsDialog.tsx | 31 +++- src/renderer/styles/devices.css | 1 + src/shared/bridge/deviceActivity.ts | 5 +- src/shared/net/local.ts | 11 ++ tests/net/bridge/nodePolicy.test.ts | 16 +- tests/net/bridge/routed/agentMark.test.ts | 42 +++++ tests/net/cli/net.test.ts | 8 + tests/renderer/deviceAgentReach.test.ts | 148 ++++++++++++++++++ 14 files changed, 288 insertions(+), 23 deletions(-) create mode 100644 tests/renderer/deviceAgentReach.test.ts diff --git a/src/cli/commands/net.ts b/src/cli/commands/net.ts index 9a81b1d958..c24bb8fb7c 100644 --- a/src/cli/commands/net.ts +++ b/src/cli/commands/net.ts @@ -18,6 +18,7 @@ import { NODE_CAPABILITIES, type NodeCapability } from '../../shared/net/capabil import { NET_ERRORS, isNetErrorCode, type NetErrorCode } from '../../shared/net/errors' import { isId } from '../../shared/net/ids' import { isJoinVia } from '../../shared/net/via' +import { isAgentReach } from '../../shared/net/local' import { isPermissionMode } from '../../shared/permissionMode' export const NET_HELP = `Usage: @@ -97,7 +98,7 @@ export const BRIDGE_HELP = `Usage: mousse-cli bridge block mousse-cli bridge unblock mousse-cli bridge limits [--max-mode ask|accept_edits|auto|full] [--terminal on|off] - [--editor on|off] [--bots on|off] + [--editor on|off] [--bots on|off] [--agent-reach none|launched|all] mousse-cli bridge caps --caps read,chat,write,settings mousse-cli bridge kind computer|phone mousse-cli bridge threads [on|off] @@ -354,7 +355,7 @@ export function prepareNetCommand(args: ParsedArgs): NetCliRequest { 'bridge.rename': [], 'bridge.setCaps': ['caps'], 'bridge.setKind': [], - 'bridge.policy': args.subcommand === 'limits' ? ['max-mode', 'terminal', 'editor', 'bots'] : [], + 'bridge.policy': args.subcommand === 'limits' ? ['max-mode', 'terminal', 'editor', 'bots', 'agent-reach'] : [], 'bridge.workOnThreads': [], 'bridge.shareBots': [], 'bridge.editorServer': [] @@ -625,10 +626,17 @@ export function prepareNetCommand(args: ParsedArgs): NetCliRequest { const mode = stringFlag(args, 'max-mode'), terminal = stringFlag(args, 'terminal'), editor = stringFlag(args, 'editor'), - bots = stringFlag(args, 'bots') - if (mode === undefined && terminal === undefined && editor === undefined && bots === undefined) + bots = stringFlag(args, 'bots'), + reach = stringFlag(args, 'agent-reach') + if ( + mode === undefined && + terminal === undefined && + editor === undefined && + bots === undefined && + reach === undefined + ) invalid( - 'bridge limits requires --max-mode ask|accept_edits|auto|full, --terminal on|off, --editor on|off and/or --bots on|off.' + 'bridge limits requires --max-mode ask|accept_edits|auto|full, --terminal on|off, --editor on|off, --bots on|off and/or --agent-reach none|launched|all.' ) if (mode !== undefined) { if (!isPermissionMode(mode)) invalid('--max-mode requires ask, accept_edits, auto or full.') @@ -646,6 +654,10 @@ export function prepareNetCommand(args: ParsedArgs): NetCliRequest { if (bots !== 'on' && bots !== 'off') invalid('--bots requires on or off.') params.bots = bots === 'on' } + if (reach !== undefined) { + if (!isAgentReach(reach)) invalid('--agent-reach requires none, launched or all.') + params.agentReach = reach + } } } return { diff --git a/src/mms/bridge/deviceActivity.ts b/src/mms/bridge/deviceActivity.ts index c1a743f15d..88220b5467 100644 --- a/src/mms/bridge/deviceActivity.ts +++ b/src/mms/bridge/deviceActivity.ts @@ -90,6 +90,7 @@ function entryOf( outcome: string thread?: string project?: string + actor?: 'agent' } ): DeviceActivityEntry { const entry: DeviceActivityEntry = { @@ -98,6 +99,7 @@ function entryOf( kind: row.kind, outcome: row.outcome } + if (row.actor === 'agent') entry.actor = 'agent' if (row.thread) entry.thread = { id: row.thread, name: threadHere(services, row.thread)?.name ?? null } if (row.project && !isHashedPath(row.project)) entry.project = { name: services.projects.getProject(row.project)?.name ?? null } diff --git a/src/mms/net/NetService.ts b/src/mms/net/NetService.ts index 7ba4cc460f..fc8e818417 100644 --- a/src/mms/net/NetService.ts +++ b/src/mms/net/NetService.ts @@ -49,7 +49,7 @@ import type { import type { PermissionMode } from '../../shared/permissionMode' import { routedVersions } from '../../shared/bridge/routed' import { bridgeRemoteMethodNames } from '../bridge/remote/capabilities' -import type { NodePolicy } from './store/nodePolicy' +import type { AgentReach, NodePolicy } from './store/nodePolicy' import type { AddonRecordStore, Clock, @@ -150,7 +150,8 @@ const policyView = (policy: NodePolicy): BridgeNodePolicy => ({ maxPermissionMode: policy.maxPermissionMode, terminal: policy.terminal, editor: policy.editor, - bots: policy.bots + bots: policy.bots, + agentReach: policy.agentReach }) interface NetConfiguration { @@ -1036,7 +1037,10 @@ export class NetService { : { maxPermissionMode: params.maxPermissionMode as PermissionMode }), ...(params.terminal === undefined ? {} : { terminal: params.terminal as boolean }), ...(params.editor === undefined ? {} : { editor: params.editor as boolean }), - ...(params.bots === undefined ? {} : { bots: params.bots as boolean }) + ...(params.bots === undefined ? {} : { bots: params.bots as boolean }), + ...(params.agentReach === undefined + ? {} + : { agentReach: params.agentReach as AgentReach }) }) this.emit() return { policy: policyView(policy) } diff --git a/src/mms/net/registerMethods.ts b/src/mms/net/registerMethods.ts index 84b43b46cf..8beaac784e 100644 --- a/src/mms/net/registerMethods.ts +++ b/src/mms/net/registerMethods.ts @@ -1,5 +1,6 @@ import { isIP } from 'node:net' import { + isAgentReach, NET_LOCAL_CAPABILITY, NET_LOCAL_METHODS, type NetLocalMethod @@ -76,7 +77,7 @@ const keys: Record = { 'bridge.rename': ['node', 'name'], 'bridge.setCaps': ['node', 'caps'], 'bridge.setKind': ['node', 'kind'], - 'bridge.policy': ['node', 'blocked', 'maxPermissionMode', 'terminal', 'editor', 'bots'], + 'bridge.policy': ['node', 'blocked', 'maxPermissionMode', 'terminal', 'editor', 'bots', 'agentReach'], 'bridge.workOnThreads': ['enabled'], 'bridge.shareBots': ['enabled'], 'bridge.editorServer': ['system'] @@ -275,7 +276,8 @@ function validate(method: NetLocalMethod, value: unknown): Record > -export type AgentReach = 'none' | 'launched' | 'all' -export const AGENT_REACHES: readonly AgentReach[] = ['none', 'launched', 'all'] -export const isAgentReach = (value: unknown): value is AgentReach => - (AGENT_REACHES as readonly unknown[]).includes(value) +export { AGENT_REACHES, isAgentReach, type AgentReach } /** A device's agents change only the threads they started here, until a person on this computer allows more. */ export const DEFAULT_AGENT_REACH: AgentReach = 'launched' diff --git a/src/renderer/components/devices/DeviceActivityRows.tsx b/src/renderer/components/devices/DeviceActivityRows.tsx index 9bff598cd6..b4ef21392b 100644 --- a/src/renderer/components/devices/DeviceActivityRows.tsx +++ b/src/renderer/components/devices/DeviceActivityRows.tsx @@ -57,6 +57,7 @@ export function DeviceActivityView({ name, activity, now, open, busy, blocked, o
  • {formatAgo(entry.at, now)} {describeActivityEntry(entry)} + {entry.actor === 'agent' && by an agent} {entry.thread && in } {entry.project?.name && project {entry.project.name}}
  • diff --git a/src/renderer/components/devices/DeviceLimitsDialog.tsx b/src/renderer/components/devices/DeviceLimitsDialog.tsx index c3dd0775c1..9696360786 100644 --- a/src/renderer/components/devices/DeviceLimitsDialog.tsx +++ b/src/renderer/components/devices/DeviceLimitsDialog.tsx @@ -3,15 +3,24 @@ import { Modal } from '../ui/Modal' import { Switch } from '../settings/SettingsRow' import { useDaemonCall } from './useDaemonCall' import { describePermissionMode, PERMISSION_MODES, type PermissionMode } from '../../../shared/permissionMode' -import type { BridgeNodePolicy } from '../../../shared/net/local' +import type { AgentReach, BridgeNodePolicy } from '../../../shared/net/local' import type { NodeId } from '../../../shared/net' const btn = 'settings-btn devices-dialog-btn' +/** The choices for what a device's agents may change here, in the order shown. */ +export const AGENT_REACH_CHOICES: ReadonlyArray<{ value: AgentReach; label: string }> = [ + { value: 'none', label: 'Nothing' }, + { value: 'launched', label: 'Threads they started' }, + { value: 'all', label: 'All threads' } +] + /** * What a computer may do on this one, set on this computer alone: the most permissive mode a * person on it can run a turn or an "Always" rule in, whether it can open terminals here, and whether - * it can open its editor on this computer's folders (an SSH login here, so shell access like a terminal). + * it can open its editor on this computer's folders (an SSH login here, so shell access like a terminal), and + * which threads here its agents may change. A service from before that setting sends no `agentReach`, and the + * choice is left out. */ export function DeviceLimitsDialog({ node, name, policy, onClose, onDone }: { node: NodeId @@ -25,13 +34,15 @@ export function DeviceLimitsDialog({ node, name, policy, onClose, onDone }: { const [mode, setMode] = useState(policy.maxPermissionMode) const [terminal, setTerminal] = useState(policy.terminal) const [editor, setEditor] = useState(policy.editor) - const changed = mode !== policy.maxPermissionMode || terminal !== policy.terminal || editor !== policy.editor + const [reach, setReach] = useState(policy.agentReach) + const changed = mode !== policy.maxPermissionMode || terminal !== policy.terminal || editor !== policy.editor || reach !== policy.agentReach const save = async () => { const answer = await call('bridge.policy', { node, ...(mode !== policy.maxPermissionMode ? { maxPermissionMode: mode } : {}), ...(terminal !== policy.terminal ? { terminal } : {}), - ...(editor !== policy.editor ? { editor } : {}) + ...(editor !== policy.editor ? { editor } : {}), + ...(reach !== policy.agentReach ? { agentReach: reach } : {}) }) if (answer) { onDone(); onClose() } } @@ -51,6 +62,18 @@ export function DeviceLimitsDialog({ node, name, policy, onClose, onDone }: {

    Subagents that {name}’s agents start on this computer run no higher than this either.

    + {reach !== undefined && <> + +

    + What {name}’s agents may start, message, steer and stop on this computer. They read threads here as {name} does. + This is a rule for a computer that works as it should, not a barrier: for one you do not trust, block it or lower its highest permission mode. +

    + }
    Terminals from this device diff --git a/src/renderer/styles/devices.css b/src/renderer/styles/devices.css index 42b0ccd9b9..e89337df1b 100644 --- a/src/renderer/styles/devices.css +++ b/src/renderer/styles/devices.css @@ -279,6 +279,7 @@ color: var(--text-secondary); } +.devices-activity-who, .devices-activity-where { color: var(--text-secondary); } diff --git a/src/shared/bridge/deviceActivity.ts b/src/shared/bridge/deviceActivity.ts index 64089b720e..2c2dcf4dc4 100644 --- a/src/shared/bridge/deviceActivity.ts +++ b/src/shared/bridge/deviceActivity.ts @@ -39,6 +39,8 @@ export interface DeviceActivityEntry { thread?: { id: string; name: string | null } /** The project the call was about, by name. A folder that was refused is never named. */ project?: { name: string | null } + /** `agent`: one of the device's agents made the call (it was marked as an agent's); absent for a person's. */ + actor?: 'agent' } export interface DeviceActivityCount { @@ -354,7 +356,8 @@ const CODE_WORDS: Record = { queue_conflict: 'the queue had changed', forbidden: 'not allowed', rate_limited: 'too many at once', - bad_request: 'not a valid request' + bad_request: 'not a valid request', + agent_reach: 'outside what its agents may change here' } /** "End; in 12 B; out 1.2 KiB" as the audit keeps it, in words. */ diff --git a/src/shared/net/local.ts b/src/shared/net/local.ts index 623a2aa06d..33efd0cf81 100644 --- a/src/shared/net/local.ts +++ b/src/shared/net/local.ts @@ -131,7 +131,18 @@ export interface BridgeNodePolicy { * it off. Absent from a service from before the switch. */ bots?: boolean + /** + * Which threads here the device's agents may change with calls marked as an agent's: none, the threads its agents + * started here (the default), or all. Absent from a service from before the setting. + */ + agentReach?: AgentReach } + +/** What a device's agents may change on this computer (`net_node_policy.agent_reach`). */ +export type AgentReach = 'none' | 'launched' | 'all' +export const AGENT_REACHES: readonly AgentReach[] = ['none', 'launched', 'all'] +export const isAgentReach = (value: unknown): value is AgentReach => + (AGENT_REACHES as readonly unknown[]).includes(value) export interface NetStatus { enabled: boolean features?: import('../featureFlags').NetFeatureFlags diff --git a/tests/net/bridge/nodePolicy.test.ts b/tests/net/bridge/nodePolicy.test.ts index b618861f7b..9bc4d3511d 100644 --- a/tests/net/bridge/nodePolicy.test.ts +++ b/tests/net/bridge/nodePolicy.test.ts @@ -723,7 +723,8 @@ describe('blocking a device on a computer', () => { maxPermissionMode: 'accept_edits', terminal: false, editor: false, - bots: true + bots: true, + agentReach: 'launched' }) await a.request('bridge.policy', { node: one.node, maxPermissionMode: 'full', terminal: true }) @@ -732,7 +733,8 @@ describe('blocking a device on a computer', () => { maxPermissionMode: 'full', terminal: true, editor: false, - bots: true + bots: true, + agentReach: 'launched' }) // The editor switch is its own: it changes neither of the others, and nothing else changes it. await a.request('bridge.policy', { node: one.node, editor: true }) @@ -741,23 +743,29 @@ describe('blocking a device on a computer', () => { maxPermissionMode: 'full', terminal: true, editor: true, - bots: true + bots: true, + agentReach: 'launched' }) // Bots on this computer is its own too: off for one device only, and nothing else moves. await a.request('bridge.policy', { node: one.node, bots: false }) expect((await device(one.node)).policy).toMatchObject({ maxPermissionMode: 'full', terminal: true, editor: true, bots: false }) await a.request('bridge.policy', { node: one.node, bots: true }) + // What its agents may change here is its own as well. + await a.request('bridge.policy', { node: one.node, agentReach: 'all' }) + expect((await device(one.node)).policy).toMatchObject({ maxPermissionMode: 'full', terminal: true, editor: true, bots: true, agentReach: 'all' }) expect((await device(two.node)).policy).toEqual({ blocked: false, maxPermissionMode: 'accept_edits', terminal: false, editor: false, - bots: true + bots: true, + agentReach: 'launched' }) await expect( a.request('bridge.policy', { node: one.node, editor: 'yes' }) ).rejects.toMatchObject({ code: 'bad_request' }) await expect(a.request('bridge.policy', { node: one.node, bots: 'no' })).rejects.toMatchObject({ code: 'bad_request' }) + await expect(a.request('bridge.policy', { node: one.node, agentReach: 'everything' })).rejects.toMatchObject({ code: 'bad_request' }) // Unknown devices, this computer and unknown modes are refused; nothing is written for them. await expect( diff --git a/tests/net/bridge/routed/agentMark.test.ts b/tests/net/bridge/routed/agentMark.test.ts index 5c226be985..487d0f23a4 100644 --- a/tests/net/bridge/routed/agentMark.test.ts +++ b/tests/net/bridge/routed/agentMark.test.ts @@ -13,6 +13,11 @@ import { normalizeQueuedMessages } from '../../../../src/mms/queue/ThreadMessage import { validateRemoteParams } from '../../../../src/mms/bridge/remote/dto' import { AGENT_MESSAGE_END, AGENT_MESSAGE_PREFIX } from '../../../../src/mms/run/mcp/appTools/agentMessage' import { agentMessageWords } from '../../../../src/shared/agentMessageWords' +import { registerNetMethods } from '../../../../src/mms/net/registerMethods' +import { DomainHandlerRegistry } from '../../../../src/mms/protocol/domainRegistry' +import type { HandlerContext } from '../../../../src/mms/protocol/handlers' +import { NET_LOCAL_CAPABILITY, type BridgeNodePolicy } from '../../../../src/shared/net/local' +import { newId } from '../../../../src/shared/net' import { cleanupAll, linked } from './routerFixture' type Loose = Record @@ -193,6 +198,43 @@ describe('a routed call marked as an agent\'s (issue #1160)', () => { expect(() => validateRemoteParams('threads.create', { name: 'x', agent: mark() })).toThrow() }, 120_000) + it('takes the reach a person here sets in Devices at the next call, and the device cannot set its own', async () => { + standInForTurns() + // A window of the owner, through the same validator and service as Settings → Devices → Limits. + const registry = new DomainHandlerRegistry() + registerNetMethods(registry, () => t.owner.net) + const window = { connection: { id: 'owner-window', clientType: 'gui', binding: { profileId: t.owner.profileId, epoch: 1 }, capabilities: new Set([NET_LOCAL_CAPABILITY]) } } as unknown as HandlerContext + const setReach = async (agentReach: unknown) => + ((await registry.dispatch(window, 'bridge.policy', { profileId: t.owner.profileId, node: t.callerNode, agentReach })) as { policy: BridgeNodePolicy }).policy + const shown = async () => + ((await t.owner.net.request('bridge.nodes', {})) as { nodes: Array<{ node: string; policy?: BridgeNodePolicy }> }).nodes.find((row) => row.node === t.callerNode)!.policy! + expect((await shown()).agentReach).toBe('launched') + await expect(setReach('everything')).rejects.toMatchObject({ code: 'bad_request' }) + + const own = t.thread('The owner\'s own') + const mine = await launched('Started by the agent') + // Nothing: even the thread its agent started is out of reach from the next call on. + expect(await setReach('none')).toMatchObject({ agentReach: 'none' }) + expect((await shown()).agentReach).toBe('none') + expect(await refusal(call('orchestrator.send', { threadId: mine, content: 'go on', clientRequestId: 'reach-1', agent: mark() }))).toBe('agent_reach') + // All threads: a thread a person here started is reached at the next call. + expect(await setReach('all')).toMatchObject({ agentReach: 'all' }) + const sent = await call('orchestrator.send', { threadId: own.id, content: 'hello from an agent', clientRequestId: 'reach-2', agent: mark() }) + expect(t.owner.runEngine.getRun(sent.runId)).toMatchObject({ threadId: own.id, source: 'mcp' }) + expect(audit.recent(3, t.callerNode)[0]).toMatchObject({ method: 'orchestrator.send', outcome: 'ok', actor: 'agent', thread: own.id }) + + // The device itself cannot widen or narrow it: the method is not routed, whatever name it is sent under, and a Bridge + // connection does not hold the local capability. + await setReach('none') + const session = t.caller.net.session(t.node) + for (const method of ['routed.bridge.policy', 'bridge.policy']) + await expect(session.rpc(method, { node: t.callerNode, agentReach: 'all' }, { id: newId('rpc'), idem: `self-${method}`, deadlineMs: 5000 })).rejects.toBeDefined() + await expect(t.client().call(t.node, 'bridge.policy', { node: t.callerNode, agentReach: 'all' }, { idem: 'self-client' })).rejects.toBeDefined() + const bridged = { connection: { id: 'bridged', clientType: 'bridge', binding: { profileId: t.owner.profileId, epoch: 1 }, capabilities: new Set(), bridgeCaller: { node: t.callerNode, user: 'usr_x', maxPermissionMode: 'full' } } } as unknown as HandlerContext + await expect(registry.dispatch(bridged, 'bridge.policy', { profileId: t.owner.profileId, node: t.callerNode, agentReach: 'all' })).rejects.toMatchObject({ code: 'capability_required' }) + expect(policy.get(t.callerNode).agentReach).toBe('none') + }, 120_000) + it('refuses what a person could do: answering past a waiting question, a looser mode, a long body, the same words again', async () => { standInForTurns() const id = await launched() diff --git a/tests/net/cli/net.test.ts b/tests/net/cli/net.test.ts index c890e04643..ada59b30da 100644 --- a/tests/net/cli/net.test.ts +++ b/tests/net/cli/net.test.ts @@ -148,6 +148,12 @@ describe('network CLI validation', () => { ) ) ).toEqual({ method: 'bridge.policy', params: { node: nodeId, terminal: true, editor: true } }) + // What the device's agents may change here. + for (const reach of ['none', 'launched', 'all']) + expect(prepareNetCommand(args('bridge', 'limits', [nodeId], [['agent-reach', reach]]))).toEqual({ + method: 'bridge.policy', + params: { node: nodeId, agentReach: reach } + }) expect( prepareNetCommand(args('bridge', 'caps', [nodeId], [['caps', 'read,chat,write,settings']])) ).toEqual({ @@ -165,6 +171,8 @@ describe('network CLI validation', () => { args('bridge', 'limits', [nodeId], [['max-mode', 'root']]), args('bridge', 'limits', [nodeId], [['terminal', 'maybe']]), args('bridge', 'limits', [nodeId], [['editor', 'maybe']]), + args('bridge', 'limits', [nodeId], [['agent-reach', 'everything']]), + args('bridge', 'block', [nodeId], [['agent-reach', 'all']]), args('bridge', 'block', [nodeId], [['editor', 'on']]), args('bridge', 'caps', [nodeId]), args('bridge', 'caps', [nodeId], [['caps', 'read,read']]), diff --git a/tests/renderer/deviceAgentReach.test.ts b/tests/renderer/deviceAgentReach.test.ts new file mode 100644 index 0000000000..036f2510b5 --- /dev/null +++ b/tests/renderer/deviceAgentReach.test.ts @@ -0,0 +1,148 @@ +// @vitest-environment jsdom +/** + * Issue #1160, agent reach: on the computer that runs the threads, Settings → Devices → a computer's Limits sets which + * threads that computer's agents may change here, and the device's activity list says which actions its agents made. + * The page is mounted as a person uses it, with only the daemon stubbed; the daemon's side of `bridge.policy` is + * covered in `tests/net/bridge/routed/agentMark.test.ts`. + */ +import { act, createElement } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import type { BridgeNodePolicy } from '../../src/shared/net/local' +import type { DeviceActivity } from '../../src/shared/bridge/deviceActivity' + +;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true + +const { NetDevicesSection } = await import('../../src/renderer/components/NetDevicesSection') + +let root: Root +let host: HTMLElement +const flush = async () => { for (let i = 0; i < 5; i++) await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)) }) } +const click = async (element: Element | null | undefined) => { + if (!element) throw new Error('nothing to click') + await act(async () => { (element as HTMLElement).click() }) + await flush() +} +const button = (label: string) => [...document.querySelectorAll('button')].find((entry) => entry.textContent === label) +const reachSelect = () => document.querySelector('[role="dialog"] select[data-field="agent-reach"]') +const choose = async (select: HTMLSelectElement, value: string) => { + await act(async () => { + select.value = value + select.dispatchEvent(new Event('change', { bubbles: true })) + }) +} + +const NOW = Date.now() +let policy: BridgeNodePolicy +const activity = (): DeviceActivity => ({ + node: 'nod_mac' as DeviceActivity['node'], + since: NOW - 7 * 86_400_000, + counts: [{ method: 'orchestrator.send', count: 1 }], + uncertain: 0, + refused: 1, + entries: [ + { at: NOW - 60_000, method: 'orchestrator.send', kind: 'refused', outcome: 'agent_reach', actor: 'agent', thread: { id: 't-1', name: 'Release notes' } }, + { at: NOW - 120_000, method: 'orchestrator.send', kind: 'change', outcome: 'ok', thread: { id: 't-2', name: 'Fix the build' } } + ], + reads: { calls: 0, bytes: 0, hours: [] }, + rules: [] +}) +const request = vi.fn(async (method: string, params?: Record) => { + switch (method) { + case 'net.status': return { enabled: true, keystore: 'unlocked', protected: true, self: { node: 'nod_self', isAuthority: true }, transports: [], peers: [], routes: [], workOnThreads: true, shareBots: true } + case 'net.transport.list': return { manifests: [], records: {}, settings: {} } + case 'net.ssh.list': return { records: [] } + case 'bridge.nodes': return { + nodes: [ + { node: 'nod_self', name: 'Desk', caps: ['read', 'chat', 'write', 'settings'], keyEpoch: 1, expiresAt: 0, kind: 'computer', self: true, revoked: false, state: 'open' }, + { node: 'nod_mac', name: 'Mac', caps: ['read', 'chat', 'write', 'settings'], keyEpoch: 1, expiresAt: 0, kind: 'computer', self: false, revoked: false, state: 'open', policy } + ] + } + case 'bridge.activity': return activity() + case 'bridge.policy': { + const { node: _node, ...change } = params! + policy = { ...policy, ...change } + return { policy } + } + default: return {} + } +}) + +beforeEach(() => { + host = document.createElement('div') + document.body.append(host) + root = createRoot(host) + request.mockClear() + policy = { blocked: false, maxPermissionMode: 'accept_edits', terminal: false, editor: false, bots: true, agentReach: 'launched' } + ;(window as unknown as { mousse: unknown }).mousse = { + platformRequest: { request }, + app: { getInfo: async () => ({ deviceName: 'Desk' }) }, + editorAsks: { list: async () => [], onChanged: () => () => undefined } + } +}) +afterEach(() => { + act(() => root.unmount()) + host.remove() +}) + +const showDevices = async () => { + await act(async () => root.render(createElement(NetDevicesSection))) + await flush() +} +const policyCalls = () => request.mock.calls.filter(([method]) => method === 'bridge.policy') + +describe('Settings → Devices → Limits: what a device\'s agents may change here', () => { + it('reads the saved choice and saves each one alone, which the dialog then reads back', async () => { + await showDevices() + await click(button('Limits…')) + const label = reachSelect()!.closest('label')! + expect(label.textContent).toContain('Agents on Mac may change') + expect([...reachSelect()!.options].map((option) => [option.value, option.textContent])).toEqual([ + ['none', 'Nothing'], ['launched', 'Threads they started'], ['all', 'All threads'] + ]) + expect(reachSelect()!.value).toBe('launched') + // Nothing changed yet: nothing to save. + expect(button('Save')!.disabled).toBe(true) + + for (const value of ['none', 'all', 'launched'] as const) { + const before = policyCalls().length + await choose(reachSelect()!, value) + await click(button('Save')) + expect(policyCalls().slice(before)).toEqual([['bridge.policy', { node: 'nod_mac', agentReach: value }]]) + // The dialog closed; opened again, it shows what the daemon now has. + expect(document.querySelector('[role="dialog"]')).toBeNull() + await click(button('Limits…')) + expect(reachSelect()!.value).toBe(value) + } + }) + + it('says it covers what that device\'s agents do here, that it is no barrier, and what to use instead', async () => { + await showDevices() + await click(button('Limits…')) + const words = document.querySelector('[role="dialog"]')!.textContent! + expect(words).toContain('Mac’s agents may start, message, steer and stop on this computer') + expect(words).toContain('They read threads here as Mac does') + expect(words).toContain('not a barrier: for one you do not trust, block it or lower its highest permission mode') + }) + + it('a computer whose service predates the setting shows no choice, and saving another limit never sends one', async () => { + const { agentReach: _gone, ...older } = policy + policy = older + await showDevices() + await click(button('Limits…')) + expect(reachSelect()).toBeNull() + await click(document.querySelector('[role="dialog"] [role="switch"][aria-label="Terminals from Mac"]')) + await click(button('Save')) + expect(policyCalls()).toEqual([['bridge.policy', { node: 'nod_mac', terminal: true }]]) + }) + + it('marks the actions its agents made in the device\'s activity, and only those', async () => { + await showDevices() + await click(button('Show details')) + const rows = [...host.querySelectorAll('.devices-activity-list li')].map((row) => row.textContent ?? '') + expect(rows).toHaveLength(2) + expect(rows[0]).toContain('by an agent') + expect(rows[0]).toContain('refused: outside what its agents may change here') + expect(rows[1]).not.toContain('agent') + }) +}) From 9951352252eb79f4e2b596012af85dc77eb2afd8 Mon Sep 17 00:00:00 2001 From: BVS Rao <112616081+bvsr365@users.noreply.github.com> Date: Sun, 15 Nov 2026 21:17:20 +0530 Subject: [PATCH 2/2] feat(settings): "Subagents on other devices" becomes "Let agents work on your other devices" The switch on the calling computer is named for what it now covers, with the same stored key (agentAccess.remoteSubagents) and computer list. The settings search entry, the refusal texts agents read, the glossary and the threat model use the new name. Refs #1160 Co-Authored-By: Claude Opus 5.5 --- docs/GLOSSARY.md | 3 ++- docs/net/threat-model.md | 4 ++-- src/mms/orchestrator/OrchestratorService.ts | 6 +++--- src/renderer/components/settings/AgentAccessSettings.tsx | 9 +++++---- src/renderer/lib/settingsSearch.ts | 2 +- src/shared/settings.ts | 2 +- tests/renderer/agentAccessSettingsScreen.test.ts | 8 ++++---- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/GLOSSARY.md b/docs/GLOSSARY.md index 5e650b5267..a0dc0f4e10 100644 --- a/docs/GLOSSARY.md +++ b/docs/GLOSSARY.md @@ -31,7 +31,7 @@ Use these terms in issues, PRs, comments, and docs. If you need a term that is n - **Delegation:** one task handed to a subagent, with its own ID and result. Giving the same subagent a second task is a second delegation on the same thread. A delegation ends as done, failed, stopped or interrupted, and that outcome does not change once the result is read. While the subagent is still waiting on its own subagents or on a delivery, the delegation is waiting on subagents and has no result yet; it ends once the subagent has nothing left to wait for. - **Subagent title:** the short name a thread gives a subagent when it starts it, such as "API reviewer". It is unique among that thread's subagents and is how the thread later continues, reads or cancels that subagent. - **Continue (a subagent):** send a follow-up to a subagent that already exists, by its title. It carries on in the same thread with what it already read, as a new delegation, instead of a new subagent starting from nothing. A message a person types in a subagent's thread is also a follow-up, and its parent hears the result. -- **Remote subagent:** a subagent an agent starts on another of the user's computers (`delegate_task` with `computer`). That computer runs it as an ordinary thread, under its own agents and accounts, in its project that holds the same repository, and its questions are answered there. Its parent continues, reads and stops it like any subagent; its result names the branch its work is on there. Agents may start one only when "Let agents start subagents on your other devices" is on in Settings → Agents → Agent access (off at first), and only on the computers checked under it. It runs no looser than its parent and within the highest permission mode that computer set for this one, which can be Full access. +- **Remote subagent:** a subagent an agent starts on another of the user's computers (`delegate_task` with `computer`). That computer runs it as an ordinary thread, under its own agents and accounts, in its project that holds the same repository, and its questions are answered there. Its parent continues, reads and stops it like any subagent; its result names the branch its work is on there. Agents may start one only when "Let agents work on your other devices" is on in Settings → Agents → Agent access (off at first), and only on the computers turned on under it. It runs no looser than its parent and within the highest permission mode that computer set for this one, which can be Full access. - **Background work:** agents and shells a provider started that keep running after the turn that started them ended. Claude keeps one live process per thread so they survive. While a thread has background work it shows Waiting, and a subagent's task waits too. - **Continuation run:** a run of a thread that records a turn the provider started on its own, because background work finished and the provider wants to read the report. It opens with a short note and ends at the provider's result. - **Workflow:** a published sequence of steps that can run from chat (its slash command), the CLI, or an automation. @@ -84,6 +84,7 @@ Use these terms in issues, PRs, comments, and docs. If you need a term that is n - **Project group:** one entry in the sidebar's Projects view. A project of this computer and the projects of other computers that hold the same repository (they share a Git remote, so `sameAs` names the project here) are one group, with all their threads, each thread row still naming its computer. A project that exists on another computer only, or matches only by its first commit (`similarTo`: forks, templates), is a group of its own, named with its computer. A group stays, with offline rows, while a computer is out of reach. - **Block (a device):** a setting on one computer that refuses every Bridge call, stream and request from one other device, at once. It is kept on that computer only, needs no authority, and is undone with Unblock. - **Highest permission mode (for a device):** the most permissive permission mode a person on another computer can run a turn or create an "Always" rule in on this computer, and the most a remote subagent that computer's agents start here can run in. A new computer starts at Auto-accept edits. +- **Agent reach (for a device):** which threads of this computer another computer's agents may change (start, message, steer, stop), set beside its highest permission mode in Settings → Devices → Limits ("Agents on may change"; or `mousse-cli bridge limits --agent-reach`): Nothing, Threads they started (the default) or All threads. Reading follows the device's ordinary access. It is a rule for a computer that marks its agents' calls as it should, not a barrier: blocking the device and its highest permission mode are the controls for one that is not trusted. - **Share bots with other devices:** the switch on each computer (Settings, Devices; or `mousse-cli bridge bots on|off`) that lets the user's phones and other computers list this computer's personal bots and chat with them. It is on by default and stored on that computer. While it is off, the lists other devices read carry no bots and every `bots.*` call they make is refused (`forbidden`, reason `setting_off`). - **Devices (of a bot):** which of the owner's devices reach one personal bot, set in its About on the computer that holds it: All my devices (the default), Only this computer, or Chosen devices. **Bots on this computer** is the switch per device in Settings, Devices that lets that device reach none of the bots there. A device that is left out finds no such bot: it is in none of its lists, and every call about it answers as for a bot that is not there. See `docs/bots.md`, Two layers. - **Editor connections from this device:** the per-device switch on the computer that runs a thread that lets one other computer open its editor on this computer's folders: its `ssh` signs in to this computer, carried inside Mousse Net, and always ends there (the other computer never names a host or a port): at Mousse's own SSH server inside the daemon, which needs no SSH server, no key and no setup on this computer, or at the computer's own SSH server when its owner chose "Use this computer's SSH server". It is off by default and separate from "Terminals from this device". It ends at once when the device is blocked, the switch (or "Let my other computers work on this computer's threads") goes off, the device loses "Works on threads" or is revoked, or Net is turned off. It is the same as shell access for the user on that computer. A Windows computer uses its own OpenSSH server instead only when the endpoint's helper is missing or does not run. diff --git a/docs/net/threat-model.md b/docs/net/threat-model.md index ec7df0cacf..cd0c6931bd 100644 --- a/docs/net/threat-model.md +++ b/docs/net/threat-model.md @@ -240,7 +240,7 @@ A window of one computer reaches a thread on another computer through a router i An agent can start a subagent on another of the user's computers (`delegate_task` with `computer`). This is the one way an agent of this computer reaches another computer, and it is narrow on purpose: - It is the daemon's own service (`src/mms/orchestrator/RemoteSubagents.ts`), not the agent, that calls the other computer, through the router's client, so the rule that only a `gui` connection routes still holds for everything an agent's tools or shell send. -- Nothing starts unless "Let agents start subagents on your other devices" (`agentAccess.remoteSubagents`) is on in Settings → Agents → Agent access, and then only on the computers the user checked under it (`agentAccess.computers`). The switch is off and the list empty by default; both are read on every `delegate_task` and `continue_subagent`. Turning the switch off stops new starts and follow-ups; a subagent already running finishes, and its parent can stop it. +- Nothing starts unless "Let agents work on your other devices" (`agentAccess.remoteSubagents`, named "Subagents on other devices" before) is on in Settings → Agents → Agent access, and then only on the computers the user turned on under it (`agentAccess.computers`). The switch is off and the list empty by default; both are read on every `delegate_task` and `continue_subagent`. Turning the switch off stops new starts and follow-ups; a subagent already running finishes, and its parent can stop it. - It makes only these routed calls: `projects.match`, `threads.create`, `composer.options`, `threads.setPermissionMode`, `threads.setModel`, `orchestrator.send`, `runs.get`, `orchestrator.pendingQuestions`, `thread.snapshot`, `workspace.getStatus`, `orchestrator.abort` and `threads.settle` (archiving a thread it just made, when the task was refused). No terminal, file, Git or settings row. - The thread there runs in the narrowest of the parent thread's mode, the parent's run and the limit that computer set for this one (it refuses a mode above that limit, so the service narrows to it first). A follow-up (`continue_subagent`) runs no looser than the run that sends it and the mode the subagent was started with. No fixed mode caps it (issue #1160): when that computer's limit for this one is Full access and the parent runs in Full access, the subagent runs in Full access there, so an agent on this computer can run commands on that one without anyone being asked. That limit starts at Auto-accept edits, so this happens only after a person on that computer raised it for this one. A task that is read-only here (`workspace: 'shared'`, or a plan ceiling) is sent in Plan mode. - A thread another device started (a remote subagent's thread, or one a phone or another computer started) cannot start remote subagents, so a chain is one computer deep. @@ -254,7 +254,7 @@ Seven routed rows take a key `agent: { thread, run, title, hops, mode }`: `threa - **Who sets it.** Only the calling computer's daemon service. The router refuses it from a window (`invalid_params`; the key is in the rows, so it would otherwise pass through), and a phone's `threads.create` takes exact keys and the backend refuses the key outright. The key is never dropped for an older owner: the caller refuses to send a key the owner's version of the row does not know (`computer_outdated`), so an agent's message is never delivered as a person's. Any change to the key's shape or meaning raises the version of all seven rows. Its fields avoid `…Id`, so the id rewriting leaves them alone. - **What the owner does with it** (`src/mms/bridge/routed/remoteAgent.ts`). The calling computer comes from the authenticated link and its name from the owner's own pairing record, never from the call. The call runs through a remote agent actor (`AgentActor.remote`) that carries the sender's mode and hop count, so nothing is looked up as if the sender were local (a lookup would find no run and fall back to the profile default, which can be Full access). Compared with the same call from a person on that device, a marked call runs as source `mcp` (no "Always" rules, no `person_turn`), in the narrowest of the mode it carried, the device limit and, for a message into an existing thread, the thread's own mode; its text is never read for `/skill` or workflow commands; it is refused while a question or approval waits (`questions_pending`); a steer into a run looser than the sender is refused (`ceiling_exceeded`); the owner builds the envelope itself (the sender's title cut to 80 characters with control, direction and zero-width characters removed, both envelope markers defused in the title and the body) and the body is at most 16,000 characters (`agent_message_too_long`); the thread, the run and a queued item record the calling computer (`sentFrom`, `run.sent_from`), so blocking the device takes the agent's work away too; and the audit row says `actor: agent` (`bridge_audit.actor`). - **The owner's own limits**, each refused with its own code: agent messages in a row (the larger of the carried count and the owner's own count from the thread's latest run; `agent_hops_exceeded`), queued agent messages and repeats (the rules every agent's message has, on one computer or two: three waiting per sender and ten in all, `agent_queue_full_per_sender` and `agent_queue_full`, and the same text from the same sender within two minutes, `duplicate_message`, refused with the reason, never dropped; a sender on another computer is counted by its computer and thread), 20 messages per device and thread in 10 minutes (`agent_rate_limited`), and 200 agent-started runs per device a day (`agent_daily_budget`). The rate limit and the budget are counted from the audit, so a restart does not reset them. A follow-up from the agent that started the thread adds none of the owner's own count, as a follow-up to a subagent does on one computer. -- **Agent reach** (`net_node_policy.agent_reach`): which threads a device's agents may change, `none`, `launched` (default: threads they started here, from the owner's own `startedFrom`) or `all`, decided at each call. A marked Stop ends only runs an agent of that device started and leaves a thread a person took over. There is no setting in the app yet. +- **Agent reach** (`net_node_policy.agent_reach`): which threads a device's agents may change, `none`, `launched` (default: threads they started here, from the owner's own `startedFrom`) or `all`, decided at each call. A marked Stop ends only runs an agent of that device started and leaves a thread a person took over. A person on the owner sets it in Settings → Devices → Limits ("Agents on may change") or with `mousse-cli bridge limits --agent-reach`, through `bridge.policy`, a local method of the owner's own windows and command line that is never routed, so a device cannot widen its own reach. The device's activity list marks the calls its agents made ("by an agent"). - **Threads they start.** A marked `threads.create` records `startedFrom.agent { thread, title, mode }` and holds the thread to that mode from its first write, so a launch cut off later has already left a thread no wider than its launcher. `createdByThreadId` stays unset: a foreign id there would be rewritten to a thread of the owner that does not exist. A marked `threads.setPermissionMode` above that mode is refused (`agent_mode_above_thread`), and such a thread cannot start subagents on a third computer. The stored sender of a message is `origin.from { node, thread, run, title }` with no `origin.threadId`; the id rewriting leaves `from` unchanged on every computer. - **A policy, not a boundary.** The owner cannot verify that a marked call came from an agent, so the mark only narrows: a marked call may do strictly less than the same call unmarked, and a caller that lies about it gains nothing. A process that controls the calling computer can still send unmarked calls, which the owner handles as a person's. The device limit, the block and the audit remain the controls against a computer that is not trusted. diff --git a/src/mms/orchestrator/OrchestratorService.ts b/src/mms/orchestrator/OrchestratorService.ts index 5422c378fc..f28528f463 100644 --- a/src/mms/orchestrator/OrchestratorService.ts +++ b/src/mms/orchestrator/OrchestratorService.ts @@ -6990,9 +6990,9 @@ export class OrchestratorService extends EventEmitter { private remoteSubagentDenial(node: string, name: string): { code: string; message: string } | undefined { const access = this.agentAccessSettings() if (!access.remoteSubagents) - return { code: 'remote_subagents_off', message: 'The user has not allowed agents to create subagents on other devices. They can turn it on in Settings → Agents → Agent access.' } + return { code: 'remote_subagents_off', message: 'The user has not turned on "Let agents work on your other devices". They can turn it on in Settings → Agents → Agent access.' } if (!access.computers.includes(node)) - return { code: 'computer_not_allowed', message: `The user has not allowed agents to start subagents on ${name}. They can allow it in Settings → Agents → Agent access.` } + return { code: 'computer_not_allowed', message: `The user has not turned on ${name} under "Let agents work on your other devices". They can turn it on in Settings → Agents → Agent access.` } return undefined } @@ -7081,7 +7081,7 @@ export class OrchestratorService extends EventEmitter { return { computers: [], note: 'This computer is not connected to the user\'s other computers.' } const access = this.agentAccessSettings() if (!access.remoteSubagents) - return { computers: [], note: 'The user has not allowed agents to create subagents on other devices (Settings → Agents → Agent access).' } + return { computers: [], note: 'The user has not turned on "Let agents work on your other devices" (Settings → Agents → Agent access).' } const allowed = new Set(access.computers) const projectId = this.threadStore?.getThread(parentThreadId)?.projectId const projectPath = projectId ? this.projectManager?.getProject(projectId)?.path : undefined diff --git a/src/renderer/components/settings/AgentAccessSettings.tsx b/src/renderer/components/settings/AgentAccessSettings.tsx index 8432fa61d4..99599978c1 100644 --- a/src/renderer/components/settings/AgentAccessSettings.tsx +++ b/src/renderer/components/settings/AgentAccessSettings.tsx @@ -6,7 +6,7 @@ import { useComputers } from '../../lib/computers' /** * Settings > Agents > Access and Subagents: whether agents may answer approvals on other threads, then whether they - * may start subagents on other devices. Both read and write the one stored `agentAccess` setting. Agents read and + * may work on the user's other devices ("Let agents work on your other devices", stored as `remoteSubagents`). Both read and write the one stored `agentAccess` setting. Agents read and * manage every thread; there is no level to choose (SPEC §15.1). */ export function AgentAccessSettings({ @@ -76,7 +76,7 @@ export function AgentAccessSettings({ 0) && goneComputers.length === 0 @@ -86,13 +86,14 @@ export function AgentAccessSettings({ An agent can start a subagent on another of your computers. It runs there under that computer’s agents and accounts, in its copy of the repository, no looser than the agent that started it and within the limit that - computer set for this one in its Devices settings. Off by default. + computer set for this one in its Devices settings. That computer also chooses which of its threads this + computer’s agents may change. Off by default. } control={ save({ remoteSubagents })} /> diff --git a/src/renderer/lib/settingsSearch.ts b/src/renderer/lib/settingsSearch.ts index 2e6e41ed8f..483a443726 100644 --- a/src/renderer/lib/settingsSearch.ts +++ b/src/renderer/lib/settingsSearch.ts @@ -85,7 +85,7 @@ export const SETTINGS_SEARCH_INDEX: readonly SettingsSearchEntry[] = [ { title: 'Access', section: 'agents', anchor: 'agents-access', keywords: ['agent access', 'other threads'] }, { title: 'Answer approvals on other threads', section: 'agents', anchor: 'agents-access-approvals', keywords: ['permissions', 'agents may answer approvals'] }, { title: 'Subagents', section: 'agents', anchor: 'agents-subagents', keywords: ['subagent'] }, - { title: 'Subagents on other devices', section: 'agents', anchor: 'agents-remote-subagents', keywords: ['computers', 'remote', 'let agents start subagents on your other devices'] }, + { title: 'Let agents work on your other devices', section: 'agents', anchor: 'agents-remote-subagents', keywords: ['computers', 'remote', 'subagents on other devices', 'let agents start subagents on your other devices'] }, { title: 'Worktree per subagent', section: 'agents', anchor: 'agents-subagent-worktrees', keywords: ['experimental', 'branch', 'give each subagent its own worktree'] }, { title: 'What bots may do here', section: 'agents', anchor: 'agents-bots-here', keywords: ['bots', 'personal bots', 'bot permissions', 'this computer', 'limit'] }, { title: 'Run commands', section: 'agents', anchor: 'agents-bots-shell', keywords: ['bots', 'shell', 'terminal', 'commands'] }, diff --git a/src/shared/settings.ts b/src/shared/settings.ts index 58a6e2b00f..cb7ba877d2 100644 --- a/src/shared/settings.ts +++ b/src/shared/settings.ts @@ -314,7 +314,7 @@ export interface AgentAccessSettings { /** An agent may answer a pending approval on another thread. */ answerApprovals: boolean /** - * "Let agents start subagents on your other devices". Off, the default, refuses every remote subagent + * "Let agents work on your other devices" (named "Subagents on other devices" before). Off, the default, refuses every remote subagent * whatever `computers` lists; the list is kept, so turning it back on restores the same computers. */ remoteSubagents: boolean diff --git a/tests/renderer/agentAccessSettingsScreen.test.ts b/tests/renderer/agentAccessSettingsScreen.test.ts index b98ef6329e..45e6449402 100644 --- a/tests/renderer/agentAccessSettingsScreen.test.ts +++ b/tests/renderer/agentAccessSettingsScreen.test.ts @@ -96,7 +96,7 @@ describe('Settings > Agents > Access', () => { }) }) - describe('subagents on other devices', () => { + describe('let agents work on your other devices', () => { const remoteSwitch = () => host.querySelector('#agent-access-remote-subagents') const on = () => remoteSwitch()!.getAttribute('aria-checked') === 'true' @@ -104,14 +104,14 @@ describe('Settings > Agents > Access', () => { show() expect(remoteSwitch()).not.toBeNull() expect(on()).toBe(false) - expect(remoteSwitch()!.getAttribute('aria-label')).toBe('Subagents on other devices') - expect(host.querySelector('label[for="agent-access-remote-subagents"]')?.textContent).toBe('Subagents on other devices') + expect(remoteSwitch()!.getAttribute('aria-label')).toBe('Let agents work on your other devices') + expect(host.querySelector('label[for="agent-access-remote-subagents"]')?.textContent).toBe('Let agents work on your other devices') expect(remoteSwitch()!.closest('section.settings-group')?.querySelector('h3')?.textContent?.trim()).toBe('Subagents') expect(host.querySelector('#agent-access-answer-approvals')!.closest('section.settings-group')?.querySelector('h3')?.textContent?.trim()).toBe('Access') expect(normalizeAgentAccessSettings(getDefaultSettings().agentAccess).remoteSubagents).toBe(false) }) - it('saves the whole setting when switched, and says to pair computers when none are connected', () => { + it('saves the whole setting when switched, under the key it always had, and says to pair computers when none are connected', () => { const { updates } = show({ answerApprovals: true }) click(remoteSwitch()!) expect(updates).toHaveBeenCalledWith({ agentAccess: { answerApprovals: true, remoteSubagents: true, computers: [] } })