Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(mobile): 从插件配置卡进入目标电脑远程桌面
Dash7329f4636eb4
diff --git a/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsx b/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsxindex e232277b64..a09e3ea950 100644--- a/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsx+++ b/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsx@@ -2,14 +2,15 @@import { act, type ReactNode } from 'react';import { createRoot, type Root } from 'react-dom/client';import { afterEach, beforeEach, expect, it, vi } from 'vitest';+import { sharedTaskHostPeer } from '@cindy/device-link';import { AuthorizationMessageCard } from '@/session/AuthorizationMessageCard';import type { NormalizedRemoteMessage } from '@/session/messageNormalize';import { InteractionPanel, PluginSetupMessageContent } from '@/session/InteractionPanel';import { remoteSessionStore, useSessionPendingInteractions } from '@/session/remoteSessionStore';import { clearAllInteractionDrafts, readAskUserDraft, readPlanReviewDraft } from '@/session/interactionDraftStore';-const { resolveInteraction, invoke } = vi.hoisted(() => ({ resolveInteraction: vi.fn(), invoke: vi.fn() }));-vi.mock('expo-router', () => ({ useLocalSearchParams: () => ({ deviceId: 'd1' }) }));+const { resolveInteraction, invoke, push } = vi.hoisted(() => ({ resolveInteraction: vi.fn(), invoke: vi.fn(), push: vi.fn() }));+vi.mock('expo-router', () => ({ useLocalSearchParams: () => ({ deviceId: 'd1' }), useRouter: () => ({ push }) }));vi.mock('@/device-link/DeviceLinkContext', () => ({ useDeviceLink: () => ({ invoke }) }));vi.mock('@/device-link/useMobileMakerTransport', () => ({useMobileMakerTransport: () => ({ resolveInteraction }),@@ -239,6 +240,27 @@ it('persistent setup shows actual steps and errors, retires desktop instructions});+it('opens only the target computer desktop without resolving or authorizing the plugin', async () => {+ const request = { kind: 'plugin_setup', requestId: 'setup-remote', revision: 1,+ ghost: { id: 'google-gmail', name: 'Gmail' }, remoteOauth: true, remoteSecret: true,+ steps: [{ id: 'account', title: 'Connect Gmail', phase: 'pending', action: { id: 'connect', kind: 'oauth_connect' } }] };+ remoteSessionStore.setPendingInteractions('s1', [{ request }]);+ await act(async () => root.render(<Harness />));+ await click('interaction.pluginSetup.remoteDesktop');+ expect(push).toHaveBeenLastCalledWith({ pathname: '/devices/desktop/[deviceId]', params: { deviceId: 'd1', deviceName: 'd1' } });+ expect(resolveInteraction).not.toHaveBeenCalled(); expect(invoke).not.toHaveBeenCalled();+ expect(host.querySelector('input')).toBeNull();+ await act(async () => root.render(<AuthorizationMessageCard message={{ authorization: request } as unknown as NormalizedRemoteMessage} />));+ await click('interaction.pluginSetup.remoteDesktop');+ expect(push).toHaveBeenCalledTimes(2);+ for (const deviceId of [undefined, sharedTaskHostPeer('test', 'd1')]) {+ await act(async () => root.render(<PluginSetupMessageContent request={request} deviceId={deviceId} busy={false} />));+ expect(host.querySelector('[data-testid="interaction.pluginSetup.remoteDesktop"]')).toBeNull();+ }+ await act(async () => root.render(<PluginSetupMessageContent request={{ ...request, terminal: true }} deviceId="d1" busy={false} />));+ expect(host.querySelector('[data-testid="interaction.pluginSetup.remoteDesktop"]')).toBeNull();+});+it('persistent setup cancellation waits for a host terminal update and allows retry after failure', async () => {let receipt!: (value: { accepted: boolean }) => void;const authorization = { kind: 'plugin_setup', requestId: 'setup-1', revision: 1,diff --git a/apps/mobile/src/i18n/locales/en/interaction.json b/apps/mobile/src/i18n/locales/en/interaction.jsonindex 2413f86c31..1883a613a5 100644--- a/apps/mobile/src/i18n/locales/en/interaction.json+++ b/apps/mobile/src/i18n/locales/en/interaction.json@@ -197,7 +197,8 @@"photoNotReadable": "This photo can't be read right now (it may not have finished downloading from iCloud). Try again later."},"pluginSetup": {- "completeOnDesktop": "Complete this setup on the controlled desktop. This card will update automatically.",+ "remoteDesktop": "Control {{device}} to complete setup",+ "completeOnDesktop": "Use Remote Desktop to complete setup on the computer. Login, authorization and credentials stay on that computer; this card updates automatically.","chooseOne": "Choose one setup method","progress": "{{satisfied}}/{{total}} completed","desktopActionHint": "On your computer: {{action}}",diff --git a/apps/mobile/src/i18n/locales/ja/interaction.json b/apps/mobile/src/i18n/locales/ja/interaction.jsonindex 9f943a465c..c99ff7cba7 100644--- a/apps/mobile/src/i18n/locales/ja/interaction.json+++ b/apps/mobile/src/i18n/locales/ja/interaction.json@@ -197,7 +197,8 @@"photoNotReadable": "この写真は現在読み込めません(iCloud からのダウンロードが未完了の可能性があります)。後でもう一度お試しください。"},"pluginSetup": {- "completeOnDesktop": "リモートのパソコンで設定を完了してください。このカードは自動的に更新されます。",+ "remoteDesktop": "{{device}} を遠隔操作して設定",+ "completeOnDesktop": "リモートデスクトップでパソコンを操作して設定できます。ログイン、認証、認証情報の保存はすべてそのパソコンで行われ、このカードは自動的に更新されます。","chooseOne": "設定方法を1つ選択してください","progress": "{{satisfied}}/{{total}} 完了","desktopActionHint": "パソコンで{{action}}",diff --git a/apps/mobile/src/i18n/locales/ko/interaction.json b/apps/mobile/src/i18n/locales/ko/interaction.jsonindex 15a54dbdcd..5a1b800c2d 100644--- a/apps/mobile/src/i18n/locales/ko/interaction.json+++ b/apps/mobile/src/i18n/locales/ko/interaction.json@@ -197,7 +197,8 @@"photoNotReadable": "이 사진은 지금 읽을 수 없습니다(iCloud에서 다운로드가 완료되지 않았을 수 있습니다). 나중에 다시 시도하세요."},"pluginSetup": {- "completeOnDesktop": "원격 컴퓨터에서 설정을 완료하세요. 이 카드는 자동으로 업데이트됩니다.",+ "remoteDesktop": "{{device}} 원격 조작으로 설정 완료",+ "completeOnDesktop": "원격 데스크톱으로 컴퓨터를 조작하여 설정하세요. 로그인, 인증 및 인증 정보 저장은 모두 해당 컴퓨터에서 이루어지며 이 카드는 자동으로 업데이트됩니다.","chooseOne": "설정 방법을 하나 선택하세요","progress": "{{satisfied}}/{{total}} 완료","desktopActionHint": "컴퓨터에서 {{action}}",diff --git a/apps/mobile/src/i18n/locales/zh-CN/interaction.json b/apps/mobile/src/i18n/locales/zh-CN/interaction.jsonindex ab485cbf82..4b9a7c149d 100644--- a/apps/mobile/src/i18n/locales/zh-CN/interaction.json+++ b/apps/mobile/src/i18n/locales/zh-CN/interaction.json@@ -197,7 +197,8 @@"photoNotReadable": "这张照片暂时无法读取(可能还没从 iCloud 下载完成),请稍后重试。"},"pluginSetup": {- "completeOnDesktop": "请在远程电脑完成设置,本卡片会自动更新状态。",+ "remoteDesktop": "遥控 {{device}} 完成设置",+ "completeOnDesktop": "可通过远程桌面操作电脑完成设置。登录、授权和凭据保存均在该电脑进行,本卡片会自动更新状态。","chooseOne": "选择一种配置方式","progress": "{{satisfied}}/{{total}} 已完成","desktopActionHint": "在电脑端{{action}}",diff --git a/apps/mobile/src/i18n/locales/zh-TW/interaction.json b/apps/mobile/src/i18n/locales/zh-TW/interaction.jsonindex 03bd0d811b..9eaccc5182 100644--- a/apps/mobile/src/i18n/locales/zh-TW/interaction.json+++ b/apps/mobile/src/i18n/locales/zh-TW/interaction.json@@ -197,7 +197,8 @@"photoNotReadable": "這張照片暫時無法讀取(可能還沒從 iCloud 下載完成),請稍後重試。"},"pluginSetup": {- "completeOnDesktop": "請在遠端電腦完成設定,本卡片會自動更新狀態。",+ "remoteDesktop": "遙控 {{device}} 完成設定",+ "completeOnDesktop": "可透過遠端桌面操作電腦完成設定。登入、授權和憑據儲存均在該電腦進行,本卡片會自動更新狀態。","chooseOne": "選擇一種配置方式","progress": "{{satisfied}}/{{total}} 已完成","desktopActionHint": "在電腦端{{action}}",diff --git a/apps/mobile/src/session/AuthorizationMessageCard.tsx b/apps/mobile/src/session/AuthorizationMessageCard.tsxindex c61d54d705..20f82a9fa9 100644--- a/apps/mobile/src/session/AuthorizationMessageCard.tsx+++ b/apps/mobile/src/session/AuthorizationMessageCard.tsx@@ -30,7 +30,7 @@ export function AuthorizationMessageCard({ message }: { message: NormalizedRemot.catch(() => setFailed(true)).finally(() => { inFlight.current = false; setBusy(false); });};return <View style={styles.wrapper} testID="authorization.message">- <PluginSetupMessageContent request={request} busy={busy} onCancel={!card.terminal && cancel && deviceId ? cancelRequest : undefined} />+ <PluginSetupMessageContent deviceId={deviceId} request={request} busy={busy} onCancel={!card.terminal && cancel && deviceId ? cancelRequest : undefined} />{failed ? <Text style={styles.error}>{t('devices.companions.actionFailed')}</Text> : null}</View>;}diff --git a/apps/mobile/src/session/InteractionPanel.tsx b/apps/mobile/src/session/InteractionPanel.tsxindex e23d7cafc5..4000401614 100644--- a/apps/mobile/src/session/InteractionPanel.tsx+++ b/apps/mobile/src/session/InteractionPanel.tsx@@ -1,6 +1,7 @@import { usePaneViewport } from '@/platform/AdaptiveWindowContext';import { createContext, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';import { useTranslation } from 'react-i18next';+import { useRouter } from 'expo-router';import { isSharedTaskPeer } from '@cindy/device-link';import { mobilePresentationLocalizer } from '@/i18n/presentationLocalizer';import {@@ -76,7 +77,7 @@ import {buildInteractionTouchLayout,type InteractionTouchLayout,} from '@/session/interactionTouchLayout';-import { remoteSessionStore } from '@/session/remoteSessionStore';+import { remoteSessionStore, useRemoteDeviceIdentity } from '@/session/remoteSessionStore';import type { PendingInteraction } from '@/session/types';import { fontWeight, iconStroke, lineHeight, monoFont, useTheme, useThemedStyles, type ThemeColors } from '@/theme';import { iconSize, radius, spacing, typeScale } from '@/theme/tokens';@@ -592,6 +593,7 @@ function InteractionItem({: null;return (<PluginSetupCard+ deviceId={deviceId}busy={busy}cancel={cancelDecision? {@@ -1498,27 +1500,29 @@ function PlanReviewCard({* 手机端做不了配置动作(Secret 输入与 OAuth 必须留在被控端,见* docs/dev-rules/plugin-security-and-authoring.md §4 与 desktop 的* interactionResolveOrigin),所以这张卡的价值全在「看懂」:哪个插件、卡在哪一步、- * 为什么失败、回电脑端要做什么。动作只有取消。+ * 为什么失败、回电脑端要做什么。可进入目标电脑的远程桌面或取消请求。*/-export function PluginSetupMessageContent({ request, busy, onCancel }: {- request: PendingInteraction['request']; busy: boolean; onCancel?: () => void;+export function PluginSetupMessageContent({ request, busy, onCancel, deviceId }: {+ request: PendingInteraction['request']; busy: boolean; onCancel?: () => void; deviceId?: string;}) {const { width } = useWindowDimensions();const { t } = useTranslation();return <CompanionInteractionContext.Provider value>- <PluginSetupCard item={{ request }} requestId={typeof request.requestId === 'string' ? request.requestId : null}+ <PluginSetupCard deviceId={deviceId} item={{ request }} requestId={typeof request.requestId === 'string' ? request.requestId : null}busy={busy} touchLayout={buildInteractionTouchLayout({ screenWidth: width, actionCount: 1 })}cancel={onCancel ? { label: t('interaction.panel.cancelRequest'), accessibilityLabel: t('interaction.panel.cancelRequestAccessibility'), onPress: onCancel } : null} /></CompanionInteractionContext.Provider>;}function PluginSetupCard({+ deviceId,busy,cancel,item,requestId,touchLayout,}: {+ deviceId?: string;busy: boolean;cancel: { accessibilityLabel: string; label: string; onPress(): void } | null;item: PendingInteraction;@@ -1576,6 +1580,9 @@ function PluginSetupCard({{presentation.terminal ? null : (<Text style={styles.pluginSetupFootnote}>{t('interaction.pluginSetup.completeOnDesktop')}</Text>)}+ {!presentation.terminal && deviceId && !isSharedTaskPeer(deviceId) ? (+ <PluginSetupRemoteDesktopButton deviceId={deviceId} busy={busy} />+ ) : null}{cancel ? (<View style={actionsStyle(styles, touchLayout)}><ResolveButton@@ -1594,6 +1601,21 @@ function PluginSetupCard({);}+/** Navigation only: authorization and credentials stay in the computer's own UI. */+function PluginSetupRemoteDesktopButton({ deviceId, busy }: { deviceId: string; busy: boolean }) {+ const router = useRouter();+ const devices = useRemoteDeviceIdentity();+ const styles = useInteractionStyles();+ const { t } = useTranslation();+ const deviceName = devices.find(device => device.deviceId === deviceId)?.name || deviceId;+ const label = t('interaction.pluginSetup.remoteDesktop', { device: deviceName });+ return <InteractionTouchButton accessibilityLabel={label} disabled={busy}+ style={styles.primaryButton} testID="interaction.pluginSetup.remoteDesktop"+ onPress={() => router.push({ pathname: '/devices/desktop/[deviceId]', params: { deviceId, deviceName } })}>+ <Text style={styles.primaryText}>{label}</Text>+ </InteractionTouchButton>;+}+/** 运行中的步骤:与桌面同语义,用 Heart Orange 表示「正在进行」。 */const PLUGIN_SETUP_RUNNING_PHASES: ReadonlySet<RemotePluginSetupPhase> = new Set(['action_running',diff --git a/docs/remote-plugin-oauth.md b/docs/remote-plugin-oauth.mdindex 04a150caa3..d636e13d8b 100644--- a/docs/remote-plugin-oauth.md+++ b/docs/remote-plugin-oauth.md@@ -179,8 +179,9 @@ gh-cli、oidc-token 或账号 vault 写入;临时 Node Secret 卡只允许其保持上游独立 RPC 行为,不自动弹卡或结束后台进程。已停止的调用不能迟到启用新授权。- 两端 Desktop 必须支持 v3。旧版仍可使用原本的远控及执行设备本地设置;新授权动作不走旧通道/明文降级,不会替用户清空已有凭据。-- Mobile 当前只可查看/取消既有卡片,未实现本机回调与保密输入;在连接该设备的新版- Desktop 完成。网站 Cookie/全量 vault 同步不在范围。+- Mobile 是目标电脑的遥控器:配置卡保留查看/取消,并提供进入目标电脑远程桌面的入口。+ 用户在电脑端 UI 完成输入、浏览器登录和授权;回调、交换及凭据保存全部在电脑执行。+ 手机不实现插件凭据表单、OAuth 回调或授权码转发。网站 Cookie/全量 vault 同步不在范围。- Auth、relay、CIS、Model Access 不需要本功能的新服务接口或部署;双方客户端需升级。### 各端范围与后续门禁@@ -188,7 +189,7 @@ gh-cli、oidc-token 或账号 vault 写入;临时 Node Secret 卡只允许其| 场景 | 本 PR 的处理 || --- | --- || Desktop → Desktop Device Link | 已适配:新私有通道经同账号授权、卡片绑定及签名握手;原有 invoke/push 规则不放宽。 |-| Mobile → Desktop Device Link | 保留既有只读配置状态、取消和完成状态。手机侧保密输入、设备码操作与浏览器回调尚未适配,必须在 PR 链接专门的跟踪 issue 后才能满足上游延期要求,不能把这三项写成已支持。 |+| Mobile → Desktop Device Link | 配置卡提供目标电脑远程桌面入口,保留状态与取消;手机仅通过既有远程画面与输入控制电脑。无手机授权桥接,不依赖新的 Google 移动客户端或手机回调;共享任务访客及终态卡片不提供远控入口。 || SSH 工作区 | 本 PR 不新增 SSH 凭据转发或远端插件安装。SSH 的 Agent/workdir 仍经 maker-remote-ssh、cc-manager 与 remote-file-service;插件由提供 MCP 的 Desktop Host 管理,授权仅改变该 Host 的连接。SSH 主机没有本桥的 Desktop 身份、OS 密钥存储和 Device Link peer,不能把它当作另一个被控 Desktop,也不向其 HOME/workdir 复制本机凭据。原有远端文件、网络与 Forge 限制保留。 |故障范围:单卡片取消/超时只收口该事务;单 peer 失效只取消该 peer 的事务;账号退出