Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(remote-agent): 被控电脑任务的 Agent 在别的电脑运行时,侧栏与手机任务列表也带波纹标识
Lizi509be22736c0
diff --git a/apps/desktop/src/renderer/__tests__/remoteAgentVendorIcon.test.tsx b/apps/desktop/src/renderer/__tests__/remoteAgentVendorIcon.test.tsxindex b1112d21eb..658e58d744 100644--- a/apps/desktop/src/renderer/__tests__/remoteAgentVendorIcon.test.tsx+++ b/apps/desktop/src/renderer/__tests__/remoteAgentVendorIcon.test.tsx@@ -3,8 +3,9 @@* Agent 在另一台电脑运行(任务在本机)的标识:Agent 图标右上角加模型选择器同款的单波纹 + 点,* 替代标题后的芯片图标(2026-10-07 用户裁决)。*- * 锁四件事:波纹不改 Agent 图标本身的大小;只有本机任务 + agentDeviceId 才画;右上角正显示- * 状态点时由状态点占位;悬停说明在哪台电脑、是否离线。+ * 锁四件事:波纹不改 Agent 图标本身的大小;有 agentDeviceId 才画(本机任务,以及 2026-10-09 起+ * 远程控制的被控电脑上的任务;SSH 任务不画);右上角正显示状态点时由状态点占位;悬停说明在哪台+ * 电脑、是否离线。*/import React from 'react';import { cleanup, render } from '@testing-library/react';@@ -31,6 +32,13 @@ vi.mock('@/hooks/useSessionPausedQueue', () => ({ useSessionPausedQueue: () => fvi.mock('@/features/device-link/useDeviceLinkDeviceList', () => ({useDeviceLinkDeviceList: () => devices.list,}));+// 本机已收到的分享:`share:mine` 是别人分享给本机的供应商。+vi.mock('@/features/provider-share/useProviderShareAgentDevices', () => ({+ useProviderShareAgentDevices: () => ({+ nameFor: (deviceId: string | null | undefined) =>+ deviceId === 'share:mine' ? 'Magi Mini · shared by Magi' : null,+ }),+}));import { RemoteSourceMark } from '@/components/icons/RemoteSourceMark';import { VendorIcon } from '@/components/sidebar/VendorIcon';@@ -132,11 +140,12 @@ describe('SessionStatusIcon for an Agent on another computer', () => {expect(getByTitle('ccAgent.sessionHeader.agentDeviceOffline:Studio Mac')).toBeTruthy();});- it('leaves local, device-link and SSH tasks unmarked', () => {+ it('leaves tasks whose Agent runs where the task is, and SSH tasks, unmarked', () => {expect(signal(renderStatus({}).container)).toBeNull();cleanup();+ // 被控电脑上的任务,Agent 就在被控电脑上(被控电脑投影 null)。expect(- signal(renderStatus({ agentDeviceId: 'device-b', deviceLinkDeviceId: 'device-c' }).container),+ signal(renderStatus({ agentDeviceId: null, deviceLinkDeviceId: 'device-c' }).container),).toBeNull();cleanup();expect(@@ -144,6 +153,17 @@ describe('SessionStatusIcon for an Agent on another computer', () => {).toBeNull();});+ it('names a provider shared with this computer for a local task', () => {+ const { container, getByTitle } = renderStatus({ agentDeviceId: 'share:mine' });+ expect(signal(container)).not.toBeNull();+ expect(getByTitle('ccAgent.sessionHeader.agentDevice:Magi Mini · shared by Magi')).toBeTruthy();+ });++ it('falls back to "another computer" instead of showing a raw id', () => {+ const { getByTitle } = renderStatus({ agentDeviceId: 'device-unknown' });+ expect(getByTitle('newChat.modelSelector.trigger.agentDeviceUnnamed')).toBeTruthy();+ });+it('gives the top-right corner to the attention dot while one is shown', () => {const withDot = renderStatus({ agentDeviceId: 'device-b' }, { hasAttentionNotification: true });expect(attentionDot(withDot.container)).toBeDefined();@@ -159,3 +179,33 @@ describe('SessionStatusIcon for an Agent on another computer', () => {expect(signal(row.container)).not.toBeNull();});});++describe('SessionStatusIcon for a task on a remotely controlled computer', () => {+ // A 远控 B 的任务,Agent 在 C 上运行(B 投影 agentDeviceId = C)。+ it('marks the Agent icon the same way and names the computer it runs on', () => {+ const { container, getByTitle } = renderStatus({+ agentDeviceId: 'device-b',+ deviceLinkDeviceId: 'device-c',+ });+ expect(signal(container)).not.toBeNull();+ expect(getByTitle('ccAgent.sessionHeader.agentDevice:Studio Mac')).toBeTruthy();+ });++ it('says when that computer is offline', () => {+ devices.list = [{ deviceId: 'device-b', name: 'Studio Mac', online: false }];+ const { getByTitle } = renderStatus({+ agentDeviceId: 'device-b',+ deviceLinkDeviceId: 'device-c',+ });+ expect(getByTitle('ccAgent.sessionHeader.agentDeviceOffline:Studio Mac')).toBeTruthy();+ });++ it("does not borrow this computer's shares to name a share the controlled computer received", () => {+ const { container, getByTitle } = renderStatus({+ agentDeviceId: 'share:mine',+ deviceLinkDeviceId: 'device-c',+ });+ expect(signal(container)).not.toBeNull();+ expect(getByTitle('newChat.modelSelector.trigger.agentDeviceUnnamed')).toBeTruthy();+ });+});diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsxindex cafb0ee02c..86127e9f4b 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx@@ -10,8 +10,9 @@* running:图标切 Thinking Orange + 呼吸;需关注:右上叠状态点(全端统一色表:* error 红 / awaiting TapTap 蓝 / 完成未读绿,tone 按行精准订阅 attention store);* 有未发送内容(草稿/暂停队列)且未选中:右下叠铅笔。- * Agent 在另一台电脑运行(任务在本机):VendorIcon 右上角加信号波纹,悬停说明哪台电脑;- * 右上角正显示状态点时由状态点占位,波纹暂不画(两者同角,叠在一起读不出)。+ * Agent 在另一台电脑运行(任务在本机,或在远程控制的被控电脑上):VendorIcon 右上角加信号+ * 波纹,悬停说明哪台电脑;右上角正显示状态点时由状态点占位,波纹暂不画(两者同角,叠在一起+ * 读不出)。* idle 时图标照常显示——让用户一眼看出"这是哪一个 agent"。**/@@ -34,6 +35,7 @@ import {type VendorIconKind,} from '@/components/sidebar/VendorIcon';import { useDeviceLinkDeviceList } from '@/features/device-link/useDeviceLinkDeviceList';+import { useProviderShareAgentDevices } from '@/features/provider-share/useProviderShareAgentDevices';import { useCindyMakeActivity } from './useCindyMakeActivity';/**@@ -42,10 +44,16 @@ import { useCindyMakeActivity } from './useCindyMakeActivity';*/function AgentDeviceVendorIcon({deviceId,+ controlledTask,showSignal,...iconProps}: {deviceId: string;+ /**+ * 任务在远程控制的被控电脑上:deviceId 是被控电脑投影的值。分享来的供应商(`share:<id>`)是+ * 被控电脑收到的,本机已收到的分享里查不到它的名字。+ */+ controlledTask: boolean;showSignal: boolean;vendor: VendorIconKind;size: number;@@ -54,16 +62,24 @@ function AgentDeviceVendorIcon({}) {const { t } = useTranslation();const device = useDeviceLinkDeviceList()?.find((item) => item.deviceId === deviceId);- const name = device?.name || deviceId;+ // 分享来的供应商(`share:<id>`)不在同账号设备列表里,本机任务的名字取自已收到的分享。+ const { nameFor: providerShareDeviceName } = useProviderShareAgentDevices();+ const name = device?.name || (controlledTask ? null : providerShareDeviceName(deviceId));const offline = device ? !device.online : false;return (<VendorIcon{...iconProps}remote={showSignal}- title={t(- offline ? 'ccAgent.sessionHeader.agentDeviceOffline' : 'ccAgent.sessionHeader.agentDevice',- { device: name },- )}+ title={+ name+ ? t(+ offline+ ? 'ccAgent.sessionHeader.agentDeviceOffline'+ : 'ccAgent.sessionHeader.agentDevice',+ { device: name },+ )+ : t('newChat.modelSelector.trigger.agentDeviceUnnamed')+ }/>);}@@ -115,11 +131,10 @@ export function SessionStatusIcon({const cindyMakeActivity = useCindyMakeActivity(session);const isRunning = isAgentRunning || isGhostBusy || cindyMakeActivity != null;const vendor = agentKindToVendor(session.agentKind);- // 任务在本机、Agent 在另一台电脑。device-link / SSH 任务整件在远端,标题旁另有远程图标。+ // Agent 在另一台电脑:任务在本机,或在远程控制的被控电脑上(值由被控电脑投影,null = Agent 就在+ // 被控电脑)。两种都用同一个波纹标识(2026-10-09 用户裁决)。SSH 任务整件在远端,没有这一说。const agentDeviceId =- session.agentDeviceId && !session.deviceLinkDeviceId && !session.remoteHostId- ? session.agentDeviceId- : null;+ session.agentDeviceId && !session.remoteHostId ? session.agentDeviceId : null;const isOrcaLead = isOrcaLeadSession(session);const isArchived = session.status === 'archived';// 角标 tone:error(含定时任务失败的 urgency context)红 > awaiting 蓝 > 完成未读绿。@@ -189,6 +204,7 @@ export function SessionStatusIcon({) : agentDeviceId ? (<AgentDeviceVendorIcondeviceId={agentDeviceId}+ controlledTask={Boolean(session.deviceLinkDeviceId)}showSignal={!(showAttentionDot && hasAttentionNotification)}vendor={vendor}size={size ?? (vendor === 'cc' ? 13 : 12)}diff --git a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts b/apps/mobile/src/__tests__/homeDesktopFirst.test.tsindex 05260a63d3..86a4be8a02 100644--- a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts+++ b/apps/mobile/src/__tests__/homeDesktopFirst.test.ts@@ -399,7 +399,11 @@ describe('mobile home desktop-first surface', () => {expect(providerMarkSource).not.toContain('CLAUDE_AGENT_PATH');expect(providerMarkSource).not.toContain('CODEX_AGENT_FLOWER_PATH');expect(vendorIconSource).toContain("import { MobileAgentMark } from './MobileAgentMark';");- expect(vendorIconSource).toContain("agentKind={vendor === 'codex' || vendor === 'pi' ? vendor : 'claude-code'}");+ // vendor → Agent mark 的映射要带上 pi,不能把 π 吞成 Claude 脸。+ expect(vendorIconSource).toContain(+ "const agentKind: AgentMarkKind = vendor === 'codex' || vendor === 'pi' ? vendor : 'claude-code';",+ );+ expect(vendorIconSource).toContain('<MobileAgentMark agentKind={agentKind} color={color} size={size} />');expect(vendorIconSource).not.toContain('viewBox="136 137 282 158"');expect(vendorIconSource).not.toContain('transform="translate(');expect(vendorIconSource).toContain('Easing.inOut(Easing.ease)');diff --git a/apps/mobile/src/__tests__/sessionListRemoteAgentMark.test.ts b/apps/mobile/src/__tests__/sessionListRemoteAgentMark.test.tsnew file mode 100644index 0000000000..e770c620b0--- /dev/null+++ b/apps/mobile/src/__tests__/sessionListRemoteAgentMark.test.ts@@ -0,0 +1,63 @@+/**+ * 任务列表里「Agent 在另一台电脑运行」的标识(2026-10-09 用户裁决:手机任务列表与桌面侧栏同一个+ * 波纹标识)。被控电脑上的任务用的是第三台电脑的远程供应商时,行首 Agent 图标右上角加与模型胶囊+ * 同款的单波纹 + 点。+ *+ * 源码契约测试:Node Vitest 环境加载不了 React Native 组件(同 mobileProviderLogo.test.ts)。+ * 空白统一折叠,格式化换行不影响断言。+ */+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import { describe, expect, it } from 'vitest';++import { sessionAgentRunsOnOtherComputer } from '@/session/sessionAgentSwitch';++function readSource(relativePath: string): string {+ return readFileSync(resolve(process.cwd(), relativePath), 'utf8')+ .replace(/\s+/g, ' ')+ .trim();+}++describe('任务列表行首的 Agent 图标', () => {+ it('Agent 在另一台电脑时才带远程标识', () => {+ const visuals = readSource('src/session/HomeListVisuals.tsx');+ expect(visuals).toContain('remote={sessionAgentRunsOnOtherComputer(item.session)}');+ // 判定只认被控电脑投影的当前位置:null / 缺省(含旧被控端)= Agent 就在被控电脑。+ expect(sessionAgentRunsOnOtherComputer({ agentDeviceId: 'device-c' })).toBe(true);+ expect(sessionAgentRunsOnOtherComputer({ agentDeviceId: null })).toBe(false);+ expect(sessionAgentRunsOnOtherComputer({})).toBe(false);+ });++ it('与模型胶囊同一个波纹,图标本身不缩放、不移位', () => {+ const icon = readSource('src/components/MobileVendorIcon.tsx');+ expect(icon).toContain("import { RemoteSourceMark } from '@/session/RemoteSourceMark';");+ expect(icon).toContain(+ '<RemoteSourceMark color={color} inset={{ x: (1 - anchor.x) * size, y: anchor.y * size }} size={size} > {mark} </RemoteSourceMark>',+ );+ // 不带标识时与改动前同一棵树。+ expect(icon).toContain(') : ( mark )}');+ expect(icon).not.toContain('scale(');+ });++ it('波纹贴字形右上角,位置与桌面 VendorIcon 同一套', () => {+ const icon = readSource('src/components/MobileVendorIcon.tsx');+ const desktop = readSource('../desktop/src/renderer/components/sidebar/VendorIcon.tsx');+ for (const anchor of ["'claude-code': { x: 0.95, y: 0.13 }", 'codex: { x: 0.9, y: 0.1 }']) {+ expect(icon).toContain(anchor);+ }+ expect(desktop).toContain('cc: { x: 0.95, y: 0.13 }');+ expect(desktop).toContain('codex: { x: 0.9, y: 0.1 }');+ // π 在手机端是描边路径,比桌面的 π 字符大,单独按路径定。+ expect(icon).toContain('pi: { x: 0.93, y: 0.19 }');+ });++ it('波纹跟随图标取色,随运行中呼吸一起变化', () => {+ const icon = readSource('src/components/MobileVendorIcon.tsx');+ // 波纹在带 opacity 的 Animated.View 里面,与字形共用同一个 color。+ const animated = icon.indexOf('<Animated.View');+ const remote = icon.indexOf('<RemoteSourceMark color={color}');+ expect(animated).toBeGreaterThan(0);+ expect(remote).toBeGreaterThan(animated);+ expect(icon.indexOf('</Animated.View>')).toBeGreaterThan(remote);+ });+});diff --git a/apps/mobile/src/components/MobileVendorIcon.tsx b/apps/mobile/src/components/MobileVendorIcon.tsxindex bfc36b25d3..e6b0b8b949 100644--- a/apps/mobile/src/components/MobileVendorIcon.tsx+++ b/apps/mobile/src/components/MobileVendorIcon.tsx@@ -1,6 +1,7 @@import { useEffect, useRef } from 'react';import { Animated, Easing } from 'react-native';import { useReduceMotionEnabled } from '@/hooks/useReduceMotion';+import { RemoteSourceMark } from '@/session/RemoteSourceMark';import { useTheme } from '@/theme';import { MobileAgentMark } from './MobileAgentMark';@@ -12,14 +13,38 @@ import { MobileAgentMark } from './MobileAgentMark';const RUNNING_BREATH_HALF_CYCLE_MS = 750;const RUNNING_BREATH_MIN_OPACITY = 0.3;+type AgentMarkKind = 'claude-code' | 'codex' | 'pi';++/**+ * 各字形笔画右上角在自身方框里的位置(0–1,已留出与波纹点的间隙),与桌面 VendorIcon 的+ * REMOTE_SIGNAL_ANCHOR 同一套。π 在手机端是 24 单位画布里的描边路径(右上沿约 20.4, 6.6),+ * 比桌面的 π 字符大,按路径定。+ */+const REMOTE_SIGNAL_ANCHOR: Record<AgentMarkKind, { x: number; y: number }> = {+ 'claude-code': { x: 0.95, y: 0.13 },+ codex: { x: 0.9, y: 0.1 },+ pi: { x: 0.93, y: 0.19 },+};+interface MobileVendorIconProps {color?: string;running?: boolean;size?: number;vendor: 'cc' | 'codex' | string;+ /**+ * Agent 在另一台电脑运行:右上角外侧叠与模型胶囊同款的单波纹 + 点(随图标取色与呼吸),+ * 图标本身大小与位置不变(与桌面侧栏同一种做法)。+ */+ remote?: boolean;}-export function MobileVendorIcon({ color: colorOverride, running = false, size = 12, vendor }: MobileVendorIconProps) {+export function MobileVendorIcon({+ color: colorOverride,+ running = false,+ size = 12,+ vendor,+ remote = false,+}: MobileVendorIconProps) {const { colors } = useTheme();const reduceMotion = useReduceMotionEnabled();const animate = running && reduceMotion === false;@@ -55,6 +80,9 @@ export function MobileVendorIcon({ color: colorOverride, running = false, size =};}, [animate, opacity]);+ const agentKind: AgentMarkKind = vendor === 'codex' || vendor === 'pi' ? vendor : 'claude-code';+ const mark = <MobileAgentMark agentKind={agentKind} color={color} size={size} />;+ const anchor = REMOTE_SIGNAL_ANCHOR[agentKind];return (<Animated.Viewaccessible@@ -62,11 +90,17 @@ export function MobileVendorIcon({ color: colorOverride, running = false, size =accessibilityRole="image"style={{ alignItems: 'center', height: size, justifyContent: 'center', opacity, width: size }}>- <MobileAgentMark- agentKind={vendor === 'codex' || vendor === 'pi' ? vendor : 'claude-code'}- color={color}- size={size}- />+ {remote ? (+ <RemoteSourceMark+ color={color}+ inset={{ x: (1 - anchor.x) * size, y: anchor.y * size }}+ size={size}+ >+ {mark}+ </RemoteSourceMark>+ ) : (+ mark+ )}</Animated.View>);}diff --git a/apps/mobile/src/session/HomeListVisuals.tsx b/apps/mobile/src/session/HomeListVisuals.tsxindex 2a66ba0cd3..47765766fe 100644--- a/apps/mobile/src/session/HomeListVisuals.tsx+++ b/apps/mobile/src/session/HomeListVisuals.tsx@@ -5,6 +5,7 @@ import { MobileVendorIcon } from '@/components/MobileVendorIcon';import { useReduceMotionEnabled } from '@/hooks/useReduceMotion';import { useTheme, useThemedStyles, type ThemeColors } from '@/theme';import { spacing, typeScale, lineHeight, fontWeight, iconSize, iconStroke } from '@/theme/tokens';+import { sessionAgentRunsOnOtherComputer } from './sessionAgentSwitch';import type { RemoteSessionListItem } from './sessionList';const HOME_SESSION_ROW_HEIGHT = 78;const HOME_SESSION_SINGLE_LINE_ROW_HEIGHT = 60;@@ -50,6 +51,8 @@ export function SessionStatusMark({// Claude 星标 logo 视觉重量偏小,+1px 光学补偿对齐 Codex 标(刻意非阶梯值)。size={isClaudeCodeAgentKind(item.session.agentKind) ? 19 : iconSize.lg}vendor={item.session.agentKind}+ // Agent 在被控电脑之外的另一台电脑运行(远程供应商):与桌面侧栏同一个波纹标识。+ remote={sessionAgentRunsOnOtherComputer(item.session)}/>)}{!archived && showDraftIndicator ? (diff --git a/packages/maker-shared/src/sessionList.ts b/packages/maker-shared/src/sessionList.tsindex 596da66877..1ed68e4fbf 100644--- a/packages/maker-shared/src/sessionList.ts+++ b/packages/maker-shared/src/sessionList.ts@@ -27,6 +27,11 @@ export interface RemoteSessionListSessionLike extends SessionInterruptionState {tags?: import('./taskTags').TaskTag[];_count?: { messages?: number } | null;agentKind: 'cc' | 'codex' | string;+ /**+ * 远程 Agent:非空 = Agent 在同账号另一台电脑上运行(desktop sessions.agent_device_id),+ * 任务仍在被控电脑;null / 缺省 = Agent 就在被控电脑(含旧被控端)。+ */+ agentDeviceId?: string | null;createdAt: string;effort?: string | null;fastMode?: boolean;