Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 修复插件产物和调用状态的远程显示 (#4692)

Chris Zhangc9fadf524866
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/cardRemoteResource.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/cardRemoteResource.test.ts
new file mode 100644
index 0000000000..a907efab0b
--- /dev/null
+++ b/apps/desktop/src/main/cindy-brain/__tests__/cardRemoteResource.test.ts
@@ -0,0 +1,88 @@
+import { describe, it, expect, vi } from 'vitest';
+vi.mock('../cardStoreDb.js', () => ({ getGhostCard: vi.fn(), upsertGhostCard: vi.fn() }));
+vi.mock('../../device-link/broadcast-tap.js', () => ({ captureDataOwnerBroadcastScope: vi.fn(), isDataOwnerBroadcastScopeCurrent: vi.fn(), tapWindowBroadcast: vi.fn(), getSafeDataOwnerPushStamp: vi.fn() }));
+import { createPluginIdentityRemoteProvider, createGhostCardRemoteProvider, projectGhostCardBlocks, persistGhostCardWithRemoteChange } from '../cardRemoteResource.js';
+import { upsertGhostCard } from '../cardStoreDb.js';
+import { isDataOwnerBroadcastScopeCurrent, tapWindowBroadcast } from '../../device-link/broadcast-tap.js';
+const image = `cindy-media://blobs/${'b'.repeat(64)}.png`;
+const audio = `cindy-media://blobs/${'c'.repeat(64)}.mp3`;
+const request = { ref: { collectionId: 'plugin-results', kind: 'card', id: JSON.stringify(['s', 'c']) }, client: { protocolVersion: 1, primitives: [] } };
+const context = { controllerDeviceId: 'phone' };
+
+describe('read-only plugin card projection', () => {
+ it('preserves readable text and managed assets, never HTML, styles or executable actions', () => {
+ const blocks = projectGhostCardBlocks(`<style>p{color:red}</style><h2>Result &amp; title</h2><p>Done</p><img src="${image}"/><div data-ghost-audio="${audio}"></div><button data-ghost-action="delete">Delete</button><script>secret()</script><img src="file:///secret"/>`);
+ expect(blocks[0].fallbackMarkdown).toBe('Result & title\nDone\n\nDelete');
+ expect(blocks.filter((b) => b.data).map((b) => b.data)).toEqual([{ url: image }, { url: audio }]);
+ expect(JSON.stringify(blocks)).not.toMatch(/<|secret|color:red|data-ghost-action/);
+ });
+ it('preserves image descriptions and declared destinations as inert text', () => {
+ const blocks = projectGhostCardBlocks(`<img src="${image}" alt="A chart"/><a data-ghost-link="https://example.com/?a=1&amp;b=2">Report</a>`);
+ expect(blocks[0].fallbackMarkdown).toContain('A chart');
+ expect(blocks[0].fallbackMarkdown).toContain('a=1&b=2');
+ expect(blocks[0].fallbackMarkdown).toContain('Report');
+ });
+ it('invalidates only after persistence and with the task boundary', async () => {
+ let resolve!: () => void;
+ vi.mocked(upsertGhostCard).mockImplementationOnce(() => new Promise<void>((done) => { resolve = done; }));
+ vi.mocked(isDataOwnerBroadcastScopeCurrent).mockReturnValue(true);
+ const write = persistGhostCardWithRemoteChange({ callId: 'c', sessionId: 's', ghostId: 'art', html: '<p>Done</p>', v: 1, height: 100, updatedAt: 1 });
+ expect(tapWindowBroadcast).not.toHaveBeenCalled();
+ resolve(); await write;
+ expect(tapWindowBroadcast).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({ sessionId: 's' }), undefined);
+ vi.mocked(tapWindowBroadcast).mockClear();
+ vi.mocked(isDataOwnerBroadcastScopeCurrent).mockReturnValue(false);
+ await persistGhostCardWithRemoteChange({ callId: 'c', sessionId: 's', ghostId: 'art', html: '<p>Done</p>', v: 1, height: 100, updatedAt: 1 });
+ expect(tapWindowBroadcast).not.toHaveBeenCalled();
+ });
+ it('reads only the requested task card and rechecks access after I/O', async () => {
+ const authorize = vi.fn(async () => {});
+ const readCard = vi.fn(async () => ({ sessionId: 's', callId: 'c', ghostId: 'art', html: '<p>Done</p>', v: 1, height: 100 }));
+ const provider = createGhostCardRemoteProvider({ readCard, authorize, captureScope: () => () => true });
+ const result = await provider.get!(context, request);
+ expect(result.blocks?.[0].fallbackMarkdown).toBe('Done');
+ expect(result).not.toHaveProperty('actions');
+ expect(authorize.mock.calls).toEqual([['s'], ['s']]);
+ readCard.mockResolvedValue({ sessionId: 'other', callId: 'c', ghostId: 'art', html: '<p>private</p>', v: 1, height: 100 });
+ await expect(provider.get!(context, request)).rejects.toThrow('Card does not exist');
+ });
+ it('rejects hidden tasks, malformed refs, missing cards and late owner changes', async () => {
+ const readCard = vi.fn(async () => ({ sessionId: 's', callId: 'c', ghostId: 'art', html: '<p>private</p>', v: 1, height: 100 }));
+ const provider = createGhostCardRemoteProvider({ readCard, authorize: async () => {}, captureScope: () => () => false });
+ await expect(provider.get!(context, request)).rejects.toThrow('Card does not exist');
+ readCard.mockClear();
+ await expect(provider.get!(context, { ...request, ref: { ...request.ref, id: 'bad' } })).rejects.toThrow('Card does not exist');
+ expect(readCard).not.toHaveBeenCalled();
+ const hidden = createGhostCardRemoteProvider({ readCard, authorize: async () => { throw new Error('hidden'); }, captureScope: () => () => true });
+ await expect(hidden.get!(context, request)).rejects.toThrow('hidden');
+ expect(readCard).not.toHaveBeenCalled();
+ const missing = createGhostCardRemoteProvider({ readCard: async () => null, authorize: async () => {}, captureScope: () => () => true });
+ await expect(missing.get!(context, request)).rejects.toThrow('Card does not exist');
+ });
+});
+
+
+describe('plugin identity for mobile annotations', () => {
+ const request = { ref: { collectionId: 'plugin-identities', kind: 'plugin', id: '["s","art"]' }, client: { protocolVersion: 1, primitives: [] } };
+ it('projects only public name and bounded raster data, never credentials or local URLs', async () => {
+ const readIdentity = vi.fn(() => ({ name: 'Art', iconDataUrl: 'data:image/png;base64,YQ==', secret: 'private' }));
+ const authorize = vi.fn(async () => {});
+ const provider = createPluginIdentityRemoteProvider({ readIdentity, authorize, captureScope: () => () => true });
+ const result = await provider.get!(context, request);
+ expect(result.display.title).toBe('Art');
+ expect(result.blocks?.[0].data).toEqual({ url: 'data:image/png;base64,YQ==' });
+ expect(JSON.stringify(result)).not.toContain('private');
+ expect(authorize).toHaveBeenCalledWith('s');
+ readIdentity.mockReturnValue({ name: 'Art', iconDataUrl: 'file:///private/icon.png', secret: 'private' });
+ expect((await provider.get!(context, request)).blocks).toEqual([]);
+ });
+ it('rejects inaccessible sessions and an account change while authorization awaits', async () => {
+ const readIdentity = vi.fn(() => ({ name: 'Art' }));
+ const provider = createPluginIdentityRemoteProvider({ readIdentity, authorize: async () => {}, captureScope: () => () => false });
+ await expect(provider.get!(context, request)).rejects.toThrow('Plugin not found');
+ expect(readIdentity).not.toHaveBeenCalled();
+ const denied = createPluginIdentityRemoteProvider({ readIdentity, authorize: async () => { throw new Error('denied'); }, captureScope: () => () => true });
+ await expect(denied.get!(context, request)).rejects.toThrow('denied');
+ expect(readIdentity).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/desktop/src/main/cindy-brain/cardRemoteResource.ts b/apps/desktop/src/main/cindy-brain/cardRemoteResource.ts
new file mode 100644
index 0000000000..d3d9255b0e
--- /dev/null
+++ b/apps/desktop/src/main/cindy-brain/cardRemoteResource.ts
@@ -0,0 +1,142 @@
+import type { GhostCardRow } from './cardService.js';
+import { createHash } from 'node:crypto';
+import { REMOTE_RESOURCE_CHANGED_CHANNEL, type RemoteResourceBlock } from '@cindy/device-link';
+import { managedToolMediaKind } from '@cindy/maker-shared/payload-summary';
+import { getGhostCard, upsertGhostCard, type GhostCardRecord } from './cardStoreDb.js';
+import { assertRemoteBotInvocationAllowed } from '../device-link/remoteBotSessionBoundary.js';
+import { remoteResourceRegistry, RemoteResourceRegistryError, type RemoteResourceProvider } from '../device-link/remoteResourceRegistry.js';
+import { captureDataOwnerBroadcastScope, isDataOwnerBroadcastScopeCurrent, tapWindowBroadcast, getSafeDataOwnerPushStamp } from '../device-link/broadcast-tap.js';
+
+const COLLECTION = 'plugin-results';
+const KIND = 'card';
+
+function decodeText(value: string): string {
+ return value.replace(/&(#x[0-9a-f]+|#\d+|amp|lt|gt|quot|apos|nbsp);/gi, (full, entity: string) => {
+ const named: Record<string, string> = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' };
+ if (named[entity.toLowerCase()]) return named[entity.toLowerCase()];
+ const code = entity[1]?.toLowerCase() === 'x' ? parseInt(entity.slice(2), 16) : parseInt(entity.slice(1), 10);
+ return Number.isInteger(code) && code > 0 && code <= 0x10ffff && !(code >= 0xd800 && code <= 0xdfff) ? String.fromCodePoint(code) : full;
+ });
+}
+
+/** Project persisted, sanitized cards into inert text and managed media. No HTML,
+ * CSS, script, action IDs or host bridge crosses the remote resource boundary. */
+export function projectGhostCardBlocks(html: string): RemoteResourceBlock[] {
+ // Stored cards have already passed sanitizeGhostCardHtml. Re-sanitizing would
+ // escape text entities a second time. This projection never interprets HTML.
+ const source = html.replace(/<(style|script)\b[^>]*>[\s\S]*?<\/\1>/gi, '');
+ const blocks: RemoteResourceBlock[] = [];
+ const urls = new Set<string>();
+ for (const match of source.matchAll(/(?:src|data-ghost-audio|data-ghost-model)="(cindy-media:\/\/blobs\/[0-9a-f]{64}\.[a-z0-9]+)"/g)) urls.add(match[1]);
+ const text = decodeText(source.replace(/<[^>]+>/g, (tag) => {
+ // Keep destinations and image descriptions readable without an executable link.
+ const link = / data-ghost-link="([^"]*)"/.exec(tag)?.[1];
+ const alt = /^<img\b/i.test(tag) ? / alt="([^"]*)"/.exec(tag)?.[1] : undefined;
+ if (link) return ` ${link} `;
+ if (alt) return ` ${alt} `;
+ return /^(?:<br\b|<hr\b|<\/(?:p|div|h[1-4]|li|tr|section|header|footer|blockquote|pre)\b)/i.test(tag) ? '\n' : /^<\/(?:td|th)\b/i.test(tag) ? '\t' : '';
+ }))
+ .replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim();
+ if (text) blocks.push({ id: 'text', primitive: 'markdown', fallbackMarkdown: text.replace(/[\\`*_{}\[\]()<>#+.!|~-]/g, '\\$&') });
+ for (const url of urls) {
+ const kind = managedToolMediaKind(url) ?? (/\.glb$/.test(url) ? 'file' : null);
+ if (kind) blocks.push({ id: `asset-${blocks.length}`, primitive: kind, fallbackMarkdown: url, data: { url } });
+ }
+ return blocks;
+}
+
+/** Read only, task-scoped resource; no list of cards or desktop interaction surface. */
+export function createGhostCardRemoteProvider(deps: {
+ readCard: (callId: string) => Promise<GhostCardRecord | null>;
+ authorize: (sessionId: string) => Promise<void>;
+ captureScope: () => () => boolean;
+}): RemoteResourceProvider {
+ return {
+ collection: { id: COLLECTION, resourceKind: KIND, title: 'Plugin results' },
+ async list() { return { collectionId: COLLECTION, revision: '1', items: [] }; },
+ async get(_context, request) {
+ const validScope = deps.captureScope();
+ let ids: unknown;
+ try { ids = JSON.parse(request.ref.id); } catch { /* rejected below */ }
+ if (!Array.isArray(ids) || ids.length !== 2 || !ids.every((id) => typeof id === 'string' && id.length > 0 && id.length <= 128)) {
+ throw new RemoteResourceRegistryError('NOT_FOUND', 'Card does not exist');
+ }
+ const [sessionId, callId] = ids as [string, string];
+ await deps.authorize(sessionId);
+ const card = await deps.readCard(callId);
+ if (!card || card.sessionId !== sessionId || !validScope()) throw new RemoteResourceRegistryError('NOT_FOUND', 'Card does not exist');
+ await deps.authorize(sessionId);
+ if (!validScope()) throw new RemoteResourceRegistryError('NOT_FOUND', 'Card does not exist');
+ return {
+ ref: request.ref,
+ display: { title: card.ghostId },
+ links: [],
+ revision: createHash('sha256').update(card.html).digest('hex'),
+ blocks: projectGhostCardBlocks(card.html),
+ };
+ },
+ };
+}
+
+let registered = false;
+export function registerGhostCardRemoteProvider(readIdentity: (id: string) => { name: string; iconDataUrl?: string } | undefined): void {
+ if (registered) return;
+ remoteResourceRegistry.register(createGhostCardRemoteProvider({
+ readCard: getGhostCard,
+ authorize: (sessionId) => assertRemoteBotInvocationAllowed([sessionId]),
+ captureScope: () => { const scope = captureDataOwnerBroadcastScope(); return () => isDataOwnerBroadcastScopeCurrent(scope); },
+ }));
+ remoteResourceRegistry.register(createPluginIdentityRemoteProvider({
+ readIdentity,
+ authorize: (sessionId) => assertRemoteBotInvocationAllowed([sessionId]),
+ captureScope: () => { const scope = captureDataOwnerBroadcastScope(); return () => isDataOwnerBroadcastScopeCurrent(scope); },
+ }));
+ registered = true;
+}
+
+export function notifyGhostCardRemoteChanged(sessionId: string | null, callId: string): void {
+ if (!sessionId) return;
+ tapWindowBroadcast(REMOTE_RESOURCE_CHANGED_CHANNEL, {
+ sessionId,
+ collectionId: COLLECTION,
+ resourceRefs: [{ collectionId: COLLECTION, kind: KIND, id: JSON.stringify([sessionId, callId]) }],
+ }, getSafeDataOwnerPushStamp());
+}
+
+/** Invalidate only after the new version is readable, and retain the write's owner. */
+export async function persistGhostCardWithRemoteChange(row: GhostCardRow): Promise<void> {
+ const scope = captureDataOwnerBroadcastScope();
+ await upsertGhostCard(row);
+ if (isDataOwnerBroadcastScopeCurrent(scope)) notifyGhostCardRemoteChanged(row.sessionId, row.callId);
+}
+
+
+/** Public identity only; never exposes the installed manifest, credentials or local paths. */
+export function createPluginIdentityRemoteProvider(deps: {
+ readIdentity: (id: string) => { name: string; iconDataUrl?: string } | undefined;
+ authorize: (sessionId: string) => Promise<void>;
+ captureScope: () => () => boolean;
+}): RemoteResourceProvider {
+ const collectionId = 'plugin-identities';
+ return {
+ collection: { id: collectionId, resourceKind: 'plugin', title: 'Plugins' },
+ async list() { return { collectionId, revision: '1', items: [] }; },
+ async get(_context, request) {
+ const valid = deps.captureScope();
+ let ids: unknown;
+ try { ids = JSON.parse(request.ref.id); } catch { /* validated below */ }
+ if (!Array.isArray(ids) || ids.length !== 2 || !ids.every((id) => typeof id === 'string' && id.length > 0 && id.length <= 128)) {
+ throw new RemoteResourceRegistryError('NOT_FOUND', 'Plugin not found');
+ }
+ await deps.authorize(ids[0]);
+ if (!valid()) throw new RemoteResourceRegistryError('NOT_FOUND', 'Plugin not found');
+ const identity = deps.readIdentity(ids[1]);
+ if (!identity) throw new RemoteResourceRegistryError('NOT_FOUND', 'Plugin not found');
+ const icon = identity.iconDataUrl;
+ const blocks: RemoteResourceBlock[] = icon && icon.length <= 256_000 && /^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/.test(icon)
+ ? [{ id: 'icon', primitive: 'image', fallbackMarkdown: '', data: { url: icon } }] : [];
+ return { ref: request.ref, display: { title: identity.name }, links: [], blocks,
+ revision: createHash('sha256').update(JSON.stringify([identity.name, blocks])).digest('hex') };
+ },
+ };
+}
diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.ts
index fd9d96f6ae..adb4fd5178 100644
--- a/apps/desktop/src/main/cindy-brain/index.ts
+++ b/apps/desktop/src/main/cindy-brain/index.ts
@@ -1,3 +1,4 @@
+import { registerGhostCardRemoteProvider, persistGhostCardWithRemoteChange } from './cardRemoteResource.js';
import { getBotAuthorizationService } from '../maker-ipc/botAuthorizationService.js';
import { isResidentBrowserGhost, spawnResidentGhost } from './residentGhost.js';
import { handleRoutineRequest } from './routineSlot.js';
@@ -1811,7 +1812,7 @@ export function getGhostCardService(): GhostCardService {
return !!g && g.enabled && g.manifest.card !== undefined;
},
sanitize: sanitizeGhostCardHtml,
- persist: (row) => upsertGhostCard(row),
+ persist: persistGhostCardWithRemoteChange,
broadcast: (payload) => {
broadcastGhostWindowPush(GHOST_CARD_UPDATED_CHANNEL, payload);
},
@@ -6404,6 +6405,10 @@ function readLegacyEncryptedSecret(file: string): LegacyMigrationRead<string> {
}
export function registerGhostIpc(): void {
+ registerGhostCardRemoteProvider((id) => {
+ const ghost = availableGhosts().find((item) => item.manifest.id === id);
+ return ghost ? { name: ghost.manifest.name, iconDataUrl: ghost.iconDataUrl } : undefined;
+ });
if (ipcRegistered) return;
ipcRegistered = true;
const manager = getGhostManager();
diff --git a/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts b/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts
index 867156b01d..088d50946d 100644
--- a/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts
+++ b/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts
@@ -14,6 +14,11 @@ const tool = (toolName = 'Bash', input: unknown = { command: 'echo hello ' + 'x'
});
describe('mobile tool projection', () => {
+ it('retains bounded plugin call identity while compacting large arguments', () => {
+ const projected = projectMobileToolMessage(tool('mcp__cindy__ghost_call', { ghost_id: 'art', tool: 'generate', grant_only: false, args: { data: 'x'.repeat(40_000) } })) as ReturnType<typeof tool>;
+ expect(projected.content.input).toEqual({ ghost_id: 'art', tool: 'generate', grant_only: false });
+ expect(bytes(projected)).toBeLessThan(2000);
+ });
it('keeps stable identity and metadata, replacing a large input with a recoverable reference', () => {
const original = tool();
const projected = projectMobileToolMessage(original);
@@ -76,7 +81,7 @@ describe('mobile tool projection', () => {
_xdt_actions: { jobId: 'job', buttons: [{ label: 'U1', customId: 'u1' }] },
xdt_audio_tracks: [{ xdt_audio_url: 'cindy-media://blobs/a.mp3', title: 'track' }],
});
- expect(projectMobileToolResult(content)).toBe(content);
+ expect(new TextEncoder().encode(projectMobileToolResult(content) as string).byteLength).toBeLessThan(MOBILE_TOOL_RESULT_BYTES);
expect(extractPayloadToolResultMedia(projectMobileToolResult(content) as string)).toEqual(extractPayloadToolResultMedia(content));
for (const output of ['x'.repeat(9000) + '\nhttps://example.com/file.pdf',
'<tool_use_error>' + 'error'.repeat(9000) + '</tool_use_error>',
@@ -87,6 +92,44 @@ describe('mobile tool projection', () => {
}
});
+ it('preserves plugin fallback assets, nested card refs and summary after large provider output', () => {
+ const url = `cindy-media://blobs/${'a'.repeat(64)}.png`;
+ const content = JSON.stringify({ ok: true, result: { providerResponse: 'x'.repeat(50000), xdt_card_id: 'card', note: 'finished' }, xdt_media_produced: [url] });
+ const projected = projectMobileToolResult(content) as string;
+ expect(JSON.parse(projected)).toMatchObject({ xdt_card_id: 'card', note: 'finished', xdt_media_produced: [url] });
+ expect(new TextEncoder().encode(projected).byteLength).toBeLessThan(MOBILE_TOOL_RESULT_BYTES);
+ expect(extractPayloadToolResultMedia(projected)).toMatchObject([{ kind: 'image', url }]);
+ const row = { ...tool(), role: 'tool_result', content };
+ expect(projectMobileToolPush('local-db:messages:created', { message: row })).toEqual({ message: projectMobileMessagePage([row], {})[0] });
+ expect(row.content).toBe(content);
+ });
+
+ it('bounds serialized media, tracks, files and actions without cutting references', () => {
+ const image = (i: number) => `cindy-media://blobs/${i.toString(16).padStart(64, 'a')}.png`;
+ for (const refs of [
+ { xdt_image_urls: Array.from({ length: 3000 }, (_, i) => image(i)) },
+ { xdt_audio_tracks: Array.from({ length: 1000 }, () => ({ xdt_audio_url: 'xdt-audio://local?path=/tmp/a.mp3', title: '音乐'.repeat(150) })) },
+ { _xdt_model_files: Array.from({ length: 1000 }, (_, i) => ({ url: `xdt-file://open?path=/tmp/${i}.pdf`, name: '文档'.repeat(100) })) },
+ ]) {
+ const content = JSON.stringify({ ...refs, xdt_card_id: 'card',
+ _xdt_actions: { buttons: [{ label: 'x'.repeat(50_000) }] }, note: '😀'.repeat(10_000) });
+ const projected = projectMobileToolResult(content) as string;
+ expect(new TextEncoder().encode(projected).byteLength).toBeLessThanOrEqual(MOBILE_TOOL_RESULT_BYTES);
+ expect(JSON.parse(projected)).toMatchObject({ xdt_card_id: 'card', _remote_content_truncated: true });
+ expect(JSON.parse(projected)).not.toHaveProperty('_xdt_actions');
+ const values = Object.values(JSON.parse(projected)).filter(Array.isArray).flat();
+ expect(values.length).toBeGreaterThan(0);
+ expect(values.length).toBeLessThanOrEqual(64);
+ const row = { ...tool(), role: 'tool_result', content };
+ const pushed = projectMobileToolPush('local-db:messages:created', { message: row }) as { message: { content: string } };
+ expect(pushed.message.content).toBe(projected);
+ }
+ const suppressed = projectMobileToolResult(JSON.stringify({ _xdt_render_image: false,
+ xdt_image_urls: Array.from({ length: 1000 }, (_, i) => image(i)) })) as string;
+ expect(JSON.parse(suppressed)._xdt_render_image).toBe(false);
+ expect(extractPayloadToolResultMedia(suppressed)).toEqual([]);
+ });
+
it('removes duplicate result bodies while keeping correlation and failure flags', () => {
const fullText = 'output '.repeat(30_000);
const push = { sessionId: 's', persistId: 'p', resolvedContent: fullText,
diff --git a/apps/desktop/src/main/device-link/mobileToolProjection.ts b/apps/desktop/src/main/device-link/mobileToolProjection.ts
index e195b751b4..338aa55633 100644
--- a/apps/desktop/src/main/device-link/mobileToolProjection.ts
+++ b/apps/desktop/src/main/device-link/mobileToolProjection.ts
@@ -2,7 +2,9 @@ import { isAgentTaskToolName } from '@cindy/maker-shared/agent-task';
import { isAgentPlanToolName } from '@cindy/maker-shared/message-render';
import { isOrcaCommunicationTool } from '@cindy/maker-shared/message-normalize';
import {
- extractPayloadToolResultMedia,
+ extractPayloadToolResultFiles,
+ extractPayloadToolCardIds,
+ parseToolResultPayload,
formatPayloadToolUseSummary,
} from '@cindy/maker-shared/payload-summary';
@@ -36,18 +38,65 @@ function exceedsInputBudget(input: unknown): boolean {
}
}
-/** Preserve structured results and all media/file references until a typed detail projection
- * exists. Cutting JSON or a reference-bearing string would silently remove artifacts. */
+/** Compact large results without cutting presentation references or emitting invalid JSON. */
export function projectMobileToolResult(content: unknown): unknown {
if (typeof content !== 'string' || encoder.encode(content).byteLength <= MOBILE_TOOL_RESULT_BYTES) return content;
- // Keep structured media payloads intact because truncating them can drop an artifact
- // reference. Plain URLs, action markers, errors, and arbitrary JSON remain bounded.
+ // References take priority over the unrelated provider response. The final
+ // serialized JSON, including escaping and multibyte text, must fit the wire budget.
try {
- const parsed: unknown = JSON.parse(content);
- if (parsed !== null && typeof parsed === 'object' && extractPayloadToolResultMedia(content).length > 0) {
- return content;
+ const source = parseToolResultPayload(content) ?? {};
+ const files = extractPayloadToolResultFiles(content);
+ const referenceKeys = [
+ 'xdt_image_url', 'xdt_video_url', 'xdt_image_urls', 'xdt_video_urls',
+ 'xdt_audio_urls', 'xdt_audio_tracks', '_xdt_audio_tracks', 'xdt_media_produced',
+ ];
+ if (files.length || extractPayloadToolCardIds(content).length
+ || referenceKeys.some((key) => key in source) || source._xdt_render_image === false) {
+ const projected: Record<string, unknown> = { _remote_content_truncated: true };
+ const fits = () => encoder.encode(JSON.stringify(projected)).byteLength <= MOBILE_TOOL_RESULT_BYTES;
+ const add = (key: string, value: unknown) => {
+ // Keep addresses/objects intact or omit them; never slice a reference or action.
+ if (value === undefined || encoder.encode(JSON.stringify(value)).byteLength > 2048) return false;
+ projected[key] = value;
+ if (fits()) return true;
+ delete projected[key];
+ return false;
+ };
+ // Presentation control flags precede references so compaction cannot revive
+ // suppressed assets or images already owned by a card.
+ for (const key of ['_xdt_render_image', 'xdt_images_in_card', 'xdt_audio_in_card']) {
+ if (typeof source[key] === 'boolean') add(key, source[key]);
+ }
+ for (const key of ['xdt_card_id', 'xdt_anchor_card_id', 'xdt_image_url', 'xdt_video_url']) {
+ if (typeof source[key] === 'string') add(key, source[key]);
+ }
+ let remainingItems = 64;
+ const addArray = (key: string, entries: unknown[]) => {
+ const kept: unknown[] = [];
+ for (const entry of entries.slice(0, 64)) {
+ if (remainingItems === 0) break;
+ if (encoder.encode(JSON.stringify(entry)).byteLength > 2048) continue;
+ kept.push(entry);
+ projected[key] = kept;
+ if (!fits()) { kept.pop(); break; }
+ remainingItems -= 1;
+ }
+ if (!kept.length) delete projected[key];
+ };
+ for (const key of referenceKeys) {
+ if (Array.isArray(source[key])) addArray(key, source[key]);
+ }
+ if (files.length) addArray('_xdt_model_files', files.map((file) => ({ url: file.url, name: file.title })));
+ add('_xdt_actions', source._xdt_actions);
+ for (const key of ['ok', 'status', 'errorCode', 'summary', 'message', 'note', 'text']) {
+ const value = source[key];
+ if (typeof value === 'string') add(key, value.length > 1024 ? value.slice(0, 1024) + TRUNCATION_SUFFIX : value);
+ else if (typeof value === 'boolean' || typeof value === 'number') add(key, value);
+ }
+ const serialized = JSON.stringify(projected);
+ if (encoder.encode(serialized).byteLength <= MOBILE_TOOL_RESULT_BYTES) return serialized;
}
- } catch { /* Plain tool output is the only format shortened in this phase. */ }
+ } catch { /* Fall back to the bounded text preview. */ }
const bytes = encoder.encode(content);
let cut = MOBILE_TOOL_RESULT_BYTES - encoder.encode(TRUNCATION_SUFFIX).byteLength;
while (cut > 0 && (bytes[cut] & 0xc0) === 0x80) cut -= 1;
@@ -69,7 +118,8 @@ export function projectMobileToolMessage(message: unknown): unknown {
|| meta?.remoteContentTruncated === true || !exceedsInputBudget(content.input)) return message;
return {
...row,
- content: { ...content, input: null, mobilePayloadProjected: true },
+ content: { ...content, input: /(?:^|:|__)ghost_call$/.test(toolName)
+ ? pluginCallIdentity(content.input) : null, mobilePayloadProjected: true },
mobileToolInputProjection: {
projected: true,
version: 1,
@@ -145,3 +195,12 @@ export function projectMobileMessagePage(messages: unknown[], options: unknown):
} : row;
});
}
+
+
+function pluginCallIdentity(value: unknown): Record<string, unknown> {
+ const input = record(value);
+ return Object.fromEntries(['ghost_id', 'tool', 'grant_only'].flatMap((key) => {
+ const value = input?.[key];
+ return typeof value === 'boolean' || (typeof value === 'string' && value.length <= 256) ? [[key, value]] : [];
+ }));
+}
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index 5efd4462d8..36063afb8a 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -9314,6 +9314,8 @@ export default function SessionScreen() {
{showMessageHistory || showSyncingShell ? (
<ChatFilePathContext.Provider value={chatFilePathContextValue}>
<MessageRenderer
+ remoteDeviceId={deviceId}
+ showPluginInvocations={Boolean(currentSession && currentSession.source !== 'bot')}
bottomOverlayHeight={bottomOverlayHeight}
contentBottomInset={nativeComposerFrameAvailable && sessionOperationLayout.composerSlot === 'editable' && !shareSelectionActive
? MOBILE_MESSAGE_LIST_BOTTOM_PADDING
diff --git a/apps/mobile/src/__tests__/pluginAttachmentBubble.test.tsx b/apps/mobile/src/__tests__/pluginAttachmentBubble.test.tsx
new file mode 100644
index 0000000000..78fbbb3eaf
--- /dev/null
+++ b/apps/mobile/src/__tests__/pluginAttachmentBubble.test.tsx
@@ -0,0 +1,85 @@
+import { createElement, useState } from 'react';
+import { renderToStaticMarkup } from 'react-dom/server';
+import { describe, expect, it, vi } from 'vitest';
+
+// Keep the production list, bubble gate, invocation header, and message model.
+// Only native surfaces and unrelated heavy viewers are replaced for Node rendering.
+vi.mock('react-native', async () => {
+ const React = await import('react');
+ const view = ({ children, testID, accessibilityLabel }: any) => React.createElement('div', { 'data-testid': testID, 'aria-label': accessibilityLabel }, children);
+ class Value { constructor(public value: number) {} interpolate() { return 0; } setValue() {} }
+ return {
+ View: view, Text: view, Pressable: view, ScrollView: view, Modal: () => null,
+ Image: Object.assign(view, { getSize() {} }), ActivityIndicator: view,
+ Animated: { Value, View: view, Text: view, createAnimatedComponent: (c: any) => c },
+ Platform: { OS: 'ios', select: (s: any) => s.ios ?? s.default },
+ StyleSheet: { create: (s: any) => s, flatten: (s: any) => s, hairlineWidth: 1 },
+ Easing: { linear: (n: number) => n, bezier: () => (n: number) => n },
+ AccessibilityInfo: {}, Alert: {}, Linking: {}, StatusBar: {},
+ useWindowDimensions: () => ({ width: 402, height: 874, scale: 3, fontScale: 1 }),
+ };
+});
+vi.mock('@legendapp/list/react-native', () => ({
+ LegendList: ({ data, renderItem }: any) => data.map((item: any, index: number) => createElement('section', { key: item.key }, renderItem({ item, index }))),
+ useRecyclingState: (initial: any) => useState(initial), useViewability: () => {},
+}));
+vi.mock('lucide-react-native', () => ({
+ ArrowLeftRight: () => null, ArrowUp: () => null, Bot: () => null, Check: () => null, ChevronDown: () => null, ChevronRight: () => null, ChevronUp: () => null, Circle: () => null, CircleAlert: () => null, CircleCheck: () => null, CircleDashed: () => null, CircleStop: () => null, Copy: () => null, Ellipsis: () => null, ExternalLink: () => null, File: () => null, Ghost: () => null, Layers: () => null, ListTodo: () => null, LoaderCircle: () => null, PencilLine: () => null, RefreshCw: () => null, Send: () => null, Share: () => null, Sparkles: () => null, Split: () => null, Timer: () => null, Trash2: () => null, TriangleAlert: () => null, Undo2: () => null, X: () => null,
+}));
+vi.mock('react-native-svg', () => ({ default: () => null, Circle: () => null }));
+vi.mock('react-native-uitextview', () => ({ UITextView: () => null }));
+vi.mock('expo-image', () => ({ Image: () => null }));
+vi.mock('react-native-safe-area-context', () => ({ useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 }) }));
+vi.mock('@/theme', async () => {
+ const tokens = await import('@/theme/tokens');
+ const colors = new Proxy({}, { get: () => '#777777' });
+ return { ...tokens, monoFont: 'monospace', useTheme: () => ({ colors, mode: 'light' }), useThemedStyles: (make: any) => make(colors) };
+});
+vi.mock('@/components/AppText', async () => ({ Text: (await import('react-native')).Text, MAX_FONT_SIZE_MULTIPLIER: 2 }));
+vi.mock('@/auth/AuthContext', () => ({ useAuth: () => ({ accountGeneration: 1 }) }));
+vi.mock('@/session/usePluginResultCard', () => ({ usePluginResultCard: () => ({}), useSessionPluginResource: () => ({ title: 'Art' }) }));
+vi.mock('@/session/remoteMediaDiskCacheExpo', () => ({ downloadRemoteMediaShareTemp: vi.fn() }));
+vi.mock('@/hooks/useReduceMotion', () => ({ useReduceMotionEnabled: () => true }));
+vi.mock('@/platform/chrome', () => ({ NativePullDownMenu: () => null, showActionMenu: vi.fn(), usesNativePullDownMenu: () => false, usesSystemActionMenu: () => false }));
+vi.mock('@/session/MobileComposerInputRow', () => ({ MobileComposerInputRow: () => null, MOBILE_COMPOSER_VOICE_ANCHOR_RIGHT: 0, MOBILE_COMPOSER_CONTROL_SIZE: 44 }));
+vi.mock('@/session/ImageLightbox', () => ({ ImageLightbox: () => null }));
+vi.mock('@/session/mermaidWebView', () => ({ MermaidDiagram: () => null }));
+vi.mock('@/session/mathWebView', () => ({ MathFormulaWebView: () => null }));
+vi.mock('@/session/mediaPlayerWebView', () => ({ RemoteMediaPlayerWebView: () => null }));
+vi.mock('@/session/MarkdownBlockContent', () => ({ MarkdownBlockContent: () => null }));
+vi.mock('@/session/MessageActionSheet', () => ({ MessageActionSheet: () => null }));
+vi.mock('@/session/AuthorizationMessageCard', () => ({ AuthorizationMessageCard: () => null }));
+vi.mock('@/session/CompanionMessageCard', () => ({ CompanionMessageCard: () => null }));
+vi.mock('@/session/PendingSendBubble', () => ({ PendingSendBubble: () => null }));
+vi.mock('@/session/messageActions', async (original) => ({ ...await original<object>(), copyMessageText: vi.fn(), writeClipboardText: vi.fn() }));
+
+import { MessageRenderer } from '@/session/MessageRenderer';
+import { buildMobileMessageRenderItems } from '@/session/messageRenderModel';
+import type { RemoteMessage } from '@/session/types';
+const msg = (id: string, role: RemoteMessage['role'], content: unknown, extra: Partial<RemoteMessage> = {}): RemoteMessage => ({ id, clientId: id, sessionId: 's', role, content, toolUseId: null, agentMeta: null, createdAt: '2026-01-01T00:00:00Z', ...extra });
+
+function render(showPluginInvocations = true, settled = false, withCall = true, kind: 'file' | 'image' = 'file') {
+ const messages = [msg('u', 'user', JSON.stringify(kind === 'file' ? { text: '', files: [{ name: 'sample.txt', path: '/tmp/sample.txt' }] } : { text: '', images: [{ url: 'https://example.com/sample.png', originalName: 'sample.png', mimeType: 'image/png' }] }))];
+ if (withCall) messages.push(msg('c', 'tool_use', { toolName: 'mcp__cindy__ghost_call', toolUseId: 'c', input: { ghost_id: 'art', tool: 'generate' } }, { toolUseId: 'c' }));
+ if (settled) messages.push(msg('r', 'tool_result', 'done', { toolUseId: 'c' }));
+ const items = buildMobileMessageRenderItems(messages, { isSessionStreaming: true }).filter((item) => item.type === 'message');
+ expect(items[0]).toMatchObject({ message: { body: '', attachments: [{ kind }] } });
+ return renderToStaticMarkup(<MessageRenderer items={items} isSessionStreaming showPluginInvocations={showPluginInvocations} />);
+}
+
+describe('attachment-only user plugin bubble', () => {
+ it.each(['file', 'image'] as const)('renders a %s-only plugin header through completion', (kind) => {
+ for (const settled of [false, true]) {
+ const html = render(true, settled, true, kind);
+ expect(html).toContain('message.userBubble');
+ expect(html).toContain('Art');
+ expect(html).toContain(settled ? 'Called' : 'Calling…');
+ }
+ });
+ it('keeps partner attachment messages free of plugin shells', () => {
+ expect(render(false)).not.toContain('message.userBubble');
+ });
+ it('does not add an empty bubble to ordinary attachments', () => {
+ expect(render(true, false, false)).not.toContain('message.userBubble');
+ });
+});
diff --git a/apps/mobile/src/__tests__/pluginInvocations.test.ts b/apps/mobile/src/__tests__/pluginInvocations.test.ts
new file mode 100644
index 0000000000..0e969b164e
--- /dev/null
+++ b/apps/mobile/src/__tests__/pluginInvocations.test.ts
@@ -0,0 +1,57 @@
+import { describe, expect, it } from 'vitest';
+import { projectLargeSettledToolInputs } from '@/session/messageToolPayloadProjection';
+import { normalizeRemoteMessages } from '@/session/messageNormalize';
+import type { RemoteMessage } from '@/session/types';
+const msg = (id: string, role: RemoteMessage['role'], content: unknown, extra: Partial<RemoteMessage> = {}): RemoteMessage => ({
+ id, clientId: id, sessionId: 's', role, content, toolUseId: null, agentMeta: null, createdAt: '2026-01-01T00:00:00Z', ...extra,
+});
+const call = (id: string, name = 'mcp__cindy__ghost_call', input: unknown = { ghost_id: 'art', tool: 'generate' }) =>
+ msg(id, 'tool_use', { toolName: name, toolUseId: id, input }, { toolUseId: id });
+describe('plugin annotations on user messages', () => {
+ it('retains call identity when large arguments are released after completion', () => {
+ const source = [msg('u', 'user', 'Draw'), call('c', undefined, { ghost_id: 'art', tool: 'generate', args: { data: 'x'.repeat(40_000) } }), msg('r', 'tool_result', 'done', { toolUseId: 'c' })];
+ const projected = projectLargeSettledToolInputs(source);
+ expect(normalizeRemoteMessages(projected)[0].pluginInvocations).toEqual([{ id: 'art', name: 'art', tools: ['generate'], hasPendingCalls: false }]);
+ expect(JSON.stringify(projected)).not.toContain('x'.repeat(40_000));
+ });
+ it('uses actual calls and discovery names, deduplicates tools, and rebuilds from history', () => {
+ const rows = [msg('user', 'user', 'Draw a cat'), call('info', 'mcp__cindy__ghost_info', { ghost_id: 'art' }),
+ msg('result', 'tool_result', JSON.stringify({ content: [{ type: 'text', text: JSON.stringify({ ok: true, ghost: { id: 'art', name: 'Art' } }) }] }), { toolUseId: 'info' }),
+ call('c1'), call('c2')];
+ for (let i = 0; i < 2; i++) expect(normalizeRemoteMessages(rows)[0].pluginInvocations).toEqual([{ id: 'art', name: 'Art', tools: ['generate'], hasPendingCalls: true }]);
+ });
+ it('settles plugins independently while other calls and assistant output continue', () => {
+ const rows = [msg('u', 'user', 'Work'), call('a'),
+ call('b', undefined, { ghost_id: 'browser', tool: 'read' }),
+ // This result is adjacent to b, but belongs only to a.
+ msg('ra', 'tool_result', '', { toolUseId: 'a' }),
+ msg('text', 'assistant', 'Still working')];
+ const plugins = () => normalizeRemoteMessages(rows)[0].pluginInvocations;
+ expect(plugins()).toMatchObject([
+ { id: 'art', hasPendingCalls: false }, { id: 'browser', hasPendingCalls: true },
+ ]);
+ rows.push(call('a2'));
+ expect(plugins()?.[0].hasPendingCalls).toBe(true);
+ rows.push(msg('rb', 'tool_result', '{"ok":false}', { toolUseId: 'b' }),
+ msg('ra2', 'tool_result', 'done', { toolUseId: 'a2' }));
+ expect(plugins()?.map((plugin) => plugin.hasPendingCalls)).toEqual([false, false]);
+ });
+ it('keeps steers in their owner turn and never carries calls into the next question', () => {
+ const rows = normalizeRemoteMessages([msg('u1', 'user', 'art'), msg('steer', 'user', 'blue', { agentMeta: { delivery: 'steer' } }), call('c'), msg('u2', 'user', 'art')]);
+ expect(rows[0].pluginInvocations).toHaveLength(1);
+ expect(rows[1].pluginInvocations).toBeUndefined();
+ expect(rows[3].pluginInvocations).toBeUndefined();
+ });
+ it('ignores mentions, discovery-only, unrelated tools and attachment preauthorization', () => {
+ const rows = normalizeRemoteMessages([msg('u', 'user', 'Use Art'), call('i', 'mcp__cindy__ghost_info'), call('other', 'not_ghost_call'), call('grant', undefined, { ghost_id: 'art', grant_only: true })]);
+ expect(rows[0].pluginInvocations).toBeUndefined();
+ });
+ it('does not credit child-agent calls or hidden synthetic turns to a visible user', () => {
+ const rows = normalizeRemoteMessages([msg('u', 'user', 'Hello'), call('child', undefined, { ghost_id: 'child' }), msg('hidden', 'user', '[UI_ACTION_TRIGGER] continue'), call('c')].map((m) => m.id === 'child' ? { ...m, agentMeta: { parentUuid: 'parent' } } : m));
+ expect(rows[0].pluginInvocations).toBeUndefined();
+ });
+ it('falls back to an ID when old host discovery was truncated', () => {
+ const rows = normalizeRemoteMessages([msg('u', 'user', 'hello'), call('info', 'mcp__cindy__ghost_info', { ghost_id: 'art' }), msg('r', 'tool_result', '{"ok":true,', { toolUseId: 'info' }), call('c')]);
+ expect(rows[0].pluginInvocations?.[0].name).toBe('art');
+ });
+});
diff --git a/apps/mobile/src/__tests__/pluginResultRendering.test.ts b/apps/mobile/src/__tests__/pluginResultRendering.test.ts
new file mode 100644
index 0000000000..3877bd9af6
--- /dev/null
+++ b/apps/mobile/src/__tests__/pluginResultRendering.test.ts
@@ -0,0 +1,57 @@
+import { describe, expect, it } from 'vitest';
+import { buildMobileMessageRenderItems } from '@/session/messageRenderModel';
+import { getRemoteResource } from '@/device-link/remoteResources';
+import { normalizeRemoteMessages } from '@/session/messageNormalize';
+import type { RemoteMessage } from '@/session/types';
+const url = `cindy-media://blobs/${'a'.repeat(64)}.png`;
+function messages(content: unknown): RemoteMessage[] {
+ return [
+ { id: 'use', clientId: 'use', sessionId: 's', role: 'tool_use', toolUseId: 'u', content: { toolName: 'mcp__cindy__ghost_call', toolUseId: 'u', input: {} }, createdAt: '2026-01-01T00:00:00Z', agentMeta: null },
+ { id: 'result', clientId: 'result', sessionId: 's', role: 'tool_result', toolUseId: 'u', content: JSON.stringify(content), createdAt: '2026-01-01T00:00:01Z', agentMeta: null },
+ ];
+}
+describe('plugin results are visible outside collapsed tool details', () => {
+ it.each([true, false])('keeps partner authorization and delivered assets as independent visible rows (streaming=%s)', (isSessionStreaming) => {
+ const rows = messages({ ok: true, result: { xdt_image_url: url, xdt_card_id: 'card', _xdt_model_files: [{ url: url.replace('.png', '.glb') }] } });
+ const user: RemoteMessage = { ...rows[0], id: 'user', clientId: 'user', role: 'user', toolUseId: null, content: 'Draw a cat', createdAt: '2025-12-31T23:59:58Z' };
+ const authorization: RemoteMessage = { ...rows[0], id: 'auth', clientId: 'auth', role: 'assistant', toolUseId: null, content: '', createdAt: '2025-12-31T23:59:59Z', agentMeta: { botAuthorization: { v: 1, sessionId: 's', snapshot: { kind: 'plugin_setup', status: 'pending', ghostId: 'art' } } } };
+ const items = buildMobileMessageRenderItems([user, authorization, ...rows], { isSessionStreaming });
+ expect(items.some((item) => item.type === 'message' && item.message.authorization?.kind === 'plugin_setup')).toBe(true);
+ expect(items.some((item) => item.type === 'message' && item.message.kind === 'user' && item.message.body === 'Draw a cat')).toBe(true);
+ const deliveries = items.filter((item) => item.type === 'tool_media');
+ expect(deliveries).toHaveLength(1);
+ const normalized = normalizeRemoteMessages(rows).find((item) => item.kind === 'tool');
+ expect(normalized?.media).toHaveLength(1);
+ expect(normalized?.files).toHaveLength(1);
+ expect(normalized?.cardIds).toEqual(['card']);
+ });
+ it.each([
+ { ok: true, result: { xdt_image_url: url } },
+ { ok: true, xdt_media_produced: [url] },
+ { ok: true, result: { xdt_card_id: 'card' } },
+ { ok: true, result: { _xdt_model_files: [{ url: url.replace('.png', '.glb') }] } },
+ ])('preserves the result in the settled history render model: %j', (result) => {
+ const rows = buildMobileMessageRenderItems(messages(result), { isSessionStreaming: false });
+ expect(rows.some((row) => row.type === 'tool_media')).toBe(true);
+ });
+ it.each([true, false])('does not duplicate ledger images embedded in the reply (streaming=%s)', (isSessionStreaming) => {
+ const rows = messages({ ok: true, xdt_media_produced: [url] });
+ rows.push({ ...rows[1], id: 'reply', clientId: 'reply', role: 'assistant', toolUseId: null, content: `![result](${url})` });
+ expect(buildMobileMessageRenderItems(rows, { isSessionStreaming }).some((row) => row.type === 'tool_media')).toBe(false);
+ });
+ it('shows a referenced card only once within a user turn', () => {
+ const rows = messages({ ok: true, xdt_card_id: 'c' });
+ rows.push(...messages({ ok: true, xdt_anchor_card_id: 'c' }).map((row) => ({ ...row, id: row.id + '2', clientId: row.clientId + '2', toolUseId: 'u2', content: row.role === 'tool_use' ? { toolName: 'mcp__cindy__ghost_call', toolUseId: 'u2', input: {} } : row.content })));
+ expect(normalizeRemoteMessages(rows).flatMap((row) => row.cardIds ?? [])).toEqual(['c']);
+ });
+ it('decodes read-only resource blocks without forwarding arbitrary data or actions', async () => {
+ const ref = { collectionId: 'plugin-results', kind: 'card', id: '["s","c"]' };
+ const resource = await getRemoteResource(async () => ({ ref, display: { title: 'Art' }, revision: '1', links: [], actions: [{ id: 'delete' }], blocks: [
+ { id: 'text', primitive: 'markdown', fallbackMarkdown: 'Done' },
+ { id: 'image', primitive: 'image', fallbackMarkdown: url, data: { url, html: '<script/>', secret: 'do-not-forward' } },
+ ] }) as never, { deviceId: 'mac', deviceName: 'Mac' }, ref);
+ expect(resource.blocks?.[0].fallbackMarkdown).toBe('Done');
+ expect(resource.blocks?.[1].data).toEqual({ url });
+ expect(resource).not.toHaveProperty('actions');
+ });
+});
diff --git a/apps/mobile/src/__tests__/remoteMedia.test.ts b/apps/mobile/src/__tests__/remoteMedia.test.ts
index 3d51ccb61b..a2920a21ec 100644
--- a/apps/mobile/src/__tests__/remoteMedia.test.ts
+++ b/apps/mobile/src/__tests__/remoteMedia.test.ts
@@ -62,6 +62,14 @@ describe("mobile remote media", () => {
expect(presignGet).toHaveBeenCalledWith("cindy/device-link/user-1/a.png");
});
+ it("resolves a plugin file for export without treating it as a picture", async () => {
+ const fetchRemoteMedia = vi.fn(async () => ({ ossKey: "files/report.pdf", mimeType: "application/pdf", size: 100 }));
+ const presignGet = vi.fn(async () => ({ getUrl: "https://oss.example/report.pdf", expiresAt: "2026-10-01T00:00:00Z" }));
+ const result = await resolveMobileRemoteMedia({ kind: "file", url: "xdt-file://open?path=%2Ftmp%2Freport.pdf" }, { fetchRemoteMedia, presignGet });
+ expect(result).toMatchObject({ previewable: false, mimeType: "application/pdf", url: "https://oss.example/report.pdf" });
+ expect(fetchRemoteMedia).toHaveBeenCalledWith("xdt-file://open?path=%2Ftmp%2Freport.pdf", undefined);
+ });
+
it("hands the ossKey to onOssKey before presign, so a presign failure is still recoverable", async () => {
// presign 失败会让本函数在返回之前抛错 —— 调用方拿不到 resolved 结果,围绕它写的
// finally 不会执行,已上传的对象永久遗留(review P1)。onOssKey 让 key 在上传成功那一刻
diff --git a/apps/mobile/src/__tests__/usePluginResultCard.test.tsx b/apps/mobile/src/__tests__/usePluginResultCard.test.tsx
new file mode 100644
index 0000000000..45d27abe9e
--- /dev/null
+++ b/apps/mobile/src/__tests__/usePluginResultCard.test.tsx
@@ -0,0 +1,79 @@
+// @vitest-environment jsdom
+import { act, createElement } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+const h = vi.hoisted(() => ({
+ focused: true, get: vi.fn(), auth: { accountGeneration: 1 },
+ push: undefined as undefined | ((device: string, payload: any) => void),
+ foreground: undefined as undefined | ((state: string) => void),
+ appState: { currentState: 'active', addEventListener: vi.fn() },
+ link: { invoke: vi.fn(), connectionEpoch: 1, status: 'online', onRemoteResourceChanged: vi.fn(), subscribe: vi.fn(), unsubscribe: vi.fn() },
+}));
+vi.mock('expo-router', () => ({ useIsFocused: () => h.focused }));
+vi.mock('react-native', () => ({ AppState: h.appState }));
+vi.mock('@/auth/AuthContext', () => ({ useAuth: () => h.auth }));
+vi.mock('@/device-link/DeviceLinkContext', () => ({ useDeviceLink: () => h.link }));
+vi.mock('@/device-link/remoteResources', () => ({ getRemoteResource: h.get }));
+vi.mock('@/device-link/focusedTopicSubscription', () => ({ startFocusedTopicSubscription: () => () => {} }));
+import { usePluginResultCard } from '@/session/usePluginResultCard';
+Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
+let root: Root | undefined;
+let current: ReturnType<typeof usePluginResultCard>;
+function Probe({ device = 'mac', task = 's', card = 'c' }: { device?: string; task?: string; card?: string }) {
+ current = usePluginResultCard(device, task, card); return null;
+}
+async function render(props = {}) {
+ root ??= createRoot(document.createElement('div'));
+ await act(async () => { root!.render(createElement(Probe, props)); });
+}
+const result = (text: string) => ({ display: { title: 'Plugin' }, blocks: [{ id: 'text', primitive: 'markdown', fallbackMarkdown: text }] });
+beforeEach(() => {
+ vi.clearAllMocks(); h.focused = true; h.link.status = 'online'; h.auth.accountGeneration = 1; h.link.connectionEpoch = 1;
+ h.appState.currentState = 'active'; h.get.mockResolvedValue(result('done'));
+ h.link.onRemoteResourceChanged.mockImplementation((cb) => { h.push = cb; return () => { h.push = undefined; }; });
+ h.appState.addEventListener.mockImplementation((_event, cb) => { h.foreground = cb; return { remove() {} }; });
+});
+afterEach(() => { act(() => root?.unmount()); root = undefined; vi.useRealTimers(); });
+describe('plugin card lifecycle on Mobile', () => {
+ it('loads history and refreshes on card change, foreground and reconnect', async () => {
+ vi.useFakeTimers(); await render();
+ expect(current.blocks?.[0].fallbackMarkdown).toBe('done');
+ expect(h.get.mock.calls[0][2]).toEqual({ collectionId: 'plugin-results', kind: 'card', id: '["s","c"]' });
+ h.get.mockResolvedValue(result('updated'));
+ await act(async () => { h.push?.('other-device', { collectionId: 'plugin-results' }); await vi.advanceTimersByTimeAsync(250); });
+ expect(h.get).toHaveBeenCalledTimes(1);
+ await act(async () => { h.push?.('mac', { collectionId: 'plugin-results' }); await vi.advanceTimersByTimeAsync(250); });
+ expect(current.blocks?.[0].fallbackMarkdown).toBe('updated');
+ await act(async () => { h.foreground?.('active'); });
+ expect(h.get).toHaveBeenCalledTimes(3);
+ h.link.connectionEpoch += 1; await render(); expect(h.get).toHaveBeenCalledTimes(4);
+ });
+ it.each(['task', 'device', 'account'])('discards the previous %s response and clears its visible content', async (boundary) => {
+ let release!: (value: unknown) => void;
+ h.get.mockImplementationOnce(() => new Promise((resolve) => { release = resolve; }));
+ await render();
+ if (boundary === 'account') h.auth.accountGeneration += 1;
+ await render(boundary === 'task' ? { task: 'new' } : boundary === 'device' ? { device: 'new' } : {});
+ await act(async () => release(result('old private content')));
+ expect(current.blocks?.[0].fallbackMarkdown).toBe('done');
+ });
+ it('pauses while unfocused or offline and refreshes on return', async () => {
+ h.focused = false; await render(); expect(h.get).not.toHaveBeenCalled();
+ h.focused = true; h.link.status = 'offline'; await render();
+ expect(current.error).toBe(true); expect(h.get).not.toHaveBeenCalled();
+ h.link.status = 'online'; await render();
+ expect(current.blocks?.[0].fallbackMarkdown).toBe('done');
+ });
+ it('drops cached content when the host revokes access', async () => {
+ await render(); expect(current.blocks?.length).toBe(1);
+ h.get.mockRejectedValueOnce(Object.assign(new Error('unavailable'), { code: 'NOT_FOUND' }));
+ await act(async () => current.retry());
+ expect(current.blocks).toBeUndefined(); expect(current.error).toBe(true);
+ });
+ it('keeps failures visible and allows retry against an old or disconnected host', async () => {
+ h.get.mockRejectedValueOnce(new Error('NOT_FOUND'));
+ await render(); expect(current.error).toBe(true);
+ await act(async () => current.retry());
+ expect(current.error).toBe(false); expect(current.blocks?.[0].fallbackMarkdown).toBe('done');
+ });
+});
diff --git a/apps/mobile/src/device-link/remoteResources.ts b/apps/mobile/src/device-link/remoteResources.ts
index ae2467a013..4bded502c9 100644
--- a/apps/mobile/src/device-link/remoteResources.ts
+++ b/apps/mobile/src/device-link/remoteResources.ts
@@ -331,7 +331,20 @@ export async function getRemoteResource(
if (!normalized || normalized.ref.kind !== ref.kind || normalized.ref.id !== ref.id) {
throw new Error('invalid remote resource response');
}
- return normalized;
+ const source = recordOf(raw);
+ const blocks = Array.isArray(source?.blocks) ? source.blocks.slice(0, 256).flatMap((rawBlock) => {
+ const block = recordOf(rawBlock);
+ const id = boundedString(block?.id, 256);
+ const primitive = boundedString(block?.primitive, 64);
+ const fallbackMarkdown = typeof block?.fallbackMarkdown === 'string' ? block.fallbackMarkdown : null;
+ if (!id || !primitive || fallbackMarkdown === null || fallbackMarkdown.length > 131072) return [];
+ // Only the inert media URL primitive is needed here. Never copy arbitrary host data.
+ const data = recordOf(block?.data);
+ const inlineIcon = ref.collectionId === 'plugin-identities' && id === 'icon' && primitive === 'image';
+ const url = boundedString(data?.url, inlineIcon ? 256_000 : 4096);
+ return [{ id, primitive, fallbackMarkdown, ...(url ? { data: { url } } : {}) }];
+ }) : undefined;
+ return { ...normalized, ...(blocks ? { blocks } : {}) };
}
function normalizeRemoteCollectionItem(
diff --git a/apps/mobile/src/i18n/locales/en/message.json b/apps/mobile/src/i18n/locales/en/message.json
index 06ec8051b9..d540eba438 100644
--- a/apps/mobile/src/i18n/locales/en/message.json
+++ b/apps/mobile/src/i18n/locales/en/message.json
@@ -1,4 +1,13 @@
{
+ "pluginInvocation": {
+ "listSeparator": ", ",
+ "status": {
+ "running": "Calling…",
+ "called": "Called",
+ "done": "Finished",
+ "selected": "Selected"
+ }
+ },
"renderer": {
"moreActions": "More message actions",
"previousQuestionJump": "Jump to previous question: {{preview}}",
diff --git a/apps/mobile/src/i18n/locales/ja/message.json b/apps/mobile/src/i18n/locales/ja/message.json
index 9e3fff786d..54217dcbe0 100644
--- a/apps/mobile/src/i18n/locales/ja/message.json
+++ b/apps/mobile/src/i18n/locales/ja/message.json
@@ -1,4 +1,13 @@
{
+ "pluginInvocation": {
+ "listSeparator": "、",
+ "status": {
+ "running": "呼び出し中…",
+ "called": "呼び出し済み",
+ "done": "完了",
+ "selected": "選択済み"
+ }
+ },
"renderer": {
"moreActions": "その他のメッセージ操作",
"previousQuestionJump": "前の質問へ移動:{{preview}}",
diff --git a/apps/mobile/src/i18n/locales/ko/message.json b/apps/mobile/src/i18n/locales/ko/message.json
index e3bed8bf7b..91b7cd350b 100644
--- a/apps/mobile/src/i18n/locales/ko/message.json
+++ b/apps/mobile/src/i18n/locales/ko/message.json
@@ -1,4 +1,13 @@
{
+ "pluginInvocation": {
+ "listSeparator": ", ",
+ "status": {
+ "running": "호출 중…",
+ "called": "호출됨",
+ "done": "완료됨",
+ "selected": "선택됨"
+ }
+ },
"renderer": {
"moreActions": "추가 메시지 작업",
"previousQuestionJump": "이전 질문으로 이동: {{preview}}",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/message.json b/apps/mobile/src/i18n/locales/zh-CN/message.json
index 17530004f0..dd483675ef 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/message.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/message.json
@@ -1,4 +1,13 @@
{
+ "pluginInvocation": {
+ "listSeparator": "、",
+ "status": {
+ "running": "调用中…",
+ "called": "已调用",
+ "done": "已完成",
+ "selected": "已选择"
+ }
+ },
"renderer": {
"moreActions": "更多消息操作",
"previousQuestionJump": "跳到上一条提问:{{preview}}",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/message.json b/apps/mobile/src/i18n/locales/zh-TW/message.json
index b2fa972a1b..dac9dea733 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/message.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/message.json
@@ -1,4 +1,13 @@
{
+ "pluginInvocation": {
+ "listSeparator": "、",
+ "status": {
+ "running": "呼叫中…",
+ "called": "已呼叫",
+ "done": "已完成",
+ "selected": "已選取"
+ }
+ },
"renderer": {
"moreActions": "更多訊息操作",
"previousQuestionJump": "跳到上一條提問:{{preview}}",
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index 504e24a270..72cc327dc5 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -1,3 +1,8 @@
+import { PluginInvocationHeader } from './PluginInvocationHeader';
+import { useAuth } from '@/auth/AuthContext';
+import { downloadRemoteMediaShareTemp } from './remoteMediaDiskCacheExpo';
+import { usePluginResultCard } from './usePluginResultCard';
+import { extractPayloadToolResultMedia, managedToolMediaKind } from '@cindy/maker-shared/payload-summary';
import { AuthorizationMessageCard } from './AuthorizationMessageCard';
import { CompanionMessageCard } from '@/session/CompanionMessageCard';
import { mobileDebugEnabled, mobileDebugLog } from '@/debug/mobileDebugLog';
@@ -606,6 +611,10 @@ export interface ShareableMessageViewport {
}
interface MessageActions {
+ /** Partner chats keep the user's bubble plain; result and authorization cards remain independent. */
+ showPluginInvocations?: boolean;
+ /** Device hosting plugin results; independent of a filesystem workdir. */
+ remoteDeviceId?: string;
/** 长按/操作条「复制消息链接」:复制该消息的会话深链(带 ?message= 锚点)。 */
onCopyMessageLink?: (clientId: string) => void;
/** Insert this message's anchored link as an atom in the active composer. */
@@ -655,6 +664,8 @@ interface MessageActions {
}
export function MessageRenderer({
+ showPluginInvocations = true,
+ remoteDeviceId,
topOverlayHeight,
focusedItemKey,
followLatestRequestKey,
@@ -1555,6 +1566,8 @@ export function MessageRenderer({
if (shareSelectionActiveRef.current) scheduleStickyShareCheckRef.current?.(true);
}, []);
const actions: MessageActions & { firstUserMessageClientId?: string } = useMemo(() => ({
+ showPluginInvocations,
+ remoteDeviceId,
onAddMessageToComposer,
onCopyMessageLink,
onForkMessage,
@@ -1584,6 +1597,8 @@ export function MessageRenderer({
isSessionStreaming,
screenWidth: viewportLayout.contentWidth,
}), [
+ showPluginInvocations,
+ remoteDeviceId,
busyClientId,
busyAction,
continuationInFlightProjectionCapability,
@@ -3260,8 +3275,10 @@ function MessageBubble({
onResolveRemoteMedia={actions.onResolveRemoteMedia}
/>
) : null;
+ const hasPluginInvocations = isUser && actions.showPluginInvocations !== false
+ && Boolean(item.message.pluginInvocations?.length);
const hasBubbleContent = !!(
- item.message.systemCardType || displayBubbleBody || item.message.secondaryBody
+ item.message.systemCardType || displayBubbleBody || item.message.secondaryBody || hasPluginInvocations
);
// 气泡是纯 View,不承接任何手势:文本选择走正文原生 Text selectable(长按文字就地选择复制),
// 气泡上不能挂 Pressable——它会参与触摸协商,干扰正文里表格/代码块横向 ScrollView 的拖动。
@@ -3276,6 +3293,15 @@ function MessageBubble({
]}
testID={isUser ? 'message.userBubble' : 'message.agentBubble'}
>
+ {hasPluginInvocations ? (
+ <PluginInvocationHeader
+ key={clientId}
+ plugins={item.message.pluginInvocations!}
+ deviceId={actions.remoteDeviceId}
+ sessionId={item.message.source.sessionId}
+ running={actions.isSessionStreaming === true && clientId === actions.lastUserInputClientId}
+ />
+ ) : null}
{hookSource ? (
<View style={styles.hookSourceHeader} testID="message.hookSource">
<Send color={colors.textSecondary} size={iconSize.xs} strokeWidth={iconStroke.regular} />
@@ -5892,12 +5918,18 @@ function ToolMediaBlock({
[item.tools],
);
const openPayload = actions.onOpenPayload;
- if (media.length === 0) return null;
+ const files = [...new Map(item.tools.flatMap((tool) => tool.files ?? []).map((file) => [file.url, file])).values()];
+ const cards = [...new Map(item.tools.flatMap((tool) => (tool.cardIds ?? []).map((callId) => ({ callId, sessionId: tool.source.sessionId }))).map((card) => [card.callId, card])).values()];
+ if (media.length === 0 && files.length === 0 && cards.length === 0) return null;
return (
<View
style={[styles.toolMediaBlock, { gap: contentLayout.attachmentGap }]}
testID="message.toolMediaBlock"
>
+ {cards.map((card) => <PluginResultCard key={card.callId} {...card} actions={actions}
+ excludedUrls={[...item.tools.flatMap((tool) => extractPayloadToolResultMedia(tool.secondaryBody ?? '').map((entry) => entry.url)), ...files.map((file) => file.url)]} />)}
+ {files.map((file) => <FileChip key={file.url} name={file.title} path={file.url} layout={contentLayout}
+ onOpen={openPayload ? () => openPayload(buildFilePayload(file.title, file.url)) : undefined} />)}
{media.map((entry, index) => (
<MediaPreview
key={`${entry.kind}:${entry.url}:${index}`}
@@ -5915,6 +5947,41 @@ function ToolMediaBlock({
);
}
+/** Read-only fallback for desktop plugin cards. Reuse native text/media/file
+ * components rather than executing plugin HTML or pretending its buttons work. */
+function PluginResultCard({ callId, sessionId, excludedUrls, actions }: {
+ callId: string; sessionId: string; excludedUrls: string[]; actions: MessageActions;
+}) {
+ const { blocks, error, retry } = usePluginResultCard(actions.remoteDeviceId, sessionId, callId);
+ const layout = buildMessageContentLayout({ screenWidth: actions.screenWidth });
+ const styles = useThemedStyles(makeStyles);
+ const { t } = useTranslation();
+ return <View style={styles.toolMediaBlock} testID="message.pluginResultCard">
+ {blocks?.map((block) => {
+ const url = (block.data as { url?: unknown } | undefined)?.url;
+ const kind = managedToolMediaKind(url);
+ if (typeof url === 'string' && excludedUrls.includes(url)) return null;
+ if (kind && typeof url === 'string') {
+ const media = { kind, url, previewable: false };
+ return <MediaPreview key={block.id} label={mediaLabel(media)} layout={layout} media={media}
+ onOpen={actions.onOpenPayload ? () => actions.onOpenPayload!(buildMediaPayload(media, mediaLabel(media))) : undefined}
+ onResolveRemoteMedia={actions.onResolveRemoteMedia} variant={kind === 'image' ? 'attachment' : 'card'} />;
+ }
+ if (block.primitive === 'file' && typeof url === 'string' && /^cindy-media:\/\/blobs\/[0-9a-f]{64}\.glb$/.test(url)) {
+ const name = url.split('/').pop()!;
+ return <FileChip key={block.id} name={name} path={url} layout={layout}
+ onOpen={actions.onOpenPayload ? () => actions.onOpenPayload!(buildFilePayload(name, url)) : undefined} />;
+ }
+ return <MarkdownBody key={block.id} text={block.fallbackMarkdown} layout={layout} streaming={false} selectable
+ onOpenPayload={actions.onOpenPayload} onOpenSessionLink={actions.onOpenSessionLink} />;
+ })}
+ {!blocks && !error ? <Text style={styles.detailText}>{t('message.renderer.loading')}</Text> : null}
+ {error ? <MessageContentOpenButton onPress={retry} accessibilityLabel={t('message.renderer.retryPreview')}>
+ <Text style={styles.detailText}>{t('message.renderer.retryPreview')}</Text>
+ </MessageContentOpenButton> : null}
+ </View>;
+}
+
/**
* 附件图原图尺寸的模块级缓存(键 = 源 media.url,跨 presign 刷新稳定)。
* FlatList 虚拟化反复 unmount/remount MediaPreview,组件态存不住尺寸;
@@ -6934,6 +7001,7 @@ function MessagePayloadBody({
if (payload.kind === 'file') {
return (
<FilePayloadBody
+ onResolveRemoteMedia={onResolveRemoteMedia}
layout={payloadLayout}
onReadTextFilePreview={onReadTextFilePreview}
payload={payload}
@@ -7152,10 +7220,12 @@ function DiffPayloadPane({
}
function FilePayloadBody({
+ onResolveRemoteMedia,
layout,
payload,
onReadTextFilePreview,
}: {
+ onResolveRemoteMedia?: ResolveRemoteMediaFn;
layout: PayloadBodyLayout;
payload: Extract<MessagePayload, { kind: 'file' }>;
onReadTextFilePreview?: (filePath: string) => Promise<RemoteTextFilePreviewResult>;
@@ -7164,6 +7234,40 @@ function FilePayloadBody({
const { t, i18n: i18nInstance } = useTranslation();
const styles = useThemedStyles(makeStyles);
const sourcePath = payload.sourcePath ?? '';
+ const { accountGeneration } = useAuth();
+ const fileContext = useContext(ChatFilePathContext);
+ const [exporting, setExporting] = useState(false);
+ const exportIdentity = JSON.stringify([accountGeneration, fileContext?.deviceId, fileContext?.sessionId, sourcePath]);
+ const exportCurrent = useRef(exportIdentity); exportCurrent.current = exportIdentity;
+ const exportBusy = useRef(false);
+ const exportGeneration = useRef(0);
+ useLayoutEffect(() => {
+ exportCurrent.current = exportIdentity;
+ exportGeneration.current += 1;
+ exportBusy.current = false;
+ setExporting(false);
+ return () => { exportGeneration.current += 1; exportCurrent.current = ''; };
+ }, [exportIdentity, onResolveRemoteMedia]);
+ const exportFile = async () => {
+ if (!onResolveRemoteMedia || exportBusy.current) return;
+ const identity = exportIdentity;
+ const generation = exportGeneration.current;
+ const valid = () => exportCurrent.current === identity && exportGeneration.current === generation;
+ exportBusy.current = true; setExporting(true);
+ try {
+ const resolved = await onResolveRemoteMedia({ kind: 'file', url: sourcePath, previewable: false }, { front: true });
+ if (!valid()) return;
+ const localUri = resolved.url.startsWith('file://') ? resolved.url : await downloadRemoteMediaShareTemp(resolved.url, resolved.mimeType, payload.title);
+ if (!valid()) return;
+ if (!localUri) throw new Error('download failed');
+ const sharing = await import('expo-sharing');
+ if (valid()) await sharing.shareAsync(localUri, { mimeType: resolved.mimeType });
+ } catch {
+ if (valid()) Alert.alert(t('files.browser.shareFailed'));
+ } finally {
+ if (valid()) { exportBusy.current = false; setExporting(false); }
+ }
+ };
const bodyPresentation = useMemo(
() => summarizeMessagePayloadBody(payload),
[i18nInstance.language, payload],
@@ -7188,6 +7292,10 @@ function FilePayloadBody({
{textPreviewStatusText(previewState, canPreview, previewKind)}
</Text>
<PayloadPathActions layout={layout} path={sourcePath}>
+ {onResolveRemoteMedia && isDesktopLocalMediaUrl(sourcePath) ? <PayloadActionButton
+ accessibilityLabel={t('files.browser.exportShare')} label={t(exporting ? 'files.browser.exporting' : 'files.browser.exportShare')}
+ layout={layout} disabled={exporting} onPress={() => { void exportFile(); }} testID="message.fileExportButton" /> : null}
+
{canPreview && previewState.status !== 'ready' ? (
<PayloadActionButton
accessibilityLabel={t('message.renderer.loadRemoteTextPreview')}
diff --git a/apps/mobile/src/session/PluginInvocationHeader.tsx b/apps/mobile/src/session/PluginInvocationHeader.tsx
new file mode 100644
index 0000000000..dc9a94814a
--- /dev/null
+++ b/apps/mobile/src/session/PluginInvocationHeader.tsx
@@ -0,0 +1,86 @@
+import { useEffect, useRef } from 'react';
+import { Animated, Easing, Image, Pressable, StyleSheet, View } from 'react-native';
+import { useRecyclingState } from '@legendapp/list/react-native';
+import { Check, ChevronDown, ChevronUp, Ghost } from 'lucide-react-native';
+import Svg, { Circle } from 'react-native-svg';
+import { Text } from '@/components/AppText';
+import { useTranslation } from 'react-i18next';
+import { useReduceMotionEnabled } from '@/hooks/useReduceMotion';
+import { iconSize, iconStroke, radius, lineHeight, spacing, typeScale, useTheme } from '@/theme';
+import { useSessionPluginResource } from './usePluginResultCard';
+import type { PluginInvocation } from './pluginInvocations';
+
+// Registered summon-seal cycle: DESIGN §14.4, identical to Desktop.
+const SUMMON_CYCLE_MS = 2400;
+
+export function PluginInvocationHeader({ plugins, running, deviceId, sessionId }: {
+ plugins: readonly PluginInvocation[]; running: boolean; deviceId?: string; sessionId: string;
+}) {
+ return <View>{plugins.map((plugin) => <PluginInvocationRow key={plugin.id} plugin={plugin} running={running && plugin.hasPendingCalls} deviceId={deviceId} sessionId={sessionId} />)}</View>;
+}
+
+function PluginInvocationRow({ plugin, running, deviceId, sessionId }: {
+ plugin: PluginInvocation; running: boolean; deviceId?: string; sessionId: string;
+}) {
+ const identity = useSessionPluginResource(deviceId, sessionId, plugin.id, 'plugin-identities', 'plugin');
+ const name = identity.title || plugin.name;
+ const icon = (identity.blocks?.find((block) => block.id === 'icon')?.data as { url?: unknown } | undefined)?.url;
+ const iconUrl = typeof icon === 'string' && icon.length <= 256_000 && /^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/.test(icon) ? icon : undefined;
+ const { colors } = useTheme();
+ const { t } = useTranslation();
+ const [expanded, setExpanded] = useRecyclingState(false);
+ const reduced = useReduceMotionEnabled();
+ const rotation = useRef(new Animated.Value(0)).current;
+ useEffect(() => {
+ if (!running || reduced !== false) { rotation.setValue(0); return; }
+ const animation = Animated.loop(Animated.timing(rotation, {
+ toValue: 1, duration: SUMMON_CYCLE_MS, easing: Easing.linear,
+ useNativeDriver: true, isInteraction: false,
+ }));
+ animation.start();
+ return () => { animation.stop(); rotation.setValue(0); };
+ }, [running, reduced, rotation]);
+ const state = t(running ? 'message.pluginInvocation.status.running' : 'message.pluginInvocation.status.called');
+ return <View style={[styles.container, { borderBottomColor: colors.border }]}>
+ <Pressable accessibilityRole="button" accessibilityState={{ expanded }}
+ accessibilityLabel={`${name} · ${state}`}
+ onPress={() => setExpanded(!expanded)} style={styles.header}>
+ <View style={styles.seal}>
+ <Animated.View pointerEvents="none" style={[StyleSheet.absoluteFill, {
+ transform: [{ rotate: rotation.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '360deg'] }) }],
+ }]}>
+ <Svg width={28} height={28} viewBox="0 0 28 28">
+ <Circle cx={14} cy={14} r={13} fill="none" stroke={colors.textTertiary} strokeWidth={iconStroke.thin}
+ strokeDasharray={running ? '68 14' : undefined} />
+ <Circle cx={14} cy={14} r={10.5} fill="none" stroke={colors.textTertiary} strokeWidth={iconStroke.thin}
+ strokeDasharray={running ? '26 40' : undefined} />
+ </Svg>
+ </Animated.View>
+ <View>{iconUrl ? <Image source={{ uri: iconUrl }} style={{ width: 18, height: 18, borderRadius: radius.pill }} /> : <Ghost size={iconSize.sm} color={colors.textSecondary} />}</View>
+ {!running && <View style={[styles.check, { backgroundColor: colors.statusDone }]}>
+ <Check size={iconSize.xs} color={colors.surface} strokeWidth={iconStroke.regular} />
+ </View>}
+ </View>
+ <Text style={[styles.name, { color: colors.textSecondary }]}>{name}</Text>
+ <Text style={[styles.status, { color: colors.textTertiary }]}>{state}</Text>
+ {expanded ? <ChevronUp size={iconSize.sm} color={colors.textTertiary} /> : <ChevronDown size={iconSize.sm} color={colors.textTertiary} />}
+ </Pressable>
+ {expanded && <View style={styles.details}>
+ <Text selectable
+ style={[styles.detail, { color: colors.textSecondary }]}>
+ {`${name}\n${plugin.tools.join(' · ')}`}
+ </Text>
+ </View>}
+ </View>;
+}
+
+const styles = StyleSheet.create({
+ container: { borderBottomWidth: StyleSheet.hairlineWidth, marginBottom: spacing.sm, paddingBottom: spacing.xs },
+ header: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, minHeight: 44 },
+ seal: { width: 28, height: 28, justifyContent: 'center', alignItems: 'center' },
+ check: { position: 'absolute', right: -1, bottom: -1, width: 12, height: 12, borderRadius: radius.pill, alignItems: 'center', justifyContent: 'center' },
+ name: { flexShrink: 1, fontSize: typeScale.caption, lineHeight: lineHeight.caption },
+ status: { fontSize: typeScale.caption, lineHeight: lineHeight.caption },
+ details: { gap: spacing.sm, paddingVertical: spacing.sm },
+ detail: { fontSize: typeScale.caption, lineHeight: lineHeight.caption },
+});
diff --git a/apps/mobile/src/session/messageNormalize.ts b/apps/mobile/src/session/messageNormalize.ts
index 418cb7ee57..d5ed3faf16 100644
--- a/apps/mobile/src/session/messageNormalize.ts
+++ b/apps/mobile/src/session/messageNormalize.ts
@@ -1,3 +1,5 @@
+import { collectPluginInvocations, type PluginInvocation } from './pluginInvocations';
+import { extractPayloadToolResultFiles, extractPayloadToolCardIds, type PayloadToolFile } from '@cindy/maker-shared/payload-summary';
import { placeBotTaskCardsAfterIntroduction, readBotCollaborationMeta, type BotCollaborationMeta } from '@cindy/maker-shared/botCollaboration';
import { readBotDirectMessageMeta, type BotDirectMessageMeta } from '@cindy/maker-shared/botDirectMessage';
import type { RemoteMessage, RemoteMessageRole } from '@/session/types';
@@ -87,6 +89,9 @@ export interface NormalizedRemoteMessage {
/** user 专用:目标桌面落库的引用范围摘要,不含被引用消息正文。 */
sessionReferences?: MobilePersistedSessionReferenceMetadata[];
media?: NormalizedToolMedia[];
+ files?: PayloadToolFile[];
+ cardIds?: string[];
+ pluginInvocations?: PluginInvocation[];
diff?: NormalizedToolDiff;
align: 'user' | 'agent';
createdAt: string;
@@ -280,6 +285,8 @@ export function normalizeRemoteMessages(
body: tool.summary,
secondaryBody,
media: extractToolResultMedia(secondaryBody ?? ''),
+ files: extractPayloadToolResultFiles(secondaryBody ?? ''),
+ cardIds: extractPayloadToolCardIds(secondaryBody ?? ''),
diff: tool.diff,
align: 'agent',
createdAt: message.createdAt,
@@ -499,6 +506,12 @@ export function normalizeRemoteMessages(
});
}
+ const pluginInvocations = collectPluginInvocations(sorted, toolResultPairing);
+ for (const row of result) {
+ if (row.kind === 'user' && !row.isSyntheticTrigger && !row.hookSource && !row.automationOrigin) {
+ row.pluginInvocations = pluginInvocations.get(row.source.clientId || row.source.id);
+ }
+ }
dedupeToolImagesAgainstAssistantMarkdown(result);
return result;
}
@@ -517,10 +530,15 @@ function dedupeToolImagesAgainstAssistantMarkdown(
if (message.kind !== 'assistant') continue;
for (const image of collectMobileMarkdownImages(message.body)) inlineUrls.add(image.url);
}
- if (inlineUrls.size === 0) return;
+ const cards = new Set<string>();
for (const message of messages.slice(lo, hi)) {
- if (message.kind !== 'tool' || !message.media?.length) continue;
- message.media = message.media.filter(
+ if (message.kind !== 'tool') continue;
+ message.cardIds = message.cardIds?.filter((id) => {
+ if (cards.has(id)) return false;
+ cards.add(id);
+ return true;
+ });
+ message.media = message.media?.filter(
(item) => item.kind !== 'image' || !inlineUrls.has(item.url),
);
}
diff --git a/apps/mobile/src/session/messageToolPayloadProjection.ts b/apps/mobile/src/session/messageToolPayloadProjection.ts
index 2cf56d1757..13cb480b01 100644
--- a/apps/mobile/src/session/messageToolPayloadProjection.ts
+++ b/apps/mobile/src/session/messageToolPayloadProjection.ts
@@ -88,7 +88,11 @@ export function projectLargeSettledToolInputs(
return {
...message,
content: {
- input: null,
+ input: /(?:^|:|__)ghost_call$/.test(tool.toolName) && tool.input && typeof tool.input === 'object'
+ ? Object.fromEntries(['ghost_id', 'tool', 'grant_only'].flatMap((key) => {
+ const value = (tool.input as Record<string, unknown>)[key];
+ return typeof value === 'boolean' || (typeof value === 'string' && value.length <= 256) ? [[key, value]] : [];
+ })) : null,
mobilePayloadProjected: true,
toolName: tool.toolName,
toolUseId: tool.toolUseId,
diff --git a/apps/mobile/src/session/pluginInvocations.ts b/apps/mobile/src/session/pluginInvocations.ts
new file mode 100644
index 0000000000..3b4e382704
--- /dev/null
+++ b/apps/mobile/src/session/pluginInvocations.ts
@@ -0,0 +1,81 @@
+import { parseMessageToolUse, type MessageToolResultPairing } from '@cindy/maker-shared/message-normalize';
+import type { RemoteMessage } from './types';
+
+export interface PluginInvocation {
+ id: string;
+ name: string;
+ tools: string[];
+ hasPendingCalls: boolean;
+}
+
+const record = (value: unknown): Record<string, unknown> | undefined =>
+ value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : undefined;
+const text = (value: unknown) => typeof value === 'string' && value.length <= 256 ? value : undefined;
+
+/** Read only the documented MCP text envelope, never arbitrary nested plugin data. */
+function infoName(raw: string | undefined, id: string): string | undefined {
+ if (!raw) return;
+ try {
+ let value: unknown = JSON.parse(raw);
+ for (let depth = 0; depth < 3; depth++) {
+ const obj = record(value);
+ const ghost = record(obj?.ghost);
+ if (obj?.ok === true && ghost?.id === id) return text(ghost.name);
+ const content = obj?.content;
+ if (!Array.isArray(content) || content.length !== 1) return;
+ const block = record(content[0]);
+ if (block?.type !== 'text' || typeof block.text !== 'string') return;
+ value = JSON.parse(block.text);
+ }
+ } catch {
+ // Old hosts truncate discovery after the identity prefix. Only accept that
+ // exact envelope prefix, and decode each complete JSON string independently.
+ const prefix = /^\s*\{\s*"ok"\s*:\s*true\s*,\s*"ghost"\s*:\s*\{\s*"id"\s*:\s*("(?:[^"\\]|\\.)*")\s*,\s*"name"\s*:\s*("(?:[^"\\]|\\.)*")/.exec(raw);
+ if (prefix) {
+ try { if (JSON.parse(prefix[1]) === id) return text(JSON.parse(prefix[2])); } catch { /* malformed */ }
+ }
+ }
+}
+
+/** Derive annotations from actual calls, not words in user prose. Steers stay in their owner turn. */
+export function collectPluginInvocations(
+ messages: readonly RemoteMessage[], pairing: MessageToolResultPairing<RemoteMessage>,
+): Map<string, PluginInvocation[]> {
+ const names = new Map<string, string>();
+ for (const message of messages) {
+ if (message.role !== 'tool_use') continue;
+ const tool = parseMessageToolUse(message);
+ const id = text(record(tool.input)?.ghost_id);
+ if (!id || !/(?:^|:|__)ghost_info$/.test(tool.toolName)) continue;
+ const raw = pairing.resultContentFor(message, tool);
+ const name = infoName(raw, id);
+ if (name) names.set(id, name);
+ }
+ const turns = new Map<string, PluginInvocation[]>();
+ let owner: string | undefined;
+ for (const message of messages) {
+ if (message.role === 'user' && message.agentMeta?.delivery !== 'steer') {
+ owner = message.clientId || message.id;
+ continue;
+ }
+ if (!owner || message.role !== 'tool_use' || message.agentMeta?.parentUuid) continue;
+ const tool = parseMessageToolUse(message);
+ if (!/(?:^|:|__)ghost_call$/.test(tool.toolName)) continue;
+ const input = record(tool.input);
+ const id = text(input?.ghost_id);
+ if (!id || input?.grant_only === true) continue;
+ const calls = turns.get(owner) ?? [];
+ let plugin = calls.find((call) => call.id === id);
+ if (!plugin) { plugin = { id, name: names.get(id) ?? id, tools: [], hasPendingCalls: false }; calls.push(plugin); }
+ // Known IDs must pair exactly: an adjacent result may belong to another
+ // concurrent plugin. Legacy ID-less calls retain the existing pairing fallback.
+ const settled = tool.toolUseId
+ ? pairing.resultByToolUseId.has(tool.toolUseId)
+ : pairing.hasResultFor(message, tool);
+ plugin.hasPendingCalls ||= !settled;
+ const name = text(input?.tool);
+ if (name && !plugin.tools.includes(name)) plugin.tools.push(name);
+ turns.set(owner, calls);
+ }
+ return turns;
+}
diff --git a/apps/mobile/src/session/remoteMedia.ts b/apps/mobile/src/session/remoteMedia.ts
index a73afde479..8857714ce1 100644
--- a/apps/mobile/src/session/remoteMedia.ts
+++ b/apps/mobile/src/session/remoteMedia.ts
@@ -83,7 +83,8 @@ export const REMOTE_MEDIA_NEVER_EXPIRES = "9999-12-31T00:00:00.000Z";
* 按不同键隔离,查看器取原图不会命中缩略图缓存。
*/
export type ResolveRemoteMediaFn = (
- media: Pick<NormalizedToolMedia, "kind" | "url" | "previewable"> & {
+ media: Pick<NormalizedToolMedia, "url" | "previewable"> & {
+ kind: NormalizedToolMedia["kind"] | "file";
thumbnail?: boolean;
},
opts?: {
@@ -106,7 +107,7 @@ export function isDirectPreviewableMediaUrl(url: unknown): url is string {
}
export function canPreviewResolvedRemoteMedia(
- kind: NormalizedToolMedia["kind"],
+ kind: NormalizedToolMedia["kind"] | "file",
mimeType: string,
): boolean {
if (kind === "image") return mimeType.startsWith("image/");
@@ -158,7 +159,7 @@ export function isResolvedRemoteMediaFresh(
}
export async function resolveMobileRemoteMedia(
- media: Pick<NormalizedToolMedia, "kind" | "url">,
+ media: { kind: NormalizedToolMedia["kind"] | "file"; url: string },
deps: MobileRemoteMediaResolverDeps,
opts?: MobileRemoteMediaResolveOptions,
): Promise<MobileResolvedRemoteMedia> {
diff --git a/apps/mobile/src/session/remoteMediaResolveQueue.ts b/apps/mobile/src/session/remoteMediaResolveQueue.ts
index 93d5c4021f..718ea900d5 100644
--- a/apps/mobile/src/session/remoteMediaResolveQueue.ts
+++ b/apps/mobile/src/session/remoteMediaResolveQueue.ts
@@ -24,7 +24,7 @@ import {
} from '@/session/remoteMedia';
export interface RemoteMediaRequest {
- kind: 'image' | 'video' | 'audio';
+ kind: 'image' | 'video' | 'audio' | 'file';
url: string;
/** 只要缩略图(被控端缩 1024px webp);与原图取件在队列/缓存层按不同键隔离。 */
thumbnail?: boolean;
diff --git a/apps/mobile/src/session/usePluginResultCard.ts b/apps/mobile/src/session/usePluginResultCard.ts
new file mode 100644
index 0000000000..11d2021dfa
--- /dev/null
+++ b/apps/mobile/src/session/usePluginResultCard.ts
@@ -0,0 +1,57 @@
+import { useCallback, useEffect, useId, useRef, useState } from 'react';
+import { useIsFocused } from 'expo-router';
+import { AppState } from 'react-native';
+import type { RemoteResourceBlock } from '@cindy/device-link';
+import { useAuth } from '@/auth/AuthContext';
+import { useDeviceLink } from '@/device-link/DeviceLinkContext';
+import { getRemoteResource } from '@/device-link/remoteResources';
+import { startFocusedTopicSubscription } from '@/device-link/focusedTopicSubscription';
+
+/** A card is a read-only remote resource, scoped to account + device + task.
+ * Refresh after foreground/reconnect and host invalidation; stale replies cannot
+ * replace a recycled row or another account's card. */
+export function usePluginResultCard(deviceId: string | undefined, sessionId: string, callId: string) {
+ return useSessionPluginResource(deviceId, sessionId, callId, 'plugin-results', 'card');
+}
+
+export function useSessionPluginResource(deviceId: string | undefined, sessionId: string, callId: string, collectionId: string, kind: string) {
+ const { invoke, connectionEpoch, status, onRemoteResourceChanged, subscribe, unsubscribe } = useDeviceLink();
+ const { accountGeneration } = useAuth();
+ const focused = useIsFocused();
+ const subscriberId = useId();
+ const [attempt, setAttempt] = useState(0);
+ const [state, setState] = useState<{ binding: string; blocks?: RemoteResourceBlock[]; title?: string; error?: boolean }>();
+ const binding = JSON.stringify([accountGeneration, deviceId, sessionId, callId, collectionId, kind]);
+ const current = useRef(binding); current.current = binding;
+ const retry = useCallback(() => setAttempt((value) => value + 1), []);
+ useEffect(() => {
+ if (!deviceId || !focused || status !== 'online') return;
+ let disposed = false;
+ let generation = 0;
+ let timer: ReturnType<typeof setTimeout> | undefined;
+ const id = JSON.stringify([sessionId, callId]);
+ const load = async () => {
+ if (AppState.currentState !== 'active') return;
+ const expected = ++generation;
+ const valid = () => !disposed && current.current === binding && generation === expected && AppState.currentState === 'active';
+ try {
+ const resource = await getRemoteResource(invoke, { deviceId, deviceName: deviceId }, { collectionId, kind, id });
+ if (valid()) setState({ binding, blocks: resource.blocks ?? [], title: typeof resource.display.title === 'string' ? resource.display.title : resource.display.title.fallback, error: kind === 'card' && !resource.blocks?.length });
+ } catch (error) {
+ const code = error && typeof error === 'object' ? (error as { code?: unknown }).code : undefined;
+ const unavailable = /NOT_FOUND|FORBIDDEN|UNAUTHORIZED/.test(String(code ?? '') + String(error));
+ if (valid()) setState((previous) => ({ binding, ...(!unavailable && previous?.binding === binding ? { blocks: previous.blocks, title: previous.title } : {}), error: true }));
+ }
+ };
+ const offPush = onRemoteResourceChanged((source, payload) => {
+ if (source !== deviceId || payload.collectionId !== collectionId) return;
+ if (payload.resourceRefs?.length && !payload.resourceRefs.some((ref) => ref.kind === kind && ref.id === id)) return;
+ if (!timer) timer = setTimeout(() => { timer = undefined; void load(); }, 200);
+ });
+ const offTopic = startFocusedTopicSubscription({ deviceId, owner: `${collectionId}:${id}:${subscriberId}`, topic: 'sessions', subscribe, unsubscribe });
+ const listener = AppState.addEventListener('change', (next) => { generation += 1; if (next === 'active') void load(); });
+ void load();
+ return () => { disposed = true; generation += 1; offPush(); offTopic(); listener.remove(); if (timer) clearTimeout(timer); };
+ }, [subscriberId, focused, binding, deviceId, sessionId, callId, collectionId, kind, attempt, connectionEpoch, status, invoke, onRemoteResourceChanged, subscribe, unsubscribe]);
+ return { title: state?.binding === binding ? state.title : undefined, blocks: state?.binding === binding ? state.blocks : undefined, error: !deviceId || status !== 'online' || (state?.binding === binding && state.error), retry };
+}
diff --git a/docs/design-rules/design-inventory.md b/docs/design-rules/design-inventory.md
index 7fbd74483d..bdbaf90127 100644
--- a/docs/design-rules/design-inventory.md
+++ b/docs/design-rules/design-inventory.md
@@ -55,7 +55,7 @@
| `mobile.auth` | mobile | 登录与添加账号 | app/(auth)/login.tsx / app/add-account.tsx | AccountSwitcherSheet, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, HomeEntryProvider, IncomingShareBridge, LoginCaptchaWebView, LoginSkinControls, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeRemoteDesktopView, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, SheetModal, SheetSurface, StartupSplashOverlay, ThemeProvider, _layout, add-account, gestureHandler, login, peerFileTransport, useLocale | apps/mobile/app/(auth)/login.tsx, apps/mobile/app/_layout.tsx, apps/mobile/app/add-account.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/LoginCaptchaWebView.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/LoginSkinControls.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 177 | 75 |
| `mobile.automations` | mobile | 自动化 | app/automations/[deviceId].tsx | AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, HomeEntryProvider, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeRemoteDesktopView, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/automations/[deviceId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 170 | 70 |
| `mobile.chat.new` | mobile | 新建任务 | app/sessions/new.tsx | AndroidUpdateSheet, AnnotationBurnInWebView, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerAttachmentTray, ComposerFrame, ComposerFrame.ios, ComposerKeyboardAvoidingView, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ContextSheetGoalView, ContextSheetGoalView.ios, ContextSheetMediaViews, DeviceLinkContext, HomeEntryProvider, HomeNativeStackHeader, ImageLightbox, IncomingShareBridge, MobileAgentMark, MobileAgentSwitcher, MobileChoicePickerList, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobileModelPickerList.ios, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, MobileVendorIcon, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeSwitch, NewTaskSelectionSheet, NewTaskSelectionSheet.ios, PaperPlaneIcon, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PushNotificationsBridge, QuietSyncIndicator, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, ThemeProvider, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, VoiceRecordingPill, _layout, gestureHandler, new, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/new.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileVendorIcon.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerFrame.ios.tsx, apps/mobile/src/session/ComposerFrame.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ComposerNativeRow.ios.tsx, apps/mobile/src/session/ComposerNativeRow.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/ContextSheetGoalView.ios.tsx, apps/mobile/src/session/ContextSheetGoalView.tsx, apps/mobile/src/session/ContextSheetMediaViews.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileAgentSwitcher.tsx, apps/mobile/src/session/MobileChoicePickerList.tsx, apps/mobile/src/session/MobileComposerInputRow.tsx, apps/mobile/src/session/MobileModelPickerList.ios.tsx, apps/mobile/src/session/MobileModelPickerList.tsx, apps/mobile/src/session/MobilePermissionPickerList.ios.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.ios.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerNativeHeader.ios.tsx, apps/mobile/src/session/ModelPickerNativeHeader.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/NativePermissionSheet.ios.tsx, apps/mobile/src/session/NativePermissionSheet.tsx, apps/mobile/src/session/NewTaskSelectionSheet.ios.tsx, apps/mobile/src/session/NewTaskSelectionSheet.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/UnifiedModelPickerSheet.tsx, apps/mobile/src/session/UnifiedModelPickerView.ios.tsx, apps/mobile/src/session/UnifiedModelPickerView.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 202 | 109 |
-| `mobile.chat.session` | mobile | 任务内容与输入 | app/sessions/[sessionId].tsx | AndroidUpdateSheet, AnnotationBurnInWebView, AppText, AuthContext, AuthorizationMessageCard, BlurBackdrop, CenteredScreen, ChatFileChipMenuSheet, CompanionMessageCard, ComposerAttachmentTray, ComposerExpandButton, ComposerExpandButton.ios, ComposerFrame, ComposerFrame.ios, ComposerKeyboardAvoidingView, ComposerNativeInput, ComposerNativeInput.ios, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerRichInput, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ContextSheetGoalView, ContextSheetGoalView.ios, ContextSheetMediaViews, ConversationSearchFilterSheet, ConversationShareSvg, ConversationShareWebView, DeviceLinkContext, FailedScheduleNotice, HomeEntryProvider, HomeGlassMenuPanel, HomeNativeStackHeader, HomeSearchBar, ImageLightbox, IncomingShareBridge, InlineQueueSection, InlineQuoteChip, InlineReferenceChip, InteractionPanel, MarkdownBlockContent, MessageActionSheet, MessageRenderer, MobileAgentMark, MobileAgentSwitcher, MobileBoundaryNotice, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobileModelPickerList.ios, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeSwitch, PaperPlaneIcon, PendingSendBubble, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PushNotificationsBridge, QuietSyncIndicator, QuoteCapsule, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RewindPreviewPanel, SentInlineAtomBody, SessionDetailsNative, SessionDetailsNative.ios, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionListDrawer, SessionMenuSheet, SessionSearchNative, SessionSearchNative.ios, SessionTailBanner, SessionUsageSummary, ShareImageNativeButton, ShareImageNativeButton.ios, ShareMessageCheckbox, ShareSelectAllButton, ShareSelectionBar, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, StreamingStatusText, ThemeProvider, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, VoiceRecordingPill, [sessionId], _layout, gestureHandler, mathWebView, mediaPlayerWebView, mermaidWebView, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/[sessionId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/AuthorizationMessageCard.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ChatFileChipMenuSheet.tsx, apps/mobile/src/session/CompanionMessageCard.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerExpandButton.ios.tsx, apps/mobile/src/session/ComposerExpandButton.tsx, apps/mobile/src/session/ComposerFrame.ios.tsx, apps/mobile/src/session/ComposerFrame.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ComposerNativeInput.ios.tsx, apps/mobile/src/session/ComposerNativeInput.tsx, apps/mobile/src/session/ComposerNativeRow.ios.tsx, apps/mobile/src/session/ComposerNativeRow.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerRichInput.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/ContextSheetGoalView.ios.tsx, apps/mobile/src/session/ContextSheetGoalView.tsx, apps/mobile/src/session/ContextSheetMediaViews.tsx, apps/mobile/src/session/ConversationSearchFilterSheet.tsx, apps/mobile/src/session/ConversationShareSvg.tsx, apps/mobile/src/session/ConversationShareWebView.tsx, apps/mobile/src/session/FailedScheduleNotice.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/InlineQueueSection.tsx, apps/mobile/src/session/InlineQuoteChip.tsx, apps/mobile/src/session/InlineReferenceChip.tsx, apps/mobile/src/session/InteractionPanel.tsx, apps/mobile/src/session/MarkdownBlockContent.tsx, apps/mobile/src/session/MessageActionSheet.tsx, apps/mobile/src/session/MessageRenderer.tsx, apps/mobile/src/session/MobileAgentSwitcher.tsx, apps/mobile/src/session/MobileBoundaryNotice.tsx, apps/mobile/src/session/MobileComposerInputRow.tsx, apps/mobile/src/session/MobileModelPickerList.ios.tsx, apps/mobile/src/session/MobileModelPickerList.tsx, apps/mobile/src/session/MobilePermissionPickerList.ios.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.ios.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerNativeHeader.ios.tsx, apps/mobile/src/session/ModelPickerNativeHeader.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/NativePermissionSheet.ios.tsx, apps/mobile/src/session/NativePermissionSheet.tsx, apps/mobile/src/session/PendingSendBubble.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/QuoteCapsule.tsx, apps/mobile/src/session/RewindPreviewPanel.tsx, apps/mobile/src/session/SentInlineAtomBody.tsx, apps/mobile/src/session/SessionDetailsNative.ios.tsx, apps/mobile/src/session/SessionDetailsNative.tsx, apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx, apps/mobile/src/session/SessionHeaderNativeControls.tsx, apps/mobile/src/session/SessionListDrawer.tsx, apps/mobile/src/session/SessionMenuSheet.tsx, apps/mobile/src/session/SessionSearchNative.ios.tsx, apps/mobile/src/session/SessionSearchNative.tsx, apps/mobile/src/session/SessionTailBanner.tsx, apps/mobile/src/session/SessionUsageSummary.tsx, apps/mobile/src/session/ShareImageNativeButton.ios.tsx, apps/mobile/src/session/ShareImageNativeButton.tsx, apps/mobile/src/session/ShareMessageCheckbox.tsx, apps/mobile/src/session/ShareSelectAllButton.tsx, apps/mobile/src/session/ShareSelectionBar.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/StreamingStatusText.tsx, apps/mobile/src/session/UnifiedModelPickerSheet.tsx, apps/mobile/src/session/UnifiedModelPickerView.ios.tsx, apps/mobile/src/session/UnifiedModelPickerView.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/session/composerRichInputHtml.ts, apps/mobile/src/session/conversationShareWebViewHtml.ts, apps/mobile/src/session/mathWebView.tsx, apps/mobile/src/session/mathWebViewHtml.ts, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.ts, apps/mobile/src/session/mermaidWebView.tsx, apps/mobile/src/session/mermaidWebViewHtml.ts, apps/mobile/src/session/selectableMarkdownHtml.ts, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 7 | 203 | 228 |
+| `mobile.chat.session` | mobile | 任务内容与输入 | app/sessions/[sessionId].tsx | AndroidUpdateSheet, AnnotationBurnInWebView, AppText, AuthContext, AuthorizationMessageCard, BlurBackdrop, CenteredScreen, ChatFileChipMenuSheet, CompanionMessageCard, ComposerAttachmentTray, ComposerExpandButton, ComposerExpandButton.ios, ComposerFrame, ComposerFrame.ios, ComposerKeyboardAvoidingView, ComposerNativeInput, ComposerNativeInput.ios, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerRichInput, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ContextSheetGoalView, ContextSheetGoalView.ios, ContextSheetMediaViews, ConversationSearchFilterSheet, ConversationShareSvg, ConversationShareWebView, DeviceLinkContext, FailedScheduleNotice, HomeEntryProvider, HomeGlassMenuPanel, HomeNativeStackHeader, HomeSearchBar, ImageLightbox, IncomingShareBridge, InlineQueueSection, InlineQuoteChip, InlineReferenceChip, InteractionPanel, MarkdownBlockContent, MessageActionSheet, MessageRenderer, MobileAgentMark, MobileAgentSwitcher, MobileBoundaryNotice, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobileModelPickerList.ios, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeSwitch, PaperPlaneIcon, PendingSendBubble, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PluginInvocationHeader, PushNotificationsBridge, QuietSyncIndicator, QuoteCapsule, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RewindPreviewPanel, SentInlineAtomBody, SessionDetailsNative, SessionDetailsNative.ios, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionListDrawer, SessionMenuSheet, SessionSearchNative, SessionSearchNative.ios, SessionTailBanner, SessionUsageSummary, ShareImageNativeButton, ShareImageNativeButton.ios, ShareMessageCheckbox, ShareSelectAllButton, ShareSelectionBar, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, StreamingStatusText, ThemeProvider, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, VoiceRecordingPill, [sessionId], _layout, gestureHandler, mathWebView, mediaPlayerWebView, mermaidWebView, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/[sessionId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/AuthorizationMessageCard.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ChatFileChipMenuSheet.tsx, apps/mobile/src/session/CompanionMessageCard.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerExpandButton.ios.tsx, apps/mobile/src/session/ComposerExpandButton.tsx, apps/mobile/src/session/ComposerFrame.ios.tsx, apps/mobile/src/session/ComposerFrame.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ComposerNativeInput.ios.tsx, apps/mobile/src/session/ComposerNativeInput.tsx, apps/mobile/src/session/ComposerNativeRow.ios.tsx, apps/mobile/src/session/ComposerNativeRow.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerRichInput.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/ContextSheetGoalView.ios.tsx, apps/mobile/src/session/ContextSheetGoalView.tsx, apps/mobile/src/session/ContextSheetMediaViews.tsx, apps/mobile/src/session/ConversationSearchFilterSheet.tsx, apps/mobile/src/session/ConversationShareSvg.tsx, apps/mobile/src/session/ConversationShareWebView.tsx, apps/mobile/src/session/FailedScheduleNotice.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/InlineQueueSection.tsx, apps/mobile/src/session/InlineQuoteChip.tsx, apps/mobile/src/session/InlineReferenceChip.tsx, apps/mobile/src/session/InteractionPanel.tsx, apps/mobile/src/session/MarkdownBlockContent.tsx, apps/mobile/src/session/MessageActionSheet.tsx, apps/mobile/src/session/MessageRenderer.tsx, apps/mobile/src/session/MobileAgentSwitcher.tsx, apps/mobile/src/session/MobileBoundaryNotice.tsx, apps/mobile/src/session/MobileComposerInputRow.tsx, apps/mobile/src/session/MobileModelPickerList.ios.tsx, apps/mobile/src/session/MobileModelPickerList.tsx, apps/mobile/src/session/MobilePermissionPickerList.ios.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.ios.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerNativeHeader.ios.tsx, apps/mobile/src/session/ModelPickerNativeHeader.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/NativePermissionSheet.ios.tsx, apps/mobile/src/session/NativePermissionSheet.tsx, apps/mobile/src/session/PendingSendBubble.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/PluginInvocationHeader.tsx, apps/mobile/src/session/QuoteCapsule.tsx, apps/mobile/src/session/RewindPreviewPanel.tsx, apps/mobile/src/session/SentInlineAtomBody.tsx, apps/mobile/src/session/SessionDetailsNative.ios.tsx, apps/mobile/src/session/SessionDetailsNative.tsx, apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx, apps/mobile/src/session/SessionHeaderNativeControls.tsx, apps/mobile/src/session/SessionListDrawer.tsx, apps/mobile/src/session/SessionMenuSheet.tsx, apps/mobile/src/session/SessionSearchNative.ios.tsx, apps/mobile/src/session/SessionSearchNative.tsx, apps/mobile/src/session/SessionTailBanner.tsx, apps/mobile/src/session/SessionUsageSummary.tsx, apps/mobile/src/session/ShareImageNativeButton.ios.tsx, apps/mobile/src/session/ShareImageNativeButton.tsx, apps/mobile/src/session/ShareMessageCheckbox.tsx, apps/mobile/src/session/ShareSelectAllButton.tsx, apps/mobile/src/session/ShareSelectionBar.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/StreamingStatusText.tsx, apps/mobile/src/session/UnifiedModelPickerSheet.tsx, apps/mobile/src/session/UnifiedModelPickerView.ios.tsx, apps/mobile/src/session/UnifiedModelPickerView.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/session/composerRichInputHtml.ts, apps/mobile/src/session/conversationShareWebViewHtml.ts, apps/mobile/src/session/mathWebView.tsx, apps/mobile/src/session/mathWebViewHtml.ts, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.ts, apps/mobile/src/session/mermaidWebView.tsx, apps/mobile/src/session/mermaidWebViewHtml.ts, apps/mobile/src/session/selectableMarkdownHtml.ts, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 7 | 203 | 230 |
| `mobile.companions.direct` | mobile | 伙伴私聊回看 | app/companions/direct/[threadId].tsx | AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, HomeEntryProvider, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeRemoteDesktopView, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [threadId], _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/companions/direct/[threadId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 170 | 49 |
| `mobile.device-management` | mobile | 设备管理 | app/devices/manage.tsx / app/devices/manage/[deviceId].tsx | AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceInformationFields, DeviceInformationFields.ios, DeviceLinkContext, DeviceManagementDialogs, DeviceManagementList, DeviceManagementList.ios, HomeEntryProvider, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeRemoteDesktopView, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RenameDeviceModal, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, manage, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/manage.tsx, apps/mobile/app/devices/manage/[deviceId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceInformationFields.ios.tsx, apps/mobile/src/device-link/DeviceInformationFields.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/DeviceManagementDialogs.tsx, apps/mobile/src/device-link/DeviceManagementList.ios.tsx, apps/mobile/src/device-link/DeviceManagementList.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/RenameDeviceModal.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 170 | 52 |
| `mobile.devices` | mobile | 主机详情 | app/devices/[deviceId].tsx | AccountSwitcherSheet, AndroidUpdateSheet, AppText, AuthContext, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ConversationSearchFilterSheet, DeviceLinkContext, HomeChromeDrawer, HomeChromeFrost, HomeEntryProvider, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeNativeStackHeader, HomeProjectMachineLabel, HomeSearchBar, IncomingShareBridge, MobileAgentMark, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, MobileVendorIcon, NativePullDownMenu, NativeRemoteDesktopView, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RemoteAccessGuide, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteTaskSuggestions, RenameSessionModal, SessionActionSheet, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionOptionsExpoSheet, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, SwipeableSessionRow, SwipeableSessionRow.ios, ThemeProvider, [deviceId], _layout, gestureHandler, index, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/[deviceId].tsx, apps/mobile/app/devices/index.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileVendorIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/RemoteAccessGuide.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/AutomationTimerIcon.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/ConversationSearchFilterSheet.tsx, apps/mobile/src/session/HomeChromeDrawer.tsx, apps/mobile/src/session/HomeChromeFrost.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/SessionActionSheet.tsx, apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx, apps/mobile/src/session/SessionHeaderNativeControls.tsx, apps/mobile/src/session/SessionOptionsExpoSheet.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SwipeableSessionRow.ios.tsx, apps/mobile/src/session/SwipeableSessionRow.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 170 | 95 |
diff --git a/packages/cindy-tools/src/__tests__/ghostMcp.test.ts b/packages/cindy-tools/src/__tests__/ghostMcp.test.ts
index 0e459a1565..0c7517f2a9 100644
--- a/packages/cindy-tools/src/__tests__/ghostMcp.test.ts
+++ b/packages/cindy-tools/src/__tests__/ghostMcp.test.ts
@@ -2041,3 +2041,22 @@ describe('Cindy market MCP transport', () => {
} finally { await client.close(); await server.close(); }
});
});
+
+
+describe("portable legacy plugin media", () => {
+ it("hoists singular image/video and audio arrays without claiming cards were delivered", async () => {
+ const payload = parsePayload(await handleGhostCall(fakeDeps({ callGhostTool: async () => ({ ok: true, result: {
+ xdt_image_url: "cindy-media://blobs/a.png", xdt_video_url: "cindy-media://blobs/a.mp4", xdt_audio_urls: ["cindy-media://blobs/a.mp3"],
+ } }) }), { ghost_id: "legacy", tool: "create" }));
+ expect(payload.xdt_image_url).toBe("cindy-media://blobs/a.png");
+ expect(payload.xdt_video_url).toBe("cindy-media://blobs/a.mp4");
+ expect(payload.xdt_audio_urls).toEqual(["cindy-media://blobs/a.mp3"]);
+ });
+ it("does not claim delivered media for a card-only or ledger-only result", async () => {
+ for (const result of [{ ok: true as const, result: { xdt_card_id: "c" } }, { ok: true as const, result: {}, producedMedia: ["cindy-media://blobs/a.png"] }]) {
+ const payload = parsePayload(await handleGhostCall(fakeDeps({ callGhostTool: async () => result }), { ghost_id: "art", tool: "create" }));
+ expect(payload.hint).not.toContain("已自动送达");
+ expect(payload.hint).not.toContain("媒体已由聊天气泡自动渲染");
+ }
+ });
+});
diff --git a/packages/cindy-tools/src/ghost/mcpServer.ts b/packages/cindy-tools/src/ghost/mcpServer.ts
index b07f65eff6..cd2c9240ea 100644
--- a/packages/cindy-tools/src/ghost/mcpServer.ts
+++ b/packages/cindy-tools/src/ghost/mcpServer.ts
@@ -773,7 +773,7 @@ export async function handleGhostManual(
* xdt_image_urls / xdt_video_urls;意识工具把媒体地址放在自己的 result 对象里,
* 这里提升到顶层(仅白名单字段、仅字符串数组,其余一概不动)。
*/
-const MEDIA_HOIST_KEYS = ["xdt_image_urls", "xdt_video_urls"] as const;
+const MEDIA_HOIST_KEYS = ["xdt_image_urls", "xdt_video_urls", "xdt_audio_urls"] as const;
/**
* 音频轨白名单字段(对象数组;与 xdt_image_urls 同规则上提到顶层)。
@@ -847,6 +847,11 @@ function hoistMediaFields(result: unknown): Record<string, unknown> {
out[key] = value;
}
}
+ for (const key of ["xdt_image_url", "xdt_video_url"] as const) {
+ const value = (result as Record<string, unknown>)[key];
+ if (typeof value === "string" && (result as Record<string, unknown>).xdt_media_inline !== true) out[key] = value;
+ }
+ if ((result as Record<string, unknown>)._xdt_render_image === false) out._xdt_render_image = false;
const audioTracks = sanitizeAudioTracks(
(result as Record<string, unknown>)[AUDIO_TRACKS_HOIST_KEY],
);
@@ -948,8 +953,11 @@ export async function handleGhostCall(
const setup = sanitizeGhostSetupAssessment(unsafeSetup);
const advisory = setup?.state === "ready" && setup.reauthSuggest ? { setup } : {};
const declaredMedia = [
+ "xdt_image_url",
"xdt_image_urls",
+ "xdt_video_url",
"xdt_video_urls",
+ "xdt_audio_urls",
"xdt_audio_tracks",
].some((k) => k in hoisted);
const producedFallback =
@@ -972,7 +980,7 @@ export async function handleGhostCall(
// - 内联语义(xdt_media_inline):桌面不画卡、不自动显示,模型必须 markdown
// 内联否则桌面用户什么都看不到。
const mediaHint =
- Object.keys(hoisted).length > 0
+ declaredMedia && hoisted._xdt_render_image !== false
? {
hint: "媒体已由聊天气泡自动渲染成卡片,不要在回复文本里用 markdown(![](…))重复嵌入这些地址;后续改图引用返回的 hash 指纹即可。xdt_card_id / xdt_anchor_card_id 是渲染层的配对令牌,忽略即可,不要复述。",
}
@@ -982,9 +990,11 @@ export async function handleGhostCall(
hint: "这些媒体已入库但桌面聊天不会自动显示——请在最终回复的 markdown 里用 ![](地址) 把图按内容对应位置嵌入展示(原样使用返回里的 xdt_image_url / cindy-media:// 地址,不要自己拼);IM/远程场景由主机按 xdt_media_produced 自动送达,无需复述该字段。不要口播下载过程。",
}
: {
- hint: "xdt_media_produced 是主机记账的送达通道:这些媒体已自动送达用户(桌面/IM),不要在回复文本里用 markdown 嵌入这些地址,也不要复述它们。",
+ hint: "xdt_media_produced 是主机记账的产物地址,不代表当前客户端已展示。请在最终回复中使用这些受管地址展示产物一次;不要只说已送达。",
}
- : {};
+ : typeof hoisted.xdt_card_id === "string" || typeof hoisted.xdt_anchor_card_id === "string"
+ ? { hint: "xdt_card_id / xdt_anchor_card_id 是卡片配对令牌,不代表所有客户端已经展示。请在最终回复中概括实际结果,不要复述令牌。" }
+ : {};
return textResult({
...resultForModel,
...advisory,
diff --git a/packages/maker-shared/src/__tests__/pluginResults.test.ts b/packages/maker-shared/src/__tests__/pluginResults.test.ts
new file mode 100644
index 0000000000..9eae75f524
--- /dev/null
+++ b/packages/maker-shared/src/__tests__/pluginResults.test.ts
@@ -0,0 +1,32 @@
+import { describe, it, expect } from 'vitest';
+import { extractPayloadToolResultMedia as media, extractPayloadToolResultFiles as files, extractPayloadToolCardIds as cards } from '../payloadSummary.js';
+import { hasVisibleHistoryResult } from '../historyViewProjection.js';
+const blob = (ext: string) => `cindy-media://blobs/${'a'.repeat(64)}.${ext}`;
+
+describe('portable plugin results', () => {
+ it('reads host ledger images, video and audio and deduplicates declarations', () => {
+ const result = JSON.stringify({ xdt_image_urls: [blob('png')], xdt_media_produced: [blob('png'), blob('mp4'), blob('mp3'), blob('glb'), 'file:///secret.png', 'https://external/p.png', 'cindy-media://other/p.png'] });
+ expect(media(result).map(({ kind, url }) => [kind, url])).toEqual([['image', blob('png')], ['video', blob('mp4')], ['audio', blob('mp3')]]);
+ expect(files(result)).toEqual([{ url: blob('glb'), title: `${'a'.repeat(64)}.glb` }]);
+ expect(hasVisibleHistoryResult(result)).toBe(true);
+ });
+ it('reads the old ghost envelope, including singular fields and card anchors', () => {
+ const result = JSON.stringify({ ok: true, result: { xdt_image_url: blob('png'), xdt_video_url: blob('mp4'), xdt_card_id: 'c', xdt_anchor_card_id: 'c' } });
+ expect(media(result).map((m) => m.kind)).toEqual(['image', 'video']);
+ expect(cards(result)).toEqual(['c']);
+ expect(media(JSON.stringify({ arbitrary: { xdt_image_url: blob('png') } }))).toEqual([]);
+ });
+ it('respects suppression in either envelope and never revives failed nested results', () => {
+ for (const result of [
+ { ok: true, _xdt_render_image: false, result: { xdt_image_url: blob('png') } },
+ { ok: true, result: { _xdt_render_image: false }, xdt_media_produced: [blob('png')] },
+ { ok: false, result: { xdt_image_url: blob('png') } },
+ ]) expect(media(JSON.stringify(result))).toEqual([]);
+ });
+ it('retains managed file and model entries without inventing arbitrary local-path access', () => {
+ const result = JSON.stringify({ ok: true, result: { _xdt_model_files: [{ url: blob('glb'), name: 'scene.glb' }, { url: 'file:///secret' }], note: 'Saved xdt-file://open?path=%2Ftmp%2Freport.pdf' } });
+ expect(files(result)).toEqual([{ url: blob('glb'), title: 'scene.glb' }, { url: 'xdt-file://open?path=%2Ftmp%2Freport.pdf', title: 'report.pdf' }]);
+ expect(files('Saved xdt-file://open?path=%2Ftmp%2Freport.pdf')[0].title).toBe('report.pdf');
+ expect(hasVisibleHistoryResult(JSON.stringify({ ok: true, result: { xdt_card_id: 'c' } }))).toBe(true);
+ });
+});
diff --git a/packages/maker-shared/src/historyViewProjection.ts b/packages/maker-shared/src/historyViewProjection.ts
index df9893143f..ede220cfb7 100644
--- a/packages/maker-shared/src/historyViewProjection.ts
+++ b/packages/maker-shared/src/historyViewProjection.ts
@@ -1,7 +1,7 @@
import { groupWorkRuns } from './workRunGrouping.js';
import { isAgentPlanToolName, isDeliveryProseText } from './messageRender.js';
import { isAgentTaskToolName } from './agentTask.js';
-import { extractPayloadToolResultMedia } from './payloadSummary.js';
+import { extractPayloadToolResultMedia, extractPayloadToolResultFiles, extractPayloadToolCardIds } from './payloadSummary.js';
import { isOrcaCommunicationTool, messageContentToPreview, parseMessageToolUse } from './messageNormalize.js';
import type { HistoryMessageSource, HistoryViewItem, HistoryWorkSummary } from './historyView.js';
@@ -23,7 +23,7 @@ export function isHistoryDetailTool(name: string): boolean {
export function hasVisibleHistoryResult(content: unknown): boolean {
const text = messageContentToPreview(content);
- if (extractPayloadToolResultMedia(text).length > 0 || /^(?:cindy-media|xdt-file):\/\/\S+$/.test(text.trim())) return true;
+ if (extractPayloadToolResultMedia(text).length > 0 || extractPayloadToolResultFiles(text).length > 0 || extractPayloadToolCardIds(text).length > 0 || /^(?:cindy-media|xdt-file):\/\/\S+$/.test(text.trim())) return true;
// Source listings often contain these field names and error markers. Only a
// real result object can claim a card; ordinary tool errors remain activities.
try {
diff --git a/packages/maker-shared/src/messageRender.ts b/packages/maker-shared/src/messageRender.ts
index 42726ba10b..68d39af699 100644
--- a/packages/maker-shared/src/messageRender.ts
+++ b/packages/maker-shared/src/messageRender.ts
@@ -106,6 +106,8 @@ export interface MessageRenderNormalizedMessage<
turnCompleted?: boolean;
/** tool 消息专用:配对 tool_result 提取出的产出媒体(驱动 tool_media 独立渲染项)。 */
media?: readonly MessageRenderToolMediaLike[];
+ files?: readonly { url: string; title: string }[];
+ cardIds?: readonly string[];
}
export interface MessageRenderOptions {
@@ -323,8 +325,9 @@ function buildLinearItems<
// tool 产出媒体(agent 出图等)提为独立 tool_media 项,紧跟所属 tool_group,
// 跳出折叠卡可见(对齐桌面 MessageStream flushSegment)。key 派生自组首 tool
// 的 clientId(与 tool_group 同源、prefix 不同),流式中组内新增 tool 时稳定。
- const mediaTools = pendingTools.filter((tool) => (tool.media?.length ?? 0) > 0);
- if (dedupeToolMediaByUrl(mediaTools.flatMap((tool) => tool.media ?? [])).length > 0) {
+ const mediaTools = pendingTools.filter((tool) => (tool.media?.length ?? 0) > 0 || (tool.files?.length ?? 0) > 0 || (tool.cardIds?.length ?? 0) > 0);
+ if (dedupeToolMediaByUrl(mediaTools.flatMap((tool) => tool.media ?? [])).length > 0
+ || mediaTools.some((tool) => (tool.files?.length ?? 0) > 0 || (tool.cardIds?.length ?? 0) > 0)) {
items.push({
type: 'tool_media',
key: `media-${messageClientId(pendingTools[0])}`,
diff --git a/packages/maker-shared/src/payloadSummary.ts b/packages/maker-shared/src/payloadSummary.ts
index 7f49f23902..528a410844 100644
--- a/packages/maker-shared/src/payloadSummary.ts
+++ b/packages/maker-shared/src/payloadSummary.ts
@@ -351,14 +351,8 @@ export function buildAttachmentPayload(
export function extractPayloadToolResultMedia(toolResult: string): ExtractedPayloadToolMediaLike[] {
if (!toolResult || typeof toolResult !== 'string') return [];
- if (
- !toolResult.includes('xdt_image_url')
- && !toolResult.includes('xdt_video_url')
- && !toolResult.includes('xdt_audio_url')
- ) {
- return [];
- }
- const parsed = parsePayloadJsonObject(toolResult);
+ if (!toolResult.includes("xdt_")) return [];
+ const parsed = parseToolResultPayload(toolResult);
if (!parsed || parsed._xdt_render_image === false) return [];
const items: ExtractedPayloadToolMediaLike[] = [];
@@ -424,6 +418,15 @@ export function extractPayloadToolResultMedia(toolResult: string): ExtractedPayl
}
}
+ // A host-recorded fallback is also a delivery channel on Mobile. Never guess
+ // a local path or classify unknown blob extensions as pictures.
+ if (Array.isArray(parsed.xdt_media_produced)) {
+ for (const url of parsed.xdt_media_produced) {
+ const kind = managedToolMediaKind(url);
+ if (kind) push(kind, url as string);
+ }
+ }
+
const seen = new Set<string>();
return items.filter((item) => {
if (seen.has(item.url)) return false;
@@ -432,6 +435,59 @@ export function extractPayloadToolResultMedia(toolResult: string): ExtractedPayl
});
}
+/** Only unwrap the documented ghost_call envelope, never arbitrary nested tool data. */
+export function parseToolResultPayload(text: string): Record<string, unknown> | null {
+ const outer = parsePayloadJsonObject(text);
+ if (!outer) return null;
+ const inner = outer.ok === true ? readPayloadRecord(outer.result) : null;
+ return inner ? { ...inner, ...outer, ...(inner._xdt_render_image === false ? { _xdt_render_image: false } : {}) } : outer;
+}
+
+export function managedToolMediaKind(url: unknown): 'image' | 'video' | 'audio' | null {
+ if (typeof url !== 'string') return null;
+ if (url.startsWith('xdt-image://')) return 'image';
+ if (url.startsWith('xdt-video://')) return 'video';
+ if (url.startsWith('xdt-audio://')) return 'audio';
+ const match = /^cindy-media:\/\/blobs\/[0-9a-f]{64}\.([a-z0-9]+)$/.exec(url);
+ if (!match) return null;
+ if (/^(png|jpe?g|gif|webp|avif|bmp|svg)$/.test(match[1])) return 'image';
+ if (/^(mp4|webm|mov|m4v)$/.test(match[1])) return 'video';
+ if (/^(mp3|wav|m4a|ogg|flac|aac|opus)$/.test(match[1])) return 'audio';
+ return null;
+}
+
+/** Portable read-only card references; the Host resolves their content in the owning task. */
+export function extractPayloadToolCardIds(text: string): string[] {
+ const parsed = parseToolResultPayload(text);
+ if (!parsed) return [];
+ return [...new Set([parsed.xdt_card_id, parsed.xdt_anchor_card_id]
+ .filter((id): id is string => typeof id === 'string' && id.length > 0 && id.length <= 128))];
+}
+
+export interface PayloadToolFile { url: string; title: string }
+
+/** Existing 3D attachments and managed file references retain a usable file entry on Mobile. */
+export function extractPayloadToolResultFiles(text: string): PayloadToolFile[] {
+ const parsed = parseToolResultPayload(text);
+ if (parsed?._xdt_render_image === false) return [];
+ const files: PayloadToolFile[] = [];
+ const add = (url: unknown, title?: unknown) => {
+ if (typeof url !== 'string' || !/^(?:xdt-file:\/\/[^\s]+|cindy-media:\/\/blobs\/[0-9a-f]{64}\.glb)$/.test(url)) return;
+ let name = url.split('/').pop()!;
+ if (url.startsWith('xdt-file://')) {
+ try { name = (new URL(url).searchParams.get('path') ?? name).split(/[\\/]/).pop() || name; } catch { /* Keep the original reference as fallback. */ }
+ }
+ if (!files.some((file) => file.url === url)) files.push({ url, title: typeof title === 'string' && title.trim() ? title : name });
+ };
+ if (Array.isArray(parsed?._xdt_model_files)) {
+ for (const raw of parsed._xdt_model_files) { const file = readPayloadRecord(raw); add(file?.url, file?.name); }
+ }
+ if (Array.isArray(parsed?.xdt_media_produced)) for (const url of parsed.xdt_media_produced) add(url);
+ // Files supplied as links in a result remain accessible without scanning arbitrary local paths.
+ for (const match of text.matchAll(/xdt-file:\/\/[^\s"<>\\)]+/g)) add(match[0]);
+ return files;
+}
+
export function buildMermaidPayload(
source: string,
localizer?: PresentationLocalizer,