Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(remote-agent): 远控任务用分享供应商时按分享目录显示模型 (#5748)
DavidShenXD91b311d90484
diff --git a/apps/desktop/src/renderer/__tests__/controlledTaskRemoteAgentPanel.test.tsx b/apps/desktop/src/renderer/__tests__/controlledTaskRemoteAgentPanel.test.tsxindex 645a46d956..27bd27556e 100644--- a/apps/desktop/src/renderer/__tests__/controlledTaskRemoteAgentPanel.test.tsx+++ b/apps/desktop/src/renderer/__tests__/controlledTaskRemoteAgentPanel.test.tsx@@ -98,6 +98,10 @@ const catalogs = vi.hoisted(() => {remoteInvocationEnabled: false,}),],+ // 分享来的供应商:控制端经自己的分享通道读到的目录(分享者已收窄到被分享的供应商)。+ 'share:abc': [+ provider('s-shared', 'S Shared', [['s-model', 'S Model']], { remoteInvocationEnabled: true }),+ ],} as Record<string, unknown[]>,};});@@ -248,6 +252,34 @@ describe('被控电脑上的任务:模型面板列出第三台电脑的远程供expect(screen.queryByRole('button', { name: 'A Local' })).toBeNull();});+ // 2026-10-10 用户反馈:A 远控 B 上 Agent 在分享上的任务,模型显示「模型信息暂不可用」。+ // 会话视图把本机也收到的那条分享并进候选、目录指向 `share:abc`(判定见 controlledTaskAgentLocation)。+ it('Agent 在本机也收到了的分享上:打开时停在分享的目录,不显示被控电脑的模型', async () => {+ const shareDevice = { deviceId: 'share:abc', name: 'Mac Mini · 来自 Magi 的分享' };+ const { onRelocate } = renderControlledTaskPanel(+ { devices: [...devices, shareDevice], selectedDeviceId: 'share:abc' },+ { deviceId: 'share:abc', modelId: 's-model', currentProviderId: 's-shared' },+ );+ expect(within(list()).getByText('S Model')).toBeTruthy();+ expect(within(list()).queryByText('B Model')).toBeNull();+ expect(+ screen+ .getByRole('button', { name: 'S Shared · Mac Mini · 来自 Magi 的分享' })+ .getAttribute('aria-pressed'),+ ).toBe('true');+ // 被控电脑那一格还在,选它的模型 = 改回被控电脑运行。+ await act(async () => {+ fireEvent.click(screen.getByRole('button', { name: 'B Main' }));+ });+ const row = within(list()).getByText('B Model').closest('[data-unified-anchor]') as HTMLElement;+ await act(async () => {+ fireEvent.click(row);+ });+ expect(onRelocate).toHaveBeenCalledWith(+ expect.objectContaining({ providerId: 'b-main', modelId: 'b-model', agentDevice: null }),+ );+ });+it('Agent 所在的第三台电脑离线:仍能回到被控电脑的目录,选中即改回被控电脑运行', async () => {catalogs.offline.add('device-c');try {diff --git a/apps/desktop/src/renderer/__tests__/remoteAgentRelocationWiring.test.ts b/apps/desktop/src/renderer/__tests__/remoteAgentRelocationWiring.test.tsindex e1bf6d1fd4..389146a8aa 100644--- a/apps/desktop/src/renderer/__tests__/remoteAgentRelocationWiring.test.ts+++ b/apps/desktop/src/renderer/__tests__/remoteAgentRelocationWiring.test.ts@@ -153,4 +153,30 @@ describe('被控电脑上的任务:换 Agent 所在电脑', () => {);expect(sessionViewSource).toContain('deviceLinkDeviceName={controlledDeviceName}');});++ it('Agent 在本机也收到了的分享上:按分享目录显示,只把那一条分享并进候选', () => {+ // 2026-10-10 用户反馈:A 远控 B 上用分享供应商的任务,模型按钮显示「模型信息暂不可用」。+ const start = sessionViewSource.indexOf('const controlledShareIds = useMemo(');+ expect(start).toBeGreaterThan(0);+ const block = sessionViewSource.slice(start, sessionViewSource.indexOf('[remoteDeviceId,', start));+ expect(block).toContain('controlledTaskReadableShareIds({');+ expect(block).toContain('agentDeviceId: session?.agentDeviceId,');+ expect(block).toContain('isReceived: isReceivedProviderShare,');+ expect(sessionViewSource).toContain(+ '...(controlledShareIds ? { readableShareIds: controlledShareIds } : {}),',+ );+ const branch = sessionViewSource.indexOf(+ 'if (remoteDeviceId) {\n return controlledAgentLocation',+ );+ const remoteBranch = sessionViewSource.slice(+ branch,+ sessionViewSource.indexOf(': undefined;', branch),+ );+ expect(remoteBranch).toContain('shareDevices: [...(controlledShareIds ?? [])]');+ // ChatInput 只认调用方放进候选的分享。+ const inputStart = chatInputSource.indexOf('const deviceLinkAgentLocation =');+ expect(chatInputSource.slice(inputStart, inputStart + 800)).toContain(+ 'readableShareIds: new Set(remoteAgentDevices.map((device) => device.deviceId)),',+ );+ });});diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsxindex 869e3a3683..8a85714c38 100644--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx@@ -1267,8 +1267,9 @@ export function ChatInput({/*** 远程控制的被控电脑上的任务(已建任务,或建到被控电脑的新任务草稿),Agent 同样可以在第三台电脑* 运行(与手机同一套)。调用方只在被控电脑支持时才传 remoteAgentDevices;SSH 任务与共享任务访客- * 不走这条。已建任务里 Agent 现在或挂着的位置是本机读不到目录的地方(被控电脑收到的分享 / 本机- * 自己)时,维持原有的被控电脑列表;草稿的落点只会是 remoteAgentDevices 里的电脑。+ * 不走这条。已建任务里 Agent 现在或挂着的位置是本机读不到目录的地方(本机没收到的分享 / 本机+ * 自己)时,维持原有的被控电脑列表;草稿的落点只会是 remoteAgentDevices 里的电脑。分享只有在+ * 调用方确认本机也收到、放进了 remoteAgentDevices 时才算读得到。*/const deviceLinkAgentLocation =!!deviceLinkDeviceId &&@@ -1280,6 +1281,7 @@ export function ChatInput({agentDeviceId: _agentDeviceId,pendingAgentDeviceId: makerChatStore.getAgentSwitchIntent(sessionId)?.agentDeviceId,selfDeviceId,+ readableShareIds: new Set(remoteAgentDevices.map((device) => device.deviceId)),}));/** 这个任务的 Agent 位置由本机呈现与切换:本机任务,或上面那种被控电脑上的任务。 */const agentLocationAware = !deviceLinkDeviceId || deviceLinkAgentLocation;diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex aeabb20ed3..e97b7b4400 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -166,6 +166,7 @@ import { useDeviceProviders } from '@/hooks/useDeviceProviders';import { useSelectableDevices } from '@/hooks/useControllableDevices';import {controlledTaskAgentLocationReadable,+ controlledTaskReadableShareIds,controlledTaskSupportsAgentLocation,selectControlledTaskAgentDevices,} from '@/lib/controlledTaskAgentLocation';@@ -2063,9 +2064,30 @@ export function CCAgentSessionView({// 生效)。Agent 当前所在电脑与挂着的换位置目标即使掉线也保留,让用户看得到、换得回来。const { devices: selectableDevices } = useSelectableDevices();const pendingAgentDeviceId = agentSwitchIntent?.agentDeviceId;+ // 供应商分享:别人分享给我的供应商也是远程 Agent 的落点(`share:<id>`),并进本机任务,+ // 不进设备切换器。已暂停 / 已不在的分享只在它正是当前或即将使用的位置时保留。+ const {+ devices: providerShareDevices,+ nameFor: providerShareDeviceName,+ isReceived: isReceivedProviderShare,+ } = useProviderShareAgentDevices([agentDeviceId, pendingAgentDeviceId]);+ // 被控电脑上的任务 Agent 现在 / 挂着的位置是分享时:分享按账号授予,本机也收到了同一条就经本机+ // 的分享通道读它的目录,模型按钮按分享显示(否则只能读到被控电脑自己的目录,显示「模型信息暂+ // 不可用」)。本机没收到的分享读不到,维持原样。+ const controlledShareIds = useMemo(+ () =>+ remoteDeviceId+ ? controlledTaskReadableShareIds({+ agentDeviceId: session?.agentDeviceId,+ pendingAgentDeviceId,+ isReceived: isReceivedProviderShare,+ })+ : undefined,+ [remoteDeviceId, session?.agentDeviceId, pendingAgentDeviceId, isReceivedProviderShare],+ );// 远程控制的被控电脑上的任务:被控电脑支持远程 Agent 时,同样列出其他电脑的供应商(与手机同一// 套)。共享任务访客读到的是自己账号的设备、与任务无关,SSH 任务不支持;Agent 现在或挂着的位置- // 在本机读不到目录的地方(被控电脑收到的分享 / 本机自己)时,维持原有的被控电脑列表。+ // 在本机读不到目录的地方(本机没收到的分享 / 本机自己)时,维持原有的被控电脑列表。const controlledAgentLocation =!!remoteDeviceId &&!session?.remoteHostId &&@@ -2075,16 +2097,12 @@ export function CCAgentSessionView({agentDeviceId: session?.agentDeviceId,pendingAgentDeviceId,selfDeviceId,+ ...(controlledShareIds ? { readableShareIds: controlledShareIds } : {}),});/** 被控电脑上的任务里 Agent 现在所在的电脑(undefined = 被控电脑本身)。 */const controlledAgentDeviceId = controlledAgentLocation? (session?.agentDeviceId ?? undefined): undefined;- // 供应商分享:别人分享给我的供应商也是远程 Agent 的落点(`share:<id>`),只并进本机任务,- // 不进设备切换器(被控电脑上的任务用不了本机收到的分享)。已暂停 / 已不在的分享只在它正是- // 当前或即将使用的位置时保留。- const { devices: providerShareDevices, nameFor: providerShareDeviceName } =- useProviderShareAgentDevices([agentDeviceId, pendingAgentDeviceId]);const remoteAgentDevices = useMemo(() => {if (session?.remoteHostId) return undefined;if (remoteDeviceId) {@@ -2093,6 +2111,10 @@ export function CCAgentSessionView({devices: selectableDevices,controlledDeviceId: remoteDeviceId,keepDeviceIds: [controlledAgentDeviceId, pendingAgentDeviceId],+ shareDevices: [...(controlledShareIds ?? [])].map((deviceId) => ({+ deviceId,+ name: providerShareDeviceName(deviceId) ?? deviceId,+ })),}): undefined;}@@ -2114,6 +2136,8 @@ export function CCAgentSessionView({session?.remoteHostId,controlledAgentLocation,controlledAgentDeviceId,+ controlledShareIds,+ providerShareDeviceName,agentDeviceId,pendingAgentDeviceId,]);diff --git a/apps/desktop/src/renderer/features/provider-share/__tests__/useProviderShareAgentDevices.test.tsx b/apps/desktop/src/renderer/features/provider-share/__tests__/useProviderShareAgentDevices.test.tsxindex f393c1770b..f31a400ace 100644--- a/apps/desktop/src/renderer/features/provider-share/__tests__/useProviderShareAgentDevices.test.tsx+++ b/apps/desktop/src/renderer/features/provider-share/__tests__/useProviderShareAgentDevices.test.tsx@@ -73,6 +73,8 @@ describe('useProviderShareAgentDevices', () => {expect(result.current.nameFor('device-123')).toBeNull();expect(result.current.isKnown('share:b')).toBe(true);expect(result.current.isKnown('share:zzz')).toBe(false);+ expect(result.current.isReceived('share:b')).toBe(true);+ expect(result.current.isReceived('share:zzz')).toBe(false);});it('keeps the current paused or removed share so the task can see and leave it', async () => {@@ -88,6 +90,7 @@ describe('useProviderShareAgentDevices', () => {const { result } = renderHook(() => useProviderShareAgentDevices(['share:x']));expect(result.current.loaded).toBe(false);expect(result.current.isKnown('share:x')).toBe(true);+ expect(result.current.isReceived('share:x')).toBe(false);expect(result.current.devices).toEqual([]);});diff --git a/apps/desktop/src/renderer/features/provider-share/useProviderShareAgentDevices.ts b/apps/desktop/src/renderer/features/provider-share/useProviderShareAgentDevices.tsindex c19d476e66..6de79fae99 100644--- a/apps/desktop/src/renderer/features/provider-share/useProviderShareAgentDevices.ts+++ b/apps/desktop/src/renderer/features/provider-share/useProviderShareAgentDevices.ts@@ -31,6 +31,8 @@ export interface ProviderShareAgentDevices {* 时返回 true,不把「暂时读不到」当成「已删除」。*/isKnown: (deviceId: string | null | undefined) => boolean;+ /** 该分享确实在本机已收到的列表里(无论是否暂停);列表未加载或为空时返回 false。 */+ isReceived: (deviceId: string | null | undefined) => boolean;}export function useProviderShareAgentDevices(@@ -90,5 +92,10 @@ export function useProviderShareAgentDevices([loaded, names],);- return { devices, loaded, nameFor, isKnown };+ const isReceived = useCallback(+ (deviceId: string | null | undefined) => !!deviceId && names.has(deviceId),+ [names],+ );++ return { devices, loaded, nameFor, isKnown, isReceived };}diff --git a/apps/desktop/src/renderer/lib/__tests__/controlledTaskAgentLocation.test.ts b/apps/desktop/src/renderer/lib/__tests__/controlledTaskAgentLocation.test.tsindex 810d60d0c8..ffd34bb782 100644--- a/apps/desktop/src/renderer/lib/__tests__/controlledTaskAgentLocation.test.ts+++ b/apps/desktop/src/renderer/lib/__tests__/controlledTaskAgentLocation.test.ts@@ -7,6 +7,7 @@ import { describe, expect, it } from 'vitest';import {controlledComputerSupportsRemoteAgent,controlledTaskAgentLocationReadable,+ controlledTaskReadableShareIds,controlledTaskSupportsAgentLocation,isControllerReadableAgentDevice,selectControlledTaskAgentDevices,@@ -43,12 +44,17 @@ describe('isControllerReadableAgentDevice', () => {expect(isControllerReadableAgentDevice('device-c', 'device-a')).toBe(true);});- it('被控电脑收到的分享、本机自己、空值都读不到', () => {+ it('本机没收到的分享、本机自己、空值都读不到', () => {expect(isControllerReadableAgentDevice('share:abc', 'device-a')).toBe(false);+ expect(isControllerReadableAgentDevice('share:abc', 'device-a', new Set(['share:xyz']))).toBe(false);expect(isControllerReadableAgentDevice('device-a', 'device-a')).toBe(false);expect(isControllerReadableAgentDevice(null, 'device-a')).toBe(false);expect(isControllerReadableAgentDevice(undefined, 'device-a')).toBe(false);});++ it('本机也收到了的分享经本机的分享通道读得到', () => {+ expect(isControllerReadableAgentDevice('share:abc', 'device-a', new Set(['share:abc']))).toBe(true);+ });});describe('controlledTaskAgentLocationReadable', () => {@@ -69,7 +75,27 @@ describe('controlledTaskAgentLocationReadable', () => {).toBe(true);});- it('现在或挂着的位置在分享 / 本机上:维持原有的被控电脑列表', () => {+ it('Agent 在本机也收到了的分享上:按分享的目录显示,也能换走', () => {+ const readableShareIds = new Set(['share:abc']);+ expect(+ controlledTaskAgentLocationReadable({+ agentDeviceId: 'share:abc',+ pendingAgentDeviceId: undefined,+ selfDeviceId: 'device-a',+ readableShareIds,+ }),+ ).toBe(true);+ expect(+ controlledTaskAgentLocationReadable({+ agentDeviceId: 'share:abc',+ pendingAgentDeviceId: 'device-c',+ selfDeviceId: 'device-a',+ readableShareIds,+ }),+ ).toBe(true);+ });++ it('现在或挂着的位置在本机没收到的分享 / 本机上:维持原有的被控电脑列表', () => {expect(controlledTaskAgentLocationReadable({agentDeviceId: 'share:abc',@@ -117,4 +143,90 @@ describe('selectControlledTaskAgentDevices', () => {{ deviceId: 'device-d', name: 'Laptop' },]);});++ it('Agent 所在的分享接在同账号电脑之后', () => {+ expect(+ selectControlledTaskAgentDevices({+ devices,+ controlledDeviceId: 'device-b',+ keepDeviceIds: ['share:abc'],+ shareDevices: [{ deviceId: 'share:abc', name: 'Mac Mini · 来自 Magi 的分享' }],+ }),+ ).toEqual([+ { deviceId: 'device-c', name: 'Studio' },+ { deviceId: 'share:abc', name: 'Mac Mini · 来自 Magi 的分享' },+ ]);+ });+});++describe('controlledTaskReadableShareIds', () => {+ const received = (id: string) => id === 'share:abc';++ it('只收当前 / 挂着位置里、本机也收到了的分享', () => {+ expect([+ ...(controlledTaskReadableShareIds({+ agentDeviceId: 'share:abc',+ pendingAgentDeviceId: 'share:zzz',+ isReceived: received,+ }) ?? []),+ ]).toEqual(['share:abc']);+ expect(+ controlledTaskReadableShareIds({+ agentDeviceId: 'device-c',+ pendingAgentDeviceId: null,+ isReceived: () => true,+ }),+ ).toBeUndefined();+ expect(+ controlledTaskReadableShareIds({+ agentDeviceId: 'share:zzz',+ pendingAgentDeviceId: undefined,+ isReceived: received,+ }),+ ).toBeUndefined();+ });+});++/**+ * 端到端串起会话视图与输入框的判定,算出模型目录所在的电脑(同 CCAgentSessionView 与 ChatInput 的+ * catalogDeviceId:Agent 位置可读时取 Agent 所在,否则取被控电脑)。2026-10-10 用户反馈:A 远控 B+ * 上 Agent 在分享上的任务,模型按钮显示「模型信息暂不可用」(读的是 B 的目录)。+ */+describe('被控电脑上的任务 Agent 在分享上:模型目录来源', () => {+ function catalogDeviceIdFor(isReceived: (id: string) => boolean): string {+ const agentDeviceId = 'share:abc';+ const shareIds = controlledTaskReadableShareIds({+ agentDeviceId,+ pendingAgentDeviceId: undefined,+ isReceived,+ });+ const sessionViewReadable = controlledTaskAgentLocationReadable({+ agentDeviceId,+ pendingAgentDeviceId: undefined,+ selfDeviceId: 'device-a',+ ...(shareIds ? { readableShareIds: shareIds } : {}),+ });+ if (!sessionViewReadable) return 'device-b';+ const remoteAgentDevices = selectControlledTaskAgentDevices({+ devices: [{ deviceId: 'device-c', name: 'Studio', online: true }],+ controlledDeviceId: 'device-b',+ keepDeviceIds: [agentDeviceId],+ shareDevices: [...(shareIds ?? [])].map((deviceId) => ({ deviceId, name: deviceId })),+ });+ const chatInputReadable = controlledTaskAgentLocationReadable({+ agentDeviceId,+ pendingAgentDeviceId: undefined,+ selfDeviceId: 'device-a',+ readableShareIds: new Set(remoteAgentDevices.map((device) => device.deviceId)),+ });+ return chatInputReadable ? agentDeviceId : 'device-b';+ }++ it('本机也收到了这条分享:读分享的目录', () => {+ expect(catalogDeviceIdFor((id) => id === 'share:abc')).toBe('share:abc');+ });++ it('本机没收到:维持读被控电脑的目录', () => {+ expect(catalogDeviceIdFor(() => false)).toBe('device-b');+ });});diff --git a/apps/desktop/src/renderer/lib/controlledTaskAgentLocation.ts b/apps/desktop/src/renderer/lib/controlledTaskAgentLocation.tsindex 414e831653..80b4df2983 100644--- a/apps/desktop/src/renderer/lib/controlledTaskAgentLocation.ts+++ b/apps/desktop/src/renderer/lib/controlledTaskAgentLocation.ts@@ -29,29 +29,53 @@ export function controlledComputerSupportsRemoteAgent(return providers.some((provider) => typeof provider.remoteInvocationEnabled === 'boolean');}+const NO_SHARES: ReadonlySet<string> = new Set();+/**- * 本机能否直接经 device-link 读这台电脑的模型目录。同账号的其他电脑可以;被控电脑收到的分享- * (`share:<id>`,凭证只在被控电脑上)与本机自己(device-link 不连自己)读不到。+ * 本机能否直接读这台电脑的模型目录。同账号的其他电脑可以(device-link);本机自己读不到+ * (device-link 不连自己)。分享(`share:<id>`)按账号授予,被控电脑收到的分享本机通常也收到了:+ * 只有本机自己的已收到列表里有它(readableShareIds)时,才经本机的分享通道读得到。*/export function isControllerReadableAgentDevice(deviceId: string | null | undefined,selfDeviceId: string | null,+ readableShareIds: ReadonlySet<string> = NO_SHARES,): deviceId is string {- return !!deviceId && !isProviderShareAgentDeviceId(deviceId) && deviceId !== selfDeviceId;+ if (!deviceId || deviceId === selfDeviceId) return false;+ return isProviderShareAgentDeviceId(deviceId) ? readableShareIds.has(deviceId) : true;+}++/**+ * 被控电脑上的任务 Agent 现在 / 挂着的位置里,本机也收到了的分享(isReceived 由本机的已收到列表+ * 判定)。没有时返回 undefined。+ */+export function controlledTaskReadableShareIds(input: {+ agentDeviceId: string | null | undefined;+ pendingAgentDeviceId: string | null | undefined;+ isReceived: (deviceId: string) => boolean;+}): ReadonlySet<string> | undefined {+ const ids = [input.agentDeviceId, input.pendingAgentDeviceId].filter(+ (id): id is string => !!id && isProviderShareAgentDeviceId(id) && input.isReceived(id),+ );+ return ids.length > 0 ? new Set(ids) : undefined;}/*** 被控电脑上的任务能不能在本机的模型面板里换 Agent 所在电脑:任务当前与挂着的换位置意图都得是- * 被控电脑本身(null)或本机读得到目录的电脑。Agent 在被控电脑收到的分享上、或就在本机时,本机+ * 被控电脑本身(null)或本机读得到目录的电脑。Agent 在本机没收到的分享上、或就在本机时,本机* 列不出那份目录,维持原有的被控电脑列表与调用。*/export function controlledTaskAgentLocationReadable(input: {agentDeviceId: string | null | undefined;pendingAgentDeviceId: string | null | undefined;selfDeviceId: string | null;+ /** 本机也收到了的分享(`share:<id>`)。 */+ readableShareIds?: ReadonlySet<string>;}): boolean {return [input.agentDeviceId, input.pendingAgentDeviceId].every(- (deviceId) => deviceId == null || isControllerReadableAgentDevice(deviceId, input.selfDeviceId),+ (deviceId) =>+ deviceId == null ||+ isControllerReadableAgentDevice(deviceId, input.selfDeviceId, input.readableShareIds),);}@@ -59,19 +83,24 @@ export function controlledTaskAgentLocationReadable(input: {* 被控电脑上的任务(已建任务或新建任务草稿)可以让 Agent 去哪些电脑:本机的可选设备(已排除本机与* 手机)里去掉被控电脑本身,留下在线的,以及任务当前 / 挂着的 Agent 所在电脑(离线也保留,让用户* 看得到、换得回来)。- * 本机自己收到的分享不列:被控电脑用不了。被控电脑收到的分享本机读不到目录,同样不列。+ * 分享只列任务当前 / 挂着的 Agent 所在、本机也读得到的那条(shareDevices,接在最后),让模型按钮按+ * 分享的目录显示、面板里看得到它;其他分享不作为新的落点列出。*/export function selectControlledTaskAgentDevices(input: {devices: readonly { deviceId: string; name: string; online: boolean }[];controlledDeviceId: string;keepDeviceIds: readonly (string | null | undefined)[];+ shareDevices?: readonly { deviceId: string; name: string }[];}): { deviceId: string; name: string }[] {const keep = new Set(input.keepDeviceIds.filter((id): id is string => !!id));- return input.devices- .filter(- (device) =>- device.deviceId !== input.controlledDeviceId &&- (device.online || keep.has(device.deviceId)),- )- .map(({ deviceId, name }) => ({ deviceId, name }));+ return [+ ...input.devices+ .filter(+ (device) =>+ device.deviceId !== input.controlledDeviceId &&+ (device.online || keep.has(device.deviceId)),+ )+ .map(({ deviceId, name }) => ({ deviceId, name })),+ ...(input.shareDevices ?? []),+ ];}diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex e7dab694e2..b2d1cdd5ae 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -617,7 +617,10 @@ handler 无 sender 依赖;不加入共享任务访客白名单,不进入自桌面远程控制 A 上的已建任务(2026-10-09)与手机同口径:A 投影的任务带 `agentDeviceId` 字段(含 null)才开放,控制端直接经 device-link 读第三台电脑的 `maker:provider:list`,A 自己的目录照远程控制列全部供应商,换位置同样带 `agentDeviceId`(null = A),换后档位记在控制端为那台电脑单独记的一份(改回 A 时写 A 的镜像)。A 收到的分享与- 控制端自己作为落点暂不在桌面控制端列出(控制端读不到那份目录);Agent 正在这类位置上时维持原有的 A 目录列表。+ 控制端自己作为新的落点暂不在桌面控制端列出;Agent 正在控制端读不到目录的位置上时维持原有的 A 目录列表。+ 例外(2026-10-10):Agent 当前 / 挂着的位置是分享(`share:<id>`)、且控制端自己的已收到列表里也有这条(分享按账号+ 授予,同账号电脑收到的是同一份)时,控制端经自己的分享通道读那份目录与 Agent 能力,模型按钮按分享显示,候选里+ 只并进这一条分享;不经 A、不新增 channel。控制端没收到时维持原样。实现见 `apps/desktop/src/renderer/lib/controlledTaskAgentLocation.ts`,回归见`controlledTaskRemoteAgentPanel.test.tsx` 与 `remoteAgentRelocationWiring.test.ts`。桌面远程控制下新建任务(建到 A 上,2026-10-09)同样开放:判据与手机新建相同(A 的 `maker:provider:list` 带