Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 别的电脑关了远程控制或不在设备清单里时,工作台经那台转来的行按离线显示
Chris0f20f867d469
diff --git a/apps/desktop/src/renderer/features/bots/BotWorkbench.tsx b/apps/desktop/src/renderer/features/bots/BotWorkbench.tsxindex e52ea00ff7..4bc9412595 100644--- a/apps/desktop/src/renderer/features/bots/BotWorkbench.tsx+++ b/apps/desktop/src/renderer/features/bots/BotWorkbench.tsx@@ -94,8 +94,11 @@ export function BotWorkbench({[hostDeviceId, hostName, self?.deviceId],);const { glance: raw, failed, fetchedAt } = useBotGlance(botId, host);- // 设备清单说它离线,或最近一次读取失败:保留上一份内容,但经那台转来的行按离线显示。- const hostOnline = !hostDeviceId || (hostDevice?.online !== false && !failed);+ // 那台电脑不在设备清单里、离线、任一端关了远程控制,或最近一次读取失败:保留上一份内容,+ // 但经那台转来的行按离线显示(不能「允许」)。清单还没加载时只看读取结果。+ const hostControllable = devices === null+ || Boolean(hostDevice && hostDevice.online && hostDevice.remoteControlEnabled && hostDevice.controlEnabled);+ const hostOnline = !hostDeviceId || (hostControllable && !failed);const glance = useMemo<BotGlance | null>(() => (raw ? rebaseGlance(raw, { ...host, online: hostOnline }) : null),[raw, host, hostOnline],diff --git a/apps/desktop/src/renderer/features/bots/__tests__/BotWorkbenchView.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/BotWorkbenchView.test.tsxindex 5ccd83562e..4ac130f868 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/BotWorkbenchView.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/BotWorkbenchView.test.tsx@@ -19,7 +19,16 @@ const m = vi.hoisted(() => ({resolveRoute: vi.fn(async (id: string) => `/cc-agent/${id}`),pinSessionOrigin: vi.fn(),mirrored: [] as Array<{ id: string }>,+ devices: [] as Array<Record<string, unknown>>,}));++function deviceList(studio: Record<string, unknown> = {}) {+ const controllable = { online: true, remoteControlEnabled: true, controlEnabled: true };+ return [+ { deviceId: 'dev-self', name: 'MacBook', isSelf: true, ...controllable },+ { deviceId: 'dev-2', name: 'Studio', isSelf: false, ...controllable, ...studio },+ ];+}vi.mock('react-router-dom', () => ({ useNavigate: () => m.navigate }));vi.mock('react-i18next', () => ({useTranslation: () => ({@@ -29,10 +38,7 @@ vi.mock('react-i18next', () => ({}),}));vi.mock('@/features/device-link/useDeviceLinkDeviceList', () => ({- useDeviceLinkDeviceList: () => [- { deviceId: 'dev-self', name: 'MacBook', isSelf: true },- { deviceId: 'dev-2', name: 'Studio', isSelf: false },- ],+ useDeviceLinkDeviceList: () => m.devices,}));vi.mock('@/lib/remoteDataOwnerPushFence', () => ({ isDeviceLinkRemotePushCurrent: () => true }));vi.mock('@/lib/sidebarWindow', () => ({ isSidebarWindow: () => false }));@@ -81,6 +87,7 @@ beforeEach(() => {listeners = [];m.makerApiForDevice.mockReturnValue(m.remoteApi);m.mirrored = [];+ m.devices = deviceList();(window as unknown as { electronAPI: unknown }).electronAPI = {localDb: { bots: { autonomy: { glance: glanceApi } } },maker: {@@ -218,6 +225,21 @@ it('greys out a remote teammate\'s rows once that computer stops answering, keepexpect(screen.getByText('删掉旧分支吗?')).toBeTruthy();});+it('greys out a remote teammate\'s rows when remote control to that computer is turned off', async () => {+ remoteInvoke.mockResolvedValue(glance({+ waiting: [row({ sessionId: 's8', question: '合并到主干吗?', waitingFor: 'permission', requestId: 'r-8' })],+ }));+ const view = render(<BotWorkbench botId="bot-1" hostDeviceId="dev-2" />);+ const allow = () => within(screen.getByText('合并到主干吗?').closest('li')!)+ .getByRole('button', { name: 'bots.workbench.glance.allow' }) as HTMLButtonElement;+ await screen.findByText('合并到主干吗?');+ expect(allow().disabled).toBe(false);++ m.devices = deviceList({ controlEnabled: false });+ view.rerender(<BotWorkbench botId="bot-1" hostDeviceId="dev-2" />);+ expect(allow().disabled).toBe(true);+});+it('never approves a confirmation that carries no request id; it opens the task instead', async () => {// 宿主把 kind 含 confirm 的交互归成权限类但没有 requestId:那件任务里唯一的权限请求不一定是这一行。const confirmRow = row({ sessionId: 's3', question: '确认要发布吗?', waitingFor: 'permission', requestId: null });