Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): show desktop-only confirmation status remotely (#3250)
Tsai Yuan7641b4c8a7a5
diff --git a/apps/desktop/src/main/__tests__/deviceLinkDispatch.test.ts b/apps/desktop/src/main/__tests__/deviceLinkDispatch.test.tsindex 1576a2b786..384b066b87 100644--- a/apps/desktop/src/main/__tests__/deviceLinkDispatch.test.ts+++ b/apps/desktop/src/main/__tests__/deviceLinkDispatch.test.ts@@ -43,6 +43,7 @@ import {isDeviceLinkInvoke,} from '../device-link/invoke-context';import * as subscriptions from '../device-link/subscriptions';+import { createDesktopOnlyConfirmationRequestId } from '../cindy-brain/desktopOnlyConfirmationProjection';beforeEach(() => {remoteControlEnabled = true;@@ -2448,7 +2449,7 @@ describe('被控端订阅 registry + topic 转发', () => {'issue_confirm','rename_sessions_confirm','ghost_grant_confirm',- ])('device-link does not forward Desktop-only %s live pushes', (kind) => {+ ])('device-link forwards a redacted Desktop-only %s live status', (kind) => {remoteControlEnabled = true;const { client, calls, feed } = makeFakeClient();wireInboundDispatch(client);@@ -2464,7 +2465,46 @@ describe('被控端订阅 registry + topic 转发', () => {},});- expect(calls.push).toEqual([]);+ expect(calls.push).toHaveLength(1);+ expect(calls.push[0]).toMatchObject({+ dst: 'ctrl-a',+ channel: MAKER_PUSH.INTERACTION_REQUEST,+ payload: {+ sessionId: 's1',+ request: { kind, requestId: expect.stringMatching(/^desktop-confirm-/) },+ },+ });+ expect(JSON.stringify(calls.push[0].payload)).not.toContain('private');+ expect(JSON.stringify(calls.push[0].payload)).not.toContain(`${kind}-1`);+ });++ it('device-link dismisses a Desktop-only status with its opaque request id', () => {+ remoteControlEnabled = true;+ const { client, calls, feed } = makeFakeClient();+ wireInboundDispatch(client);+ feed(subFrame('ctrl-a', SUB, ['session:s1']));++ const sourceRequestId = createDesktopOnlyConfirmationRequestId();+ tapWindowBroadcast(MAKER_PUSH.INTERACTION_REQUEST, {+ sessionId: 's1',+ request: { kind: 'issue_confirm', requestId: sourceRequestId, draft: { title: 'private' } },+ });+ const remoteRequestId = (calls.push[0].payload as {+ request: { requestId: string };+ }).request.requestId;++ tapWindowBroadcast(MAKER_PUSH.INTERACTION_DISMISSED, {+ sessionId: 's1',+ requestId: sourceRequestId,+ reason: 'resolved',+ });++ expect(calls.push[1]).toMatchObject({+ dst: 'ctrl-a',+ channel: MAKER_PUSH.INTERACTION_DISMISSED,+ payload: { sessionId: 's1', requestId: remoteRequestId, reason: 'resolved' },+ });+ expect(JSON.stringify(calls.push[1].payload)).not.toContain(sourceRequestId);});it('explicit unsubscribe removes the final remembered topic and stops the tap', () => {diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostGrantConfirmBridge.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostGrantConfirmBridge.test.tsindex 0a07a6b3de..09c4f58343 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostGrantConfirmBridge.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostGrantConfirmBridge.test.ts@@ -55,7 +55,9 @@ describe('GhostGrantConfirmBridge', () => {items: PAYLOAD.items,},});- expect((payload as { request: { requestId: string } }).request.requestId).toBeTruthy();+ expect((payload as { request: { requestId: string } }).request.requestId).toMatch(+ /^desktop-confirm-source-/,+ );expect(bridge.pendingSnapshots('other-session')).toEqual([]);expect(bridge.pendingSnapshots('sess-1')).toEqual([{ sessionId: 'sess-1', request: (payload as { request: unknown }).request },diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostSetupInteractionBridge.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostSetupInteractionBridge.test.tsindex 02f256a1e5..a21cc8abbb 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostSetupInteractionBridge.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostSetupInteractionBridge.test.ts@@ -1,11 +1,14 @@import { describe, expect, it, vi } from 'vitest';import { MAKER_PUSH } from '../../maker-ipc/channels';+import { createDesktopOnlyConfirmationRequestId } from '../desktopOnlyConfirmationProjection';import {+ projectInteractionDismissedForRemote,GhostSetupInteractionBridge,parseGhostSetupInlineSubmit,parseGhostSetupInlineSubmitRequest,parseGhostSetupInteractionCommand,+ projectInteractionRequestForRemote,projectPendingInteractionsForRemote,sanitizeGhostSetupRequestForRemote,sanitizeGhostSetupSnapshotForRemote,@@ -392,17 +395,97 @@ describe('sanitizeGhostSetupSnapshotForRemote', () => {const remote = projectPendingInteractionsForRemote(pending, true);expect(remote).not.toBe(pending);- expect(remote).toHaveLength(3);+ expect(remote).toHaveLength(6);expect(JSON.stringify(remote[0])).not.toContain('desktop-only.example');expect(remote[1].request).toBe(permission.request);expect(remote[2].request).toBe(future.request);expect(JSON.stringify(remote)).not.toContain('private');expect(JSON.stringify(remote)).not.toContain('/Users/me/private.png');+ for (const entry of remote.slice(3)) {+ expect(entry.request).toEqual({+ kind: expect.any(String),+ requestId: expect.stringMatching(/^desktop-confirm-/),+ });+ expect(entry.request.requestId).not.toMatch(/issue-1|rename-1|grant-1/);+ }expect(localSetup.request.steps[0].action.form.fields[0].externalLink).toEqual({url: 'https://desktop-only.example/keys',});expect(local).toEqual(pending);});++ it('maps a desktop-only confirmation dismissal to its opaque remote request id', () => {+ const sourceRequest = {+ kind: 'issue_confirm',+ requestId: createDesktopOnlyConfirmationRequestId(),+ draft: { title: 'private' },+ };+ const projected = projectInteractionRequestForRemote(sourceRequest)!;+ const dismissed = projectInteractionDismissedForRemote({+ sessionId: 'session-1',+ requestId: sourceRequest.requestId,+ reason: 'resolved',+ });++ expect(dismissed).toEqual({+ sessionId: 'session-1',+ requestId: projected.requestId,+ reason: 'resolved',+ });+ expect(JSON.stringify(dismissed)).not.toContain(sourceRequest.requestId);+ });++ it('maps a dismissal when the desktop-only confirmation predates Device Link activation', () => {+ const requestId = createDesktopOnlyConfirmationRequestId();++ const dismissed = projectInteractionDismissedForRemote({+ sessionId: 'session-1',+ requestId,+ reason: 'resolved',+ });++ expect(dismissed).toMatchObject({+ sessionId: 'session-1',+ requestId: expect.stringMatching(/^desktop-confirm-/),+ reason: 'resolved',+ });+ expect(JSON.stringify(dismissed)).not.toContain(requestId);+ });++ it('keeps the opaque dismissal id stable after the Host confirmation timeout', () => {+ vi.useFakeTimers();+ try {+ const requestId = createDesktopOnlyConfirmationRequestId();+ const projected = projectInteractionRequestForRemote({+ kind: 'issue_confirm',+ requestId,+ })!;+ vi.advanceTimersByTime(9 * 60 * 1000);++ expect(projectInteractionDismissedForRemote({ requestId })).toEqual({+ requestId: projected.requestId,+ });+ } finally {+ vi.useRealTimers();+ }+ });++ it('projects more than 128 concurrent confirmations without evicting source ids', () => {+ const sourceRequestIds = Array.from(+ { length: 256 },+ () => createDesktopOnlyConfirmationRequestId(),+ );++ for (const requestId of sourceRequestIds) {+ const projected = projectInteractionRequestForRemote({+ kind: 'ghost_grant_confirm',+ requestId,+ })!;+ const dismissed = projectInteractionDismissedForRemote({ requestId });+ expect(dismissed).toEqual({ requestId: projected.requestId });+ expect(JSON.stringify(dismissed)).not.toContain(requestId);+ }+ });});describe('parseGhostSetupInteractionCommand', () => {diff --git a/apps/desktop/src/main/cindy-brain/desktopOnlyConfirmationProjection.ts b/apps/desktop/src/main/cindy-brain/desktopOnlyConfirmationProjection.tsnew file mode 100644index 0000000000..28863c9d52--- /dev/null+++ b/apps/desktop/src/main/cindy-brain/desktopOnlyConfirmationProjection.ts@@ -0,0 +1,21 @@+import { createHmac, randomBytes, randomUUID } from 'node:crypto';++const DESKTOP_ONLY_CONFIRMATION_SOURCE_PREFIX = 'desktop-confirm-source-';+const desktopOnlyConfirmationProjectionKey = randomBytes(32);++/** Creates a Host-only capability id that can be recognized without retaining request state. */+export function createDesktopOnlyConfirmationRequestId(): string {+ return `${DESKTOP_ONLY_CONFIRMATION_SOURCE_PREFIX}${randomUUID()}`;+}++export function isDesktopOnlyConfirmationRequestId(requestId: string): boolean {+ return requestId.startsWith(DESKTOP_ONLY_CONFIRMATION_SOURCE_PREFIX);+}++/** Produces the stable opaque id exposed to Device Link for request/dismissal correlation. */+export function projectDesktopOnlyConfirmationRequestId(requestId: string): string {+ const digest = createHmac('sha256', desktopOnlyConfirmationProjectionKey)+ .update(requestId)+ .digest('hex');+ return `desktop-confirm-${digest}`;+}diff --git a/apps/desktop/src/main/cindy-brain/ghostGrantConfirmBridge.ts b/apps/desktop/src/main/cindy-brain/ghostGrantConfirmBridge.tsindex 29e3ef5838..7f922ab182 100644--- a/apps/desktop/src/main/cindy-brain/ghostGrantConfirmBridge.ts+++ b/apps/desktop/src/main/cindy-brain/ghostGrantConfirmBridge.ts@@ -19,10 +19,9 @@* 本模块保持 electron-free(broadcast 由 register.ts 注入),单测直接 new。*/-import { randomUUID } from 'node:crypto';-import { MAKER_PUSH } from '../maker-ipc/channels';import { HOST_CONFIRM_TIMEOUT_MS } from '../maker-ipc/hostConfirmTiming.js';+import { createDesktopOnlyConfirmationRequestId } from './desktopOnlyConfirmationProjection.js';/*** 过户通道:attachments = 媒体文件进总仓;dir = 上行读票据;save_dir = 下行@@ -101,7 +100,7 @@ export class GhostGrantConfirmBridge {sessionId: string,payload: GhostGrantConfirmPayload,): Promise<GhostGrantConfirmDecision> {- const requestId = randomUUID();+ const requestId = createDesktopOnlyConfirmationRequestId();const request: GhostGrantConfirmInteractionSnapshot = {kind: 'ghost_grant_confirm',requestId,diff --git a/apps/desktop/src/main/cindy-brain/ghostSetupInteractionBridge.ts b/apps/desktop/src/main/cindy-brain/ghostSetupInteractionBridge.tsindex 8b38014c3e..0075d93042 100644--- a/apps/desktop/src/main/cindy-brain/ghostSetupInteractionBridge.ts+++ b/apps/desktop/src/main/cindy-brain/ghostSetupInteractionBridge.ts@@ -11,8 +11,13 @@ import type {GhostSetupErrorCode,GhostSetupStepPhase,} from '../../shared/ghost.js';+import { randomUUID } from 'node:crypto';import { GHOST_SECRET_VALUE_MAX_CHARS, isGhostSetupErrorCode } from '../../shared/ghost.js';import { MAKER_PUSH } from '../maker-ipc/channels.js';+import {+ isDesktopOnlyConfirmationRequestId,+ projectDesktopOnlyConfirmationRequestId,+} from './desktopOnlyConfirmationProjection.js';export interface GhostSetupInteractionStep {id: string;@@ -367,6 +372,19 @@ function isDesktopOnlyConfirmationRequest(request: unknown): boolean {);}+// Device Link must not receive a host confirmation's real request id: it is the+// capability checked by the trusted Desktop resolver. A process-keyed HMAC+// keeps request/dismissal correlation stable without retaining source ids.++function projectDesktopOnlyConfirmation(request: Record<string, unknown>): Record<string, unknown> | null {+ const requestId = request.requestId;+ if (typeof requestId !== 'string' || requestId.length === 0) return null;+ // Preserve only the known kind so mobile can render its existing read-only+ // guidance. Drafts, file paths, previews, identities, and the real id stay+ // on the controlled Desktop.+ return { kind: request.kind, requestId: projectDesktopOnlyConfirmationRequestId(requestId) };+}+/*** Host-owned confirmations stay on the trusted Desktop. This keeps their* request ids and local payload details (for example file paths and previews)@@ -374,10 +392,24 @@ function isDesktopOnlyConfirmationRequest(request: unknown): boolean {* projection used for remote status/cancellation.*/export function projectInteractionRequestForRemote<T>(request: T): T | null {- if (isDesktopOnlyConfirmationRequest(request)) return null;+ if (isDesktopOnlyConfirmationRequest(request)) {+ return projectDesktopOnlyConfirmation(request as Record<string, unknown>) as T | null;+ }return sanitizeGhostSetupRequestForRemote(request);}+/** Rewrites a Host-only dismissal to the same opaque id exposed by its request projection. */+export function projectInteractionDismissedForRemote<T>(payload: T): T {+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return payload;+ const requestId = (payload as { requestId?: unknown }).requestId;+ if (typeof requestId !== 'string') return payload;+ if (!isDesktopOnlyConfirmationRequestId(requestId)) return payload;+ return {+ ...(payload as Record<string, unknown>),+ requestId: projectDesktopOnlyConfirmationRequestId(requestId),+ } as T;+}+export function projectPendingInteractionsForRemote<T extends { request: unknown }>(pending: T[],remote: boolean,diff --git a/apps/desktop/src/main/device-link/dispatch.ts b/apps/desktop/src/main/device-link/dispatch.tsindex 20cb429dc5..667de15226 100644--- a/apps/desktop/src/main/device-link/dispatch.ts+++ b/apps/desktop/src/main/device-link/dispatch.ts@@ -83,7 +83,10 @@ import * as subscriptions from './subscriptions';import { LEGACY_TOPIC, type ActiveController } from './subscriptions';import { MAKER_PUSH } from '../maker-ipc/channels.js';import { RECOVERY_CHECKPOINT_MARKER } from '../maker-ipc/recoveryCoordinator.js';-import { projectInteractionRequestForRemote } from '../cindy-brain/ghostSetupInteractionBridge.js';+import {+ projectInteractionDismissedForRemote,+ projectInteractionRequestForRemote,+} from '../cindy-brain/ghostSetupInteractionBridge.js';import {remoteWorkingDirRejectionToIpcError,type RemoteWorkingDirCheckResult,@@ -1278,6 +1281,9 @@ function forwardPush(channel: string, payload: unknown, ownerStamp?: PushOwnerStif (request === null) return;remotePayload = { ...payload, request };}+ if (channel === MAKER_PUSH.INTERACTION_DISMISSED) {+ remotePayload = projectInteractionDismissedForRemote(remotePayload);+ }const dsts = subscriptions.getControllersForTopic(topic);// The active registry describes peer topic intent, not whether this host can// currently write to the relay. During host-side reconnects sendPush is adiff --git a/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts b/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.tsindex 36a7e343df..0f6a09e351 100644--- a/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts+++ b/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts@@ -57,7 +57,9 @@ describe('IssueConfirmBridge', () => {githubUserIdentity: GITHUB_IDENTITY,},});- expect((payload as { request: { requestId: string } }).request.requestId).toBeTruthy();+ expect((payload as { request: { requestId: string } }).request.requestId).toMatch(+ /^desktop-confirm-source-/,+ );expect(bridge.pendingSnapshots('other-session')).toEqual([]);expect(bridge.pendingSnapshots('sess-1')).toEqual([{ sessionId: 'sess-1', request: (payload as { request: unknown }).request },diff --git a/apps/desktop/src/main/github-issue/issueConfirmBridge.ts b/apps/desktop/src/main/github-issue/issueConfirmBridge.tsindex 231d12fcd3..846ad12599 100644--- a/apps/desktop/src/main/github-issue/issueConfirmBridge.ts+++ b/apps/desktop/src/main/github-issue/issueConfirmBridge.ts@@ -17,11 +17,10 @@* 本模块保持 electron-free(broadcast 由调用方注入),单测直接 new。*/-import { randomUUID } from 'node:crypto';-import type { CindyRegion } from '@cindy/maker-shared/brand-identity';import { normalizeIssuePublicName } from '../../shared/issuePublicName.js';+import { createDesktopOnlyConfirmationRequestId } from '../cindy-brain/desktopOnlyConfirmationProjection.js';import { MAKER_PUSH } from '../maker-ipc/channels';import { HOST_CONFIRM_TIMEOUT_MS } from '../maker-ipc/hostConfirmTiming.js';@@ -120,7 +119,7 @@ export class IssueConfirmBridge {submissionChoices: IssueSubmissionChoices,suggestedPublicName?: string,): Promise<IssueConfirmDecision> {- const requestId = randomUUID();+ const requestId = createDesktopOnlyConfirmationRequestId();const request: IssueConfirmInteractionSnapshot = {kind: 'issue_confirm',requestId,diff --git a/apps/desktop/src/main/session-title-rename/__tests__/renameSessionsConfirmBridge.test.ts b/apps/desktop/src/main/session-title-rename/__tests__/renameSessionsConfirmBridge.test.tsindex 115e51bcb6..f71a991e1b 100644--- a/apps/desktop/src/main/session-title-rename/__tests__/renameSessionsConfirmBridge.test.ts+++ b/apps/desktop/src/main/session-title-rename/__tests__/renameSessionsConfirmBridge.test.ts@@ -45,7 +45,9 @@ describe('RenameSessionsConfirmBridge', () => {sessionId: 'sess-1',request: { kind: 'rename_sessions_confirm', changes: CHANGES },});- expect((payload as { request: { requestId: string } }).request.requestId).toBeTruthy();+ expect((payload as { request: { requestId: string } }).request.requestId).toMatch(+ /^desktop-confirm-source-/,+ );expect(bridge.pendingSnapshots('other-session')).toEqual([]);expect(bridge.pendingSnapshots('sess-1')).toEqual([{ sessionId: 'sess-1', request: (payload as { request: unknown }).request },diff --git a/apps/desktop/src/main/session-title-rename/renameSessionsConfirmBridge.ts b/apps/desktop/src/main/session-title-rename/renameSessionsConfirmBridge.tsindex 03a93f8e81..b4e658238b 100644--- a/apps/desktop/src/main/session-title-rename/renameSessionsConfirmBridge.ts+++ b/apps/desktop/src/main/session-title-rename/renameSessionsConfirmBridge.ts@@ -7,8 +7,7 @@* 在 confirmed 后继续。*/-import { randomUUID } from 'node:crypto';-+import { createDesktopOnlyConfirmationRequestId } from '../cindy-brain/desktopOnlyConfirmationProjection.js';import { MAKER_PUSH } from '../maker-ipc/channels';import { HOST_CONFIRM_TIMEOUT_MS } from '../maker-ipc/hostConfirmTiming.js';@@ -59,7 +58,7 @@ export class RenameSessionsConfirmBridge {sessionId: string,changes: RenameSessionsConfirmItem[],): Promise<RenameSessionsConfirmDecision> {- const requestId = randomUUID();+ const requestId = createDesktopOnlyConfirmationRequestId();const request: RenameSessionsConfirmInteractionSnapshot = {kind: 'rename_sessions_confirm',requestId,diff --git a/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts b/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.tsindex 67a5273ac2..9cd2c9d087 100644--- a/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts+++ b/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts@@ -105,6 +105,9 @@ function makeFakeHost(deviceId: string) {arr.push({ request, persistId });pending.set(sessionId, arr);},+ clearPending(sessionId: string): void {+ pending.delete(sessionId);+ },registerPush(cb: (p: RemotePush) => void): () => void {pushCb = (push) => cb({ ...push, ownerStamp: push.ownerStamp ?? TEST_OWNER_STAMP });return () => {@@ -319,71 +322,123 @@ describe('device-link 远程交互往返 — plan_review', () => {});});-describe('device-link 远程交互往返 — issue_confirm draft', () => {- const issueRequest = {- kind: 'issue_confirm',- requestId: 'issue-draft-1',- draft: { title: '原始标题', body: '原始正文', type: 'bug' },- env: {- appVersion: '0.1.18',- platform: 'darwin',- arch: 'arm64',- osVersion: '15.0',+describe('device-link Desktop-only 确认 — 控制端只读投影', () => {+ it('只读提示展示期间保留 ChatInput,不把控制端锁死', () => {+ const src = readFileSync(+ resolve(__dirname, '..', 'features', 'cc-agent', 'CCAgentSessionView.tsx'),+ 'utf8',+ );+ const branchStart = src.indexOf('/* 互斥:控制端能终结的 pending interaction');+ const chatInput = src.indexOf('<ChatInput', branchStart);+ expect(branchStart).toBeGreaterThan(-1);+ expect(chatInput).toBeGreaterThan(branchStart);+ expect(src.slice(branchStart, chatInput)).not.toContain(+ 'pendingRemoteDesktopConfirmation',+ );+ });++ it.each(['issue_confirm', 'rename_sessions_confirm', 'ghost_grant_confirm'] as const)(+ '%s live push 只建立不可操作状态,dismissal 后清除',+ async (kind) => {+ const s = openRemoteSession();+ const requestId = `opaque-${kind}`;++ host.hostInteraction(s, {+ kind,+ requestId,+ });+ await flush();++ const state = makerChatStore.getSnapshot(s);+ expect(state.pendingRemoteDesktopConfirmation).toEqual({ kind, requestId });+ expect(state.pendingIssueConfirm).toBeNull();+ expect(state.pendingRenameSessionsConfirm).toBeNull();+ expect(state.pendingGhostGrantConfirm).toBeNull();+ expect(host.resolved).toHaveLength(0);+ expect(local.localResolveInteraction).not.toHaveBeenCalled();++ host.hostDismiss(s, requestId, 'resolved');+ await flush();+ expect(makerChatStore.getSnapshot(s).pendingRemoteDesktopConfirmation).toBeNull();},- submissionIdentity: { kind: 'platform', login: 'cindy-issue' },- suggestedPublicName: '当前昵称',- };+ );- it('逐键保存不通知 makerChatStore 全局订阅,响应后清除草稿', async () => {+ it('远程来源即使误带完整 payload 也不能获得可操作确认能力', async () => {const s = openRemoteSession();- host.hostInteraction(s, issueRequest);- await flush();- expect(makerChatStore.getSnapshot(s).pendingIssueConfirm?.requestId).toBe('issue-draft-1');- expect(makerChatStore.getSnapshot(s).pendingIssueConfirm).toMatchObject({- submissionIdentity: { kind: 'platform', login: 'cindy-issue' },- suggestedPublicName: '当前昵称',+ host.hostInteraction(s, {+ kind: 'issue_confirm',+ requestId: 'opaque-full-payload',+ draft: { title: '敏感标题', body: '敏感正文', type: 'bug' },+ env: { appVersion: '1', platform: 'darwin', arch: 'arm64', osVersion: '1' },+ submissionIdentity: { kind: 'platform', login: 'private' },});+ await flush();- const globalListener = vi.fn();- const unsubscribe = makerChatStore.subscribeAll(globalListener);- saveIssueConfirmDraft(s, 'issue-draft-1', {- title: '编辑后的标题',- body: '编辑后的正文',- type: 'feature',- publicName: '匿名',+ expect(makerChatStore.getSnapshot(s).pendingRemoteDesktopConfirmation).toEqual({+ kind: 'issue_confirm',+ requestId: 'opaque-full-payload',});+ expect(makerChatStore.getSnapshot(s).pendingIssueConfirm).toBeNull();+ });- expect(getIssueConfirmDraft(s, 'issue-draft-1')).toMatchObject({- title: '编辑后的标题',- body: '编辑后的正文',- type: 'feature',- publicName: '匿名',+ it('并发确认按到达顺序排队,关闭任一项都不会丢失其余确认', async () => {+ const s = openRemoteSession();+ host.hostInteraction(s, { kind: 'issue_confirm', requestId: 'opaque-a' });+ host.hostInteraction(s, { kind: 'ghost_grant_confirm', requestId: 'opaque-b' });+ await flush();++ expect(makerChatStore.getSnapshot(s).pendingRemoteDesktopConfirmation).toEqual({+ kind: 'issue_confirm',+ requestId: 'opaque-a',});- expect(globalListener).not.toHaveBeenCalled();- makerChatStore.respondToIssueConfirm(s, { confirmed: false });+ host.hostDismiss(s, 'opaque-b', 'resolved');await flush();- expect(getIssueConfirmDraft(s, 'issue-draft-1')).toBeUndefined();- expect(makerChatStore.getSnapshot(s).pendingIssueConfirm).toBeNull();- unsubscribe();- makerChatStore.purgeSession(s);+ expect(makerChatStore.getSnapshot(s).pendingRemoteDesktopConfirmation?.requestId).toBe(+ 'opaque-a',+ );++ host.hostInteraction(s, { kind: 'ghost_grant_confirm', requestId: 'opaque-b' });+ await flush();+ host.hostDismiss(s, 'opaque-a', 'resolved');+ await flush();+ expect(makerChatStore.getSnapshot(s).pendingRemoteDesktopConfirmation).toEqual({+ kind: 'ghost_grant_confirm',+ requestId: 'opaque-b',+ });});- it('interaction dismissed 时清除对应草稿', async () => {+ it('重连快照可重建多个只读状态,后续权威快照将其逐项收口', async () => {const s = openRemoteSession();- host.hostInteraction(s, issueRequest);- await flush();- saveIssueConfirmDraft(s, 'issue-draft-1', {- title: '未提交标题',- body: '未提交正文',- type: 'bug',+ host.seedPending(s, {+ kind: 'issue_confirm',+ requestId: 'opaque-snapshot-a',+ });+ host.seedPending(s, {+ kind: 'rename_sessions_confirm',+ requestId: 'opaque-snapshot-b',});- host.hostDismiss(s, 'issue-draft-1', 'timeout');- await flush();- expect(getIssueConfirmDraft(s, 'issue-draft-1')).toBeUndefined();- expect(makerChatStore.getSnapshot(s).pendingIssueConfirm).toBeNull();- makerChatStore.purgeSession(s);+ await makerChatStore.reconcilePendingInteractions(s);+ expect(makerChatStore.getSnapshot(s).pendingRemoteDesktopConfirmation).toEqual({+ kind: 'issue_confirm',+ requestId: 'opaque-snapshot-a',+ });++ host.clearPending(s);+ host.seedPending(s, {+ kind: 'rename_sessions_confirm',+ requestId: 'opaque-snapshot-b',+ });+ await makerChatStore.reconcilePendingInteractions(s);+ expect(makerChatStore.getSnapshot(s).pendingRemoteDesktopConfirmation).toEqual({+ kind: 'rename_sessions_confirm',+ requestId: 'opaque-snapshot-b',+ });++ host.clearPending(s);+ await makerChatStore.reconcilePendingInteractions(s);+ expect(makerChatStore.getSnapshot(s).pendingRemoteDesktopConfirmation).toBeNull();});});diff --git a/apps/desktop/src/renderer/__tests__/makerQueueState.test.ts b/apps/desktop/src/renderer/__tests__/makerQueueState.test.tsindex 4b29857da6..e79bf30602 100644--- a/apps/desktop/src/renderer/__tests__/makerQueueState.test.ts+++ b/apps/desktop/src/renderer/__tests__/makerQueueState.test.ts@@ -121,6 +121,9 @@ const state = (overrides: Partial<SessionChatState> = {}): SessionChatState => (turnStoppedByUser: false,lastAgentMeta: null,...overrides,+ pendingRemoteDesktopConfirmation: overrides.pendingRemoteDesktopConfirmation ?? null,+ pendingRemoteDesktopConfirmationQueue:+ overrides.pendingRemoteDesktopConfirmationQueue ?? [],});describe('makerQueueState', () => {diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex 27e34155bc..72f67ca028 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -66,6 +66,7 @@ import { PermissionPrompt } from '@/components/new-chat/PermissionPrompt';import { IssueConfirmCard } from './IssueConfirmCard';import { RenameSessionsConfirmCard } from './RenameSessionsConfirmCard';import { GhostGrantConfirmCard } from './GhostGrantConfirmCard';+import { RemoteDesktopConfirmationNotice } from './RemoteDesktopConfirmationNotice';import { AskUserQuestionPrompt } from '@/components/new-chat/AskUserQuestionPrompt';import { PluginSetupPrompt } from '@/components/new-chat/PluginSetupPrompt';import { PlanViewerCard } from '@/components/new-chat/PlanViewerCard';@@ -1560,6 +1561,7 @@ export function CCAgentSessionView({pendingRenameSessionsConfirm,respondToRenameSessionsConfirm,pendingGhostGrantConfirm,+ pendingRemoteDesktopConfirmation,respondToGhostGrantConfirm,lastExpandedPlanViewerState,updatePlanContent,@@ -4015,7 +4017,8 @@ export function CCAgentSessionView({pendingPluginSetup ||pendingIssueConfirm ||pendingRenameSessionsConfirm ||- pendingGhostGrantConfirm,+ pendingGhostGrantConfirm ||+ pendingRemoteDesktopConfirmation,);useEffect(() => {if (shareSelectionActive && shareSelectionBlocked) shareSelectionStore.exit();@@ -4374,7 +4377,8 @@ export function CCAgentSessionView({pendingPluginSetup ||pendingIssueConfirm ||pendingRenameSessionsConfirm ||- pendingGhostGrantConfirm+ pendingGhostGrantConfirm ||+ pendingRemoteDesktopConfirmation)}className="mb-0"@@ -4563,7 +4567,8 @@ export function CCAgentSessionView({pendingPluginSetup ||pendingIssueConfirm ||pendingRenameSessionsConfirm ||- pendingGhostGrantConfirm+ pendingGhostGrantConfirm ||+ pendingRemoteDesktopConfirmation)}placeholder={@@ -4630,13 +4635,17 @@ export function CCAgentSessionView({pending={pendingGhostGrantConfirm}onRespond={respondToGhostGrantConfirm}/>+ ) : pendingRemoteDesktopConfirmation ? (+ <RemoteDesktopConfirmationNotice+ key={pendingRemoteDesktopConfirmation.requestId}+ />) : null}</InteractionPromptHost>{/* 会话内 /goal 进行中状态条(composer 上方);无 goal 时返回 null 不占位。 */}<GoalIndicator sessionId={sessionId} />- {/* 互斥:有任意 pending interaction 时,下方 takeover/overlay/ChatInput- 全部静默 — 跟改造前 ternary 链 (Plan ? : Perm ? : Ask ? :- Takeover ? : ChatInput) 的语义一致。+ {/* 互斥:控制端能终结的 pending interaction 会接管 composer;+ Desktop-only 只读确认只能提示等待,必须保留 ChatInput,避免控制端+ 既处理不了确认又无法继续发送或排队消息。优先级 (高 → 低):1. attached (远程接管中) → TakeoverMask (90px)2. worktreePreparing → WorktreeCreatingOverlay (90px, 视觉同款)diff --git a/apps/desktop/src/renderer/features/cc-agent/RemoteDesktopConfirmationNotice.tsx b/apps/desktop/src/renderer/features/cc-agent/RemoteDesktopConfirmationNotice.tsxnew file mode 100644index 0000000000..2be27da1b7--- /dev/null+++ b/apps/desktop/src/renderer/features/cc-agent/RemoteDesktopConfirmationNotice.tsx@@ -0,0 +1,29 @@+import { MonitorSmartphone } from 'lucide-react';+import { useTranslation } from 'react-i18next';++/** Read-only projection for confirmations that can only be resolved on the Host Desktop. */+export function RemoteDesktopConfirmationNotice() {+ const { t } = useTranslation();++ return (+ <div+ className="flex w-full max-w-[914px] items-start gap-3 rounded-[12px] border border-[var(--chat-input-border)] bg-[var(--chat-input-bg)] px-4 py-3"+ data-testid="remote-desktop-confirmation-notice"+ role="status"+ >+ <MonitorSmartphone+ aria-hidden="true"+ className="mt-0.5 shrink-0 text-[var(--status-bar-meta)]"+ size={18}+ />+ <div className="min-w-0">+ <p className="text-14 font-semibold leading-tight text-[var(--chat-input-text)]">+ {t('ccAgent.remoteDesktopConfirmation.title')}+ </p>+ <p className="mt-1 text-12 leading-relaxed text-[var(--status-bar-meta)]">+ {t('ccAgent.remoteDesktopConfirmation.description')}+ </p>+ </div>+ </div>+ );+}diff --git a/apps/desktop/src/renderer/features/cc-agent/__tests__/RemoteDesktopConfirmationNotice.test.tsx b/apps/desktop/src/renderer/features/cc-agent/__tests__/RemoteDesktopConfirmationNotice.test.tsxnew file mode 100644index 0000000000..94e66be6eb--- /dev/null+++ b/apps/desktop/src/renderer/features/cc-agent/__tests__/RemoteDesktopConfirmationNotice.test.tsx@@ -0,0 +1,29 @@+// @vitest-environment jsdom++import { cleanup, render, screen } from '@testing-library/react';+import { afterEach, describe, expect, it, vi } from 'vitest';++import { RemoteDesktopConfirmationNotice } from '../RemoteDesktopConfirmationNotice';++vi.mock('react-i18next', () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++afterEach(cleanup);++describe('RemoteDesktopConfirmationNotice', () => {+ it('renders a read-only status without confirmation actions', () => {+ render(<RemoteDesktopConfirmationNotice />);++ const status = screen.getByRole('status');++ expect(status.className).toContain('rounded-[12px]');+ expect(status.textContent).toContain(+ 'ccAgent.remoteDesktopConfirmation.title',+ );+ expect(status.textContent).toContain(+ 'ccAgent.remoteDesktopConfirmation.description',+ );+ expect(screen.queryByRole('button')).toBeNull();+ });+});diff --git a/apps/desktop/src/renderer/hooks/useCCAgentChat.ts b/apps/desktop/src/renderer/hooks/useCCAgentChat.tsindex af35576a61..b726a4143c 100644--- a/apps/desktop/src/renderer/hooks/useCCAgentChat.ts+++ b/apps/desktop/src/renderer/hooks/useCCAgentChat.ts@@ -44,6 +44,7 @@ import {type PendingIssueConfirm,type PendingRenameSessionsConfirm,type PendingGhostGrantConfirm,+ type PendingRemoteDesktopConfirmation,type PendingPlanReview,type PlanViewerState,type QueuedMessage,@@ -255,6 +256,8 @@ interface UseCCAgentChatReturn {respondToRenameSessionsConfirm: (result: { confirmed: true } | { confirmed: false }) => void;/** ghost_grant_confirm: Currently pending ghost file-grant confirm card */pendingGhostGrantConfirm: PendingGhostGrantConfirm | null;+ /** Device Link Desktop controller: read-only host confirmation status. */+ pendingRemoteDesktopConfirmation: PendingRemoteDesktopConfirmation | null;/** ghost_grant_confirm: Respond to the pending ghost file-grant confirm card */respondToGhostGrantConfirm: (result: { confirmed: true; allowDirs?: boolean } | { confirmed: false },@@ -885,6 +888,7 @@ export function useCCAgentChat(pendingRenameSessionsConfirm: lightState.pendingRenameSessionsConfirm,respondToRenameSessionsConfirm,pendingGhostGrantConfirm: lightState.pendingGhostGrantConfirm,+ pendingRemoteDesktopConfirmation: lightState.pendingRemoteDesktopConfirmation,respondToGhostGrantConfirm,planViewerState: lightState.planViewerState,setPlanViewerState,diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex d8ba2aa13f..6f5b9f7c33 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -7872,6 +7872,10 @@"waitForReply": "Waiting for your reply in the document area…","modelSwitchedFastModeOff": "Model switched, Fast Mode disabled"},+ "remoteDesktopConfirmation": {+ "title": "Confirmation required on the controlled computer",+ "description": "Open Cindy on the controlled computer to review and respond."+ },"handoff": {"card": {"lastActive": {diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 0d82e5e570..e2c515a6d1 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -7860,6 +7860,10 @@"waitForReply": "ドキュメント領域での返信を待っています…","modelSwitchedFastModeOff": "モデルを切り替えました。Fast Mode は無効になりました"},+ "remoteDesktopConfirmation": {+ "title": "制御対象のコンピューターで確認が必要です",+ "description": "制御対象のコンピューターで Cindy を開き、内容を確認して応答してください。"+ },"handoff": {"card": {"lastActive": {diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 27d8db365c..26051f0270 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -7860,6 +7860,10 @@"waitForReply": "문서 영역에서 회신을 기다리는 중…","modelSwitchedFastModeOff": "모델이 전환되었으며 Fast Mode가 비활성화되었습니다"},+ "remoteDesktopConfirmation": {+ "title": "제어 대상 컴퓨터에서 확인이 필요합니다",+ "description": "제어 대상 컴퓨터에서 Cindy를 열어 내용을 검토하고 응답하세요."+ },"handoff": {"card": {"lastActive": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 3ed278eae1..9c2948a121 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -7860,6 +7860,10 @@"waitForReply": "等待你在文档区回复…","modelSwitchedFastModeOff": "已切换模型,Fast Mode 已关闭"},+ "remoteDesktopConfirmation": {+ "title": "需要在被控电脑上确认",+ "description": "请在被控电脑上打开 Cindy,查看并处理这项确认。"+ },"handoff": {"card": {"lastActive": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 12a719ff4e..4877c722f4 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -7860,6 +7860,10 @@"waitForReply": "等待你在文件區回覆…","modelSwitchedFastModeOff": "已切換模型,Fast Mode 已關閉"},+ "remoteDesktopConfirmation": {+ "title": "需要在受控電腦上確認",+ "description": "請在受控電腦上開啟 Cindy,查看並處理這項確認。"+ },"handoff": {"card": {"lastActive": {diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 189510e2bb..8ba1cf619a 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -830,6 +830,17 @@ export interface PendingRenameSessionsConfirm {}>;}+/**+ * Device Link 控制端对 Desktop-only 确认的只读投影。+ *+ * 真实 requestId 与确认内容只留在被控 Desktop;控制端只持有不可用于 resolve 的+ * opaque id,以便显示等待状态并和 INTERACTION_DISMISSED 收敛。+ */+export interface PendingRemoteDesktopConfirmation {+ requestId: string;+ kind: 'issue_confirm' | 'rename_sessions_confirm' | 'ghost_grant_confirm';+}+/** FP-3: Plan Viewer Card display state. */export type PlanViewerState = 'expanded' | 'half' | 'minimized' | 'edit';@@ -2462,6 +2473,10 @@ export interface SessionChatState {pendingRenameSessionsConfirm: PendingRenameSessionsConfirm | null;/** ghost_grant_confirm: ghost_call 过户 workdir 外文件的确认卡片; null when none. */pendingGhostGrantConfirm: PendingGhostGrantConfirm | null;+ /** Device Link 控制端上的 Desktop-only 只读确认提示; null when none. */+ pendingRemoteDesktopConfirmation: PendingRemoteDesktopConfirmation | null;+ /** 同一会话内其余 Desktop-only 只读确认,按首次收到顺序等待展示。 */+ pendingRemoteDesktopConfirmationQueue: PendingRemoteDesktopConfirmation[];/** FP-3: Plan Viewer Card display state (only meaningful when pendingPlanReview != null). */planViewerState: PlanViewerState;/** FP-3: Last non-minimized state — used to restore from minimized via the "+" button. */@@ -2663,6 +2678,7 @@ export type SessionChatLightState = Pick<| 'pendingIssueConfirm'| 'pendingRenameSessionsConfirm'| 'pendingGhostGrantConfirm'+ | 'pendingRemoteDesktopConfirmation'| 'planViewerState'| 'lastExpandedPlanViewerState'| 'pendingQueue'@@ -2724,6 +2740,8 @@ function createInitialState(): SessionChatState {pendingIssueConfirm: null,pendingRenameSessionsConfirm: null,pendingGhostGrantConfirm: null,+ pendingRemoteDesktopConfirmation: null,+ pendingRemoteDesktopConfirmationQueue: [],planViewerState: 'expanded',lastExpandedPlanViewerState: 'expanded',oldestMessageId: null,@@ -2800,6 +2818,8 @@ export const EMPTY_SESSION_STATE: SessionChatState = Object.freeze({pendingIssueConfirm: null,pendingRenameSessionsConfirm: null,pendingGhostGrantConfirm: null,+ pendingRemoteDesktopConfirmation: null,+ pendingRemoteDesktopConfirmationQueue: [],planViewerState: 'expanded',lastExpandedPlanViewerState: 'expanded',pendingQueue: [],@@ -3399,7 +3419,9 @@ function _isSessionBusy(sessionId: string, s: SessionChatState): boolean {s.pendingPlanReview ||s.pendingIssueConfirm ||s.pendingRenameSessionsConfirm ||- s.pendingGhostGrantConfirm+ s.pendingGhostGrantConfirm ||+ s.pendingRemoteDesktopConfirmation ||+ s.pendingRemoteDesktopConfirmationQueue.length > 0);}@@ -5288,6 +5310,8 @@ export function handleStreamEvent(pendingIssueConfirm: null,pendingRenameSessionsConfirm: null,pendingGhostGrantConfirm: null,+ pendingRemoteDesktopConfirmation: null,+ pendingRemoteDesktopConfirmationQueue: [],// agent-meta: turn 结束清空,下一 turn 重新累积。lastAgentMeta: null,queueAbortPending: false,@@ -5495,6 +5519,8 @@ export function handleStreamEvent(pendingIssueConfirm: null,pendingRenameSessionsConfirm: null,pendingGhostGrantConfirm: null,+ pendingRemoteDesktopConfirmation: null,+ pendingRemoteDesktopConfirmationQueue: [],// agent-meta: turn 异常结束也清空。lastAgentMeta: null,// 出错也是 turn 终结:清掉 isRunning,否则 RunningStatusBar 会一直停在@@ -5582,6 +5608,27 @@ export function handleStreamEvent(// ghost 过户确认卡被 main 兜底关闭(超时/会话清理),ephemeral 无落库,直接清。return { ...state, pendingGhostGrantConfirm: null };}+ if (state.pendingRemoteDesktopConfirmation?.requestId === data.requestId) {+ const [next = null, ...remaining] = state.pendingRemoteDesktopConfirmationQueue;+ return {+ ...state,+ pendingRemoteDesktopConfirmation: next,+ pendingRemoteDesktopConfirmationQueue: remaining,+ };+ }+ if (+ state.pendingRemoteDesktopConfirmationQueue.some(+ (confirmation) => confirmation.requestId === data.requestId,+ )+ ) {+ return {+ ...state,+ pendingRemoteDesktopConfirmationQueue:+ state.pendingRemoteDesktopConfirmationQueue.filter(+ (confirmation) => confirmation.requestId !== data.requestId,+ ),+ };+ }if (state.pendingAskUser?.requestId === data.requestId) {// resolved + answers → 翻成 answered 并填答案(与答题端 answerUserQuestion 同款 reply / answers,// 卡片据此渲染 ✓ 选项);否则(真·放弃)标 expired。@@ -5872,6 +5919,8 @@ function forceFinalizeOnSessionClosed(state: SessionChatState): SessionChatState!state.pendingIssueConfirm &&!state.pendingRenameSessionsConfirm &&!state.pendingGhostGrantConfirm &&+ !state.pendingRemoteDesktopConfirmation &&+ state.pendingRemoteDesktopConfirmationQueue.length === 0 &&!state.messages.some((m) => m.isStreaming) &&!state.queueAbortPending &&state.steeringQueueClientIds.length === 0 &&@@ -5925,6 +5974,8 @@ function forceFinalizeOnSessionClosed(state: SessionChatState): SessionChatStatependingIssueConfirm: null,pendingRenameSessionsConfirm: null,pendingGhostGrantConfirm: null,+ pendingRemoteDesktopConfirmation: null,+ pendingRemoteDesktopConfirmationQueue: [],queueAbortPending: false,steeringQueueClientIds: [],continuationTurnClientId: null,@@ -7105,7 +7156,11 @@ function initGlobalListeners(options: GlobalListenerOptions = {}): void {);// ── Maker interaction request: permission/ask/plan 三合一,按 kind 分发 ──- const handleInteractionRequestRaw = (raw: unknown, ingress: LiveIngressContext = {}) => {+ const handleInteractionRequestRaw = (+ raw: unknown,+ ingress: LiveIngressContext = {},+ remoteSnapshotDeviceId?: string,+ ) => {if (!isCurrentLiveIngress(ingress)) return;const payload = raw as {sessionId?: string;@@ -7134,6 +7189,49 @@ function initGlobalListeners(options: GlobalListenerOptions = {}): void {// 用它当气泡 clientId(permission 无此字段)。const persistId = payload.persistId;+ if (+ (ingress.remoteDeviceId || remoteSnapshotDeviceId) &&+ (kind === 'issue_confirm' ||+ kind === 'rename_sessions_confirm' ||+ kind === 'ghost_grant_confirm')+ ) {+ setState(sessionId, (s) => {+ const confirmation: PendingRemoteDesktopConfirmation = {+ kind,+ requestId: request.requestId,+ };+ const current = s.pendingRemoteDesktopConfirmation;+ if (!current) {+ return {+ ...s,+ pendingIssueConfirm: null,+ pendingRenameSessionsConfirm: null,+ pendingGhostGrantConfirm: null,+ pendingRemoteDesktopConfirmation: confirmation,+ };+ }+ if (current.requestId === confirmation.requestId) {+ return { ...s, pendingRemoteDesktopConfirmation: confirmation };+ }+ const queuedIndex = s.pendingRemoteDesktopConfirmationQueue.findIndex(+ (queued) => queued.requestId === confirmation.requestId,+ );+ if (queuedIndex >= 0) {+ const nextQueue = s.pendingRemoteDesktopConfirmationQueue.slice();+ nextQueue[queuedIndex] = confirmation;+ return { ...s, pendingRemoteDesktopConfirmationQueue: nextQueue };+ }+ return {+ ...s,+ pendingRemoteDesktopConfirmationQueue: [+ ...s.pendingRemoteDesktopConfirmationQueue,+ confirmation,+ ],+ };+ });+ return;+ }+if (request.kind === 'permission') {const metadata = request.metadata as Record<string, unknown> | undefined;const data: CCAgentPermissionRequestPayload = {@@ -7253,6 +7351,8 @@ function initGlobalListeners(options: GlobalListenerOptions = {}): void {githubUserIdentity,suggestedPublicName,},+ pendingRemoteDesktopConfirmation: null,+ pendingRemoteDesktopConfirmationQueue: [],}));return;}@@ -7268,6 +7368,8 @@ function initGlobalListeners(options: GlobalListenerOptions = {}): void {setState(sessionId, (s) => ({...s,pendingRenameSessionsConfirm: { requestId: request.requestId, changes },+ pendingRemoteDesktopConfirmation: null,+ pendingRemoteDesktopConfirmationQueue: [],}));return;}@@ -7276,7 +7378,12 @@ function initGlobalListeners(options: GlobalListenerOptions = {}): void {// ephemeral 卡片(同 permission 语义,无 persistId 不落库),直接写 state。const parsed = parseGhostGrantConfirmRequest(request);if (!parsed) return;- setState(sessionId, (s) => ({ ...s, pendingGhostGrantConfirm: parsed }));+ setState(sessionId, (s) => ({+ ...s,+ pendingGhostGrantConfirm: parsed,+ pendingRemoteDesktopConfirmation: null,+ pendingRemoteDesktopConfirmationQueue: [],+ }));return;}};@@ -7308,7 +7415,8 @@ function initGlobalListeners(options: GlobalListenerOptions = {}): void {);// 模块级桥接:供 reconcilePendingInteractions(打开/重连会话时的快照重建)复用同一套// 按 kind 分发逻辑。handler 只依赖模块级 setState/handleStreamEvent,无闭包局部状态,引用安全。- applyInteractionRequestRef = handleInteractionRequestRaw;+ applyInteractionRequestRef = (raw, source) =>+ handleInteractionRequestRaw(raw, {}, source?.remoteDeviceId);// ── Maker interaction dismissed: setPermissionMode 切换 / close 时关掉对话框 ──const handleInteractionDismissedRaw = (raw: unknown, ingress: LiveIngressContext = {}) => {@@ -8309,6 +8417,7 @@ function selectLightState(state: SessionChatState): SessionChatLightState {pendingIssueConfirm: state.pendingIssueConfirm,pendingRenameSessionsConfirm: state.pendingRenameSessionsConfirm,pendingGhostGrantConfirm: state.pendingGhostGrantConfirm,+ pendingRemoteDesktopConfirmation: state.pendingRemoteDesktopConfirmation,planViewerState: state.planViewerState,lastExpandedPlanViewerState: state.lastExpandedPlanViewerState,pendingQueue: state.pendingQueue,@@ -8353,6 +8462,7 @@ function lightStateEquals(a: SessionChatLightState, b: SessionChatLightState): ba.pendingIssueConfirm === b.pendingIssueConfirm &&a.pendingRenameSessionsConfirm === b.pendingRenameSessionsConfirm &&a.pendingGhostGrantConfirm === b.pendingGhostGrantConfirm &&+ a.pendingRemoteDesktopConfirmation === b.pendingRemoteDesktopConfirmation &&a.planViewerState === b.planViewerState &&a.lastExpandedPlanViewerState === b.lastExpandedPlanViewerState &&a.pendingQueue === b.pendingQueue &&@@ -8726,7 +8836,8 @@ function setTitleUpdateCallback(sessionId: string, cb: (() => void) | undefined)* initGlobalListeners 注入的「interaction-request 分发」引用,供 reconcilePendingInteractions* 复用(打开/重连会话时把当前挂起交互重建成可操作面板)。handler 无闭包局部依赖。*/-let applyInteractionRequestRef: ((raw: unknown) => void) | null = null;+let applyInteractionRequestRef:+ ((raw: unknown, source?: { remoteDeviceId?: string }) => void) | null = null;/*** 快照重建:拉取某会话当前挂起的交互(permission/ask/plan)并重建可操作面板。@@ -8787,6 +8898,7 @@ function reconcilePendingInteractions(// a Device Link reconnect cannot leave cards that the Host already closed.// Other interaction kinds keep their existing replay semantics.const authoritativePluginSetupIds = new Set<string>();+ const authoritativeRemoteDesktopConfirmationIds = new Set<string>();for (const item of list) {const request = item?.request;if (@@ -8796,6 +8908,15 @@ function reconcilePendingInteractions() {authoritativePluginSetupIds.add(request.requestId);}+ if (+ (request?.kind === 'issue_confirm' ||+ request?.kind === 'rename_sessions_confirm' ||+ request?.kind === 'ghost_grant_confirm') &&+ typeof request.requestId === 'string' &&+ request.requestId.length > 0+ ) {+ authoritativeRemoteDesktopConfirmationIds.add(request.requestId);+ }}if (!isCurrentInteractionReconcile()) return 0;setState(sessionId, (state) => {@@ -8819,8 +8940,40 @@ function reconcilePendingInteractions(authoritativePluginSetupIds.has(state.pluginSetupCommandInFlight.requestId)? state.pluginSetupCommandInFlight: null;+ const nextRemoteDesktopConfirmation =+ stickyDeviceAtStart || interactionOriginAtStart+ ? state.pendingRemoteDesktopConfirmation &&+ authoritativeRemoteDesktopConfirmationIds.has(+ state.pendingRemoteDesktopConfirmation.requestId,+ )+ ? state.pendingRemoteDesktopConfirmation+ : null+ : state.pendingRemoteDesktopConfirmation;+ const nextRemoteDesktopConfirmationQueue =+ stickyDeviceAtStart || interactionOriginAtStart+ ? state.pendingRemoteDesktopConfirmationQueue.filter((confirmation) =>+ authoritativeRemoteDesktopConfirmationIds.has(confirmation.requestId),+ )+ : state.pendingRemoteDesktopConfirmationQueue;+ const [promotedRemoteDesktopConfirmation = null, ...remainingRemoteConfirmations] =+ nextRemoteDesktopConfirmation+ ? [nextRemoteDesktopConfirmation, ...nextRemoteDesktopConfirmationQueue]+ : nextRemoteDesktopConfirmationQueue;+ const remoteQueueChanged =+ remainingRemoteConfirmations.length !==+ state.pendingRemoteDesktopConfirmationQueue.length ||+ remainingRemoteConfirmations.some(+ (confirmation, index) =>+ confirmation !== state.pendingRemoteDesktopConfirmationQueue[index],+ );- if (!currentChanged && !queueChanged && nextCommand === state.pluginSetupCommandInFlight) {+ if (+ !currentChanged &&+ !queueChanged &&+ nextCommand === state.pluginSetupCommandInFlight &&+ promotedRemoteDesktopConfirmation === state.pendingRemoteDesktopConfirmation &&+ !remoteQueueChanged+ ) {return state;}return {@@ -8829,15 +8982,22 @@ function reconcilePendingInteractions(pendingPluginSetupQueue: survivingQueue,pluginSetupViewerState: currentChanged ? 'expanded' : state.pluginSetupViewerState,pluginSetupCommandInFlight: nextCommand,+ pendingRemoteDesktopConfirmation: promotedRemoteDesktopConfirmation,+ pendingRemoteDesktopConfirmationQueue: remainingRemoteConfirmations,};});for (const item of list) {if (!isCurrentInteractionReconcile()) return 0;- applyInteractionRequestRef?.({- sessionId,- request: item.request,- persistId: item.persistId,- });+ applyInteractionRequestRef?.(+ {+ sessionId,+ request: item.request,+ persistId: item.persistId,+ },+ {+ remoteDeviceId: stickyDeviceAtStart ?? interactionOriginAtStart ?? undefined,+ },+ );}return list.length;});@@ -13400,6 +13560,8 @@ async function clearSessionAfterGuardImpl(sessionId: string, clearedAt: string):askUserDraft: null,pendingPlanReview: null,pendingIssueConfirm: null,+ pendingRemoteDesktopConfirmation: null,+ pendingRemoteDesktopConfirmationQueue: [],pendingQueue: s.pendingQueue.filter((item) =>postClearOptimisticClientIds.has(item.clientId),),diff --git a/apps/mobile/src/__tests__/interactionModel.test.ts b/apps/mobile/src/__tests__/interactionModel.test.tsindex 44e4b0f21f..24a2884b5c 100644--- a/apps/mobile/src/__tests__/interactionModel.test.ts+++ b/apps/mobile/src/__tests__/interactionModel.test.ts@@ -242,14 +242,16 @@ describe('interactionModel', () => {expect(interactionPanelSource).not.toContain('optionCheckboxMark');});- it('keeps issue confirmation unsupported in the mobile adapter and panel', () => {+ it('keeps every Host-owned confirmation read-only in the mobile adapter and panel', () => {const interactionPanelSource = readFileSync(resolve(process.cwd(), 'src/session/InteractionPanel.tsx'), 'utf8');expect('buildIssueConfirmReviewPresentation' in mobileInteractionModel).toBe(false);expect('buildIssueConfirmDecision' in mobileInteractionModel).toBe(false);expect('normalizeIssueConfirm' in mobileInteractionModel).toBe(false);- expect(interactionPanelSource).toContain("if (kind === 'issue_confirm')");- expect(interactionPanelSource).toContain("t('interaction.panel.issueConfirmUnsupported')");+ expect(interactionPanelSource).toContain(+ "kind === 'issue_confirm' || kind === 'rename_sessions_confirm' || kind === 'ghost_grant_confirm'",+ );+ expect(interactionPanelSource).toContain("t('interaction.panel.desktopConfirmUnsupported')");expect(interactionPanelSource).not.toContain('buildIssueConfirmReviewPresentation');});diff --git a/apps/mobile/src/i18n/locales/en/interaction.json b/apps/mobile/src/i18n/locales/en/interaction.jsonindex 198dec3b62..1ced8f2888 100644--- a/apps/mobile/src/i18n/locales/en/interaction.json+++ b/apps/mobile/src/i18n/locales/en/interaction.json@@ -37,7 +37,7 @@"queuePositionNth": "no. {{index}}","composerBlockedByPending": "Handle the pending request from your computer before typing again.","missingRequestId": "This remote interaction has no requestId, so the decision can't be sent back.",- "issueConfirmUnsupported": "Issue submission is confirmed only on your computer. Go back to the desktop app to confirm or cancel.",+ "desktopConfirmUnsupported": "This confirmation is handled only on the controlled computer. Go back to the desktop app to continue.","unsupportedType": "This remote interaction type isn't supported on mobile yet.","unsupportedKind": "Unsupported","desktopOnlyKind": "On Computer",@@ -107,6 +107,14 @@"title": "Issue Needs Confirmation","label": "Issue"},+ "rename_sessions_confirm": {+ "title": "Session Names Need Confirmation",+ "label": "Rename"+ },+ "ghost_grant_confirm": {+ "title": "File Access Needs Confirmation",+ "label": "File Access"+ },"plugin_setup": {"title": "Plugin Setup Needed on Your Computer","label": "Plugin"diff --git a/apps/mobile/src/i18n/locales/ja/interaction.json b/apps/mobile/src/i18n/locales/ja/interaction.jsonindex 491fa549d7..6301a78655 100644--- a/apps/mobile/src/i18n/locales/ja/interaction.json+++ b/apps/mobile/src/i18n/locales/ja/interaction.json@@ -37,7 +37,7 @@"queuePositionNth": "{{index}} 番目","composerBlockedByPending": "パソコンからの保留中のリクエストを処理してから入力を続けてください。","missingRequestId": "このリモート操作には requestId がないため、決定を返信できません。",- "issueConfirmUnsupported": "Issue の送信確認はパソコンでのみ行えます。デスクトップアプリに戻って確認またはキャンセルしてください。",+ "desktopConfirmUnsupported": "この確認は操作対象のパソコンでのみ処理できます。デスクトップアプリに戻って続けてください。","unsupportedType": "このリモート操作タイプはモバイルではまだ対応していません。","unsupportedKind": "未対応","desktopOnlyKind": "パソコンで処理",@@ -107,6 +107,14 @@"title": "Issue の内容を確認してください","label": "Issue"},+ "rename_sessions_confirm": {+ "title": "セッション名の変更を確認してください",+ "label": "名前変更"+ },+ "ghost_grant_confirm": {+ "title": "ファイルアクセスを確認してください",+ "label": "ファイルアクセス"+ },"plugin_setup": {"title": "パソコンでプラグインの設定が必要です","label": "プラグイン"diff --git a/apps/mobile/src/i18n/locales/ko/interaction.json b/apps/mobile/src/i18n/locales/ko/interaction.jsonindex 6ef7c1695d..07290f737f 100644--- a/apps/mobile/src/i18n/locales/ko/interaction.json+++ b/apps/mobile/src/i18n/locales/ko/interaction.json@@ -37,7 +37,7 @@"queuePositionNth": "{{index}}번째","composerBlockedByPending": "컴퓨터의 대기 중인 요청을 처리한 뒤 계속 입력할 수 있습니다.","missingRequestId": "이 원격 상호작용에는 requestId가 없어 결정을 돌려보낼 수 없습니다.",- "issueConfirmUnsupported": "Issue 제출 확인은 컴퓨터에서만 처리됩니다. 데스크톱 앱으로 돌아가 확인하거나 취소하세요.",+ "desktopConfirmUnsupported": "이 확인은 제어 중인 컴퓨터에서만 처리할 수 있습니다. 데스크톱 앱으로 돌아가 계속하세요.","unsupportedType": "이 원격 상호작용 유형은 모바일에서 아직 지원되지 않습니다.","unsupportedKind": "미지원","desktopOnlyKind": "컴퓨터에서 처리",@@ -107,6 +107,14 @@"title": "이슈 내용을 확인해 주세요","label": "이슈"},+ "rename_sessions_confirm": {+ "title": "세션 이름 변경을 확인해 주세요",+ "label": "이름 변경"+ },+ "ghost_grant_confirm": {+ "title": "파일 접근을 확인해 주세요",+ "label": "파일 접근"+ },"plugin_setup": {"title": "컴퓨터에서 플러그인 설정이 필요합니다","label": "플러그인"diff --git a/apps/mobile/src/i18n/locales/zh-CN/interaction.json b/apps/mobile/src/i18n/locales/zh-CN/interaction.jsonindex bbc68b7e33..105506d099 100644--- a/apps/mobile/src/i18n/locales/zh-CN/interaction.json+++ b/apps/mobile/src/i18n/locales/zh-CN/interaction.json@@ -37,7 +37,7 @@"queuePositionNth": "第 {{index}}","composerBlockedByPending": "先处理电脑端的待处理请求后才能继续输入。","missingRequestId": "这个远程交互缺少 requestId,无法回传决定。",- "issueConfirmUnsupported": "Issue 提交确认只在电脑端处理。请回到桌面端确认或取消提交。",+ "desktopConfirmUnsupported": "此确认只能在被控电脑处理。请回到桌面端继续。","unsupportedType": "手机版暂不支持这个远程交互类型。","unsupportedKind": "暂不支持","desktopOnlyKind": "电脑端处理",@@ -107,6 +107,14 @@"title": "需要确认 Issue 内容","label": "Issue"},+ "rename_sessions_confirm": {+ "title": "需要确认任务名称变更",+ "label": "重命名"+ },+ "ghost_grant_confirm": {+ "title": "需要确认文件访问权限",+ "label": "文件访问"+ },"plugin_setup": {"title": "需要在电脑端配置插件","label": "插件"diff --git a/apps/mobile/src/i18n/locales/zh-TW/interaction.json b/apps/mobile/src/i18n/locales/zh-TW/interaction.jsonindex 60c62f3a24..3486e01f46 100644--- a/apps/mobile/src/i18n/locales/zh-TW/interaction.json+++ b/apps/mobile/src/i18n/locales/zh-TW/interaction.json@@ -37,7 +37,7 @@"queuePositionNth": "第 {{index}}","composerBlockedByPending": "先處理電腦端的待處理請求後才能繼續輸入。","missingRequestId": "這個遠端互動缺少 requestId,無法回傳決定。",- "issueConfirmUnsupported": "Issue 提交確認只在電腦端處理。請回到桌面端確認或取消提交。",+ "desktopConfirmUnsupported": "此確認只能在被控電腦處理。請回到桌面端繼續。","unsupportedType": "手機版暫不支援這個遠端互動型別。","unsupportedKind": "暫不支援","desktopOnlyKind": "電腦端處理",@@ -107,6 +107,14 @@"title": "需要確認 Issue 內容","label": "Issue"},+ "rename_sessions_confirm": {+ "title": "需要確認任務名稱變更",+ "label": "重新命名"+ },+ "ghost_grant_confirm": {+ "title": "需要確認檔案存取權限",+ "label": "檔案存取"+ },"plugin_setup": {"title": "需要在電腦端配置插件","label": "插件"diff --git a/apps/mobile/src/session/InteractionPanel.tsx b/apps/mobile/src/session/InteractionPanel.tsxindex e4274f5b9b..890cf0b00a 100644--- a/apps/mobile/src/session/InteractionPanel.tsx+++ b/apps/mobile/src/session/InteractionPanel.tsx@@ -93,6 +93,8 @@ const LOCALIZED_INTERACTION_KINDS = new Set(['ask_user_question','plan_review','issue_confirm',+ 'rename_sessions_confirm',+ 'ghost_grant_confirm','plugin_setup',]);@@ -538,10 +540,10 @@ function InteractionItem({/>);}- if (kind === 'issue_confirm') {+ if (kind === 'issue_confirm' || kind === 'rename_sessions_confirm' || kind === 'ghost_grant_confirm') {return (<UnsupportedCard- message={t('interaction.panel.issueConfirmUnsupported')}+ message={t('interaction.panel.desktopConfirmUnsupported')}request={item.request}touchLayout={touchLayout}/>