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。

feat(mobile): 持久保存待发消息并核对桌面接收状态 (#4339)

Dash0853459983d2
diff --git a/apps/desktop/src/main/localDb/__tests__/agentInputQueueSnapshotsPersistence.test.ts b/apps/desktop/src/main/localDb/__tests__/agentInputQueueSnapshotsPersistence.test.ts
index eacfac27aa..fa0682abf9 100644
--- a/apps/desktop/src/main/localDb/__tests__/agentInputQueueSnapshotsPersistence.test.ts
+++ b/apps/desktop/src/main/localDb/__tests__/agentInputQueueSnapshotsPersistence.test.ts
@@ -1,19 +1,26 @@
import Database from 'better-sqlite3';
+import { drizzle } from 'drizzle-orm/better-sqlite3';
import { describe, expect, it, vi } from 'vitest';
const mocks = vi.hoisted(() => ({
getDbClient: vi.fn(),
+ epoch: 1,
}));
vi.mock('../client/current', () => ({
getDbClient: mocks.getDbClient,
+ getCurrentDbClientSnapshot: () => ({ client: mocks.getDbClient(), userId: "test", clientEpoch: mocks.epoch }),
}));
import {
AgentInputQueueSnapshotTooLargeError,
awaitAgentInputQueueSnapshotPersistence,
loadAgentInputQueueSnapshotCounts,
+ loadAgentInputQueueSnapshot,
saveAgentInputQueueSnapshot,
+ saveCancelledInputDelivery,
+ hasInputDeliveryCancellation,
+ readInputDeliveryReceipts,
} from '../agentInputQueueSnapshots.js';
import type { AgentInputQueuedMessage } from '../../../shared/agentInputQueue.js';
@@ -63,6 +70,79 @@ function installDb(
}
describe('agent input queue snapshot durability boundary', () => {
+ it.each([false, true])('matches restoration when a persisted array contains malformed rows (all malformed: %s)', async (allMalformed) => {
+ const sqlite = new Database(':memory:');
+ sqlite.exec(`
+ CREATE TABLE agent_input_queue_snapshots (session_id TEXT PRIMARY KEY, payload TEXT NOT NULL, updated_at INTEGER);
+ CREATE TABLE messages (session_id TEXT, client_id TEXT, role TEXT, rewind_at INTEGER);
+ `);
+ const sid = `receipt-malformed-${allMalformed}`;
+ const good = allMalformed ? [] : [queued('pending', 'valid'), queued('accepted', 'history')];
+ const payload = JSON.stringify([...good, null, 'legacy row', { clientId: 'bad' }, { clientId: 'removed' }]);
+ sqlite.prepare('INSERT INTO agent_input_queue_snapshots VALUES (?, ?, ?)').run(sid, payload, 1);
+ sqlite.prepare('INSERT INTO messages VALUES (?, ?, ?, ?)').run(sid, 'history', 'user', null);
+ sqlite.prepare('INSERT INTO messages VALUES (?, ?, ?, ?)').run(sid, 'removed', 'message_tombstone', 1);
+ mocks.getDbClient.mockReturnValue({ drizzle: drizzle(sqlite) });
+ try {
+ expect((await loadAgentInputQueueSnapshot(sid)).map((item) => item.clientId)).toEqual(good.map((item) => item.clientId));
+ const expected = [
+ { clientId: 'valid', state: allMalformed ? 'unknown' : 'pending' },
+ { clientId: 'bad', state: 'unknown' },
+ { clientId: 'history', state: 'accepted' },
+ { clientId: 'removed', state: 'removed' },
+ ];
+ await expect(readInputDeliveryReceipts(sid, expected.map((item) => item.clientId))).resolves.toEqual(expected);
+ await expect(readInputDeliveryReceipts(sid, ['bad'])).resolves.toEqual([{ clientId: 'bad', state: 'unknown' }]);
+ expect(sqlite.prepare('SELECT payload FROM agent_input_queue_snapshots').get()).toEqual({ payload });
+ } finally { sqlite.close(); }
+ });
+ it.each(['settled', 'pending', 'receipt-retry'] as const)('does not let %s cancellation replace a failed snapshot boundary', async (timing) => {
+ const sid = `snapshot-cancel-${timing}`;
+ const failure = new Error('snapshot failed');
+ const gate = deferred<void>();
+ const snapshotWrite = vi.fn().mockImplementationOnce(() => gate.promise).mockResolvedValue(undefined);
+ const cancelWrite = vi.fn().mockResolvedValue(undefined);
+ if (timing === 'receipt-retry') cancelWrite.mockRejectedValueOnce(new Error('cancel failed'));
+ const select = vi.fn(() => ({ from: () => ({ where: async () => [{ role: 'message_tombstone' }] }) }));
+ mocks.getDbClient.mockReturnValue({ drizzle: {
+ insert: () => ({ values: () => ({ onConflictDoUpdate: snapshotWrite, onConflictDoNothing: cancelWrite }) }),
+ select,
+ } });
+ const snapshot = saveAgentInputQueueSnapshot(sid, [queued()]);
+ const rejectedSnapshot = expect(snapshot).rejects.toBe(failure);
+ if (timing !== 'pending') { gate.reject(failure); await rejectedSnapshot; }
+ const cancel = saveCancelledInputDelivery(sid, 'cancelled-other');
+ if (timing === 'pending') { gate.reject(failure); await rejectedSnapshot; }
+ if (timing === 'receipt-retry') await expect(cancel).rejects.toThrow('cancel failed');
+ else await expect(cancel).resolves.toBe(true);
+ await expect(awaitAgentInputQueueSnapshotPersistence(sid)).rejects.toBe(failure);
+ const priorReads = select.mock.calls.length;
+ await expect(readInputDeliveryReceipts(sid, ['client-queued'])).rejects.toBe(failure);
+ expect(select.mock.calls.length).toBe(priorReads);
+ expect(cancelWrite).toHaveBeenCalledTimes(timing === 'receipt-retry' ? 2 : 1);
+ await saveAgentInputQueueSnapshot(sid, [queued()]);
+ await expect(awaitAgentInputQueueSnapshotPersistence(sid)).resolves.toBeUndefined();
+ });
+
+ it('rejects through Promise handlers when the database owner is unavailable', async () => {
+ mocks.getDbClient.mockImplementation(() => { throw new Error('DbClient not ready'); });
+ try {
+ const operations = [
+ () => saveAgentInputQueueSnapshot('owner-unavailable', [queued()]),
+ () => saveCancelledInputDelivery('owner-unavailable', 'client-1'),
+ () => awaitAgentInputQueueSnapshotPersistence('owner-unavailable'),
+ () => readInputDeliveryReceipts('owner-unavailable', ['client-1']),
+ ];
+ for (const operation of operations) {
+ const cleanup = vi.fn();
+ await operation().catch(cleanup);
+ expect(cleanup).toHaveBeenCalledWith(expect.objectContaining({ message: 'DbClient not ready' }));
+ }
+ } finally {
+ mocks.getDbClient.mockReset();
+ }
+ });
+
it('waits for the current session write and resolves after the DB operation', async () => {
const gate = deferred<void>();
const { onConflictDoUpdate } = installDb({ write: () => gate.promise });
@@ -238,4 +318,105 @@ describe('agent input queue snapshot durability boundary', () => {
'db unavailable',
);
});
+ it('does not erase a snapshot when cancellation persistence fails, and retries the intent first', async () => {
+ let failing = true;
+ const inserted: Array<Record<string, unknown>> = [];
+ const insert = vi.fn(() => ({ values: (row: Record<string, unknown>) => ({
+ onConflictDoNothing: async () => {
+ if (failing) throw new Error('disk full');
+ inserted.push(row);
+ },
+ onConflictDoUpdate: async () => { inserted.push(row); },
+ }) }));
+ const where = vi.fn(async () => undefined);
+ mocks.getDbClient.mockReturnValue({ drizzle: { insert, delete: () => ({ where }) } });
+ await expect(saveCancelledInputDelivery('cancel-retry', 'cancelled-id')).rejects.toThrow('disk full');
+ await expect(saveAgentInputQueueSnapshot('cancel-retry', [])).rejects.toThrow('disk full');
+ expect(where).not.toHaveBeenCalled();
+ failing = false;
+ await saveAgentInputQueueSnapshot('cancel-retry', []);
+ expect(inserted).toEqual([expect.objectContaining({ role: 'message_tombstone', content: 'null', clientId: 'cancelled-id' })]);
+ expect(where).toHaveBeenCalledOnce();
+ expect(hasInputDeliveryCancellation('cancel-retry', 'cancelled-id')).toBe(true);
+ await expect(awaitAgentInputQueueSnapshotPersistence('cancel-retry')).resolves.toBeUndefined();
+ });
+ it.each(['user', 'rewound-user', 'message_tombstone', 'absent'])('only confirms cancellation when its durable namespace is sealed: %s', async (existing) => {
+ const sqlite = new Database(':memory:');
+ sqlite.exec('CREATE TABLE messages (session_id TEXT, client_id TEXT, role TEXT, content TEXT, rewind_at INTEGER, UNIQUE(session_id, client_id))');
+ const sid = `cancel-conflict-${existing}`;
+ const cid = 'same-client-id';
+ if (existing !== 'absent') sqlite.prepare('INSERT INTO messages VALUES (?, ?, ?, ?, ?)')
+ .run(sid, cid, existing === 'rewound-user' ? 'user' : existing, 'original', existing === 'rewound-user' ? 1 : null);
+ mocks.getDbClient.mockReturnValue({ drizzle: {
+ insert: () => ({ values: (row: Record<string, unknown>) => ({ onConflictDoNothing: async () => {
+ sqlite.prepare('INSERT INTO messages VALUES (?, ?, ?, ?, ?) ON CONFLICT DO NOTHING')
+ .run(row.sessionId, row.clientId, row.role, row.content, row.rewindAt);
+ } }) }),
+ select: () => ({ from: () => ({ where: async () => sqlite.prepare('SELECT role FROM messages WHERE session_id = ? AND client_id = ?').all(sid, cid) }) }),
+ } });
+ try {
+ const expected = existing === 'absent' || existing === 'message_tombstone';
+ // Register synchronously to stop a late enqueue while the durable claim is checked.
+ const cancellation = saveCancelledInputDelivery(sid, cid);
+ expect(hasInputDeliveryCancellation(sid, cid)).toBe(true);
+ expect(await cancellation).toBe(expected);
+ // The replay fence stays closed even when executed history beat cancellation.
+ expect(hasInputDeliveryCancellation(sid, cid)).toBe(true);
+ // A repeated cancellation has the same answer and never replaces executed content.
+ expect(await saveCancelledInputDelivery(sid, cid)).toBe(expected);
+ expect(sqlite.prepare('SELECT content FROM messages').get()).toEqual({ content: existing === 'absent' ? 'null' : 'original' });
+ } finally { sqlite.close(); }
+ });
+ it.each(['missing', 'read-error'])('does not acknowledge an unverified cancellation and can retry: %s', async (failure) => {
+ const where = vi.fn();
+ if (failure === 'missing') where.mockResolvedValueOnce([]);
+ else where.mockRejectedValueOnce(new Error('db unavailable'));
+ where.mockResolvedValue([{ role: 'message_tombstone' }]);
+ mocks.getDbClient.mockReturnValue({ drizzle: {
+ insert: () => ({ values: () => ({ onConflictDoNothing: async () => undefined }) }),
+ select: () => ({ from: () => ({ where }) }),
+ } });
+ const sid = `cancel-unverified-${failure}`;
+ await expect(saveCancelledInputDelivery(sid, 'id')).rejects.toThrow();
+ expect(hasInputDeliveryCancellation(sid, 'id')).toBe(true);
+ await expect(saveCancelledInputDelivery(sid, 'id')).resolves.toBe(true);
+ });
+ it('fences queued writes at an account switch without writing to the next account', async () => {
+ const gate = deferred<void>();
+ const first = installDb({ write: () => gate.promise });
+ const write1 = saveAgentInputQueueSnapshot('owner-switch', [queued('a')]);
+ const write2 = saveAgentInputQueueSnapshot('owner-switch', [queued('b')]);
+ await Promise.resolve();
+ mocks.epoch += 1;
+ const second = installDb();
+ gate.resolve();
+ await expect(write1).rejects.toThrow('DbClient not ready');
+ await expect(write2).rejects.toThrow('DbClient not ready');
+ expect(first.insert).toHaveBeenCalledOnce();
+ expect(second.insert).not.toHaveBeenCalled();
+ await saveAgentInputQueueSnapshot('owner-switch', [queued('new-owner')]);
+ expect(second.insert).toHaveBeenCalledOnce();
+ });
+ it('reads the queue before history so a queue-to-message transfer cannot appear unknown', async () => {
+ const events: string[] = [];
+ const where = vi.fn()
+ .mockImplementationOnce(async () => { events.push('queue'); return [{ payload: JSON.stringify([queued('a', 'id-a')]) }]; })
+ .mockImplementationOnce(async () => { events.push('history'); return [
+ { clientId: 'id-a', role: 'user', rewindAt: null },
+ { clientId: 'id-b', role: 'message_tombstone', rewindAt: 123 },
+ ]; });
+ mocks.getDbClient.mockReturnValue({ drizzle: { select: () => ({ from: () => ({ where }) }) } });
+ expect(await readInputDeliveryReceipts('receipt-transfer', ['id-a', 'id-b', 'id-c'])).toEqual([
+ { clientId: 'id-a', state: 'accepted' }, { clientId: 'id-b', state: 'removed' }, { clientId: 'id-c', state: 'unknown' },
+ ]);
+ expect(events).toEqual(['queue', 'history']);
+ });
+ it.each(['{invalid', '{}', 'null'])('does not report unknown when the delivery snapshot is corrupt (%s) or its database read fails', async (payload) => {
+ const where = vi.fn().mockResolvedValue([{ payload }]);
+ mocks.getDbClient.mockReturnValue({ drizzle: { select: () => ({ from: () => ({ where }) }) } });
+ await expect(readInputDeliveryReceipts('receipt-invalid', ['id-a'])).rejects.toThrow();
+ where.mockRejectedValueOnce(new Error('db unavailable'));
+ await expect(readInputDeliveryReceipts('receipt-invalid', ['id-a'])).rejects.toThrow('db unavailable');
+ });
+
});
diff --git a/apps/desktop/src/main/localDb/agentInputQueueSnapshots.ts b/apps/desktop/src/main/localDb/agentInputQueueSnapshots.ts
index bbcd11aa10..f4f86fed96 100644
--- a/apps/desktop/src/main/localDb/agentInputQueueSnapshots.ts
+++ b/apps/desktop/src/main/localDb/agentInputQueueSnapshots.ts
@@ -3,7 +3,7 @@
*
* 职责:AgentInputCoordinator 的 pendingQueue 内容变化时覆盖写单行快照,
* 重启后打开会话时读回并恢复为「暂停中的队列」。写入是尽力而为的辅助信号:
- * 失败只落日志,绝不阻塞派发主流程;per-session 写链保序(参考
+ * 普通写入失败只落日志;durable delivery 在确认接收前必须等待写入成功。per-session 写链保序(参考
* sessionActiveTurn 的 chainWrite),避免"后发先至"让旧快照覆盖新快照。
*
* 体量守卫:payload 超过 MAX_PAYLOAD_BYTES 时先剥离 files[].base64(剪贴板
@@ -11,10 +11,12 @@
* (宁可让上层保留可重试的输入,不把未持久化误报成成功)。
*/
-import { eq } from 'drizzle-orm';
+import { and, eq, inArray } from 'drizzle-orm';
+import { randomUUID } from 'node:crypto';
+import type { InputDeliveryReceipt } from '@cindy/device-link';
-import { getDbClient } from './client/current';
-import { agentInputQueueSnapshots } from './schema';
+import { getDbClient, getCurrentDbClientSnapshot, type CurrentDbClientSnapshot } from './client/current';
+import { agentInputQueueSnapshots, messages } from './schema';
import { createLogger } from '../logger';
import {
sanitizeQueuedMessageForPersistence,
@@ -29,7 +31,7 @@ const SNAPSHOT_COUNT_QUERY_BATCH_SIZE = 200;
/** per-session 写链:只做覆盖写/删除排队保序,无读改写。 */
const _writeChains = new Map<string, Promise<void>>();
-/** 当前 session 最近一次写操作的真实结果(保留 reject 供 durable boundary 等待者观察)。 */
+/** 最近一次真实队列快照写入的结果;取消墓碑不能替代队列落盘证明。 */
const _latestWriteResults = new Map<string, Promise<void>>();
/**
@@ -53,9 +55,49 @@ export class AgentInputQueueSnapshotTooLargeError extends Error {
}
}
-function chainWrite(sessionId: string, op: () => Promise<void>): Promise<void> {
+function queueOwner() {
+ const owner = getCurrentDbClientSnapshot();
+ if (!owner) throw new Error('DbClient not ready');
+ return owner;
+}
+function assertQueueOwner(owner: CurrentDbClientSnapshot) {
+ if (getCurrentDbClientSnapshot()?.clientEpoch !== owner.clientEpoch) throw new Error('DbClient not ready');
+}
+const pendingCancellations = new Map<string, Set<string>>();
+// Keep successful cancellations in memory too: a concurrent enqueue's final SELECT may
+// have completed just before the tombstone committed, while its continuation is still queued.
+// This is a replay fence, not evidence that cancellation beat an existing user row.
+const cancelledDeliveryIds = new Map<string, Set<string>>();
+const queueKey = (owner: CurrentDbClientSnapshot, sid: string) => `${owner.clientEpoch}:${sid}`;
+async function flushCancellations(owner: CurrentDbClientSnapshot, sessionId: string) {
+ const key = queueKey(owner, sessionId);
+ const intents = pendingCancellations.get(key);
+ if (!intents) return;
+ for (const clientId of intents) {
+ assertQueueOwner(owner);
+ const now = Date.now();
+ await owner.client.drizzle.insert(messages).values({
+ id: randomUUID(), sessionId, clientId, role: 'message_tombstone',
+ content: 'null', createdAt: now, rewindAt: now,
+ }).onConflictDoNothing();
+ intents.delete(clientId);
+ }
+ if (!intents.size) pendingCancellations.delete(key);
+}
+export function hasInputDeliveryCancellation(sessionId: string, clientId: string): boolean {
+ return cancelledDeliveryIds.get(queueKey(queueOwner(), sessionId))?.has(clientId) === true;
+}
+async function chainWrite(sessionId: string, kind: 'snapshot' | 'cancellation', op: (owner: CurrentDbClientSnapshot) => Promise<void>): Promise<void> {
+ const owner = queueOwner();
+ const sid = sessionId;
+ sessionId = queueKey(owner, sid);
const prev = _writeChains.get(sessionId) ?? Promise.resolve();
- const opResult = prev.then(op);
+ const opResult = prev.then(async () => {
+ assertQueueOwner(owner);
+ if (pendingCancellations.has(queueKey(owner, sid))) await flushCancellations(owner, sid);
+ await op(owner);
+ assertQueueOwner(owner);
+ });
// The operation promise is returned to the caller and may be intentionally
// observed later through awaitAgentInputQueueSnapshotPersistence(). Attach a
// no-op rejection observer now so a fire-and-forget caller cannot create an
@@ -68,7 +110,7 @@ function chainWrite(sessionId: string, op: () => Promise<void>): Promise<void> {
// a later successful write replaces it. Treating a rejected write as
// "nothing pending" would let attachment ownership advance past a snapshot
// that never became crash-recoverable.
- void opResult.then(
+ if (kind === 'snapshot') void opResult.then(
() => {
if (_latestWriteResults.get(sessionId) === opResult) {
_latestWriteResults.delete(sessionId);
@@ -77,7 +119,7 @@ function chainWrite(sessionId: string, op: () => Promise<void>): Promise<void> {
() => undefined,
);
_writeChains.set(sessionId, chainNext);
- _latestWriteResults.set(sessionId, opResult);
+ if (kind === 'snapshot') _latestWriteResults.set(sessionId, opResult);
return opResult;
}
@@ -91,8 +133,65 @@ function chainWrite(sessionId: string, op: () => Promise<void>): Promise<void> {
* later writes are chained after it and are not silently skipped. A session
* with no pending write is already at the latest known durable boundary.
*/
-export function awaitAgentInputQueueSnapshotPersistence(sessionId: string): Promise<void> {
- return _latestWriteResults.get(sessionId) ?? Promise.resolve();
+export async function awaitAgentInputQueueSnapshotPersistence(sessionId: string): Promise<void> {
+ return _latestWriteResults.get(queueKey(queueOwner(), sessionId)) ?? Promise.resolve();
+}
+
+/** Seal cancellation before the following queue snapshot can forget its delivery ID. */
+export async function saveCancelledInputDelivery(sessionId: string, clientId: string): Promise<boolean> {
+ const owner = queueOwner();
+ const key = queueKey(owner, sessionId);
+ const intents = pendingCancellations.get(key) ?? new Set<string>();
+ intents.add(clientId);
+ pendingCancellations.set(key, intents);
+ const cancelled = cancelledDeliveryIds.get(key) ?? new Set<string>();
+ cancelled.add(clientId);
+ cancelledDeliveryIds.set(key, cancelled);
+ await chainWrite(sessionId, 'cancellation', async () => undefined);
+ // After restart this namespace may already belong to executed history. INSERT
+ // ... ON CONFLICT DO NOTHING succeeding does not prove cancellation won.
+ const rows = await owner.client.drizzle.select({ role: messages.role }).from(messages)
+ .where(and(eq(messages.sessionId, sessionId), eq(messages.clientId, clientId)));
+ assertQueueOwner(owner);
+ if (!rows[0]) throw new Error('Input delivery cancellation unavailable');
+ return rows[0].role === 'message_tombstone';
+}
+
+/** Queue ownership and terminal history share the existing durable clientId namespace. */
+export async function readInputDeliveryReceipts(
+ sessionId: string, clientIds: string[],
+): Promise<InputDeliveryReceipt[]> {
+ const owner = queueOwner();
+ // Retrying a failed cancellation must precede observing absence or advancing a snapshot.
+ if (pendingCancellations.has(queueKey(owner, sessionId))) {
+ await chainWrite(sessionId, 'cancellation', async () => undefined);
+ }
+ await awaitAgentInputQueueSnapshotPersistence(sessionId);
+ assertQueueOwner(owner);
+ if (clientIds.length === 0) return [];
+ // Read the source before the destination of the queue -> history ownership transfer.
+ const snapshots = await owner.client.drizzle.select({ payload: agentInputQueueSnapshots.payload })
+ .from(agentInputQueueSnapshots).where(eq(agentInputQueueSnapshots.sessionId, sessionId));
+ const raw: unknown = snapshots[0] ? JSON.parse(snapshots[0].payload) : [];
+ if (!Array.isArray(raw)) {
+ throw new Error('Input delivery snapshot unavailable');
+ }
+ // Match restoration's per-entry validation without rewriting the durable snapshot.
+ const pending = new Set(raw.filter(isRestorableQueuedMessage).map((item) => item.clientId));
+ const rows = await owner.client.drizzle.select({
+ clientId: messages.clientId, role: messages.role, rewindAt: messages.rewindAt,
+ }).from(messages).where(and(eq(messages.sessionId, sessionId), inArray(messages.clientId, clientIds)));
+ assertQueueOwner(owner);
+ const persisted = new Map(rows.map((row) => [row.clientId, row]));
+ return clientIds.map((clientId) => {
+ const row = persisted.get(clientId);
+ return {
+ clientId,
+ state: row
+ ? row.role === 'message_tombstone' || row.rewindAt !== null ? 'removed' : 'accepted'
+ : pending.has(clientId) ? 'pending' : 'unknown',
+ };
+ });
}
function stripInlineBase64(items: AgentInputQueuedMessage[]): AgentInputQueuedMessage[] {
@@ -123,9 +222,9 @@ export function saveAgentInputQueueSnapshot(
sessionId: string,
items: AgentInputQueuedMessage[],
): Promise<void> {
- return chainWrite(sessionId, async () => {
+ return chainWrite(sessionId, 'snapshot', async (owner) => {
try {
- const db = getDbClient().drizzle;
+ const db = owner.client.drizzle;
if (items.length === 0) {
await db
.delete(agentInputQueueSnapshots)
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts
index 342fa7c9f0..298012e2ef 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts
@@ -9473,6 +9473,44 @@ describe('AgentInputCoordinator crash-recovery queue snapshots (issue #761)', ()
expect(latestSnapshotClientIds(h.persistQueueSnapshot)).toEqual(['q-2']);
});
+ it('retries an unchanged failed snapshot at the durable boundary and deduplicates a successful retry', async () => {
+ const h = createHarness();
+ const sid = 'snapshot-boundary-retry';
+ await h.coordinator.ensureQueueRestored(sid);
+ h.setRunning(true);
+ h.persistQueueSnapshot.mockRejectedValueOnce(new Error('sqlite busy'));
+ h.coordinator.enqueue(sid, makeItem('q-1', 'keep queued'));
+ await flush();
+ h.persistQueueSnapshot.mockClear();
+ h.persistQueueSnapshot.mockRejectedValueOnce(new Error('still busy'));
+ h.coordinator.retryQueueSnapshotPersistence(sid);
+ await flush();
+ expect(latestSnapshotClientIds(h.persistQueueSnapshot)).toEqual(['q-1']);
+ h.coordinator.retryQueueSnapshotPersistence(sid);
+ await flush();
+ expect(h.persistQueueSnapshot).toHaveBeenCalledTimes(2);
+ h.coordinator.retryQueueSnapshotPersistence(sid);
+ expect(h.persistQueueSnapshot).toHaveBeenCalledTimes(2);
+ expect(h.sendToAgent).not.toHaveBeenCalled();
+ });
+
+ it('does not retry an unrestored snapshot or replay old contents after a newer successful write', async () => {
+ const h = createHarness();
+ const sid = 'snapshot-boundary-current';
+ h.coordinator.retryQueueSnapshotPersistence(sid);
+ expect(h.persistQueueSnapshot).not.toHaveBeenCalled();
+ await h.coordinator.ensureQueueRestored(sid);
+ h.setRunning(true);
+ h.persistQueueSnapshot.mockRejectedValueOnce(new Error('sqlite busy'));
+ h.coordinator.enqueue(sid, makeItem('q-1', 'first'));
+ h.coordinator.enqueue(sid, makeItem('q-2', 'second'));
+ await flush();
+ const writes = h.persistQueueSnapshot.mock.calls.length;
+ h.coordinator.retryQueueSnapshotPersistence(sid);
+ expect(h.persistQueueSnapshot).toHaveBeenCalledTimes(writes);
+ expect(latestSnapshotClientIds(h.persistQueueSnapshot)).toEqual(['q-1', 'q-2']);
+ });
+
it('includes a dispatching-but-unpersisted head in the snapshot (single queued message window)', async () => {
const h = createHarness();
const sid = 'snapshot-active-window';
diff --git a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
index 8f958e2a2e..5eff967dca 100644
--- a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
+++ b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
@@ -1090,6 +1090,11 @@ export class AgentInputCoordinator {
return this.toProjection(sessionId, this.getState(sessionId));
}
+ /** Retry a failed current snapshot without rewriting successful or unrestored queues. */
+ retryQueueSnapshotPersistence(sessionId: string): void {
+ this.maybePersistQueueSnapshot(sessionId);
+ }
+
/**
* Main-only control snapshot. Queue mutation services need the authoritative
* item rather than the renderer/device-link projection: projected rows omit
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index dfb9521b0c..75de0fae5f 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -88,6 +88,7 @@ import {
import {
CONTROLLER_CAPABILITY_SET_MODEL_EXPLICIT_PROVIDER_NULL_V1,
DL_SESSION_REFERENCE_CAPABILITY_CHANNEL,
+ readInputDeliveryClientIds,
} from '@cindy/device-link';
import { and, desc, eq, gte, inArray, isNull, lt, sql } from 'drizzle-orm';
import { applyScheduledModelSelection, ScheduledModelSelectionBusyError, type ScheduledModelSelection, type ScheduledModelSelectionLease } from './scheduledModelSelection';
@@ -252,10 +253,13 @@ import { workdirDiagnosticContext, workdirDiagnosticErrorCode } from '../workdir
import { statWorkingDirectory, mkdirWorkingDirectory, realpathWorkingDirectory, findSimilarWorkingDirectory } from '../workdir-probe-host/index.js';
import { getMessagesForHistory } from '../localDb/chatHistoryReader.js';
import {
- awaitAgentInputQueueSnapshotPersistence,
+ awaitAgentInputQueueSnapshotPersistence as awaitQueuedSnapshotWrite,
loadAgentInputQueueSnapshot,
loadAgentInputQueueSnapshotCounts,
saveAgentInputQueueSnapshot,
+ saveCancelledInputDelivery,
+ readInputDeliveryReceipts,
+ hasInputDeliveryCancellation,
} from '../localDb/agentInputQueueSnapshots.js';
import {
ensureDialogueWorkspaceDir,
@@ -13626,6 +13630,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
});
};
+ async function awaitAgentInputQueueSnapshotPersistence(sessionId: string): Promise<void> {
+ inputCoordinator.retryQueueSnapshotPersistence(sessionId);
+ await awaitQueuedSnapshotWrite(sessionId);
+ }
+
const inputCoordinator: AgentInputCoordinator = new AgentInputCoordinator({
sendToAgent: async (sessionId, message, createOpts, sendOpts) => {
try {
@@ -14053,6 +14062,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
},
// 队列项未派发即被丢弃(stop/remove/clearSession) → 释放暂存的 accepted 副作用, 防回调表泄漏。
onDiscardedQueuedMessage: (sessionId, item) => {
+ if (item.durableDelivery === true) {
+ void saveCancelledInputDelivery(sessionId, item.clientId).catch((error) => {
+ log.warn('input delivery cancellation persistence failed', { sessionId, error: String(error) });
+ });
+ }
welcomeDispatchReceipts.settle(sessionId, item.clientId, false);
rollbackAgentIslandUserPrompt(sessionId, item.clientId, 'discarded');
discardQueuedAttachmentOwnership(sessionId, item.clientId);
@@ -14592,6 +14606,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const normalized: AgentInputQueuedMessage = { ...msg };
delete normalized.sharedTaskAuthor;
delete normalized.autoReviewUserText;
+ if (normalized.durableDelivery !== true) delete normalized.durableDelivery;
// Only Main-created welcomes and restored host snapshots may carry this policy.
delete normalized.toolsDisabled;
const refs = requireSessionRefs(normalized.sessionRefs);
@@ -14904,9 +14919,16 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
};
};
- ipcMain.handle(MAKER_INVOKE.INPUT_GET_PROJECTION, async (_e, sessionId: unknown) => {
+ ipcMain.handle(MAKER_INVOKE.INPUT_GET_PROJECTION, async (_e, sessionId: unknown, options?: unknown) => {
const sid = requireSessionId(sessionId);
const remote = isDeviceLinkInvoke();
+ if (!remote) assertTrustedAppRendererEvent(_e);
+ let deliveryClientIds: string[] | undefined;
+ try {
+ deliveryClientIds = readInputDeliveryClientIds(options);
+ } catch {
+ throwIpcError('INVALID_PARAMS', 'Invalid deliveryClientIds');
+ }
assertRemoteInputClearNotInFlight(sid, remote);
// The queue snapshot is process-local, but the clear boundary is durable.
// Hydrate it for both renderer and device-link callers before restoring the
@@ -14920,9 +14942,19 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
// 崩溃恢复(issue #761):renderer 打开会话首次取 projection 前,先把持久化的
// 排队输入读回内存态,返回值即含恢复后的队列,不依赖 push 补发。
// 失败时仍返回当前内存态 projection(宁可漏恢复也不阻塞会话打开)。
- await inputCoordinator.ensureQueueRestored(sid).catch(() => undefined);
+ if (deliveryClientIds) await inputCoordinator.ensureQueueRestored(sid);
+ else await inputCoordinator.ensureQueueRestored(sid).catch(() => undefined);
+ assertRemoteInputClearNotInFlight(sid, remote);
+ if (deliveryClientIds) await awaitAgentInputQueueSnapshotPersistence(sid);
+ const deliveryReceipts = deliveryClientIds
+ ? await readInputDeliveryReceipts(sid, deliveryClientIds)
+ : undefined;
assertRemoteInputClearNotInFlight(sid, remote);
- return inputCoordinator.getProjection(sid);
+ return {
+ ...inputCoordinator.getProjection(sid),
+ inputDeliveryVersion: 1,
+ ...(deliveryReceipts ? { deliveryReceipts } : {}),
+ };
});
// device-link 出方向:远程入队消息的 OSS 引用(files[] + persistedContent)在入队前一次性物化成本地
@@ -14936,6 +14968,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const deviceLinkInvoke = isDeviceLinkInvoke();
if (!deviceLinkInvoke) assertTrustedAppRendererEvent(event);
const parsed = await prepareSharedTaskInput(sid, requireQueuedMessage(item));
+ if (parsed.durableDelivery) await awaitAgentInputQueueSnapshotPersistence(sid);
assertRemoteInputClearNotInFlight(sid, deviceLinkInvoke);
const clearBoundaryPrecondition = readRemoteInputClearBoundaryPrecondition(opts);
if (!deviceLinkInvoke) await observeLocalInputClearBoundary(sid);
@@ -14983,6 +15016,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
// coordinator. Return the current projection before materialising a new
// copy of its attachments.
if (inputCoordinator.hasKnownClientId(sid, parsed.clientId)) {
+ if (parsed.durableDelivery) await awaitAgentInputQueueSnapshotPersistence(sid);
return inputCoordinator.getProjection(sid);
}
const materialized = await materializeQueuedOssAttachmentsDeferred(sid, parsed);
@@ -15023,6 +15057,19 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
assertCurrentInputGeneration();
assertRemoteInputClearNotInFlight(sid, deviceLinkInvoke);
+ if (parsed.durableDelivery) {
+ await awaitAgentInputQueueSnapshotPersistence(sid);
+ const persisted = await remoteInputClientIdWasPersisted(sid, parsed.clientId);
+ assertCurrentInputGeneration();
+ assertRemoteInputClearNotInFlight(sid, deviceLinkInvoke);
+ if (persisted || hasInputDeliveryCancellation(sid, parsed.clientId)) {
+ await materialized.cleanupBeforeAcceptance?.();
+ if (attachmentOwnerId) await discardSpecificQueuedAttachmentOwnership(sid, parsed.clientId, attachmentOwnerId);
+ await awaitAgentInputQueueSnapshotPersistence(sid);
+ return inputCoordinator.getProjection(sid);
+ }
+ }
+
// 「继续任务」durable ack 延后到 vendor dispatch 成功(onDispatchedUserTurn):
// 排队可取消时旧中断提示必须能恢复;accepted 但仍可能 cancelled-before-dispatch
// 时也不能提前 ack。续跑项本身由 coordinator 插到队首(普通输入仍 FIFO)。
@@ -15043,6 +15090,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
await materialized.cleanupBeforeAcceptance?.();
await discardSpecificQueuedAttachmentOwnership(sid, parsed.clientId, attachmentOwnerId);
}
+ if (parsed.durableDelivery) await awaitAgentInputQueueSnapshotPersistence(sid);
return projection;
}
acceptedByCoordinator = true;
@@ -15051,6 +15099,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
}
markQueuedAttachmentDurableAfterSnapshot(sid, parsed.clientId, attachmentOwnerId);
commitAutoTitle();
+ if (parsed.durableDelivery) await awaitAgentInputQueueSnapshotPersistence(sid);
return projection;
} catch (err) {
if (!acceptedByCoordinator) {
@@ -15413,11 +15462,24 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const sid = requireSessionId(sessionId);
await assertRemoteInputControlBoundary(sid, isDeviceLinkInvoke(), opts);
const cid = requireClientId(clientId);
+ const durable = !!opts && typeof opts === 'object' && (opts as { durableDelivery?: unknown }).durableDelivery === true;
+ const before = inputCoordinator.getProjection(sid);
+ if (durable && (before.steeringQueueClientIds.includes(cid)
+ || (!before.pendingQueue.some((item) => item.clientId === cid)
+ && inputCoordinator.hasKnownClientId(sid, cid)))) {
+ // Once drain or steer owns the item, removal cannot cancel its in-flight persistence.
+ // Never insert a tombstone in front of that user row.
+ return { ...before, inputDeliveryCancelled: false };
+ }
+ // Register the intent and remove synchronously before drain can take a pending item.
+ const cancellation = durable ? saveCancelledInputDelivery(sid, cid) : undefined;
const result = inputCoordinator.remove(sid, cid);
+ const inputDeliveryCancelled = await cancellation;
+ await awaitAgentInputQueueSnapshotPersistence(sid);
if (!inputCoordinator.hasPendingQueuedWork(sid)) {
getAgentIslandService()?.notifyQueueEmptied(sid);
}
- return result;
+ return durable ? { ...result, inputDeliveryCancelled: inputDeliveryCancelled === true } : result;
},
);
diff --git a/apps/desktop/src/shared/agentInputQueue.ts b/apps/desktop/src/shared/agentInputQueue.ts
index eb43dca60d..ac5c294873 100644
--- a/apps/desktop/src/shared/agentInputQueue.ts
+++ b/apps/desktop/src/shared/agentInputQueue.ts
@@ -227,6 +227,8 @@ export interface AgentInputQueuedMessage {
/** Host-owned text-only input; retained by queue persistence and retry. */
toolsDisabled?: boolean;
clientId: string;
+ /** Opt-in: a cancelled delivery ID must never become a fresh enqueue on reconnect. */
+ durableDelivery?: true;
text: string;
/**
* Host-owned receipt for the first acceptance boundary. The controlled
diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx
index 4da8f9ede0..c02bd02704 100644
--- a/apps/mobile/app/_layout.tsx
+++ b/apps/mobile/app/_layout.tsx
@@ -4,6 +4,7 @@ import { ResidentHomeListProvider } from '@/session/ResidentHomeList';
import { AndroidUpdateSheet } from '@/update/AndroidUpdateSheet';
import { PeerFileTransport } from '@/device-link/peerFileTransport';
import { startLocalDiagnostics } from '@/debug/localDiagnostics';
+import { MobileOutboxBridge } from '@/session/MobileOutboxBridge';
import {
DarkTheme as NavigationDarkTheme,
DefaultTheme as NavigationLightTheme,
@@ -363,6 +364,7 @@ function RootAfterUpdateChannel({ channel }: { channel: UpdateChannel }) {
<DeviceLinkProvider>
<PeerFileTransport />
<PrecreatedWorktreeRecoveryBridge />
+ <MobileOutboxBridge />
<HomeEntryProvider>
<NavigationGate />
</HomeEntryProvider>
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index 8aa48fc34d..e66dc6da24 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -21,6 +21,10 @@ import { SharedTaskEndedState } from '@/session/SharedTaskEndedState';
import { useSessionResourceCards } from '@/session/useSessionResourceCards';
import { SessionResourceCards } from '@/session/SessionResourceCards';
import { mobileDebugLog } from '@/debug/mobileDebugLog';
+import { getMobileAuthOwner, isMobileAuthOwnerCurrent, subscribeMobileAuthOwner } from '@/auth/authOwnerGeneration';
+import { mobileDurableOutbox, durableOutboxDisplayItem, getCurrentMobileOutboxRecords, reconcileMobileOutboxDrafts } from '@/session/mobileDurableOutbox';
+import { retainOutboxFile, durableOutboxUploadUri, removeOutboxFiles, outboxAttachmentNeedsLocalBytes } from '@/session/durableOutboxFiles';
+import { isDurableOutboxSettled, isDurableOutboxUnsent, observeDurableOutboxSending, type DurableOutboxRecord } from '@/session/durableOutbox';
import { isInFlightDeviceLinkError, isSharedTaskPeer } from '@cindy/device-link';
import { takeRefinementContextTail, truncateRefinementReply } from '@cindy/voice-input-core';
import {
@@ -418,16 +422,9 @@ import {
import {
buildOutboxItem,
createOutboxClientId,
- isSafelyUnsentOutboxEnqueueError,
outboxDisplayItem,
outboxItemAttachments,
- outboxItemReady,
- outboxItemRetrying,
- outboxItemWaitingForConnection,
- outboxItemWithEnqueueFailure,
- outboxWithUploadResult,
recoverOutboxItemsToComposerDraft,
- replaceOutboxItem,
shouldHoldOutboxDispatchForConnection,
type MobileOutboxConnectionState,
type MobileOutboxItem,
@@ -859,22 +856,6 @@ function attachmentIdSetsEqual(
return idsA.length === idsB.length && idsA.every((id, index) => id === idsB[index]);
}
-/**
- * 将无法继续派发的 outbox 条目按会话恢复为可见草稿 + 引用 store。
- * marker-bearing body 只留作未编辑重发的隐藏顺序基线,绝不写进输入框。
- */
-function restoreOutboxItemsToDraft(items: readonly MobileOutboxItem[]): void {
- const itemsBySession = new Map<string, MobileOutboxItem[]>();
- for (const item of items) {
- const sessionItems = itemsBySession.get(item.sessionId) ?? [];
- sessionItems.push(item);
- itemsBySession.set(item.sessionId, sessionItems);
- }
- for (const [draftSessionId, sessionItems] of itemsBySession) {
- restoreRecoverableItemsToDraft(draftSessionId, sessionItems);
- }
-}
-
/**
* 把一组待发条目按给定顺序合并回某个会话的草稿。
*
@@ -1043,6 +1024,7 @@ export default function SessionScreen() {
return () => subscription.remove();
}, [deviceId, sessionId]);
const auth = useAuth();
+ const outboxOwner = useSyncExternalStore(subscribeMobileAuthOwner, getMobileAuthOwner, getMobileAuthOwner);
const windowDimensions = useWindowDimensions();
const insets = useSafeAreaInsets();
const keyboardState = useMobileKeyboardState();
@@ -1333,8 +1315,9 @@ export default function SessionScreen() {
discardAllPendingUploads,
discardAllPendingUploadsForScopeChange,
waitForPendingUploads,
- claimActiveUploads,
- releaseClaimedUploads,
+ beginOutboxAttachmentHandoff,
+ getUploadedSource,
+ releaseUploadedSources,
waitForPastePlaceholdersSettled,
hasPastePlaceholders,
getPendingUploadCount,
@@ -1343,16 +1326,10 @@ export default function SessionScreen() {
deviceId,
getAccessToken: () => auth.getAccessToken(),
getAttachmentCount: () => attachmentsRef.current.length,
- onUploaded: (rawAttachment, candidate, localId) => {
+ onUploaded: (rawAttachment, candidate) => {
// 标注类 candidate:记录「矢量笔迹 + 原图」再编辑真相并打 annotated wire 标。
const attachment = composerAnnotationsRef.current
?.decorateUploadedAttachment(rawAttachment, candidate) ?? rawAttachment;
- // outbox 域:任务已随乐观消息发出——附件填回对应消息的槽位,不进 composer
- // 托盘;再编辑真相同步 forget(消息已离开 composer,与发送成功后的清理同语义)。
- if (routeUploadToOutboxRef.current(localId, { attachment })) {
- composerAnnotationsRef.current?.forgetAttachment(attachment.id);
- return;
- }
// send() 在 waitForPendingUploads 落定后同步读 ref,而 setState 到 commit 有
// 微任务延迟——这里派发时同步镜像,保证「上传完成→立即发送」不丢刚落定的附件。
attachmentsRef.current = [...attachmentsRef.current, attachment];
@@ -1366,10 +1343,7 @@ export default function SessionScreen() {
}
setAttachments((current) => [...current, attachment]);
},
- onError: (message, context) => {
- // outbox 域任务的失败路由给对应消息气泡(标失败可重试),不落 composer 错误条。
- const uploadLocalId = context?.uploadLocalId;
- if (uploadLocalId && routeUploadToOutboxRef.current(uploadLocalId, { failed: true })) return;
+ onError: (message) => {
setAttachmentError(message);
},
onPicked: () => {
@@ -1377,35 +1351,11 @@ export default function SessionScreen() {
requestAnimationFrame(() => composerInputRef.current?.focus());
},
});
- // 换会话与退屏的 outbox 回收:未派发条目的文字合并回草稿库(用户已「发出」的文字
- // 不能静默蒸发,回来时出现在输入框里),在途上传任务丢弃(与托盘退出语义一致,
- // controller 会中止传输并回收已完成的 OSS 对象),已就绪附件回收中转对象。
- // 已交接进 pendingQueue / enqueue 在途的消息不在 outbox,不受影响。
- // deps 安全性:removePendingUpload 是 controller.remove 的稳定引用(controller
- // useMemo([]) 单例),不会让本 effect 每 render 重建;auth 经 remoteMediaDepsRef 读最新。
+ // The page only owns its composer. Accepted outbox records belong to the app bridge.
useEffect(() => {
outboxSessionAliveRef.current = sessionId;
- return () => {
- // 先撤存活标记:此后到达的派发失败回插 / 上传结果一律走 salvage 降级,
- // 不会再写进即将清空的 ref 或下一个会话的 outbox。
- outboxSessionAliveRef.current = null;
- const items = outboxRef.current;
- if (items.length === 0) return;
- outboxRef.current = [];
- setOutboxItems([]);
- // 草稿按条目自身归属写回(而非本 effect 捕获的 sessionId):防御性一致。
- // 引用正文同步恢复 quote store,输入框只接收剥过 marker 的可见文字。
- restoreOutboxItemsToDraft(items);
- for (const item of items) {
- for (const localId of [...item.waitingIds, ...item.failedIds]) removePendingUpload(localId);
- for (const attachment of outboxItemAttachments(item)) {
- discardMobileUploadedAttachment(attachment, {
- getToken: () => remoteMediaDepsRef.current.auth.getAccessToken(),
- });
- }
- }
- };
- }, [sessionId, removePendingUpload]);
+ return () => { outboxSessionAliveRef.current = null; };
+ }, [sessionId]);
// 排队编辑复用 composer;推荐只属于用户的普通草稿。
const [queueEditing, setQueueEditing] = useState<QueueEditingState | null>(null);
const [voiceStartPending, setVoiceStartPending] = useState(false);
@@ -1489,6 +1439,7 @@ export default function SessionScreen() {
for (const attachment of editing?.stashedAttachments ?? []) {
attachmentsById.set(attachment.id, attachment);
}
+ releaseUploadedSources([...attachmentsById.keys()]);
attachmentsRef.current = [];
setAttachments([]);
setAttachmentPreviews({});
@@ -1669,11 +1620,28 @@ export default function SessionScreen() {
// ref 在 send() 同步段立即置位,后续点击当场拦下(同 new.tsx creatingRef /
// voiceStopInFlightRef 的既有模式)。
const sendInFlightRef = useRef(false);
- // 本地待发队列(outbox):附件仍在上传时点发送,消息立即以待发气泡上屏并入此队,
- // 附件落定后按 FIFO 逐条真正 enqueue(状态机纯函数在 sessionOutbox.ts)。ref 是
- // 同步真源(上传回调 / 派发循环 / send 同步段都要读最新值),state 只驱动渲染。
- const [outboxItems, setOutboxItems] = useState<readonly MobileOutboxItem[]>([]);
- const outboxRef = useRef<readonly MobileOutboxItem[]>([]);
+ const rawOutboxRecords = useSyncExternalStore(mobileDurableOutbox.subscribe, mobileDurableOutbox.getSnapshot);
+ const durableOutboxRecords = useMemo(() => rawOutboxRecords.filter((record) => record.accountId === outboxOwner.accountKey && !isDurableOutboxSettled(record)), [rawOutboxRecords, outboxOwner]);
+ const outboxItems = useMemo(() => durableOutboxRecords
+ .filter((r) => r.deviceId === deviceId && r.item.sessionId === sessionId && r.accountId === getMobileAuthOwner().accountKey)
+ .map(durableOutboxDisplayItem), [durableOutboxRecords, deviceId, sessionId]);
+ const outboxRef = useRef<readonly MobileOutboxItem[]>(outboxItems);
+ outboxRef.current = outboxItems;
+ useEffect(() => observeDurableOutboxSending(mobileDurableOutbox, deviceId, sessionId, (record) => {
+ markQueueItemSending(record.prepared!);
+ rememberSentAttachmentPreviews(record.item.clientId, outboxItemAttachments(record.item), (attachment) => {
+ const slot = record.item.attachmentSlots.findIndex((item) => item?.id === attachment.id);
+ const upload = record.uploads.find((item) => item.slot === slot);
+ return upload ? durableOutboxUploadUri(record, upload) : record.item.slotMeta[slot]?.previewUri;
+ });
+ }, (clientId) => {
+ setSendingQueueClientIds((current) => {
+ if (!current.has(clientId)) return current;
+ const next = new Set(current);
+ next.delete(clientId);
+ return next;
+ });
+ }, outboxOwner.accountKey), [outboxOwner, deviceId, sessionId, markQueueItemSending, rememberSentAttachmentPreviews]);
const pageMessageWorkLeaseRef = useRef<ReturnType<
typeof remoteSessionStore.acquireSessionMessageWork
> | null>(null);
@@ -1697,23 +1665,8 @@ export default function SessionScreen() {
useLayoutEffect(() => {
pageMessageWorkLeaseRef.current?.update(pageHasMessageWork);
}, [pageHasMessageWork]);
- // 派发循环重入锁 + 路由函数的 ref 中转(onUploaded 闭包声明在组件前部,实际
- // 路由/派发逻辑声明在 send() 附近,经 ref 断开声明顺序依赖,同 composerAnnotationsRef)。
- const outboxPumpBusyRef = useRef(false);
- const routeUploadToOutboxRef = useRef<
- (localId: string, result: { attachment: RemoteSerializedAttachment } | { failed: true }) => boolean
- >(() => false);
- // outbox 宿主存活标记:值 = 当前有 outbox 回收责任的 sessionId,cleanup(切会话
- // 收尸 / 卸载)时置 null。dispatch 失败回插与上传结果路由据此判断条目所属会话
- // 是否还在场——不在场就降级 salvage,绝不写进别的会话或没人消费的 ref。
+ // Only pre-accept composer continuations belong to this page; delivery belongs to the app.
const outboxSessionAliveRef = useRef<string | null>(sessionId);
- // 原地切 session(实例复用)时 render 阶段同步清渲染 state,不闪现旧会话的待发
- // 气泡;ref 此刻不清——sessionId 键控的 cleanup effect(下方)还要读它做回收。
- const [prevOutboxSessionId, setPrevOutboxSessionId] = useState(sessionId);
- if (prevOutboxSessionId !== sessionId) {
- setPrevOutboxSessionId(sessionId);
- setOutboxItems([]);
- }
const [messageListFollowLatestRequestKey, setMessageListFollowLatestRequestKey] = useState(0);
const [bottomOverlayContentHeight, setBottomOverlayContentHeight] = useState(0);
const [topOverlayHeight, setTopOverlayHeight] = useState(0);
@@ -3106,11 +3059,11 @@ export default function SessionScreen() {
? Promise.resolve()
: hydrateQuotes(sessionId);
- void Promise.all([
+ void reconcileMobileOutboxDrafts(sessionId).then(() => Promise.all([
quoteHydration,
readComposerDocumentDraft(sessionId),
readComposerDraft(sessionId),
- ]).then(([, storedDocument, storedDraft]) => {
+ ])).then(([, storedDocument, storedDraft]) => {
if (cancelled || appliedRouteDraftRef.current !== key) return;
const hydratedQuotes = [...getQuotes(sessionId)];
const fallbackText = storedDraft ?? routeDraft ?? '';
@@ -3148,6 +3101,8 @@ export default function SessionScreen() {
clearQuotes(sessionId);
applyComposerDocument(nextDocument);
setComposerDraftHydrated(true);
+ }).catch((error) => {
+ if (!cancelled) setError(formatRemoteError(error));
});
return () => {
cancelled = true;
@@ -3750,9 +3705,19 @@ export default function SessionScreen() {
style: 'cancel',
onPress: () => {
if (!creationTask) return;
+ const ownerAtEdit = getMobileAuthOwner();
void prepareNewSessionCreationForEdit(sessionId)
- .then((prepared) => {
- if (!prepared) return;
+ .then(async (prepared) => {
+ if (!prepared || !isMobileAuthOwnerCurrent(ownerAtEdit) || outboxSessionAliveRef.current !== sessionId) return;
+ const durableFirst = getCurrentMobileOutboxRecords().find((r) => r.item.sessionId === sessionId && r.deviceId === deviceId && r.creation);
+ if (durableFirst) {
+ const owner = getMobileAuthOwner();
+ await mobileDurableOutbox.update(durableFirst, { suspended: true, state: 'failed', error: t('session.screen.firstMessageNotSent') });
+ if (!isMobileAuthOwnerCurrent(owner) || outboxSessionAliveRef.current !== sessionId) return;
+ dismissNewSessionCreation(sessionId);
+ router.replace({ pathname: '/sessions/new', params: { recoverySessionId: sessionId, deviceId, deviceName } });
+ return;
+ }
// 创建期间发出的后续消息必须一起带回新建页(review P1):它们此刻在 outbox 里,
// 而下一行 dismiss 会连同合成会话行一起删掉——会话页 unmount 时 cleanup 会把它们
// 写进那个已经不存在的会话的草稿,用户在新建页看不到、也再也找不回来。
@@ -3819,6 +3784,16 @@ export default function SessionScreen() {
return;
}
if (status === 'enqueue-failed') {
+ const durableFirst = getCurrentMobileOutboxRecords().find((r) => r.item.sessionId === sessionId && r.deviceId === deviceId && r.creation);
+ if (durableFirst) {
+ const owner = getMobileAuthOwner();
+ void mobileDurableOutbox.update(durableFirst, { state: 'queued', suspended: false, error: undefined }).then(() => {
+ if (isMobileAuthOwnerCurrent(owner)) dismissNewSessionCreation(sessionId);
+ }).catch((err) => {
+ if (isMobileAuthOwnerCurrent(owner) && outboxSessionAliveRef.current === sessionId) setError(formatRemoteError(err));
+ });
+ return;
+ }
// 首条消息没发出,而创建期间用户可能已经发了后续消息(composer 全程可用)。
//
// 「首条回输入框 + 后续留在 outbox」是不可恢复的:重试失败的 outbox 条目会把后续
@@ -3867,12 +3842,15 @@ export default function SessionScreen() {
? creationTask.firstMessageClientId
: null;
const sending = new Set(sendingQueueClientIds);
+ for (const record of durableOutboxRecords) {
+ if (record.item.sessionId === sessionId && record.deviceId === deviceId && record.state !== 'host-owned') sending.add(record.item.clientId);
+ }
if (!creationPendingClientId || sending.has(creationPendingClientId)) {
return sending;
}
sending.add(creationPendingClientId);
return sending;
- }, [creationTask, sendingQueueClientIds]);
+ }, [creationTask, sendingQueueClientIds, durableOutboxRecords, sessionId, deviceId]);
// 已读回执:liveActivity **签名变化且 attention=true**(会话开着时新 turn 完成翻
// 未读,或 attention 一直为 true 但内容更新——新 turn 完成会经 completed→running→
@@ -4342,6 +4320,9 @@ export default function SessionScreen() {
const activeIds = new Set([
...sendingQueueClientIds,
...settlingItemsForRender.map((item) => item.clientId),
+ ...durableOutboxRecords.filter((record) => record.deviceId === deviceId
+ && record.item.sessionId === sessionId && record.state !== 'failed'
+ && !record.cancelRequested && !record.suspended).map((record) => record.item.clientId),
]);
// Only the enqueue path can reserve a transcript position. A vanished
// busy queue has no reliable local turn boundary: history and projection
@@ -4351,7 +4332,7 @@ export default function SessionScreen() {
rawMessages, activeIds, confirmedUserClientIds,
);
}, [optimisticUserState, sessionId, rawMessages,
- sendingQueueClientIds, settlingItemsForRender, confirmedUserClientIds]);
+ sendingQueueClientIds, settlingItemsForRender, confirmedUserClientIds, durableOutboxRecords, deviceId]);
if (optimisticUserState.sessionId === sessionId && optimisticUsers !== optimisticUserState.items) {
setOptimisticUserState({ sessionId, items: optimisticUsers });
}
@@ -5426,6 +5407,7 @@ export default function SessionScreen() {
});
// 标注附件退场时同步清「矢量笔迹 + 原图副本」的再编辑真相。
composerAnnotationsRef.current?.forgetAttachment(id);
+ releaseUploadedSources([id]);
setAttachmentError(null);
}, [attachments, auth]);
@@ -5478,30 +5460,6 @@ export default function SessionScreen() {
));
}, []);
- // ————— 本地待发队列(outbox):附件上传中消息先上屏 —————
- // 状态机纯函数在 sessionOutbox.ts;这里只做 React 接线与 enqueue 派发。
- // 所有更新经此单点:ref(同步真源)与 state(渲染)一起写。
- const updateOutbox = (updater: (items: readonly MobileOutboxItem[]) => readonly MobileOutboxItem[]) => {
- const next = updater(outboxRef.current);
- if (next === outboxRef.current) return;
- outboxRef.current = next;
- setOutboxItems(next);
- };
-
- /**
- * 无法回插 outbox 时的兜底(所属会话已离场 / 屏已卸载):文字合并回**条目所属
- * 会话**的草稿库与引用 store(持久化,不静默蒸发),已就绪附件回收 OSS
- * 中转对象。派发失败才会走到这里,此时附件必然已全部落定(ready 才派发),
- * 没有在途任务要清。
- */
- const salvageOutboxItem = (item: MobileOutboxItem) => {
- restoreOutboxItemsToDraft([item]);
- for (const attachment of outboxItemAttachments(item)) {
- discardMobileUploadedAttachment(attachment, {
- getToken: () => remoteMediaDepsRef.current.auth.getAccessToken(),
- });
- }
- };
const readAuthoritativeEnqueueAcceptance = async (targetSessionId: string, clientId: string,
expectedRemoteEpoch: number) => {
@@ -5524,291 +5482,62 @@ export default function SessionScreen() {
}
};
- /**
- * 派发一条就绪的 outbox 条目:构建 queued(权限档用发送时刻快照,model / effort
- * 等跟随会话最新值)→ 乐观进本地 pendingQueue(待发气泡原位变为排队气泡,同帧
- * 无跳变)→ enqueue RPC(弱网重试 + 对账,同原发送路径口径)。enqueue 确认未
- * 应用时条目回 outbox 队首标失败,气泡保留可重试——不恢复草稿(消息还在屏上)。
- * 全程使用 item.sessionId(而非闭包 sessionId):dispatch 在途窗口用户可能原地
- * 切会话,消息必须始终发进它所属的会话(review P1)。
- */
- const dispatchOutboxItem = async (item: MobileOutboxItem) => {
- if (outboxSessionAliveRef.current !== item.sessionId) return 'stopped' as const;
- const messageWorkLease = remoteSessionStore.acquireSessionMessageWork(item.sessionId, true);
- try {
- const failItem = (message: string) => {
- // 归属校验:条目所属会话已离场(切会话 cleanup 已跑 / 屏已卸载)时不回插
- // 共享 ref——那会把 A 会话的失败气泡画进 B,或写进没人消费的 ref 让文字
- // 蒸发(review P1)。降级为草稿写回 + 附件回收。
- if (outboxSessionAliveRef.current !== item.sessionId) {
- salvageOutboxItem(item);
- return;
- }
- updateOutbox((items) => (
- items.some((existing) => existing.clientId === item.clientId)
- ? replaceOutboxItem(items, outboxItemWithEnqueueFailure(item, message))
- : [outboxItemWithEnqueueFailure(item, message), ...items]
- ));
- };
- const waitForConnection = (error: unknown) => {
- // 与失败回插同一归属边界:离场后不能把旧会话气泡塞进当前页面,降级回该
- // 会话的持久草稿;仍在本页则恢复为 uploading/ready,留在 FIFO 队首。
- if (outboxSessionAliveRef.current !== item.sessionId) {
- salvageOutboxItem(item);
- return;
- }
- const waiting = outboxItemWaitingForConnection(item);
- updateOutbox((items) => (
- items.some((existing) => existing.clientId === item.clientId)
- ? replaceOutboxItem(items, waiting)
- : [waiting, ...items]
- ));
- setError(formatRemoteError(error));
- };
- const sessionNow = remoteSessionStore.getSessions().find((entry) => entry.id === item.sessionId);
- if (!sessionNow) {
- failItem(t('session.screen.sessionNotFoundResync'));
- return;
- }
- if (!sessionNow.workingDir) {
- failItem(t('session.screen.missingWorkingDir'));
- return;
- }
- const sessionAtSend = { ...sessionNow, permissionMode: item.permissionModeAtSend };
- const queuedDraft = {
- ...buildQueuedTextMessage(sessionAtSend, item.text, new Date(), item.clientId, {
- attachments: outboxItemAttachments(item),
- quotesEncoded: item.quotesEncoded,
- agentReferences: item.agentReferences,
- pastedTextRanges: item.pastedTextRanges,
- slashCommandRanges: item.slashCommandRanges,
- }),
- ...(item.sessionRefs && item.sessionRefs.length > 0
- ? { sessionRefs: [...item.sessionRefs] }
- : {}),
- };
- let queued: QueuedRemoteMessage;
- try {
- queued = await prepareMobileQueuedSessionReferences(
- queuedDraft,
- invoke,
- remoteSessionStore.getSessionDeviceId,
- deviceId,
- );
- } catch (err) {
- // prepare 期间条目仍在 outbox;离场 cleanup 已负责恢复草稿与回收附件,
- // 这里既不能重复 salvage,也不能让旧 continuation 继续 enqueue。
- if (outboxSessionAliveRef.current !== item.sessionId) return 'stopped' as const;
- if (isAutoRecoveringSessionReferencePreparationError(err)) {
- waitForConnection(err);
- return 'deferred' as const;
- }
- failItem(formatRemoteError(err));
- return;
- }
- if (outboxSessionAliveRef.current !== item.sessionId) return 'stopped' as const;
- // 乐观交接:进本地 pendingQueue 的同一同步段把条目移出 outbox,气泡原位从
- // 「发送中」变「排队中」不闪断;enqueue 成功后用权威 projection 覆盖 reconcile。
- const projectionBeforeSend = remoteSessionStore.getInputProjection(item.sessionId);
- markQueueItemSending(queued);
- remoteSessionStore.setInputProjectionOptimistically(item.sessionId, {
- ...projectionBeforeSend,
- sessionId: projectionBeforeSend.sessionId || item.sessionId,
- pendingQueue: [...projectionBeforeSend.pendingQueue, queued],
- });
- updateOutbox((items) => items.filter((entry) => entry.clientId !== item.clientId));
- // outbox 条目的槽位预览接着给排队气泡用:交接后图不能因为换了数据源就消失。
- rememberSentAttachmentPreviews(
- item.clientId,
- outboxItemAttachments(item),
- (attachment) => {
- const slotIndex = item.attachmentSlots.findIndex((slot) => slot?.id === attachment.id);
- return slotIndex >= 0 ? item.slotMeta[slotIndex]?.previewUri : null;
- },
- );
- // outbox 气泡本来就在转圈:交接进 pendingQueue 后 enqueue 仍在途,徽标继续转圈,
- // 不要在这一帧闪成排队 icon 再回来(也不能谎报「已入队」)。
- const projectionRemoteEpochAtRequestStart =
- remoteSessionStore.captureInputProjectionRemoteEpoch(item.sessionId);
- const projectionEpochAtRequestStart =
- remoteSessionStore.captureInputProjectionAuthorityEpoch(item.sessionId);
- let enqueueAccepted = false;
- try {
- // 弱网重试与写序边界同 send() 原路径(仅明确可安全重发的瞬时传输错误)。
- let projection: InputProjection | undefined;
- for (let attempt = 0; ; attempt++) {
- try {
- projection = await maker.input.enqueue(item.sessionId, queued, { sendAtMs: Date.now() });
- break;
- } catch (err) {
- if (
- attempt >= ENQUEUE_RECONNECT_RETRIES
- || !isRetryableEnqueueTransportError(err)
- || isInFlightDeviceLinkError(err)
- ) throw err;
- await new Promise((resolve) => setTimeout(resolve, ENQUEUE_RECONNECT_BACKOFF_MS * 2 ** attempt));
- }
- }
- remoteSessionStore.setInputProjectionIfCurrent(
- item.sessionId,
- projection,
- projectionEpochAtRequestStart,
- projectionRemoteEpochAtRequestStart,
- queued.clientId,
- );
- enqueueAccepted = true;
- } catch (err) {
- // 与原路径同口径:先对账分辨「确实没应用」vs「已应用但响应丢了」。
- const safeToRetry = isSafelyUnsentOutboxEnqueueError(err);
- const accepted = await readAuthoritativeEnqueueAcceptance(
- item.sessionId, queued.clientId, projectionRemoteEpochAtRequestStart,
- );
- enqueueAccepted = accepted;
- if (!accepted) {
- const current = remoteSessionStore.getInputProjection(item.sessionId);
- remoteSessionStore.setInputProjectionOptimistically(item.sessionId, {
- ...current,
- pendingQueue: current.pendingQueue.filter((entry) => entry.clientId !== queued.clientId),
- });
- if (safeToRetry) {
- waitForConnection(err);
- return 'deferred' as const;
- }
- failItem(formatRemoteError(err));
- }
- } finally {
- // 入队确认、回 outbox / 失败,或转交 optimistic projection 等待权威同步后,
- // 都不再是当前 RPC 在途;收掉 sending 标记,避免后续同 id 气泡悬空转圈。
- clearQueueItemSending(queued, enqueueAccepted, projectionBeforeSend);
- }
- // enqueue / 对账期间离场时,成功路径无需恢复草稿,但旧 pump 也绝不能接着
- // 消费新任务的 outbox;失败路径已由 failItem / waitForConnection 按 A 收口。
- if (outboxSessionAliveRef.current !== item.sessionId) return 'stopped' as const;
- } finally {
- messageWorkLease.release();
- }
- };
-
- /** 会话行的同步真源(store);命令式路径不能读可能落后一帧的 render 快照。 */
const readSessionRowNow = () => remoteSessionStore.getSessions().find((item) => item.id === sessionId) ?? null;
-
- /** async pump 每轮读取 ref 中的最新连接态,断线后立即停在当前 FIFO 队首。 */
- const outboxConnectionBlockedNow = () => shouldHoldOutboxDispatchForConnection(
- outboxConnectionStateRef.current,
- );
-
- /**
- * 「会话参数还没就绪,现在不能 enqueue」——outbox 只排队不派发的判据。
- *
- * 下列状态中消息仍然照常上屏(乐观语义,composer 不进只读档),只是派发要等:
- * - relay / 目标 presence 断开、设备熔断或请求命中自动恢复类错误;
- * - 会话行还没到:没有任何可用的发送参数;
- * - 缓存种入行:字段经瘦身 / 截断(240 字符),不能当发送参数;
- * - 新建在途 / 创建管线未收口:会话可能还没在被控端建成,且首条 enqueue 落定前
- * 抢发的消息 sendAtMs 会早于首条、被排到它前面(newSessionCreation.ts 注释)。
- *
- * 读 store 而非 render 快照:pump 是异步循环,每轮都要看当下的真相。
- */
+ const outboxConnectionBlockedNow = () => shouldHoldOutboxDispatchForConnection(outboxConnectionStateRef.current);
const outboxDispatchBlockedNow = () => {
- if (outboxConnectionBlockedNow()) return true;
const row = readSessionRowNow();
- // 「会话在被控端还不存在」是子集;派发还额外要求字段权威、创建管线已收口。
- if (isRemoteSessionMissing(row)) return true;
- if (row?.cacheSeeded) return true;
- return getNewSessionCreationTask(sessionId) !== null;
- };
-
- /** FIFO 派发循环:队首就绪(附件齐、无失败)才派发;失败条目留在队首阻塞后续保顺序。 */
- const pumpOutbox = async () => {
- if (outboxPumpBusyRef.current) return;
- outboxPumpBusyRef.current = true;
- try {
- for (;;) {
- const head = outboxRef.current[0];
- if (!head || !outboxItemReady(head)) return;
- // 会话未就绪:条目原样留在 outbox(气泡继续转圈,不标失败),就绪时由
- // 下方的解禁 effect 重新 pump。
- if (outboxDispatchBlockedNow()) return;
- updateOutbox((items) => replaceOutboxItem(items, { ...head, phase: 'dispatching' }));
- const result = await dispatchOutboxItem({ ...head, phase: 'dispatching' });
- if (result === 'deferred' || result === 'stopped') return;
- }
- } finally {
- outboxPumpBusyRef.current = false;
- }
- };
-
- // 上传结果路由(hook 的 onUploaded/onError 经 ref 调到最新闭包):localId 属于
- // outbox 条目 → 填槽/标失败并驱动派发,返回 true;否则返回 false 走 composer 托盘。
- routeUploadToOutboxRef.current = (localId, result) => {
- const owner = outboxRef.current.find((item) => item.slotByLocalId[localId] !== undefined);
- if (!owner) return false;
- const next = outboxWithUploadResult(outboxRef.current, localId, result);
- if (next !== outboxRef.current) outboxRef.current = next;
- // 归属校验:条目属于已离场会话(原地切 session 后 cleanup 尚未跑的一帧窗口)
- // 时只写 ref 等 cleanup 收尸——不 setState(不把旧会话气泡画进新会话)、不
- // pump(不派发离场条目);成功产物已填进槽位,cleanup 会统一回收(review P1)。
- if (owner.sessionId !== sessionId) return true;
- setOutboxItems(outboxRef.current);
- void pumpOutbox();
- return true;
+ return outboxConnectionBlockedNow() || isRemoteSessionMissing(row) || row?.cacheSeeded === true
+ || getNewSessionCreationTask(sessionId) !== null;
};
-
- /** 重试失败条目:失败附件任务重跑(取新鲜 token),enqueue 失败型直接重新派发。 */
+ const findDurableOutboxRecord = (clientId: string) => getCurrentMobileOutboxRecords().find((r) =>
+ r.deviceId === deviceId && r.item.sessionId === sessionId && r.item.clientId === clientId);
const retryOutboxItem = (clientId: string) => {
- const item = outboxRef.current.find((entry) => entry.clientId === clientId);
- if (!item || item.phase !== 'failed') return;
+ const record = findDurableOutboxRecord(clientId);
+ if (!record || record.state !== 'failed') return;
+ if (record.creation && !record.prepared && !record.template) {
+ const owner = getMobileAuthOwner();
+ void mobileDurableOutbox.update(record, { suspended: true }).then(() => {
+ if (isMobileAuthOwnerCurrent(owner) && outboxSessionAliveRef.current === sessionId) {
+ router.push({ pathname: '/sessions/new', params: { recoverySessionId: sessionId, deviceId, deviceName } });
+ }
+ }).catch((err) => setError(formatRemoteError(err)));
+ return;
+ }
setQueueSelectedClientId(null);
- for (const localId of item.failedIds) retryPendingUpload(localId);
- updateOutbox((items) => replaceOutboxItem(items, outboxItemRetrying(item)));
- void pumpOutbox();
+ void mobileDurableOutbox.update(record, {
+ state: record.prepared ? 'confirming' : 'queued', error: undefined,
+ }).catch((err) => setError(formatRemoteError(err)));
};
-
- /** 删除待发条目:在途上传取消(controller 会回收已完成的 OSS 对象),就绪附件回收。 */
const removeOutboxItem = (clientId: string) => {
- const item = outboxRef.current.find((entry) => entry.clientId === clientId);
- if (!item) return;
- setQueueSelectedClientId(null);
- updateOutbox((items) => items.filter((entry) => entry.clientId !== clientId));
- for (const localId of [...item.waitingIds, ...item.failedIds]) removePendingUpload(localId);
- for (const attachment of outboxItemAttachments(item)) {
- discardMobileUploadedAttachment(attachment, { getToken: () => auth.getAccessToken() });
+ const record = findDurableOutboxRecord(clientId);
+ if (!record) return;
+ // Until creation succeeds, this row also owns the recovery form for every later message.
+ if (record.creation && !record.prepared && !record.template) {
+ setError(t('session.outbox.creationRecoveryRequired'));
+ return;
}
- // 队首失败条目被删除后,后面的条目可能已就绪。
- void pumpOutbox();
+ setQueueSelectedClientId(null);
+ const owner = getMobileAuthOwner();
+ const remove = async () => {
+ if (isDurableOutboxUnsent(record)) {
+ await mobileDurableOutbox.update(record, { state: 'host-owned', cleanupOutcome: 'cancelled', cancelRequested: true, error: undefined });
+ } else await mobileDurableOutbox.update(record, { cancelRequested: true, state: 'confirming' });
+ };
+ void remove().catch((err) => {
+ if (isMobileAuthOwnerCurrent(owner) && outboxSessionAliveRef.current === sessionId) setError(formatRemoteError(err));
+ });
};
-
const outboxDisplayItems = useMemo(() => outboxItems.map(outboxDisplayItem), [outboxItems]);
- /**
- * 取出并清空某会话的 outbox 条目(创建失败的两条收尾路径都要用)。
- *
- * 必须同步取走:调用方紧接着会 dismiss task / 删合成会话行,留在 ref 里的条目会被
- * unmount cleanup 写进一个即将消失的会话草稿里,等于丢消息。
- *
- * `uploads` 决定在途 / 失败上传任务的归宿——两条收尾路径的答案不同(review P1):
- * - `release-to-tray`:交还 composer 托盘(留在本页时的正解)。任务继续跑,落定后
- * routeUploadToOutbox 找不到归属条目、产物回落托盘;失败卡也回托盘可重试。取消
- * 重传是错的:用户已经等过一次上传,粘贴来源的本地文件此时可能已被回收,连重选
- * 都做不到。
- * - `cancel`:取消并回收中转对象,返回未能保住的条数。跨页导航(返回新建页)时
- * 上传 controller 随会话页销毁,保不住,只能取消 + 由调用方告知用户。
- */
+ // Legacy creation tasks have no app-owned first record. Never downgrade durable follow-ups
+ // into the old ephemeral draft recovery; new creation tasks use the branch above.
const takeOutboxForSession = (
- targetSessionId: string,
- uploads: 'release-to-tray' | 'cancel',
+ targetSessionId: string, _uploads: 'release-to-tray' | 'cancel',
): { items: MobileOutboxItem[]; cancelledUploadCount: number } => {
- const taken = outboxRef.current.filter((item) => item.sessionId === targetSessionId);
- if (taken.length === 0) return { items: [], cancelledUploadCount: 0 };
- updateOutbox((items) => items.filter((item) => item.sessionId !== targetSessionId));
- const pendingLocalIds = taken.flatMap((item) => [...item.waitingIds, ...item.failedIds]);
- if (uploads === 'release-to-tray') {
- // 已就绪附件的中转对象由调用方决定是否随草稿保留,不在这里回收。
- releaseClaimedUploads(pendingLocalIds);
- return { items: taken, cancelledUploadCount: 0 };
- }
- for (const localId of pendingLocalIds) removePendingUpload(localId);
- return { items: taken, cancelledUploadCount: pendingLocalIds.length };
+ if (getCurrentMobileOutboxRecords().some((r) => r.item.sessionId === targetSessionId && r.deviceId === deviceId)) {
+ throw new Error(t('session.outbox.restoreFailed'));
+ }
+ return { items: [], cancelledUploadCount: 0 };
};
// 待发送气泡(排队 / 落定 / 本地 outbox)作为消息流末尾的渲染项。
@@ -6039,28 +5768,13 @@ export default function SessionScreen() {
if (shareOperationSeqRef.current === operationSeq) setConversationShareBusy(false);
}
}, [conversationShareBusy, exportConversationSharePng, selectedShareMessages.length, shareSelectionActive, shareSelectionRevision, t]);
- // 解禁唤醒:会话参数就绪(fresh 元数据到达 / 新建管线收口)的那一帧重新 pump,把
- // 未就绪期间攒下的待发消息按 FIFO 发出去。渲染态判据与 outboxDispatchBlockedNow
- // 同构(那个读 store,供异步循环用;这个供 effect 依赖比较用)。
- // 声明位置在创建管线收口 effect 之后:enqueue-failed 那一帧要先把 outbox 条目标成
- // 失败挡住队首,再轮到这里 pump,否则后续消息会超车到首条消息前面。
- const outboxDispatchBlocked = !currentSession
- || currentSession.cacheSeeded === true
- || currentSession.pendingLocalCreation === true
- || creationTask !== null
- || outboxConnectionDispatchBlocked;
- useEffect(() => {
- if (outboxDispatchBlocked) return;
- void pumpOutbox();
- // pumpOutbox 是每 render 重建的普通闭包,不入依赖(入了会每帧重跑);它内部读
- // outboxRef / store 的最新真相,不依赖捕获值。
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [connectionEpoch, outboxDispatchBlocked]);
-
async function send(options: {
draftOverride?: string;
documentOverride?: ComposerDocument;
} = {}) {
+ // A committed outbox item may still own the draft shown during hydration.
+ // Do not submit that snapshot before its durable handoff is reconciled.
+ if (!composerDraftHydrated) return;
if (
voiceState === 'listening' &&
options.draftOverride === undefined &&
@@ -6157,12 +5871,16 @@ export default function SessionScreen() {
// 旧协议 Plan 依赖会话级 permissionMode,不能排在既有本地消息后,也不能在
// 已知断线时托管给自动恢复。必须在乐观清空和任何 await 前拒绝,原草稿原位保留。
if (legacyPlanRequiresLiveDispatch && (
- dispatchBlockedAtSend || outboxRef.current.length > 0 || outboxPumpBusyRef.current
+ dispatchBlockedAtSend || outboxRef.current.length > 0
)) {
sendInFlightRef.current = false;
setSending(false);
return;
}
+ const useDurableOutbox = outboxEligible && !earlyLocalCommand && !earlyDesktopCommand && !legacyPlanRequiresLiveDispatch;
+ const planModeAtSend = runtimeOptions?.planModeSupported === true
+ ? (readSessionRowNow() ?? currentSession).planModeEnabled === true
+ : undefined;
pendingSkillSelectionRef.current = null;
dismissPromptRecommendation();
// 乐观第一拍:点发送立刻清空输入框并跟到底部,不等任何网络往返(enqueue 是
@@ -6217,13 +5935,13 @@ export default function SessionScreen() {
let scopeExitDraftRecovered = false;
const sendScopeStillAlive = () => outboxSessionAliveRef.current === sessionId;
const recoverCapturedDraftForScopeExit = () => {
- if (scopeExitDraftRecovered || !outboxEligible) return;
+ if (scopeExitDraftRecovered || !outboxEligible || useDurableOutbox) return;
scopeExitDraftRecovered = true;
// 乐观清空已持久删除 A 草稿;切到 B 后不能再读写共享 composer ref。
// 直接按捕获的发送快照合并回 A 的草稿库,并保留 A 期间新输入的后续文字。
restoreRecoverableItemsToDraft(sessionId, [capturedDraftRecoveryItem()]);
};
- if (text) applyComposerDocument(documentAfterOptimisticClear);
+ if (text && !useDurableOutbox) applyComposerDocument(documentAfterOptimisticClear);
// A pasted message link is committed to the editor synchronously, while
// its readable body is fetched from the source device asynchronously.
// The optimistic clear above preserves the existing "tap sends this
@@ -6251,26 +5969,7 @@ export default function SessionScreen() {
// 可能点 × 放弃或切换编辑目标——等待结束后以快照与最新 ref 比对,不一致则中止
// 保存,防止编辑文本被当成一条全新消息发出(PR#709 review P1)。
requestMessageListFollowLatest();
- // —— 乐观 outbox 路径:附件仍在上传、消息含任务引用(其 capability 读取也可能
- // 途中断线),或 outbox 已有排队消息时不再原地等待,消息立即以待发气泡上屏,
- // 条件满足后由派发循环真正入队。豁免场景走
- // 下方原路径:排队编辑保存(语义是改队列原条目)、纯文本本地命令(/context 等,
- // 本地卡片无顺序问题;此时 composer 域无在途上传,waitForPendingUploads 秒回)。
- // 粘贴占位窗口(uploadsInFlight 计入占位数)同样走本分支:先等占位落定再划归,
- // 见分支内注释——不豁免,否则占位窗口内的发送会经原路径直接 enqueue 超车
- // outbox 在途消息(greptile review P1)。除占位等待外判断与划归全程同步,无竞态窗。
- // outboxPumpBusyRef 也算「outbox 在途」:派发起点条目即移出 outbox,enqueue
- // 弱网重试窗内 outbox 可能为空——此时新消息若走原路径会并发 enqueue 超车
- // 在途消息,破坏 FIFO(review P1);计入 pump busy 让它同样进 outbox 排队。
- // 会话参数未就绪(缓存种入 / 新建在途)同样走本分支:此刻 enqueue 不可用,但消息
- // 照常上屏,由派发循环在就绪后按序发出——composer 不再为此进只读档。
- const shouldUseLocalOutbox = outboxEligible && !earlyLocalCommand && !earlyDesktopCommand
- && (sessionRefsAtSend.length > 0 || uploadsInFlight > 0 || outboxRef.current.length > 0
- || outboxPumpBusyRef.current || dispatchBlockedAtSend);
- // 旧协议 Plan 依赖会话级 permissionMode,无法安全跨断线 / 页面生命周期托管。
- // 本 PR 的本地 FIFO 因此只接普通消息与现代 Plan;连接正常且队列为空时,
- // 旧协议 Plan 即使含附件 / 引用也回落到下方原有在线路径,等待材料后直接派发。
- const useLocalOutbox = shouldUseLocalOutbox && !legacyPlanRequiresLiveDispatch;
+ const useLocalOutbox = useDurableOutbox;
if (useLocalOutbox) {
try {
// workingDir 校验只对「此刻就能派发」的消息前置:dialogue 会话的工作目录由
@@ -6292,14 +5991,61 @@ export default function SessionScreen() {
return;
}
}
- // 划归:当前全部未 claim 上传任务(active + 失败卡)随本条消息走——离开
- // composer 托盘与限额,产物经 onUploaded/onError 的 localId 路由回填。
- const claimedUploads = claimActiveUploads();
- const readyAttachments = attachmentsRef.current;
- // 本地预览快照(必须在下方清理 previews 映射之前取):outbox 气泡从第一帧
- // 就以图片形态渲染,不做「附件行→图片」的形态跳变;缺失时渲染层按 ossRef
- // 查 sentAttachmentThumbStore 兜底。
- const readyPreviews = readyAttachments.map((attachment) => attachmentPreviews[attachment.id] ?? null);
+ const ownerAtSend = getMobileAuthOwner();
+ const handoff = await beginOutboxAttachmentHandoff();
+ let record: DurableOutboxRecord | undefined;
+ let committed = false;
+ try {
+ const pendingSources = await handoff.prepare();
+ if (!sendScopeStillAlive() || !isMobileAuthOwnerCurrent(ownerAtSend)) return;
+ const readyAttachments = [...attachmentsRef.current];
+ const readyPreviews = readyAttachments.map((attachment) => attachmentPreviews[attachment.id] ?? null);
+ const permissionModeAtSend = permissionModeOrAsk(currentSession.permissionMode);
+ const item = buildOutboxItem({
+ clientId: createOutboxClientId(), sessionId, text, quotesEncoded: quotesEncodedAtSend,
+ sessionRefs: sessionRefsAtSend, agentReferences: agentReferencesAtSend,
+ pastedTextRanges: pastedTextRangesAtSend, slashCommandRanges: slashCommandRangesAtSend ?? [],
+ permissionModeAtSend, planModeAtSend, readyAttachments, readyPreviews,
+ claimedUploads: pendingSources.map(({ localId, source }) => ({ localId, failed: false, kind: source.kind, previewUri: source.uri })),
+ });
+ const clearedAt = currentSession.clearedAt ? Date.parse(currentSession.clearedAt) : null;
+ record = {
+ version: 1, accountId: ownerAtSend.accountKey, deviceId, item, createdAt: Date.now(),
+ draftHandoff: { before: documentBeforeSend, after: documentAfterOptimisticClear },
+ state: 'queued', uploads: [], clearBoundaryMs: clearedAt !== null && Number.isFinite(clearedAt) ? clearedAt : null,
+ };
+ for (let slot = 0; slot < readyAttachments.length; slot++) {
+ const source = getUploadedSource(readyAttachments[slot].id);
+ if (!source && !outboxAttachmentNeedsLocalBytes(readyAttachments[slot])) continue;
+ if (!source) throw new Error(t('session.screen.attachmentsNotCarriedBack', { count: 1 }));
+ record.uploads.push(await retainOutboxFile(record, slot, source));
+ }
+ for (const { localId, source } of pendingSources) {
+ record.uploads.push(await retainOutboxFile(record, item.slotByLocalId[localId]!, source));
+ }
+ if (!sendScopeStillAlive() || !isMobileAuthOwnerCurrent(ownerAtSend)) return;
+ await mobileDurableOutbox.add(record);
+ committed = true;
+ handoff.release(true);
+ // Durable ownership precedes clearing the composer or deleting annotation sources.
+ if (!isMobileAuthOwnerCurrent(ownerAtSend) || !sendScopeStillAlive()) {
+ const stored = readComposerDocumentDraftSync(sessionId);
+ if (stored && composerDocumentsEqual(stored, documentBeforeSend)) {
+ saveComposerDraft(sessionId, '');
+ saveComposerDocumentDraft(sessionId, emptyComposerDocument());
+ clearQuotes(sessionId);
+ }
+ return;
+ }
+ if (composerDocumentsEqual(composerDocumentRef.current, documentBeforeSend)) {
+ applyComposerDocument(documentAfterOptimisticClear);
+ }
+ rememberSentAttachmentPreviews(record.item.clientId, readyAttachments, (attachment) => {
+ const slot = readyAttachments.findIndex((a) => a.id === attachment.id);
+ const upload = record?.uploads.find((u) => u.slot === slot);
+ return record && upload ? durableOutboxUploadUri(record, upload) : readyPreviews[slot] ?? null;
+ });
+ releaseUploadedSources(readyAttachments.map((a) => a.id));
// 本批映射清理(与原发送成功路径同口径):附件已随消息离开 composer 域。
const sentAttachmentIds = new Set(readyAttachments.map((attachment) => attachment.id));
setMediaAssetAttachments((current) => Object.fromEntries(
@@ -6311,35 +6057,26 @@ export default function SessionScreen() {
for (const attachmentId of sentAttachmentIds) {
composerAnnotationsRef.current?.forgetAttachment(attachmentId);
}
- setAttachments([]);
- attachmentsRef.current = [];
+ const remainingAttachments = attachmentsRef.current.filter((a) => !sentAttachmentIds.has(a.id));
+ setAttachments(remainingAttachments);
+ attachmentsRef.current = remainingAttachments;
setAttachmentError(null);
// plan 一次性语义:权限档快照进条目(派发按快照发),chip 立即恢复——
// 不等附件上传完,与「消息已发出」的乐观语义一致。
- const permissionModeAtSend = permissionModeOrAsk(currentSession.permissionMode);
if (permissionModeAtSend === 'plan') {
const fallback = runtimeOptions?.permissionOptions.find((option) => option.id !== 'plan')?.id ?? 'ask';
const remembered = prePlanPermissionModeRef.current;
const restored = remembered && remembered !== 'plan' ? remembered : fallback;
void maker.setPermissionMode(sessionId, restored).catch(() => undefined);
}
- updateOutbox((items) => [...items, buildOutboxItem({
- clientId: createOutboxClientId(),
- sessionId,
- text,
- quotesEncoded: quotesEncodedAtSend,
- sessionRefs: sessionRefsAtSend,
- agentReferences: agentReferencesAtSend,
- pastedTextRanges: pastedTextRangesAtSend,
- slashCommandRanges: slashCommandRangesAtSend ?? [],
- permissionModeAtSend,
- readyAttachments,
- readyPreviews,
- claimedUploads,
- })]);
voiceDictionaryLearningTrackerRef.current?.flush();
requestMessageListFollowLatest();
- void pumpOutbox();
+ } finally {
+ handoff.release(committed);
+ if (!committed && record) await removeOutboxFiles(record).catch(() => undefined);
+ }
+ } catch (err) {
+ setError(formatRemoteError(err));
} finally {
sendInFlightRef.current = false;
setSending(false);
@@ -7280,8 +7017,9 @@ export default function SessionScreen() {
discardMobileUploadedAttachment(attachment, { getToken: () => auth.getAccessToken() });
discardedIds.add(attachment.id);
}
+ releaseUploadedSources([...discardedIds]);
return discardedIds;
- }, [auth, sessionId]);
+ }, [auth, sessionId, releaseUploadedSources]);
const discardQueueEditTransientAttachments = useCallback((
editing: QueueEditingState,
diff --git a/apps/mobile/app/sessions/new.tsx b/apps/mobile/app/sessions/new.tsx
index a75f29a8e7..674fd86ba4 100644
--- a/apps/mobile/app/sessions/new.tsx
+++ b/apps/mobile/app/sessions/new.tsx
@@ -1,4 +1,8 @@
import { isRemoteTaskSuggestionId } from '@/session/remoteTaskSuggestionsModel';
+import { mobileDurableOutbox, holdDurableOutboxCreation, getCurrentMobileOutboxRecords } from '@/session/mobileDurableOutbox';
+import { retainOutboxFile, durableOutboxUploadUri, removeRetainedOutboxFiles, outboxAttachmentNeedsLocalBytes } from '@/session/durableOutboxFiles';
+import { buildOutboxItem, createOutboxClientId } from '@/session/sessionOutbox';
+import type { DurableOutboxRecord } from '@/session/durableOutbox';
import { stripTrailingPathSeparators } from '@cindy/maker-shared/path-text';
import { takeRefinementContextTail } from '@cindy/voice-input-core';
import { Stack, useIsFocused, useLocalSearchParams, useRouter } from 'expo-router';
@@ -14,6 +18,7 @@ import {
useMemo,
useRef,
useState,
+ useSyncExternalStore,
type ReactNode,
type SetStateAction,
} from 'react';
@@ -180,8 +185,8 @@ import { newSessionText } from '@/session/newSessionMessages';
import { i18n } from '@/i18n';
import {
getMobileAuthOwner,
- isMobileAuthOwnerCurrent,
subscribeMobileAuthOwner,
+ isMobileAuthOwnerCurrent,
} from '@/auth/authOwnerGeneration';
import { useTranslation } from 'react-i18next';
import {
@@ -428,6 +433,7 @@ export default function NewRemoteSessionScreen() {
visualFocusComposer?: string;
visualDraft?: string;
suggestion?: string;
+ recoverySessionId?: string;
}>();
const routeDeviceId = String(params.deviceId ?? '');
const routeDeviceName = String(params.deviceName ?? routeDeviceId);
@@ -437,6 +443,7 @@ export default function NewRemoteSessionScreen() {
const router = useRouter();
const nativeSelectionSheet = Platform.OS === 'ios';
const auth = useAuth();
+ const outboxOwner = useSyncExternalStore(subscribeMobileAuthOwner, getMobileAuthOwner, getMobileAuthOwner);
const {
getPresenceAvailability,
invoke,
@@ -510,6 +517,8 @@ export default function NewRemoteSessionScreen() {
workingDir: initialWorkingDir ?? '',
});
const firstMessageRef = useRef(draft.firstMessage);
+ const [planModeDraftOn, setPlanModeDraftOn] = useState(false);
+ const prePlanPermissionModeRef = useRef<string | null>(null);
const firstMessageSelectionRef = useRef({ start: draft.firstMessage.length, end: draft.firstMessage.length });
const [firstMessageSelection, setFirstMessageSelection] = useState(firstMessageSelectionRef.current);
const [creating, setCreating] = useState(false);
@@ -624,20 +633,58 @@ export default function NewRemoteSessionScreen() {
// 附件是已上传完成的引用,原样回列即可继续使用;notice 是「有内容没能带回」的告知
// (创建期间发出的消息可能超出单条上限,装不下的只能丢,但不能静默丢,review P1)。
// 声明在 attachmentError 之后:notice 就落在附件错误行上。
+ const outboxRecoveryRef = useRef<DurableOutboxRecord | null>(null);
+ const restoreCreationDraft = useCallback((recovered: NewSessionDraft, files: RemoteSerializedAttachment[], plan?: { enabled: boolean; restorePermissionMode: string | null }) => {
+ userTouchedWorkspaceRef.current = true;
+ userTouchedRuntimeRef.current = true;
+ appliedPermissionMemoryRef.current = true;
+ runtimeActionSeqRef.current += 1;
+ firstMessageRef.current = recovered.firstMessage;
+ const selection = { start: recovered.firstMessage.length, end: recovered.firstMessage.length };
+ firstMessageSelectionRef.current = selection;
+ setFirstMessageSelection(selection);
+ attachmentsRef.current = files;
+ setAttachments(files);
+ if (plan) {
+ setPlanModeDraftOn(plan.enabled);
+ prePlanPermissionModeRef.current = plan.restorePermissionMode;
+ }
+ setDraft(recovered);
+ }, []);
+ const leaveForeignOutboxRecovery = useCallback(() => {
+ const record = outboxRecoveryRef.current;
+ if (!record || record.accountId === getMobileAuthOwner().accountKey) return false;
+ router.replace('/devices');
+ return true;
+ }, [router]);
+ useEffect(() => {
+ const owner = outboxOwner;
+ if (leaveForeignOutboxRecovery()) return;
+ const sid = String(params.recoverySessionId ?? '');
+ if (!sid) return;
+ let active = true;
+ let restored = false;
+ const restore = () => {
+ if (!active || restored || !isMobileAuthOwnerCurrent(owner)) return;
+ const record = getCurrentMobileOutboxRecords().find((r) => r.item.sessionId === sid && r.creation);
+ if (!record?.creation || record.prepared) return;
+ restored = true;
+ outboxRecoveryRef.current = record;
+ userTouchedDeviceRef.current = true;
+ restoreCreationDraft(record.creation.draft,
+ record.item.attachmentSlots.filter((a): a is RemoteSerializedAttachment => a !== null),
+ { enabled: record.creation.planModeArm, restorePermissionMode: record.creation.restorePermissionMode });
+ setSelectedDeviceId(record.deviceId);
+ setSelectedDeviceName(record.creation.deviceName);
+ };
+ const unsubscribe = mobileDurableOutbox.subscribe(restore);
+ void mobileDurableOutbox.ready().then(restore);
+ return () => { active = false; unsubscribe(); };
+ }, [params.recoverySessionId, outboxOwner, leaveForeignOutboxRecovery, restoreCreationDraft]);
useEffect(() => {
const stashed = drainStashedNewSessionDraft();
if (!stashed) return;
- // 返回编辑沿用草稿的工作区,不能被随后加载的全局默认覆盖。
- userTouchedWorkspaceRef.current = true;
- firstMessageRef.current = stashed.draft.firstMessage;
- const restoredSelection = {
- start: stashed.draft.firstMessage.length,
- end: stashed.draft.firstMessage.length,
- };
- firstMessageSelectionRef.current = restoredSelection;
- setFirstMessageSelection(restoredSelection);
- setDraft(stashed.draft);
- setAttachments([...stashed.attachments]);
+ restoreCreationDraft(stashed.draft, [...stashed.attachments]);
if (stashed.notice) setAttachmentError(stashed.notice);
if (stashed.deviceId) {
userTouchedDeviceRef.current = true;
@@ -664,6 +711,8 @@ export default function NewRemoteSessionScreen() {
discardAllPendingUploads,
waitForPendingUploads,
getPendingUploadCount,
+ getUploadedSource,
+ releaseUploadedSources,
} = useMobileLocalAttachments({
getAccessToken: () => auth.getAccessToken(),
getAttachmentCount: () => attachmentsRef.current.length,
@@ -976,6 +1025,7 @@ export default function NewRemoteSessionScreen() {
useEffect(() => {
const storedAgentKind = newSessionPreferences?.agentKind;
if (!newSessionPreferencesLoaded || !storedAgentKind) return;
+ if (userTouchedRuntimeRef.current) return;
if (appliedStoredAgentRef.current === storedAgentKind) return;
const expectedDeviceId = preferredDefaultDevice?.deviceId ?? '';
if (expectedDeviceId && selectedDeviceId !== expectedDeviceId) return;
@@ -1064,10 +1114,11 @@ export default function NewRemoteSessionScreen() {
const remembered = newSessionPreferences?.permissionModeByAgent[draft.agentKind];
if (!remembered || remembered === draft.permissionMode) return;
let cancelled = false;
+ const seqAtTrigger = runtimeActionSeqRef.current;
void confirmFullAccessChange(draft.permissionMode, remembered, {
restoringRememberedChoice: true,
}).then((confirmed) => {
- if (cancelled || !confirmed) return;
+ if (cancelled || !confirmed || seqAtTrigger !== runtimeActionSeqRef.current) return;
setDraft((current) => ({ ...current, permissionMode: remembered }));
});
return () => {
@@ -1180,7 +1231,6 @@ export default function NewRemoteSessionScreen() {
);
// 权限按钮 / 权限下拉不体现 plan(对齐桌面 PR#494 / Cursor):计划模式激活时展示
// 进入前的底层权限档(无记录时回退首个非 plan 档),激活态由 composer 的 PlanModeChip 表达。
- const prePlanPermissionModeRef = useRef<string | null>(null);
const displayPermissionMode = draft.permissionMode === 'plan'
? ((prePlanPermissionModeRef.current && prePlanPermissionModeRef.current !== 'plan')
? prePlanPermissionModeRef.current
@@ -1741,6 +1791,7 @@ export default function NewRemoteSessionScreen() {
// 在途上传同样作废(codex review R10):不取消的话它们完成后会经 onUploaded 把
// 上一台电脑期间选的附件塞进新电脑的草稿;丢弃后由控制器在完成时回收 OSS 对象。
discardAllPendingUploads();
+ releaseUploadedSources(attachments.map((attachment) => attachment.id));
setAttachments([]);
setMediaAssetAttachments({});
setAttachmentPreviews({});
@@ -3859,6 +3910,7 @@ export default function NewRemoteSessionScreen() {
});
// 标注附件退场时同步清「矢量笔迹 + 原图副本」的再编辑真相。
composerAnnotationsRef.current?.forgetAttachment(id);
+ releaseUploadedSources([id]);
}, [attachments, auth]);
// 圈点标注(托盘再编辑)与附件管线的接线(新建会话页无聊天场景,chat 配置不用)。
@@ -4032,11 +4084,10 @@ export default function NewRemoteSessionScreen() {
// - 新协议(capabilities.planMode.supported):本地布尔草稿态,创建会话后经
// maker:set-plan-mode 武装首条消息,消耗由被控端执行;不污染 draft.permissionMode。
// - 老被控端兼容(permissionModes 仍含 'plan'):沿用草稿 permissionMode 切换 + 创建后恢复。
- // prePlanPermissionModeRef 声明在 displayPermissionMode 计算处(权限按钮展示需要)。
+ // Plan 草稿与底层权限快照由恢复入口一并回填。
const planModeCapability = runtimeOptions.planModeSupported;
const legacyPlanSupported = runtimeOptions.permissionOptions.some((option) => option.id === 'plan');
const planModeSupported = planModeCapability || legacyPlanSupported;
- const [planModeDraftOn, setPlanModeDraftOn] = useState(false);
const planModeOn = planModeCapability ? planModeDraftOn : draft.permissionMode === 'plan';
const togglePlanMode = useCallback((next: boolean) => {
if (planModeCapability) {
@@ -4054,6 +4105,7 @@ export default function NewRemoteSessionScreen() {
}, [draft.permissionMode, patchDraft, planModeCapability, runtimeOptions.permissionOptions]);
const create = useCallback(async () => {
+ if (leaveForeignOutboxRecovery()) return;
if (
creatingRef.current
|| voicePermissionRequestInFlightRef.current
@@ -4096,6 +4148,7 @@ export default function NewRemoteSessionScreen() {
// 回来的是新 mount,creatingRef 天然复位。
let handedOff = false;
let releasePrecreatedRegistration: (() => void) | null = null;
+ let releaseDurableCreation: (() => void) | null = null;
const accountIdAtCreate = auth.user?.id?.trim() ?? '';
const authOwnerAtCreate = getMobileAuthOwner();
const isCurrentOwner = () => (
@@ -4201,7 +4254,25 @@ export default function NewRemoteSessionScreen() {
// 幂等),点创建**立即**进入会话页;openLink / 鉴权 revalidate / createSession
// / 首条消息 enqueue 全部由 newSessionCreation 模块级后台管线完成(本页
// unmount 不终止),失败重试面在会话页(横幅:重试 / 返回编辑)。
- const sessionId = createNewSessionId();
+ const recovering = outboxRecoveryRef.current;
+ if (recovering && recovering.deviceId !== selectedDeviceId) {
+ throw new Error(t('session.outbox.recoveryTarget'));
+ }
+ const sessionId = recovering?.item.sessionId ?? createNewSessionId();
+ if (recovering) {
+ // Editing creation parameters is allowed only after the original task is proven absent.
+ let found = false;
+ try { found = !!(await maker.getSession(sessionId)); }
+ catch (error) {
+ if (!formatRemoteError(error).includes('NOT_FOUND')) throw error;
+ }
+ if (!isCurrentOwner()) return;
+ if (found) {
+ const latest = getCurrentMobileOutboxRecords().find((r) => r.item.clientId === recovering.item.clientId && r.item.sessionId === sessionId);
+ if (latest && !latest.prepared) await mobileDurableOutbox.update(latest, { suspended: false, state: 'queued' });
+ throw new Error(t('session.outbox.taskAlreadyCreated'));
+ }
+ }
let precreatedWorktree: {
path: string;
recoveryKey: string;
@@ -4360,6 +4431,63 @@ export default function NewRemoteSessionScreen() {
return;
}
}
+ const agentKindSnapshot = effectiveDraft.agentKind;
+ const deviceIdSnapshot = selectedDeviceId;
+ // 老协议 plan 一次性语义(对齐桌面 PR#494):入队后恢复进入前的底层权限档。
+ const legacyPlanRestore = effectiveDraft.permissionMode === 'plan'
+ ? (() => {
+ const fallback = runtimeOptions.permissionOptions.find((option) => option.id !== 'plan')?.id ?? 'ask';
+ const remembered = prePlanPermissionModeRef.current;
+ return remembered && remembered !== 'plan' ? remembered : fallback;
+ })()
+ : null;
+ if (!isCurrentOwner()) return;
+ releaseDurableCreation = holdDurableOutboxCreation(sessionId);
+ const firstMessageClientId = recovering?.item.clientId ?? createOutboxClientId();
+ // Legacy Plan requires a live session-wide permission change. Keep its existing
+ // online creation pipeline instead of introducing deferred permission mutations.
+ const useDurableCreation = legacyPlanRestore === null;
+ if (recovering && !useDurableCreation) throw new Error(t('session.outbox.legacyPlanRecovery'));
+ if (useDurableCreation) {
+ const firstRecord: DurableOutboxRecord = {
+ version: 1, accountId: authOwnerAtCreate.accountKey, deviceId: deviceIdSnapshot,
+ createdAt: recovering?.createdAt ?? Date.now(), state: 'queued', suspended: false, uploads: [], clearBoundaryMs: null,
+ creation: { draft: effectiveDraft, deviceName: selectedDeviceName,
+ planModeArm: planModeCapability && planModeDraftOn, restorePermissionMode: legacyPlanRestore },
+ item: buildOutboxItem({
+ clientId: firstMessageClientId, sessionId, text: effectiveDraft.firstMessage,
+ quotesEncoded: false, agentReferences: [], pastedTextRanges: [], slashCommandRanges: [],
+ permissionModeAtSend: effectiveDraft.permissionMode, readyAttachments: sendAttachments,
+ readyPreviews: sendAttachments.map((a) => attachmentPreviews[a.id] ?? null), claimedUploads: [],
+ }),
+ };
+ let filesCommitted = false;
+ try {
+ for (let slot = 0; slot < sendAttachments.length; slot++) {
+ const attachment = sendAttachments[slot];
+ const source = getUploadedSource(attachment.id);
+ const oldSlot = recovering?.item.attachmentSlots.findIndex((a) => a?.id === attachment.id);
+ const oldUpload = recovering?.uploads.find((u) => u.slot === oldSlot);
+ if (source) firstRecord.uploads.push(await retainOutboxFile(firstRecord, slot, source));
+ else if (recovering && oldUpload) firstRecord.uploads.push(await retainOutboxFile(firstRecord, slot, {
+ ...oldUpload, uri: durableOutboxUploadUri(recovering, oldUpload),
+ }));
+ else if (outboxAttachmentNeedsLocalBytes(attachment)) throw new Error(t('session.screen.attachmentsNotCarriedBack', { count: 1 }));
+ }
+ if (!isCurrentOwner() || !ensureDeviceAlive()) return;
+ if (recovering) {
+ const latest = getCurrentMobileOutboxRecords().find((r) => r.item.clientId === firstMessageClientId && r.item.sessionId === sessionId);
+ if (!latest || latest.prepared) throw new Error('OUTBOX_STALE_WRITE');
+ await mobileDurableOutbox.update(latest, firstRecord);
+ } else await mobileDurableOutbox.add(firstRecord);
+ filesCommitted = true;
+ } finally {
+ if (!filesCommitted) await removeRetainedOutboxFiles(firstRecord).catch(() => undefined);
+ }
+ outboxRecoveryRef.current = firstRecord;
+ if (!isCurrentOwner() || !ensureDeviceAlive()) return;
+ releaseUploadedSources(sendAttachments.map((a) => a.id));
+ }
// 提交点联合终检(Greptile/Codex review P1):目录就绪后的清理 effect 跑在渲染后,
// 用户可能在清理生效前点创建——创建路径自身必须守卫;来源失效时 model 随之一并
// 回退(其他来源顶替 / 首项 / 内置默认),并同步校准 effort、组合变化时 fastMode
@@ -4450,20 +4578,10 @@ export default function NewRemoteSessionScreen() {
if (!ensureDeviceAlive()) return;
applyGuard(guardResult);
}
- const agentKindSnapshot = effectiveDraft.agentKind;
- const deviceIdSnapshot = selectedDeviceId;
- // 老协议 plan 一次性语义(对齐桌面 PR#494):入队后恢复进入前的底层权限档。
- const legacyPlanRestore = effectiveDraft.permissionMode === 'plan'
- ? (() => {
- const fallback = runtimeOptions.permissionOptions.find((option) => option.id !== 'plan')?.id ?? 'ask';
- const remembered = prePlanPermissionModeRef.current;
- return remembered && remembered !== 'plan' ? remembered : fallback;
- })()
- : null;
- if (!isCurrentOwner()) return;
startNewSessionCreation({
startedAt,
sessionId,
+ firstMessageClientId,
deviceId: deviceIdSnapshot,
deviceName: selectedDeviceName,
draft: effectiveDraft,
@@ -4520,6 +4638,12 @@ export default function NewRemoteSessionScreen() {
isCurrentOwner,
transport: {
maker,
+ handoffFirstMessage: useDurableCreation ? async (item) => {
+ if (!isCurrentOwner()) throw new Error('OUTBOX_OWNER_CHANGED');
+ const record = getCurrentMobileOutboxRecords().find((r) => r.item.sessionId === sessionId && r.item.clientId === firstMessageClientId);
+ if (!record) throw new Error('OUTBOX_STALE_WRITE');
+ await mobileDurableOutbox.update(record, { template: item, state: 'queued', suspended: false, error: undefined });
+ } : undefined,
openLink,
subscribe,
prepareQueuedMessage: (item) => prepareMobileQueuedSessionReferences(
@@ -4553,6 +4677,7 @@ export default function NewRemoteSessionScreen() {
setError(raw);
} finally {
releasePrecreatedRegistration?.();
+ releaseDurableCreation?.();
if (!handedOff) {
creatingRef.current = false;
setCreating(false);
@@ -4568,6 +4693,7 @@ export default function NewRemoteSessionScreen() {
selectedDeviceName,
draft,
finishVoiceRecording,
+ leaveForeignOutboxRecovery,
getPresenceAvailability,
maker,
openLink,
@@ -4597,6 +4723,7 @@ export default function NewRemoteSessionScreen() {
// composer 附件不随目标带入(与桌面一致)。goal.set 失败时报错留在面板,会话已创建,
// 用户可进会话重设目标,重试本表单会新建会话。
const createGoalSession = useCallback(async (input: { objective: string; limits?: MobileGoalLimitsInput }) => {
+ if (leaveForeignOutboxRecovery()) return;
if (creatingRef.current || goalBusy) return;
if (!selectedDeviceId) {
setGoalError(t('session.new.selectDeviceError'));
@@ -5312,6 +5439,7 @@ export default function NewRemoteSessionScreen() {
confirmAgentUnauthenticated,
draft,
goalBusy,
+ leaveForeignOutboxRecovery,
maker,
openLink,
patchDraft,
diff --git a/apps/mobile/src/__tests__/chatQuoteCrossDevice.test.ts b/apps/mobile/src/__tests__/chatQuoteCrossDevice.test.ts
index 19751fc8a6..5d49f1a175 100644
--- a/apps/mobile/src/__tests__/chatQuoteCrossDevice.test.ts
+++ b/apps/mobile/src/__tests__/chatQuoteCrossDevice.test.ts
@@ -28,8 +28,8 @@ describe('mobile cross-device quote wiring', () => {
expect(source).toContain('quotesEncoded: quotesEncodedAtSend');
expect(source).toContain('pastedTextRanges: pastedTextRangesAtSend');
expect(source).toContain('slashCommandRanges: slashCommandRangesAtSend');
- expect(source).toContain('quotesEncoded: item.quotesEncoded');
- expect(source).toContain('restoreOutboxItemsToDraft([item])');
+ expect(readSource('src/session/MobileOutboxBridge.tsx')).toContain('quotesEncoded: item.quotesEncoded');
+ expect(source).toContain('await mobileDurableOutbox.add(record)');
expect(source).toContain('saveComposerDocumentDraft(\n draftSessionId,\n recovery.document,');
expect(source).toContain('createQueueEditTextState(item)');
expect(source).toContain('resolveQueueEditTextSubmission(queueEditAtSendStart.textState, documentAtSend)');
diff --git a/apps/mobile/src/__tests__/composerDraftStore.test.ts b/apps/mobile/src/__tests__/composerDraftStore.test.ts
index d1f1045d37..d367d0b1b2 100644
--- a/apps/mobile/src/__tests__/composerDraftStore.test.ts
+++ b/apps/mobile/src/__tests__/composerDraftStore.test.ts
@@ -24,6 +24,29 @@ vi.mock('@react-native-async-storage/async-storage', () => ({
}));
describe('composerDraftStore', () => {
+ it.each(['both', 'text-only', 'new-draft'] as const)('reconciles a committed send after a crash with %s remaining', async (state) => {
+ const { __testing, reconcileCommittedComposerDraft, readComposerDraft, readComposerDocumentDraft } = await import('@/session/composerDraftStore');
+ const { textComposerDocument, emptyComposerDocument } = await import('@/session/composerDocument');
+ const before = textComposerDocument('already sent');
+ const after = emptyComposerDocument();
+ store.set(__testing.storageKeyForSession('s1'), state === 'new-draft' ? 'later edit' : 'already sent');
+ if (state !== 'text-only') store.set(__testing.documentStorageKeyForSession('s1'), JSON.stringify(state === 'new-draft' ? textComposerDocument('later edit') : before));
+ await reconcileCommittedComposerDraft('s1', { before, after }, () => {});
+ expect(await readComposerDraft('s1')).toBe(state === 'new-draft' ? 'later edit' : null);
+ expect(await readComposerDocumentDraft('s1')).toEqual(state === 'new-draft' ? textComposerDocument('later edit') : state === 'text-only' ? null : after);
+ });
+ it('propagates draft handoff storage failure and retries the unmodified disk proof', async () => {
+ const { __testing, reconcileCommittedComposerDraft } = await import('@/session/composerDraftStore');
+ const { textComposerDocument, emptyComposerDocument } = await import('@/session/composerDocument');
+ const storage = (await import('@react-native-async-storage/async-storage')).default;
+ const before = textComposerDocument('sent');
+ store.set(__testing.documentStorageKeyForSession('s1'), JSON.stringify(before));
+ store.set(__testing.storageKeyForSession('s1'), 'sent');
+ vi.mocked(storage.setItem).mockRejectedValueOnce(new Error('disk busy'));
+ await expect(reconcileCommittedComposerDraft('s1', { before, after: emptyComposerDocument() }, () => {})).rejects.toThrow('disk busy');
+ await reconcileCommittedComposerDraft('s1', { before, after: emptyComposerDocument() }, () => {});
+ expect(store.get(__testing.storageKeyForSession('s1'))).toBe('');
+ });
beforeEach(async () => {
vi.useRealTimers();
vi.clearAllMocks();
diff --git a/apps/mobile/src/__tests__/durableOutbox.test.ts b/apps/mobile/src/__tests__/durableOutbox.test.ts
new file mode 100644
index 0000000000..26f1e7d61f
--- /dev/null
+++ b/apps/mobile/src/__tests__/durableOutbox.test.ts
@@ -0,0 +1,880 @@
+import { describe, expect, it, vi } from "vitest";
+import { accountVaultKey } from '@cindy/auth-client';
+import {
+ createDurableOutbox,
+ isDurableOutboxUnsent,
+ observeDurableOutboxSending,
+ type DurableOutboxRecord,
+ type OutboxStorage,
+} from "../session/durableOutbox";
+import {
+ createDurableOutboxDelivery,
+ type DeliveryProjection,
+} from "../session/durableOutboxDelivery";
+import type { QueuedRemoteMessage, RemoteMessage } from "../session/types";
+import { appendOptimisticUserMessage, projectOptimisticUserMessages, type OptimisticUserMessage } from '../session/optimisticUserMessages';
+
+function deferred<T>() {
+ let resolve!: (value: T) => void;
+ const promise = new Promise<T>((done) => {
+ resolve = done;
+ });
+ return { promise, resolve };
+}
+function disk(): OutboxStorage & { data: Map<string, string> } {
+ const data = new Map<string, string>();
+ return {
+ data,
+ getAllKeys: async () => [...data.keys()],
+ getItem: async (k) => data.get(k) ?? null,
+ setItem: async (k, v) => {
+ data.set(k, v);
+ },
+ removeItem: async (k) => {
+ data.delete(k);
+ },
+ };
+}
+function message(
+ clientId = "id-1",
+ sessionId = "session-a",
+): DurableOutboxRecord {
+ return {
+ version: 1,
+ accountId: "alice",
+ deviceId: "mac-a",
+ createdAt: 1,
+ state: "queued",
+ uploads: [],
+ item: {
+ clientId,
+ sessionId,
+ text: "keep this message",
+ quotesEncoded: false,
+ agentReferences: [],
+ pastedTextRanges: [],
+ slashCommandRanges: [],
+ permissionModeAtSend: "plan",
+ attachmentSlots: [],
+ slotMeta: [],
+ slotByLocalId: {},
+ waitingIds: [],
+ failedIds: [],
+ enqueueError: null,
+ phase: "uploading",
+ },
+ };
+}
+function projection(
+ clientId = "id-1",
+ state: "unknown" | "pending" | "accepted" | "removed" = "unknown",
+): DeliveryProjection {
+ return {
+ pendingQueue: [],
+ inputDeliveryVersion: 1,
+ clearBoundaryMs: null,
+ deliveryReceipts: [{ clientId, state }],
+ } as unknown as DeliveryProjection;
+}
+async function setup(storage = disk()) {
+ const store = createDurableOutbox(storage);
+ await store.activate("alice");
+ let active = true;
+ const deps = {
+ store,
+ isCurrent: () => active,
+ canRun: () => true,
+ projection: vi.fn(async (r: DurableOutboxRecord) =>
+ projection(r.item.clientId),
+ ),
+ session: vi.fn(async (r: DurableOutboxRecord): Promise<{ id: string; status: string } | null> =>
+ ({ id: r.item.sessionId, status: "active" }),
+ ),
+ prepare: vi.fn(
+ async (r: DurableOutboxRecord) =>
+ ({
+ clientId: r.item.clientId,
+ text: r.item.text,
+ }) as QueuedRemoteMessage,
+ ),
+ upload: vi.fn(async () => ({
+ id: "file-1",
+ name: "photo.png",
+ path: "oss-ref",
+ ext: "png",
+ size: 123,
+ category: "image" as const,
+ mimeType: "image/png",
+ })),
+ enqueue: vi.fn(async (_r: DurableOutboxRecord) => projection()),
+ cancel: vi.fn(async () => true),
+ history: vi.fn(async () => false),
+ applyProjection: vi.fn(),
+ cleanup: vi.fn(async () => {}),
+ discardUploads: vi.fn(),
+ retryable: () => true,
+ describe: () => "offline",
+ confirmationMessage: "check receipt",
+ clearedMessage: "task cleared",
+ };
+ const runner = createDurableOutboxDelivery(deps);
+ return {
+ store,
+ deps,
+ runner,
+ storage,
+ deactivate: () => {
+ active = false;
+ },
+ };
+}
+
+describe("durable mobile outbox ownership", () => {
+ it.each([
+ [false, false, undefined, true],
+ [true, false, 1, true],
+ [true, true, 1, false],
+ [true, undefined, 1, false],
+ [false, true, 1, false],
+ [false, undefined, 1, false],
+ [false, undefined, undefined, true],
+ ] as const)('offline disposal respects prepared=%s enqueueStarted=%s sendAtMs=%s', async (prepared, enqueueStarted, sendAtMs, unsent) => {
+ const { store, storage } = await setup();
+ const record = { ...message(), prepared: prepared ? { clientId: 'id-1' } as QueuedRemoteMessage : undefined, enqueueStarted, sendAtMs };
+ expect(isDurableOutboxUnsent(record)).toBe(unsent);
+ await store.add(record);
+ await store.update(store.getSnapshot()[0]!, isDurableOutboxUnsent(record)
+ ? { state: 'host-owned', cleanupOutcome: 'cancelled', cancelRequested: true }
+ : { state: 'confirming', cancelRequested: true });
+ // Cold restart, with the same offline gate used by the bridge.
+ const { deps, store: restarted } = await setup(storage);
+ deps.projection.mockRejectedValue(new Error('offline'));
+ await createDurableOutboxDelivery({ ...deps, canRun: (r) => r.cleanupOutcome !== undefined }).run();
+ expect(deps.projection).not.toHaveBeenCalled();
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ expect(restarted.getSnapshot()).toHaveLength(unsent ? 0 : 1);
+ expect(deps.cleanup).toHaveBeenCalledTimes(unsent ? 1 : 0);
+ });
+
+ it.each([false, true, undefined])('deleted prepared task respects enqueueStarted=%s', async (enqueueStarted) => {
+ const { store, runner, deps } = await setup();
+ await store.add({ ...message(), prepared: { clientId: 'id-1' } as QueuedRemoteMessage, enqueueStarted });
+ deps.projection.mockRejectedValue(Object.assign(new Error('not found'), { code: 'NOT_FOUND' }));
+ deps.session.mockResolvedValue({ id: 'session-a', status: 'deleted' });
+ await runner.run();
+ expect(deps.cleanup).toHaveBeenCalledWith(expect.anything(), enqueueStarted === false);
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ });
+ it('recovers draft handoff before delivery and retains the proof when reconciliation fails', async () => {
+ const storage = disk();
+ const seed = createDurableOutbox(storage);
+ await seed.activate('alice');
+ const record = { ...message(), draftHandoff: {
+ before: { version: 1 as const, nodes: [{ type: 'text' as const, text: 'sent' }] },
+ after: { version: 1 as const, nodes: [] },
+ } };
+ await seed.add(record);
+ const recover = vi.fn(async () => {});
+ recover.mockRejectedValueOnce(new Error('draft storage busy'));
+ const restarted = createDurableOutbox(storage, recover);
+ await restarted.activate('alice');
+ await expect(restarted.reconcileDrafts()).rejects.toThrow('draft storage busy');
+ expect(restarted.getSnapshot()[0]?.draftHandoff).toEqual(record.draftHandoff);
+ await restarted.reconcileDrafts();
+ const again = createDurableOutbox(storage, recover);
+ await again.activate('alice');
+ await again.reconcileDrafts();
+ expect(recover).toHaveBeenCalledTimes(2);
+ expect(again.getSnapshot()[0]?.draftHandoff).toBeUndefined();
+ });
+ it('does not send before draft reconciliation succeeds or block a different task on its failure', async () => {
+ const { deps, storage } = await setup();
+ const recover = vi.fn(async () => { throw new Error('draft busy'); });
+ const store = createDurableOutbox(storage, recover);
+ await store.activate('alice');
+ await store.add({ ...message(), draftHandoff: {
+ before: { version: 1, nodes: [{ type: 'text', text: 'sent' }] },
+ after: { version: 1, nodes: [] },
+ } });
+ await store.add(message('other', 'session-b'));
+ const runner = createDurableOutboxDelivery({ ...deps, store });
+ await runner.run();
+ expect(deps.enqueue).toHaveBeenCalledOnce();
+ expect(deps.enqueue.mock.calls[0]?.[0].item.clientId).toBe('other');
+ expect(store.getSnapshot().find((r) => r.item.clientId === 'id-1')?.draftHandoff).toBeDefined();
+ });
+ it('keeps preparation explicitly unsent if the sending write fails before a crash', async () => {
+ const { store, runner, deps, storage } = await setup();
+ await store.add(message());
+ const write = storage.setItem;
+ vi.spyOn(storage, 'setItem').mockImplementation(async (key, value) => {
+ if (JSON.parse(value).state === 'sending') throw new Error('disk busy');
+ await write(key, value);
+ });
+ await runner.run();
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ expect(store.getSnapshot()[0]).toMatchObject({ enqueueStarted: false, prepared: { clientId: 'id-1' } });
+ const recovered = await setup(storage);
+ recovered.deps.projection.mockRejectedValue(Object.assign(new Error('missing'), { code: 'NOT_FOUND' }));
+ recovered.deps.session.mockResolvedValue({ id: 'session-a', status: 'deleted' });
+ await recovered.runner.run();
+ expect(recovered.deps.cleanup).toHaveBeenCalledWith(expect.anything(), true);
+ });
+ it.each([false, true])('cleans a positively deleted task even when cancellation is %s', async (cancelRequested) => {
+ const { store, runner, deps } = await setup();
+ await store.add({ ...message(), cancelRequested, state: 'confirming',
+ prepared: { clientId: 'id-1' } as QueuedRemoteMessage });
+ deps.projection.mockRejectedValue(new Error('[NOT_FOUND] Session session-a not found'));
+ deps.session.mockResolvedValue({ id: 'session-a', status: 'deleted' });
+ await runner.run();
+ expect(deps.cleanup).toHaveBeenCalledWith(expect.objectContaining({ cleanupOutcome: 'accepted' }), false);
+ expect(store.getSnapshot()).toEqual([]);
+ expect(deps.cancel).not.toHaveBeenCalled();
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ });
+ it.each(['active', 'absent', 'wrong-id', 'unavailable', 'hidden', 'timeout'] as const)(
+ 'retains an uncreated first message when deletion evidence is %s', async (evidence) => {
+ const { store, runner, deps, storage } = await setup();
+ await store.add({ ...message(), creation: { draft: {} } as DurableOutboxRecord['creation'] });
+ deps.projection.mockRejectedValue(evidence === 'timeout'
+ ? new Error('timed out: NOT_FOUND is not authoritative')
+ : Object.assign(new Error('not found'), { code: 'NOT_FOUND' }));
+ if (evidence === 'absent') deps.session.mockResolvedValue(null);
+ if (evidence === 'wrong-id') deps.session.mockResolvedValue({ id: 'session-b', status: 'deleted' });
+ if (evidence === 'unavailable') deps.session.mockRejectedValue(new Error('offline'));
+ if (evidence === 'hidden') deps.session.mockRejectedValue(new Error('[NOT_FOUND] Session does not exist'));
+ await runner.run();
+ expect(storage.data.size).toBe(1);
+ expect(store.getSnapshot()[0]?.cleanupOutcome).toBeUndefined();
+ expect(deps.cleanup).not.toHaveBeenCalled();
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ if (evidence === 'timeout') expect(deps.session).not.toHaveBeenCalled();
+ },
+ );
+ it.each(['files', 'ledger'] as const)('resumes deleted-task cleanup after %s failure without remote evidence', async (failure) => {
+ const { store, runner, deps, storage } = await setup();
+ await store.add(message());
+ deps.projection.mockRejectedValue(new Error('[NOT_FOUND] Session session-a not found'));
+ deps.session.mockResolvedValue({ id: 'session-a', status: 'deleted' });
+ if (failure === 'files') deps.cleanup.mockRejectedValueOnce(new Error('busy'));
+ else vi.spyOn(storage, 'removeItem').mockRejectedValueOnce(new Error('busy'));
+ await runner.run();
+ expect(store.getSnapshot()[0]?.cleanupOutcome).toBe('cancelled');
+ runner.stop();
+ const recovered = await setup(storage);
+ await recovered.runner.run();
+ expect(recovered.store.getSnapshot()).toEqual([]);
+ expect(recovered.deps.cleanup).toHaveBeenCalledWith(expect.objectContaining({ cleanupOutcome: 'cancelled' }), true);
+ expect(recovered.deps.projection).not.toHaveBeenCalled();
+ expect(recovered.deps.session).not.toHaveBeenCalled();
+ expect(recovered.deps.enqueue).not.toHaveBeenCalled();
+ });
+ it('ignores a deletion probe completed after an account switch', async () => {
+ const { store, runner, deps, storage, deactivate } = await setup();
+ await store.add(message());
+ deps.projection.mockRejectedValue(new Error('[NOT_FOUND] Session session-a not found'));
+ deps.session.mockImplementationOnce(async () => {
+ deactivate();
+ return { id: 'session-a', status: 'deleted' };
+ });
+ await runner.run();
+ expect(storage.data.size).toBe(1);
+ expect(deps.cleanup).not.toHaveBeenCalled();
+ });
+ it.each(['keys', 'item', 'json'] as const)('retries failed %s loading through ready and add without losing persisted work', async (failure) => {
+ const storage = disk();
+ const seed = createDurableOutbox(storage);
+ await seed.activate('alice');
+ await seed.add(message());
+ const readKeys = vi.spyOn(storage, 'getAllKeys');
+ const readItem = vi.spyOn(storage, 'getItem');
+ if (failure === 'keys') readKeys.mockRejectedValueOnce(new Error('busy'));
+ if (failure === 'item') readItem.mockRejectedValueOnce(new Error('busy'));
+ if (failure === 'json') readItem.mockResolvedValueOnce('{broken');
+ const store = createDurableOutbox(storage);
+ await expect(store.activate('alice')).rejects.toThrow();
+ expect(store.getSnapshot()).toEqual([]);
+ const loading = store.ready();
+ expect(store.activate('alice')).toBe(loading);
+ await Promise.all([loading, store.add({ ...message('id-2'), createdAt: 2 })]);
+ expect(store.getSnapshot().map((r) => r.item.clientId)).toEqual(['id-1', 'id-2']);
+ expect(readKeys).toHaveBeenCalledTimes(2);
+ });
+ it('keeps corrupt storage intact across retries and does not allow add to overwrite it', async () => {
+ const storage = disk();
+ const key = 'cindy.mobile.outbox.v1.alice/mac-a/session-a/id-1';
+ storage.data.set(key, '{broken');
+ const store = createDurableOutbox(storage);
+ await expect(store.activate('alice')).rejects.toThrow();
+ await expect(store.add(message())).rejects.toThrow();
+ await expect(store.ready()).rejects.toThrow();
+ expect(storage.data.get(key)).toBe('{broken');
+ expect(store.getSnapshot()).toEqual([]);
+ });
+ it('does not let an old activation failure invalidate the new account loading', async () => {
+ const storage = disk();
+ const pending = deferred<readonly string[]>();
+ const keys = vi.spyOn(storage, 'getAllKeys').mockImplementationOnce(() => pending.promise);
+ vi.spyOn(storage, 'getItem').mockRejectedValueOnce(new Error('old account read failed'));
+ const store = createDurableOutbox(storage);
+ const old = store.activate('alice');
+ const rejected = expect(old).rejects.toThrow('old account read failed');
+ const next = store.activate('bob');
+ pending.resolve(['cindy.mobile.outbox.v1.alice/mac-a/session-a/id-1']);
+ await rejected;
+ await next;
+ await store.ready();
+ expect(store.getAccountId()).toBe('bob');
+ expect(keys).toHaveBeenCalledTimes(2);
+ });
+ it('reconfirms a cancellation tombstone after its first response is lost', async () => {
+ const { store, runner, deps } = await setup();
+ await store.add({ ...message(), state: 'confirming', cancelRequested: true,
+ prepared: { clientId: 'id-1' } as QueuedRemoteMessage });
+ deps.cancel.mockRejectedValueOnce(new Error('response lost'));
+ await runner.run();
+ expect(store.getSnapshot()[0]?.cancelRequested).toBe(true);
+ expect(deps.cleanup).not.toHaveBeenCalled();
+ deps.projection.mockResolvedValue(projection('id-1', 'removed'));
+ runner.wake();
+ await runner.run();
+ expect(deps.cancel).toHaveBeenCalledTimes(2);
+ expect(deps.cleanup).toHaveBeenCalledWith(expect.objectContaining({ cleanupOutcome: 'cancelled' }), true);
+ expect(store.getSnapshot()).toEqual([]);
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ });
+ it('does not claim cancelled uploads when a removed receipt is followed by cancel=false', async () => {
+ const { store, runner, deps } = await setup();
+ await store.add({ ...message(), state: 'confirming', cancelRequested: true,
+ prepared: { clientId: 'id-1' } as QueuedRemoteMessage });
+ deps.projection.mockResolvedValue(projection('id-1', 'removed'));
+ deps.cancel.mockResolvedValue(false);
+ await runner.run();
+ runner.wake();
+ await runner.run();
+ expect(deps.cleanup).toHaveBeenCalledWith(expect.objectContaining({ cleanupOutcome: 'accepted' }), false);
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ });
+ it.each([
+ ['accepted', 'files'], ['accepted', 'ledger'],
+ ['cancelled', 'files'], ['cancelled', 'ledger'],
+ ] as const)('recovers %s cleanup after %s deletion fails without consulting the host or resending', async (outcome, failure) => {
+ const { store, runner, deps, storage } = await setup();
+ await store.add({ ...message(), state: 'confirming', cancelRequested: outcome === 'cancelled',
+ prepared: { clientId: 'id-1' } as QueuedRemoteMessage });
+ deps.projection.mockResolvedValue(projection('id-1', 'removed'));
+ if (failure === 'files') deps.cleanup.mockRejectedValueOnce(new Error('filesystem busy'));
+ else vi.spyOn(storage, 'removeItem').mockRejectedValueOnce(new Error('storage busy'));
+ await runner.run();
+ expect(store.getSnapshot()[0]).toMatchObject({ state: 'host-owned', cleanupOutcome: outcome });
+ runner.stop();
+ const recovered = await setup(storage);
+ expect(recovered.store.getSnapshot()[0]?.cleanupOutcome).toBe(outcome);
+ recovered.deps.projection.mockRejectedValue(new Error('host offline'));
+ await recovered.runner.run();
+ expect(recovered.deps.cleanup).toHaveBeenCalledWith(expect.objectContaining({ cleanupOutcome: outcome }), outcome === 'cancelled');
+ expect(recovered.store.getSnapshot()).toEqual([]);
+ expect(recovered.deps.projection).not.toHaveBeenCalled();
+ expect(recovered.deps.upload).not.toHaveBeenCalled();
+ expect(recovered.deps.enqueue).not.toHaveBeenCalled();
+ expect(recovered.deps.cancel).not.toHaveBeenCalled();
+ });
+ it('does not delete bytes when persisting completion fails', async () => {
+ const { store, runner, deps, storage } = await setup();
+ await store.add(message());
+ deps.projection.mockResolvedValue(projection('id-1', 'removed'));
+ vi.spyOn(storage, 'setItem').mockRejectedValueOnce(new Error('disk full'));
+ await runner.run();
+ expect(deps.cleanup).not.toHaveBeenCalled();
+ expect(store.getSnapshot()[0]?.cleanupOutcome).toBeUndefined();
+ expect(storage.data.size).toBe(1);
+ });
+ it('keeps completion after an account switch during cleanup and never blocks the next message', async () => {
+ const { store, runner, deps, storage, deactivate } = await setup();
+ await store.add({ ...message(), state: 'host-owned', cleanupOutcome: 'cancelled' });
+ await store.add({ ...message('id-2'), createdAt: 2 });
+ deps.cleanup.mockImplementationOnce(async () => { deactivate(); });
+ await runner.run();
+ expect(storage.data.size).toBe(2);
+ runner.stop();
+ const recovered = await setup(storage);
+ recovered.deps.cleanup.mockRejectedValue(new Error('still busy'));
+ await recovered.runner.run();
+ expect(recovered.deps.enqueue).toHaveBeenCalledWith(expect.objectContaining({ item: expect.objectContaining({ clientId: 'id-2' }) }));
+ expect(recovered.store.getSnapshot().find((r) => r.item.clientId === 'id-1')?.cleanupOutcome).toBe('cancelled');
+ });
+ it('isolates identical membership IDs across realms without claiming unqualified draft data', async () => {
+ const storage = disk();
+ const store = createDurableOutbox(storage);
+ await store.activate('alice');
+ await store.add(message());
+ const oldData = [...storage.data.entries()][0]!;
+ const globalKey = accountVaultKey('global', 'alice');
+ const cnKey = accountVaultKey('cn', 'alice');
+ await store.activate(globalKey);
+ expect(store.getSnapshot()).toEqual([]);
+ await store.add({ ...message(), accountId: globalKey });
+ const oldRecord = store.getSnapshot()[0]!;
+ const sending = vi.fn();
+ const unsubscribe = observeDurableOutboxSending(store, 'mac-a', 'session-a', sending, vi.fn(), cnKey);
+ await store.activate(cnKey);
+ expect(store.getSnapshot()).toEqual([]);
+ await expect(store.update(oldRecord, { state: 'sending' })).rejects.toThrow('OUTBOX_OWNER_CHANGED');
+ await store.add({ ...message(), accountId: cnKey });
+ await store.update(store.getSnapshot()[0]!, { state: 'sending', prepared: { clientId: 'id-1' } as QueuedRemoteMessage });
+ expect(sending).toHaveBeenCalledOnce();
+ expect(sending.mock.calls[0]?.[0].accountId).toBe(cnKey);
+ await store.activate(globalKey);
+ expect(store.getSnapshot()[0]?.accountId).toBe(globalKey);
+ expect(store.getSnapshot()[0]?.state).toBe('queued');
+ expect(storage.data.get(oldData[0])).toBe(oldData[1]);
+ unsubscribe();
+ });
+ it.each(['unknown', 'pending'] as const)('settles legacy %s cancellation as confirmation required without deleting or resending', async (state) => {
+ const { store, runner, deps } = await setup();
+ await store.add({ ...message(), state: 'confirming', cancelRequested: true,
+ prepared: { clientId: 'id-1' } as QueuedRemoteMessage });
+ deps.projection.mockResolvedValue({ ...projection('id-1', state), inputDeliveryVersion: undefined });
+ await runner.run();
+ expect(store.getSnapshot()[0]).toMatchObject({ state: 'failed', cancelRequested: true, error: 'check receipt' });
+ expect(deps.cancel).not.toHaveBeenCalled();
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ expect(deps.cleanup).not.toHaveBeenCalled();
+ });
+ it.each(['removed', 'history'] as const)('does not authorize remote attachment deletion from %s evidence', async (evidence) => {
+ const { store, runner, deps } = await setup();
+ await store.add({ ...message(), state: 'confirming', cancelRequested: true,
+ prepared: { clientId: 'id-1' } as QueuedRemoteMessage });
+ const record = store.getSnapshot()[0]!;
+ deps.projection.mockResolvedValue({ ...projection('id-1', evidence === 'removed' ? 'removed' : 'unknown'), inputDeliveryVersion: undefined });
+ deps.history.mockResolvedValue(true);
+ await runner.run();
+ expect(store.getSnapshot()).toEqual([]);
+ expect(deps.cleanup).toHaveBeenCalledWith(expect.objectContaining({ ...record, state: 'host-owned', cleanupOutcome: 'accepted' }), false);
+ expect(deps.cancel).not.toHaveBeenCalled();
+ });
+ it('reserves a visible user slot synchronously before an immediate assistant reply', async () => {
+ const { store, deps, runner } = await setup();
+ let source: RemoteMessage[] = [];
+ let slots: readonly OptimisticUserMessage[] = [];
+ const reserved = vi.fn((r: DurableOutboxRecord) => {
+ slots = appendOptimisticUserMessage(slots, source, r.prepared!, r.item.sessionId);
+ });
+ const settled = vi.fn();
+ const off = observeDurableOutboxSending(store, 'mac-a', 'session-a', reserved, settled);
+ deps.prepare.mockImplementation(async (r) => ({ clientId: r.item.clientId, text: r.item.text,
+ persistedContent: r.item.text, model: 'test', effort: 'medium', permissionMode: 'ask', workingDir: '/test',
+ createOpts: { agentKind: 'codex', model: 'test', workingDir: '/test' },
+ chatMessage: { clientId: r.item.clientId, role: 'user', content: r.item.text, createdAt: '2026-09-12T00:00:00Z' },
+ }));
+ deps.enqueue.mockImplementation(async () => {
+ expect(reserved).toHaveBeenCalledTimes(1);
+ source = [{ clientId: 'reply', role: 'assistant' } as RemoteMessage];
+ return projection();
+ });
+ await store.add(message());
+ await runner.run();
+ expect(projectOptimisticUserMessages(source, slots).map((r) => r.clientId)).toEqual(['id-1', 'reply']);
+ expect(settled).toHaveBeenCalledWith('id-1');
+ // A retry and a newly mounted page cannot infer another historical boundary.
+ const current = store.getSnapshot()[0]!;
+ const retry = await store.update(current, { state: 'queued' });
+ await store.update(retry, { state: 'sending' });
+ expect(reserved).toHaveBeenCalledTimes(1);
+ off();
+ const hydrated = vi.fn();
+ const offHydrated = observeDurableOutboxSending(store, 'mac-a', 'session-a', hydrated, () => {});
+ const retryAgain = await store.update(store.getSnapshot()[0]!, { state: 'queued' });
+ await store.update(retryAgain, { state: 'sending' });
+ await store.add({ ...message('other', 'other-session'), state: 'sending', prepared: retryAgain.prepared });
+ expect(hydrated).not.toHaveBeenCalled();
+ offHydrated();
+ });
+ it("publishes only after persistence and restores original IDs, attachment slots and permission after restart", async () => {
+ const storage = disk();
+ const store = createDurableOutbox(storage);
+ await store.activate("alice");
+ const gate = deferred<void>();
+ const write = storage.setItem;
+ storage.setItem = async (k, v) => {
+ await gate.promise;
+ await write(k, v);
+ };
+ const record = message();
+ record.uploads = [
+ {
+ slot: 0,
+ fileName: "slot-0.png",
+ size: 123,
+ name: "photo.png",
+ kind: "image",
+ },
+ ];
+ record.item.attachmentSlots = [null];
+ const adding = store.add(record);
+ await Promise.resolve();
+ expect(store.getSnapshot()).toEqual([]);
+ gate.resolve();
+ await adding;
+ const restarted = createDurableOutbox(storage);
+ await restarted.activate("alice");
+ expect(restarted.getSnapshot()).toEqual([record]);
+ await restarted.activate("bob");
+ expect(restarted.getSnapshot()).toEqual([]);
+ await restarted.activate("alice");
+ expect(restarted.getSnapshot()[0]?.item.clientId).toBe("id-1");
+ });
+ it("does not accept a message when disk is full", async () => {
+ const storage = disk();
+ storage.setItem = async () => {
+ throw new Error("disk full");
+ };
+ const { store, runner, deps } = await setup(storage);
+ await expect(store.add(message())).rejects.toThrow("disk full");
+ await runner.run();
+ expect(store.getSnapshot()).toEqual([]);
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ });
+ it("does not resurrect a removed record through a late upload update", async () => {
+ const { store } = await setup();
+ const record = message();
+ await store.add(record);
+ await store.remove(record);
+ await expect(store.update(record, { state: "sending" })).rejects.toThrow(
+ "OUTBOX_STALE_WRITE",
+ );
+ expect(store.getSnapshot()).toEqual([]);
+ });
+ it("keeps a committed old-account write safe when logout races disk completion", async () => {
+ const storage = disk();
+ const { store } = await setup(storage);
+ const entered = deferred<void>();
+ const finish = deferred<void>();
+ const write = storage.setItem;
+ storage.setItem = async (k, v) => {
+ entered.resolve();
+ await finish.promise;
+ await write(k, v);
+ };
+ const saving = store.add(message());
+ await entered.promise;
+ const switching = store.activate("bob");
+ finish.resolve();
+ await expect(saving).resolves.toBeUndefined();
+ await switching;
+ expect(store.getSnapshot()).toEqual([]);
+ await store.activate("alice");
+ expect(store.getSnapshot()).toHaveLength(1);
+ });
+ it("isolates dotted and slash-containing owner/device/session keys", async () => {
+ const storage = disk();
+ const { store } = await setup(storage);
+ await store.add({ ...message("c", "b.c"), deviceId: "a" });
+ await store.add({ ...message("c", "c"), deviceId: "a.b" });
+ expect(storage.data.size).toBe(2);
+ });
+});
+
+describe("app-owned delivery and reconciliation", () => {
+ it.each(['legacy', 'legacy-prepared'] as const)('keeps %s enqueue success uncertain across restart until history confirms it', async (host) => {
+ const first = await setup();
+ const legacy = { pendingQueue: [] } as unknown as DeliveryProjection;
+ if (host === 'legacy') first.deps.projection.mockResolvedValue(legacy);
+ first.deps.enqueue.mockResolvedValue(legacy);
+ await first.store.add(host === 'legacy' ? message() : { ...message(), retrySafe: false,
+ prepared: { clientId: 'id-1' } as QueuedRemoteMessage });
+ await first.runner.run();
+ expect(first.store.getSnapshot()[0]).toMatchObject({ state: 'confirming', error: 'check receipt' });
+ first.runner.stop();
+ const second = await setup(first.storage);
+ second.deps.projection.mockResolvedValue(legacy);
+ await second.runner.run();
+ expect(second.store.getSnapshot()[0]).toMatchObject({ state: 'failed', error: 'check receipt' });
+ expect(second.deps.enqueue).not.toHaveBeenCalled();
+ expect(second.deps.cleanup).not.toHaveBeenCalled();
+ second.deps.history.mockResolvedValue(true);
+ second.runner.wake();
+ await second.runner.run();
+ expect(second.store.getSnapshot()).toEqual([]);
+ expect(second.deps.cleanup).toHaveBeenCalledOnce();
+ });
+ it.each(['sending', 'host-owned'] as const)('never promotes legacy pending or restored %s to durable ownership', async (state) => {
+ const { store, deps, runner } = await setup();
+ await store.add({ ...message(), state, retrySafe: false, clearBoundaryMs: null,
+ prepared: { clientId: 'id-1' } as QueuedRemoteMessage });
+ await store.add({ ...message('id-2'), createdAt: 2 });
+ deps.projection.mockResolvedValue({ pendingQueue: [{ clientId: 'id-1' }], clearBoundaryMs: null } as unknown as DeliveryProjection);
+ await runner.run();
+ expect(store.getSnapshot()[0]).toMatchObject({ state: 'confirming', error: 'check receipt' });
+ deps.projection.mockResolvedValue({ pendingQueue: [], clearBoundaryMs: 123 } as unknown as DeliveryProjection);
+ runner.wake();
+ await runner.run();
+ expect(store.getSnapshot()[0]).toMatchObject({ state: 'failed', error: 'task cleared' });
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ expect(deps.cleanup).not.toHaveBeenCalled();
+ });
+ it.each([true, false])("persists creation Plan=%s on the input before enqueue", async (planModeArm) => {
+ const { store, runner, deps } = await setup();
+ const record = message();
+ record.creation = {
+ draft: { agentKind: 'claude-code', workspaceKind: 'project', workingDir: '/repo',
+ model: 'test', providerId: null, effort: 'medium', permissionMode: 'ask',
+ fastMode: false, firstMessage: record.item.text },
+ deviceName: 'Mac', planModeArm, restorePermissionMode: null,
+ };
+ await store.add(record);
+ await runner.run();
+ expect(deps.enqueue.mock.calls[0]?.[0].prepared?.createOpts.planMode).toBe(planModeArm);
+ expect(store.getSnapshot()[0]?.prepared?.createOpts.planMode).toBe(planModeArm);
+ });
+ it("sends without a page and keeps display ownership until history confirms the message", async () => {
+ const { store, runner, deps } = await setup();
+ await store.add(message());
+ await runner.run();
+ expect(deps.enqueue).toHaveBeenCalledTimes(1);
+ expect(deps.enqueue.mock.calls[0]?.[0].prepared?.clientId).toBe("id-1");
+ expect(store.getSnapshot()[0]?.state).toBe("host-owned");
+ runner.wake();
+ deps.projection.mockResolvedValue(projection("id-1", "accepted"));
+ deps.history.mockResolvedValue(true);
+ await runner.run();
+ expect(store.getSnapshot()).toEqual([]);
+ expect(deps.cleanup).toHaveBeenCalledOnce();
+ });
+ it("restarts after a lost receipt, finds durable host ownership, and never enqueues twice", async () => {
+ const first = await setup();
+ await first.store.add(message());
+ first.deps.enqueue.mockRejectedValue(new Error("response lost"));
+ await first.runner.run();
+ expect(first.store.getSnapshot()[0]?.state).toBe("confirming");
+ const second = await setup(first.storage);
+ second.deps.projection.mockResolvedValue(projection("id-1", "pending"));
+ await second.runner.run();
+ expect(second.deps.enqueue).not.toHaveBeenCalled();
+ expect(second.store.getSnapshot()[0]?.state).toBe("host-owned");
+ });
+ it("retries an uncertain new-host write with exactly the persisted payload and clientId", async () => {
+ const first = await setup();
+ await first.store.add(message());
+ first.deps.enqueue.mockRejectedValue(new Error("response lost"));
+ await first.runner.run();
+ const sent = first.deps.enqueue.mock.calls[0]?.[0];
+ const second = await setup(first.storage);
+ await second.runner.run();
+ const retried = second.deps.enqueue.mock.calls[0]?.[0];
+ expect(retried?.prepared).toEqual(sent?.prepared);
+ expect(retried?.sendAtMs).toBe(sent?.sendAtMs);
+ expect(second.deps.prepare).not.toHaveBeenCalled();
+ });
+ it("holds uncertain writes on legacy hosts, including after restart", async () => {
+ const first = await setup();
+ await first.store.add(message());
+ first.deps.projection.mockResolvedValue({
+ pendingQueue: [],
+ } as unknown as DeliveryProjection);
+ first.deps.enqueue.mockRejectedValue(new Error("response lost"));
+ await first.runner.run();
+ const second = await setup(first.storage);
+ second.deps.projection.mockResolvedValue({
+ pendingQueue: [],
+ } as unknown as DeliveryProjection);
+ await second.runner.run();
+ expect(second.deps.enqueue).not.toHaveBeenCalled();
+ expect(second.store.getSnapshot()[0]?.error).toBe("check receipt");
+ });
+ it("does not replay a message after the desktop clear boundary changes", async () => {
+ const { store, runner, deps } = await setup();
+ await store.add({ ...message(), clearBoundaryMs: null });
+ deps.projection.mockResolvedValue({
+ ...projection(),
+ clearBoundaryMs: 123,
+ });
+ await runner.run();
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ expect(store.getSnapshot()[0]?.error).toBe("task cleared");
+ });
+ it("seals a cancellation before discarding an uncertain message", async () => {
+ const { store, runner, deps } = await setup();
+ await store.add({
+ ...message(),
+ state: "confirming",
+ prepared: { clientId: "id-1" } as QueuedRemoteMessage,
+ cancelRequested: true,
+ });
+ const gate = deferred<void>();
+ deps.cancel.mockImplementation(async () => {
+ await gate.promise;
+ return true;
+ });
+ const running = runner.run();
+ await vi.waitFor(() => expect(deps.cancel).toHaveBeenCalledOnce());
+ expect(store.getSnapshot()).toHaveLength(1);
+ expect(deps.cleanup).not.toHaveBeenCalled();
+ const cancelledRecord = store.getSnapshot()[0]!;
+ gate.resolve();
+ await running;
+ expect(store.getSnapshot()).toHaveLength(0);
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ expect(deps.cleanup).toHaveBeenCalledWith(expect.objectContaining({ ...cancelledRecord, state: 'host-owned', cleanupOutcome: 'cancelled' }), true);
+ });
+ it("keeps FIFO within a task while other computers can continue", async () => {
+ const { store, runner, deps } = await setup();
+ await store.add({ ...message("first"), state: "failed" });
+ await store.add({ ...message("second"), createdAt: 2 });
+ await store.add({
+ ...message("other", "session-b"),
+ deviceId: "mac-b",
+ createdAt: 3,
+ });
+ await runner.run();
+ expect(deps.enqueue.mock.calls.map(([r]) => r.item.clientId)).toEqual([
+ "other",
+ ]);
+ });
+ it("does not enqueue after the account changes during preparation", async () => {
+ const { store, runner, deps, deactivate } = await setup();
+ await store.add(message());
+ const gate = deferred<QueuedRemoteMessage>();
+ deps.prepare.mockImplementation(() => gate.promise);
+ const running = runner.run();
+ await vi.waitFor(() => expect(deps.prepare).toHaveBeenCalledOnce());
+ deactivate();
+ gate.resolve({ clientId: "id-1" } as QueuedRemoteMessage);
+ await running;
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ expect(store.getSnapshot()[0]?.state).toBe("queued");
+ });
+ it("cleans up host-owned messages after a clear instead of polling invisible history forever", async () => {
+ const { store, runner, deps } = await setup();
+ await store.add({
+ ...message(),
+ state: "host-owned",
+ clearBoundaryMs: null,
+ });
+ deps.projection.mockResolvedValue({
+ ...projection("id-1", "accepted"),
+ clearBoundaryMs: 123,
+ });
+ await runner.run();
+ expect(store.getSnapshot()).toHaveLength(0);
+ expect(deps.history).not.toHaveBeenCalled();
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ });
+ it("keeps a too-late cancellation under host ownership instead of claiming it cancelled dispatch", async () => {
+ const { store, runner, deps } = await setup();
+ await store.add({
+ ...message(),
+ prepared: { clientId: "id-1" } as QueuedRemoteMessage,
+ state: "confirming",
+ cancelRequested: true,
+ });
+ deps.cancel.mockResolvedValue(false);
+ await runner.run();
+ expect(store.getSnapshot()[0]?.state).toBe("host-owned");
+ expect(store.getSnapshot()[0]?.cancelRequested).toBe(false);
+ expect(deps.cleanup).not.toHaveBeenCalled();
+ });
+ it("reuploads expired attachment references from the durable file without changing clientId", async () => {
+ const { store, deps } = await setup();
+ const record = message();
+ record.uploads = [
+ {
+ slot: 0,
+ fileName: "slot-0.png",
+ size: 123,
+ name: "photo.png",
+ kind: "image",
+ },
+ ];
+ record.item.attachmentSlots = [
+ {
+ id: "old",
+ name: "photo.png",
+ path: "expired",
+ ext: "png",
+ size: 123,
+ category: "image",
+ mimeType: "image/png",
+ },
+ ];
+ await store.add(record);
+ const runner = createDurableOutboxDelivery({
+ ...deps,
+ mediaFailed: () => true,
+ });
+ deps.enqueue.mockRejectedValueOnce(
+ new Error("DEVICE_LINK_MEDIA_TRANSFER_FAILED"),
+ );
+ await runner.run();
+ runner.wake();
+ await runner.run();
+ expect(deps.upload).toHaveBeenCalledOnce();
+ expect(deps.discardUploads).toHaveBeenCalledWith(expect.objectContaining({ refreshUploads: false }), [record.item.attachmentSlots[0]]);
+ expect(deps.discardUploads.mock.invocationCallOrder[0]).toBeLessThan(deps.upload.mock.invocationCallOrder[0]!);
+ expect(deps.enqueue.mock.calls.map(([r]) => r.prepared?.clientId)).toEqual([
+ "id-1",
+ "id-1",
+ ]);
+ expect(store.getSnapshot()[0]?.item.attachmentSlots[0]?.id).toBe("file-1");
+ });
+ it.each(['disk-failure', 'late-upload', 'success'] as const)('settles upload ownership after %s', async (outcome) => {
+ const { store, deps, storage, runner } = await setup();
+ await store.add({ ...message(), uploads: [{ slot: 0, fileName: 'file.png', name: 'file.png', kind: 'image', size: 1 }],
+ item: { ...message().item, attachmentSlots: [null] } });
+ const attachment = await deps.upload();
+ deps.upload.mockClear();
+ deps.upload.mockImplementationOnce(async () => {
+ if (outcome === 'late-upload') runner.stop();
+ return attachment;
+ });
+ if (outcome === 'disk-failure') vi.spyOn(storage, 'setItem').mockRejectedValueOnce(new Error('disk full'));
+ await runner.run();
+ if (outcome === 'success') {
+ expect(deps.discardUploads).not.toHaveBeenCalled();
+ expect(deps.enqueue).toHaveBeenCalledOnce();
+ } else {
+ expect(deps.discardUploads).toHaveBeenCalledWith(expect.anything(), [attachment]);
+ expect(deps.enqueue).not.toHaveBeenCalled();
+ expect(store.getSnapshot()[0]?.item.attachmentSlots).toEqual([null]);
+ }
+ });
+ it('retains superseded references when replacing the ledger fails, then only discards upload-backed slots', async () => {
+ const { store, deps, storage, runner } = await setup();
+ const old = await deps.upload();
+ const unchanged = { ...old, id: 'not-replaced', path: 'other' };
+ await store.add({ ...message(), refreshUploads: true, prepared: { clientId: 'id-1' } as QueuedRemoteMessage,
+ uploads: [{ slot: 0, fileName: 'file.png', name: 'file.png', kind: 'image', size: 1 }],
+ item: { ...message().item, attachmentSlots: [old, unchanged] } });
+ deps.upload.mockClear();
+ const write = vi.spyOn(storage, 'setItem').mockRejectedValueOnce(new Error('disk full'));
+ await runner.run();
+ expect(deps.discardUploads).not.toHaveBeenCalled();
+ expect(deps.upload).not.toHaveBeenCalled();
+ expect(store.getSnapshot()[0]?.item.attachmentSlots).toEqual([old, unchanged]);
+ write.mockRestore();
+ runner.wake();
+ await runner.run();
+ expect(deps.discardUploads).toHaveBeenCalledWith(expect.anything(), [old]);
+ expect(store.getSnapshot()[0]?.item.attachmentSlots[1]).toEqual(unchanged);
+ });
+ it("persists the first creation message as the FIFO barrier across restart", async () => {
+ const first = await setup();
+ await first.store.add({ ...message("first"), suspended: true });
+ await first.store.add({ ...message("follow-up"), createdAt: 2 });
+ const second = await setup(first.storage);
+ const runner = createDurableOutboxDelivery({
+ ...second.deps,
+ canRun: (r) => !r.suspended,
+ });
+ await runner.run();
+ expect(second.deps.enqueue).not.toHaveBeenCalled();
+ const head = second.store.getSnapshot()[0]!;
+ await second.store.update(head, { suspended: false });
+ await runner.run();
+ runner.wake();
+ await runner.run();
+ expect(
+ second.deps.enqueue.mock.calls.map(([r]) => r.item.clientId),
+ ).toEqual(["first", "follow-up"]);
+ });
+});
diff --git a/apps/mobile/src/__tests__/durableOutboxFiles.test.ts b/apps/mobile/src/__tests__/durableOutboxFiles.test.ts
new file mode 100644
index 0000000000..05f98e0ea9
--- /dev/null
+++ b/apps/mobile/src/__tests__/durableOutboxFiles.test.ts
@@ -0,0 +1,198 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import type {
+ DurableOutboxRecord,
+ DurableUpload,
+} from "../session/durableOutbox";
+import { buildMobileRemoteFileAttachment, buildMobileUploadedAttachment } from '../session/attachments';
+const fs = vi.hoisted(() => ({
+ ledger: new Map<string, string>(),
+ directories: new Map<string, string[]>(),
+ stageExists: true,
+ removeStage: vi.fn(),
+ stagePaths: [] as string[],
+ documentDirectory: "file:///sandbox/Documents/",
+ makeDirectoryAsync: vi.fn(async () => {}),
+ copyAsync: vi.fn(async (_options: { from: string; to: string }) => {}),
+ getInfoAsync: vi.fn(async (_uri: string) => ({
+ exists: true,
+ isDirectory: false,
+ size: 123,
+ })),
+ deleteAsync: vi.fn(async () => {}),
+ readDirectoryAsync: vi.fn(async (uri: string): Promise<string[]> => fs.directories.get(uri) ?? []),
+}));
+vi.mock('@react-native-async-storage/async-storage', () => ({ default: {
+ getAllKeys: vi.fn(async () => [...fs.ledger.keys()]),
+ getItem: vi.fn(async (key: string) => fs.ledger.get(key) ?? null),
+} }));
+vi.mock("expo-file-system/legacy", () => fs);
+vi.mock('expo-file-system', () => ({ Directory: class {
+ constructor(uri: string) { fs.stagePaths.push(uri); }
+ get exists() { return fs.stageExists; }
+ delete() { fs.removeStage(); }
+} }));
+import {
+ durableOutboxDirectory,
+ durableOutboxUploadUri,
+ retainOutboxFile,
+ retainComposerAttachmentFile,
+ removeRetainedOutboxFiles,
+ initializeComposerAttachmentStage,
+ initializeOutboxFiles,
+ outboxAttachmentNeedsLocalBytes,
+} from "../session/durableOutboxFiles";
+const record = {
+ accountId: "owner/../a",
+ deviceId: "mac",
+ item: { sessionId: "../session", clientId: "id" },
+} as DurableOutboxRecord;
+const source = {
+ uri: "file:///cache/prepared.jpg",
+ name: "photo.jpg",
+ size: 123,
+ mimeType: "image/jpeg",
+ kind: "image" as const,
+};
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ delete (globalThis as { __cindyOutboxStageInitialized?: boolean }).__cindyOutboxStageInitialized;
+ delete (globalThis as { __cindyOutboxFilesInitialized?: Promise<void> }).__cindyOutboxFilesInitialized;
+ fs.ledger.clear();
+ fs.directories.clear();
+ fs.stageExists = true;
+ fs.stagePaths.length = 0;
+ fs.removeStage.mockReset();
+ fs.documentDirectory = "file:///sandbox/Documents/";
+ fs.getInfoAsync.mockResolvedValue({
+ exists: true,
+ isDirectory: false,
+ size: 123,
+ });
+});
+describe("outbox-owned attachment bytes", () => {
+ it('reclaims pre-commit and replaced files while preserving every account ledger', async () => {
+ const root = fs.documentDirectory + 'message-outbox/';
+ fs.directories.set(root, ['alice', 'bob']);
+ for (const accountId of ['alice', 'bob']) {
+ const r = { ...record, version: 1, accountId, uploads: [{ fileName: 'slot-0.jpg' }] } as DurableOutboxRecord;
+ const dir = durableOutboxDirectory(r);
+ fs.ledger.set(`cindy.mobile.outbox.v1.${accountId}/mac/session/id`, JSON.stringify(r));
+ fs.directories.set(root + accountId + '/', ['mac']);
+ fs.directories.set(root + accountId + '/mac/', ['%2E%2E%2Fsession']);
+ fs.directories.set(root + accountId + '/mac/%2E%2E%2Fsession/', ['id', 'uncommitted']);
+ fs.directories.set(dir, ['slot-0.jpg', 'slot-1.jpg']);
+ fs.directories.set(dir.replace('/id/', '/uncommitted/'), ['slot-0.jpg']);
+ }
+ fs.getInfoAsync.mockImplementation(async (uri) => ({ exists: true, isDirectory: fs.directories.has(uri), size: 123 }));
+ await initializeOutboxFiles();
+ expect(fs.deleteAsync).toHaveBeenCalledTimes(4);
+ expect(fs.deleteAsync.mock.calls.flat()).not.toContain(durableOutboxDirectory({ ...record, accountId: 'alice' }) + 'slot-0.jpg');
+ expect(fs.deleteAsync.mock.calls.flat()).not.toContain(durableOutboxDirectory({ ...record, accountId: 'bob' }) + 'slot-0.jpg');
+ await retainOutboxFile(record, 0, source);
+ await initializeOutboxFiles();
+ expect(fs.deleteAsync).toHaveBeenCalledTimes(4);
+ });
+ it('blocks copying and deletion on a corrupt ledger, then retries safely', async () => {
+ fs.ledger.set('cindy.mobile.outbox.v1.broken', '{broken');
+ await expect(retainOutboxFile(record, 0, source)).rejects.toThrow();
+ expect(fs.copyAsync).not.toHaveBeenCalled();
+ expect(fs.deleteAsync).not.toHaveBeenCalled();
+ fs.ledger.clear();
+ await retainOutboxFile(record, 0, source);
+ expect(fs.copyAsync).toHaveBeenCalledOnce();
+ });
+ it('requires retry bytes for phone uploads but preserves Desktop file references without a phone copy', () => {
+ const remote = buildMobileRemoteFileAttachment('/Users/dash/report.pdf')!;
+ const uploaded = buildMobileUploadedAttachment({ ossKey: 'uploads/report.pdf', name: 'report.pdf', size: 123, sha256: 'a'.repeat(64) })!;
+ expect(outboxAttachmentNeedsLocalBytes(remote)).toBe(false);
+ expect(outboxAttachmentNeedsLocalBytes(uploaded)).toBe(true);
+ expect(outboxAttachmentNeedsLocalBytes({ path: 'cindy-oss-attach://m/legacy' })).toBe(true);
+ });
+ it('clears previous-runtime staging once without touching retained outbox files or active composers', async () => {
+ initializeComposerAttachmentStage();
+ await retainComposerAttachmentFile('one', 'id', source.uri, source.size);
+ await retainComposerAttachmentFile('two', 'id', source.uri, source.size);
+ initializeComposerAttachmentStage();
+ expect(fs.stagePaths).toEqual(['file:///sandbox/Documents/outbox-attachment-stage/']);
+ expect(fs.removeStage).toHaveBeenCalledOnce();
+ expect(fs.copyAsync).toHaveBeenCalledTimes(2);
+ });
+ it('does not write staging bytes after cleanup fails and retries on the next retain', async () => {
+ fs.removeStage.mockImplementationOnce(() => { throw new Error('directory busy'); });
+ await expect(retainComposerAttachmentFile('one', 'id', source.uri, source.size)).rejects.toThrow('directory busy');
+ expect(fs.makeDirectoryAsync).not.toHaveBeenCalled();
+ expect(fs.copyAsync).not.toHaveBeenCalled();
+ await retainComposerAttachmentFile('one', 'id', source.uri, source.size);
+ expect(fs.removeStage).toHaveBeenCalledTimes(2);
+ expect(fs.copyAsync).toHaveBeenCalledOnce();
+ });
+ it('accepts an absent staging directory on first launch', () => {
+ fs.stageExists = false;
+ initializeComposerAttachmentStage();
+ expect(fs.removeStage).not.toHaveBeenCalled();
+ });
+ it('does not repeat startup deletion when Fast Refresh reloads the module', async () => {
+ await retainComposerAttachmentFile('active', 'id', source.uri, source.size);
+ vi.resetModules();
+ const refreshed = await import('../session/durableOutboxFiles');
+ refreshed.initializeComposerAttachmentStage();
+ await refreshed.retainComposerAttachmentFile('next', 'id', source.uri, source.size);
+ expect(fs.removeStage).toHaveBeenCalledOnce();
+ });
+ it('keeps composer PUT bytes outside evictable caches and verifies the copy', async () => {
+ const target = await retainComposerAttachmentFile('composer/owner', 'file/id', source.uri, source.size);
+ expect(target).toBe('file:///sandbox/Documents/outbox-attachment-stage/composer%2Fowner/file%2Fid');
+ expect(fs.copyAsync).toHaveBeenCalledWith({ from: source.uri, to: target });
+ expect(fs.getInfoAsync).toHaveBeenCalledWith(target);
+ });
+ it('removes partial composer copies and refuses cache fallback', async () => {
+ fs.copyAsync.mockRejectedValueOnce(new Error('disk full'));
+ await expect(retainComposerAttachmentFile('owner', 'id', source.uri, source.size)).rejects.toThrow('disk full');
+ expect(fs.deleteAsync).toHaveBeenCalledWith('file:///sandbox/Documents/outbox-attachment-stage/owner/id', { idempotent: true });
+ fs.documentDirectory = '';
+ await expect(retainComposerAttachmentFile('owner', 'id', source.uri, source.size)).rejects.toThrow('OUTBOX_STORAGE_UNAVAILABLE');
+ expect(fs.copyAsync).toHaveBeenCalledOnce();
+ });
+ it("copies and verifies the full attachment before handing ownership to a record", async () => {
+ const upload = await retainOutboxFile(record, 0, source);
+ expect(fs.copyAsync).toHaveBeenCalledWith({
+ from: source.uri,
+ to: durableOutboxUploadUri(record, upload),
+ });
+ expect(upload.size).toBe(123);
+ expect(durableOutboxDirectory(record)).not.toContain("/../");
+ });
+ it("rejects a partial copy rather than accepting a message with missing bytes", async () => {
+ fs.getInfoAsync.mockResolvedValue({
+ exists: true,
+ isDirectory: false,
+ size: 12,
+ });
+ await expect(retainOutboxFile(record, 0, source)).rejects.toThrow(
+ "OUTBOX_FILE_COPY_FAILED",
+ );
+ expect(fs.deleteAsync).toHaveBeenCalledWith(fs.copyAsync.mock.calls[0]?.[0].to, { idempotent: true });
+ });
+ it("rolls back new copies without deleting older recovery files in the same directory", async () => {
+ const upload = await retainOutboxFile(record, 0, source);
+ await removeRetainedOutboxFiles({ ...record, uploads: [upload] });
+ expect(fs.deleteAsync).toHaveBeenCalledTimes(1);
+ expect(fs.deleteAsync).toHaveBeenCalledWith(durableOutboxUploadUri(record, upload), { idempotent: true });
+ });
+ it("uses relative filenames so a sandbox path change after restore does not break attachments", () => {
+ const upload = { fileName: "slot-0.jpg" } as DurableUpload;
+ const previous = durableOutboxUploadUri(record, upload);
+ fs.documentDirectory = "file:///new-sandbox/Documents/";
+ expect(durableOutboxUploadUri(record, upload)).toBe(
+ previous.replace("sandbox/", "new-sandbox/"),
+ );
+ });
+ it("rejects forged filenames before reading or deleting outside the message directory", () => {
+ expect(() =>
+ durableOutboxUploadUri(record, {
+ fileName: "../other/file.jpg",
+ } as DurableUpload),
+ ).toThrow("OUTBOX_FILE_INVALID");
+ });
+});
diff --git a/apps/mobile/src/__tests__/inputProjection.test.ts b/apps/mobile/src/__tests__/inputProjection.test.ts
index 4d586ad754..a03be3cc6e 100644
--- a/apps/mobile/src/__tests__/inputProjection.test.ts
+++ b/apps/mobile/src/__tests__/inputProjection.test.ts
@@ -17,6 +17,7 @@ import { parseAttachmentOssRef } from '@/session/attachmentOssRef';
import { textComposerDocument } from '@/session/composerDocument';
import { localizeAgentError } from '@/session/agentErrorI18n';
import type { RemoteSession } from '@/session/types';
+import { buildOutboxItem } from '@/session/sessionOutbox';
const ATTACHMENT_SHA256 = 'a'.repeat(64);
@@ -41,6 +42,17 @@ function session(patch: Partial<RemoteSession> = {}): RemoteSession {
}
describe('inputProjection', () => {
+ it.each([true, false, undefined])('keeps the stored Plan snapshot %s across a later host toggle and serialization', (planModeAtSend) => {
+ const original = buildOutboxItem({ clientId: 'plan-id', sessionId: 's1', text: 'plan snapshot',
+ permissionModeAtSend: 'ask', planModeAtSend, readyAttachments: [], claimedUploads: [] });
+ const recovered = JSON.parse(JSON.stringify(original));
+ const queued = buildQueuedTextMessage(session({ planModeEnabled: !planModeAtSend }), recovered.text,
+ new Date(), recovered.clientId, { planMode: recovered.planModeAtSend });
+ expect(queued.createOpts.planMode).toBe(planModeAtSend);
+ expect(queued.permissionMode).toBe('ask');
+ if (planModeAtSend === undefined) expect(queued.createOpts).not.toHaveProperty('planMode');
+ });
+
beforeAll(async () => {
await i18n.changeLanguage('zh-CN');
});
diff --git a/apps/mobile/src/__tests__/mobileDurableOutboxOwner.test.ts b/apps/mobile/src/__tests__/mobileDurableOutboxOwner.test.ts
new file mode 100644
index 0000000000..66e92fc27a
--- /dev/null
+++ b/apps/mobile/src/__tests__/mobileDurableOutboxOwner.test.ts
@@ -0,0 +1,85 @@
+import { beforeEach, expect, it, vi } from 'vitest';
+import { getMobileAuthOwner, setMobileAuthOwner } from '../auth/authOwnerGeneration';
+import type { DurableOutboxRecord } from '../session/durableOutbox';
+
+const mocks = vi.hoisted(() => ({ discard: vi.fn(), removeFiles: vi.fn(async () => {}), data: new Map<string, string>() }));
+vi.mock('@react-native-async-storage/async-storage', () => ({ default: {
+ getAllKeys: async () => [...mocks.data.keys()],
+ getItem: async (key: string) => mocks.data.get(key) ?? null,
+ setItem: async (key: string, value: string) => { mocks.data.set(key, value); },
+ removeItem: async (key: string) => { mocks.data.delete(key); },
+} }));
+vi.mock('../session/durableOutboxFiles', () => ({ durableOutboxUploadUri: vi.fn(), removeOutboxFiles: mocks.removeFiles }));
+vi.mock('../session/mobileAttachmentUpload', () => ({ discardMobileUploadedAttachment: mocks.discard }));
+import { cleanupOutboxResources, discardOutboxUploads, getCurrentMobileOutboxRecords, mobileDurableOutbox } from '../session/mobileDurableOutbox';
+
+function record(): DurableOutboxRecord {
+ return { version: 1, accountId: getMobileAuthOwner().accountKey, deviceId: 'mac', createdAt: 1,
+ state: 'queued', uploads: [], item: { clientId: 'message', sessionId: 'task',
+ text: 'draft', quotesEncoded: false, agentReferences: [], pastedTextRanges: [],
+ slashCommandRanges: [], permissionModeAtSend: 'ask', slotMeta: [], slotByLocalId: {},
+ waitingIds: [], failedIds: [], enqueueError: null, phase: 'uploading',
+ attachmentSlots: [{ id: 'attachment', path: 'oss-ref', name: 'photo.png', ext: 'png',
+ size: 1, category: 'image', mimeType: 'image/png' }],
+ } };
+}
+beforeEach(async () => {
+ setMobileAuthOwner(null);
+ await mobileDurableOutbox.activate('');
+ mocks.data.clear();
+ mocks.discard.mockReset();
+ mocks.removeFiles.mockReset();
+ setMobileAuthOwner('alice', 'global');
+ await mobileDurableOutbox.activate(getMobileAuthOwner().accountKey);
+});
+
+it('still disposes confirmed-cancelled uploads when local deletion rejects', async () => {
+ mocks.removeFiles.mockRejectedValueOnce(new Error('filesystem unavailable'));
+ await expect(cleanupOutboxResources(record(), getMobileAuthOwner(), async () => 'token', true)).rejects.toThrow('filesystem unavailable');
+ expect(mocks.discard).toHaveBeenCalledOnce();
+ expect(await mocks.discard.mock.calls[0]![1].getToken()).toBe('token');
+});
+
+it('never disposes host-owned uploads even when local deletion rejects', async () => {
+ mocks.removeFiles.mockRejectedValueOnce(new Error('filesystem unavailable'));
+ await expect(cleanupOutboxResources(record(), getMobileAuthOwner(), async () => 'token', false)).rejects.toThrow('filesystem unavailable');
+ expect(mocks.discard).not.toHaveBeenCalled();
+});
+
+it('hides the old realm ledger synchronously before the bridge activates the new owner', async () => {
+ await mobileDurableOutbox.add(record());
+ expect(getCurrentMobileOutboxRecords()).toHaveLength(1);
+ setMobileAuthOwner('alice', 'cn');
+ expect(mobileDurableOutbox.getSnapshot()).toHaveLength(1);
+ expect(getCurrentMobileOutboxRecords()).toEqual([]);
+});
+
+it('keeps cleanup-only rows durable but hides them from sending and creation recovery views', async () => {
+ await mobileDurableOutbox.add(record());
+ await mobileDurableOutbox.update(mobileDurableOutbox.getSnapshot()[0]!, { state: 'host-owned', cleanupOutcome: 'cancelled' });
+ expect(mobileDurableOutbox.getSnapshot()).toHaveLength(1);
+ expect(getCurrentMobileOutboxRecords()).toEqual([]);
+});
+
+it('does not use a token that arrives after a same-membership realm switch', async () => {
+ let resolve!: (token: string) => void;
+ const token = new Promise<string>((done) => { resolve = done; });
+ const getToken = vi.fn(() => token);
+ discardOutboxUploads(record(), getMobileAuthOwner(), getToken);
+ const readToken = mocks.discard.mock.calls[0]![1].getToken as () => Promise<string | null>;
+ const pending = readToken();
+ setMobileAuthOwner('alice', 'cn');
+ resolve('old-realm-token');
+ expect(await pending).toBeNull();
+ expect(await readToken()).toBeNull();
+ expect(getToken).toHaveBeenCalledOnce();
+});
+
+it('uses the current owner token for confirmed cancellation and refuses a different owner record', async () => {
+ const own = record();
+ discardOutboxUploads(own, getMobileAuthOwner(), async () => 'token');
+ expect(await mocks.discard.mock.calls[0]![1].getToken()).toBe('token');
+ setMobileAuthOwner('alice', 'cn');
+ discardOutboxUploads(own, getMobileAuthOwner(), async () => 'other-token');
+ expect(mocks.discard).toHaveBeenCalledOnce();
+});
diff --git a/apps/mobile/src/__tests__/mobileLocalAttachmentUpload.test.ts b/apps/mobile/src/__tests__/mobileLocalAttachmentUpload.test.ts
index 6718c80fa2..56732a66f9 100644
--- a/apps/mobile/src/__tests__/mobileLocalAttachmentUpload.test.ts
+++ b/apps/mobile/src/__tests__/mobileLocalAttachmentUpload.test.ts
@@ -101,6 +101,30 @@ describe('isCameraUnavailableOnSimulator', () => {
});
describe('createMobileLocalAttachmentUploadController', () => {
+ it('bounds a durable handoff whose local preparation never settles, then cleans a late result', async () => {
+ vi.useFakeTimers();
+ try {
+ let finish!: (value: { uri: string }) => void;
+ const cleanupLocalUris = vi.fn(async () => {});
+ const { deps, uploaded } = makeDeps();
+ const controller = createMobileLocalAttachmentUploadController(deps);
+ controller.enqueue([{ ...candidate('a.jpg'), cleanupLocalUris,
+ resolve: () => new Promise((resolve) => { finish = resolve; }),
+ }], { token: new Promise(() => {}) });
+ const handoff = controller.beginHandoff();
+ const failed = handoff.prepare().catch((error: Error) => error);
+ await vi.advanceTimersByTimeAsync(180_000);
+ expect(await failed).toBeInstanceOf(Error);
+ handoff.release(false);
+ await vi.advanceTimersByTimeAsync(0);
+ expect(await controller.waitForIdle()).toEqual({ failedCount: 1 });
+ finish({ uri: 'file:///tmp/late-handoff.jpg' });
+ await vi.advanceTimersByTimeAsync(0);
+ expect(cleanupLocalUris).toHaveBeenCalledWith(['file:///tmp/late-handoff.jpg']);
+ expect(uploaded).toEqual([]);
+ controller.dispose();
+ } finally { vi.useRealTimers(); }
+ });
it('releases send waiters when credential preparation never settles and preserves the attachment', async () => {
vi.useFakeTimers();
try {
@@ -117,6 +141,34 @@ describe('createMobileLocalAttachmentUploadController', () => {
} finally { vi.useRealTimers(); }
});
+ it('fences old preparation when the token delay makes the upload deadline expire first', async () => {
+ vi.useFakeTimers();
+ try {
+ let tokenReady!: (value: string) => void;
+ let sourceReady!: (value: { uri: string }) => void;
+ const cleanupLocalUris = vi.fn(async () => {});
+ const original = { ...candidate('a.jpg'), cleanupLocalUris, resolve: vi.fn()
+ .mockImplementationOnce(() => new Promise((resolve) => { sourceReady = resolve; }))
+ .mockResolvedValueOnce({ uri: 'file:///tmp/retry.jpg' }) };
+ const { deps, uploaded } = makeDeps();
+ const controller = createMobileLocalAttachmentUploadController(deps);
+ controller.enqueue([original], { token: new Promise((resolve) => { tokenReady = resolve; }) });
+ await vi.advanceTimersByTimeAsync(100_000);
+ tokenReady('t');
+ await vi.advanceTimersByTimeAsync(80_000);
+ expect(await controller.waitForIdle()).toEqual({ failedCount: 1 });
+ controller.retry('local-attachment-upload-1', { token: 'new-token' });
+ await vi.advanceTimersByTimeAsync(0);
+ await controller.waitForIdle();
+ sourceReady({ uri: 'file:///tmp/old-source.jpg' });
+ await vi.advanceTimersByTimeAsync(0);
+ expect(uploaded).toHaveLength(1);
+ expect(uploaded[0].candidate.uri).toBe('file:///tmp/retry.jpg');
+ expect(cleanupLocalUris).toHaveBeenCalledWith(['file:///tmp/old-source.jpg']);
+ controller.dispose();
+ } finally { vi.useRealTimers(); }
+ });
+
it('a timed-out source cannot publish into a subsequent retry and only its temporary result is cleaned', async () => {
vi.useFakeTimers();
try {
@@ -851,4 +903,46 @@ describe('in-flight 取消(abort 传递)', () => {
expect(signals).toHaveLength(2);
expect(signals[0]).not.toBe(signals[1]);
});
+ it('hands off prepared bytes without waiting for a network token and fences page disposal', async () => {
+ const token = new Promise<string>(() => undefined);
+ const cleaned: string[] = [];
+ const { deps } = makeDeps();
+ const controller = createMobileLocalAttachmentUploadController(deps);
+ controller.enqueue([{ ...candidate('a.jpg'), cleanupLocalUris: async (uris) => { cleaned.push(...uris); } }], { token });
+ const handoff = controller.beginHandoff();
+ const sources = await handoff.prepare();
+ expect(sources[0]?.source.uri).toBe('file:///tmp/a.jpg');
+ controller.dispose();
+ expect(cleaned).toEqual([]);
+ handoff.release(true);
+ });
+ it('rolls back a handoff when persistence fails and lets the original upload reach the composer', async () => {
+ const gate = gatedUpload();
+ const { deps, uploaded } = makeDeps({ upload: gate.upload });
+ const controller = createMobileLocalAttachmentUploadController(deps);
+ controller.enqueue([candidate('a.jpg')], { token: 't' });
+ const handoff = controller.beginHandoff(); await handoff.prepare(); await flush();
+ gate.release('a.jpg'); await flush(); expect(uploaded).toHaveLength(0);
+ handoff.release(false); await controller.waitForIdle(); expect(uploaded).toHaveLength(1);
+ });
+ it('discards the old PUT when durable ownership commits even if the PUT completed during copying', async () => {
+ const gate = gatedUpload(); const { deps, uploaded, discarded } = makeDeps({ upload: gate.upload });
+ const controller = createMobileLocalAttachmentUploadController(deps);
+ controller.enqueue([candidate('a.jpg')], { token: 't' });
+ const handoff = controller.beginHandoff(); await handoff.prepare(); await flush();
+ gate.release('a.jpg'); await flush(); handoff.release(true); await flush();
+ expect(uploaded).toHaveLength(0); expect(discarded).toHaveLength(1);
+ });
+ it('clears the delivery flag and recycles OSS when local staging fails, allowing a later handoff', async () => {
+ const { deps, discarded } = makeDeps();
+ deps.onUploaded = async () => { throw new Error('disk full'); };
+ const controller = createMobileLocalAttachmentUploadController(deps);
+ controller.enqueue([candidate('a.jpg')], { token: 't' });
+ expect((await controller.waitForIdle()).failedCount).toBe(1);
+ expect(discarded).toHaveLength(1);
+ await controller.waitForDelivering();
+ const handoff = controller.beginHandoff();
+ expect(await handoff.prepare()).toHaveLength(1); handoff.release(false);
+ });
+
});
diff --git a/apps/mobile/src/__tests__/newSession.test.ts b/apps/mobile/src/__tests__/newSession.test.ts
index 61f383bd18..08fcd153e1 100644
--- a/apps/mobile/src/__tests__/newSession.test.ts
+++ b/apps/mobile/src/__tests__/newSession.test.ts
@@ -1591,8 +1591,8 @@ describe('new session composer surface', () => {
const atStart = slashEnd;
const atEnd = newSource.indexOf('const removeAttachment = useCallback', atStart);
const atSource = newSource.slice(atStart, atEnd);
- const restoreStart = newSource.indexOf('firstMessageRef.current = stashed.draft.firstMessage;');
- const restoreEnd = newSource.indexOf('setDraft(stashed.draft);', restoreStart);
+ const restoreStart = newSource.indexOf('const restoreCreationDraft = useCallback');
+ const restoreEnd = newSource.indexOf('setDraft(recovered);', restoreStart);
const restoreSource = newSource.slice(restoreStart, restoreEnd);
for (const source of [slashSource, atSource]) {
@@ -1602,9 +1602,11 @@ describe('new session composer surface', () => {
source.indexOf('setFirstMessageSelection(selection)'),
);
}
- expect(restoreSource).toContain('firstMessageRef.current = stashed.draft.firstMessage;');
- expect(restoreSource).toContain('firstMessageSelectionRef.current = restoredSelection;');
- expect(restoreSource).toContain('setFirstMessageSelection(restoredSelection);');
+ expect(restoreSource).toContain('firstMessageRef.current = recovered.firstMessage;');
+ expect(restoreSource).toContain('firstMessageSelectionRef.current = selection;');
+ expect(restoreSource).toContain('setFirstMessageSelection(selection);');
+ expect(newSource).toContain('restoreCreationDraft(stashed.draft, [...stashed.attachments]);');
+ expect(newSource).toContain('restoreCreationDraft(record.creation.draft,');
});
it('does not double-apply the Android safe-area inset to the top navigation', () => {
@@ -1982,7 +1984,7 @@ describe('new session worktree wiring (source locks)', () => {
recovery,
);
const sessionId = newSource.indexOf(
- 'const sessionId = createNewSessionId();',
+ 'const sessionId = recovering?.item.sessionId ?? createNewSessionId();',
pendingGuard,
);
const worktreeCreate = newSource.indexOf(
diff --git a/apps/mobile/src/__tests__/newSessionCreation.test.ts b/apps/mobile/src/__tests__/newSessionCreation.test.ts
index 9ce6bde956..b7ebd1814a 100644
--- a/apps/mobile/src/__tests__/newSessionCreation.test.ts
+++ b/apps/mobile/src/__tests__/newSessionCreation.test.ts
@@ -923,4 +923,25 @@ describe('newSessionCreation pipeline', () => {
phase: 'session-create-started',
}]);
});
+ it('hands the persisted first message to the outbox without issuing a competing enqueue', async () => {
+ const maker = makeMaker();
+ const params = makeParams('durable-first', maker, { firstMessageClientId: 'persisted-first-id', planModeArm: true });
+ const handoff = vi.fn(async () => undefined);
+ params.transport.handoffFirstMessage = handoff;
+ startNewSessionCreation(params);
+ await flushPipeline();
+ expect(handoff).toHaveBeenCalledWith(expect.objectContaining({ clientId: 'persisted-first-id', text: DRAFT.firstMessage }));
+ expect(maker.input.enqueue).not.toHaveBeenCalled();
+ expect(maker.setPlanMode).not.toHaveBeenCalled();
+ expect(getNewSessionCreationTask('durable-first')).toBeNull();
+ expect(remoteSessionStore.getSessions().find((session) => session.id === 'durable-first')?.pendingLocalCreation).toBe(false);
+ });
+ it('keeps the creation task recoverable when saving the first-message handoff fails', async () => {
+ const maker = makeMaker(); const params = makeParams('durable-first-failed', maker, { firstMessageClientId: 'saved-id' });
+ params.transport.handoffFirstMessage = async () => { throw new Error('disk full'); };
+ startNewSessionCreation(params); await flushPipeline();
+ expect(maker.input.enqueue).not.toHaveBeenCalled();
+ expect(getNewSessionCreationTask('durable-first-failed')).toMatchObject({ status: 'enqueue-failed', firstMessageClientId: 'saved-id' });
+ });
+
});
diff --git a/apps/mobile/src/__tests__/newSessionDraftRecovery.test.ts b/apps/mobile/src/__tests__/newSessionDraftRecovery.test.ts
new file mode 100644
index 0000000000..fd4f483479
--- /dev/null
+++ b/apps/mobile/src/__tests__/newSessionDraftRecovery.test.ts
@@ -0,0 +1,60 @@
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+import ts from 'typescript';
+import { expect, it, vi } from 'vitest';
+import { DEFAULT_NEW_SESSION_DRAFT } from '../session/newSession';
+
+// Exercise the actual screen callback without loading native UI modules.
+const source = ts.createSourceFile('new.tsx', readFileSync(resolve(process.cwd(), 'app/sessions/new.tsx'), 'utf8'), ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
+function fixture() {
+ let expression: ts.Expression | undefined;
+ const visit = (node: ts.Node) => {
+ if (ts.isVariableDeclaration(node) && node.name.getText(source) === 'restoreCreationDraft') expression = node.initializer;
+ ts.forEachChild(node, visit);
+ };
+ visit(source);
+ if (!expression) throw new Error('Missing draft recovery callback');
+ const state = { draft: { ...DEFAULT_NEW_SESSION_DRAFT }, selection: { start: 0, end: 0 }, plan: false, files: [] as unknown[] };
+ const bindings = {
+ useCallback: (fn: unknown) => fn,
+ userTouchedWorkspaceRef: { current: false }, userTouchedRuntimeRef: { current: false },
+ appliedPermissionMemoryRef: { current: false }, runtimeActionSeqRef: { current: 10 },
+ firstMessageRef: { current: '' }, firstMessageSelectionRef: { current: state.selection },
+ attachmentsRef: { current: state.files }, prePlanPermissionModeRef: { current: null as string | null },
+ setFirstMessageSelection: (value: typeof state.selection) => { state.selection = value; },
+ setAttachments: (value: unknown[]) => { state.files = value; },
+ setPlanModeDraftOn: (value: boolean) => { state.plan = value; },
+ setDraft: vi.fn((value: typeof state.draft) => { state.draft = value; }),
+ };
+ const compiled = ts.transpileModule(`const apply = ${expression.getText(source)};`, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText;
+ const apply = new Function(...Object.keys(bindings), `${compiled}\nreturn apply;`)(...Object.values(bindings));
+ return { ...bindings, state, apply };
+}
+
+it.each([true, false])('restores Plan=%s and makes recovered text immediately available to composer actions', (enabled) => {
+ const f = fixture();
+ const draft = { ...DEFAULT_NEW_SESSION_DRAFT, firstMessage: 'Recovered message', model: 'saved-model', permissionMode: 'ask' };
+ const files = [{ id: 'saved-file' }];
+ f.apply(draft, files, { enabled, restorePermissionMode: 'ask' });
+ // Slash/mention/voice actions read these refs before another text-change event.
+ const caret = f.firstMessageSelectionRef.current.end;
+ const edited = f.firstMessageRef.current.slice(0, caret) + ' appended' + f.firstMessageRef.current.slice(caret);
+ expect(edited).toBe('Recovered message appended');
+ expect(f.state.selection).toEqual({ start: draft.firstMessage.length, end: draft.firstMessage.length });
+ expect(f.state.plan).toBe(enabled);
+ expect(f.prePlanPermissionModeRef.current).toBe('ask');
+ expect(f.state.draft).toEqual(draft);
+ expect(f.attachmentsRef.current).toBe(files);
+ expect(f.state.files).toBe(files);
+ expect(f.userTouchedWorkspaceRef.current && f.userTouchedRuntimeRef.current && f.appliedPermissionMemoryRef.current).toBe(true);
+ // A previously captured runtime preference continuation is now stale.
+ expect(f.runtimeActionSeqRef.current).not.toBe(10);
+});
+
+it('uses the same text recovery without inventing a Plan snapshot for legacy stashes', () => {
+ const f = fixture();
+ f.state.plan = true;
+ f.apply({ ...DEFAULT_NEW_SESSION_DRAFT, firstMessage: 'legacy draft' }, []);
+ expect(f.firstMessageRef.current).toBe('legacy draft');
+ expect(f.state.plan).toBe(true);
+});
diff --git a/apps/mobile/src/__tests__/newSessionWorkspaceEffects.test.tsx b/apps/mobile/src/__tests__/newSessionWorkspaceEffects.test.tsx
index 188617ee2a..184a77621e 100644
--- a/apps/mobile/src/__tests__/newSessionWorkspaceEffects.test.tsx
+++ b/apps/mobile/src/__tests__/newSessionWorkspaceEffects.test.tsx
@@ -33,6 +33,8 @@ const declarations = new Set([
'patchDraft', 'selectWorkingDir', 'rememberWorkingDirForDevice', 'selectDialogueWorkspace',
'selectRecentProject', 'openProjectBrowse',
'firstMessageRef', 'firstMessageSelectionRef', 'firstMessageSelection',
+ 'restoreCreationDraft', 'userTouchedRuntimeRef', 'appliedPermissionMemoryRef',
+ 'runtimeActionSeqRef', 'attachments', 'attachmentsRef', 'planModeDraftOn', 'prePlanPermissionModeRef',
]);
const effectMarkers = new Set([
'drainStashedNewSessionDraft', 'readNewSessionPreferences',
@@ -83,7 +85,7 @@ const bindingNames = [
'isRemoteTaskSuggestionId', 'params', 't',
'initialWorkingDir', 'visualInitialDraft', 'sessions', 'readNewSessionPreferences',
'saveNewSessionPreferences', 'drainStashedNewSessionDraft', 'loadBrowsePath', 'setDevicePickerOpen',
- 'setAttachments', 'setAttachmentError', 'setBrowseOpen', 'setBrowseError',
+ 'setAttachmentError', 'setBrowseOpen', 'setBrowseError',
'setShowHiddenDirectories', 'setWorkspacePickerOpen',
];
const compiled = ts.transpileModule(`function usePageWorkspace(bindings) {
diff --git a/apps/mobile/src/__tests__/optimisticSessionComposer.test.ts b/apps/mobile/src/__tests__/optimisticSessionComposer.test.ts
index 0229cae680..c5bb8c8a46 100644
--- a/apps/mobile/src/__tests__/optimisticSessionComposer.test.ts
+++ b/apps/mobile/src/__tests__/optimisticSessionComposer.test.ts
@@ -21,6 +21,22 @@ function readSource(relativePath: string): string {
const SCREEN = 'app/sessions/[sessionId].tsx';
describe('mobile optimistic composer while session is not ready', () => {
+ it('uses the shared unsent proof to cancel locally before requiring a remote receipt', () => {
+ const source = readSource(SCREEN);
+ const remove = source.slice(source.indexOf('const removeOutboxItem ='), source.indexOf('const outboxDisplayItems ='));
+ expect(remove).toContain('if (isDurableOutboxUnsent(record))');
+ expect(remove).toContain("cleanupOutcome: 'cancelled'");
+ expect(remove).toContain("else await mobileDurableOutbox.update(record, { cancelRequested: true, state: 'confirming' })");
+ });
+
+ it('waits for committed draft ownership recovery before submitting the visible draft', () => {
+ const source = readSource(SCREEN);
+ const send = source.slice(source.indexOf(' async function send(options:'));
+ expect(send.indexOf('if (!composerDraftHydrated) return;')).toBeGreaterThan(0);
+ expect(send.indexOf('if (!composerDraftHydrated) return;')).toBeLessThan(send.indexOf('const documentAtSend ='));
+ expect(source).toContain('reconcileMobileOutboxDrafts(sessionId).then(() => Promise.all([');
+ });
+
it('keeps the composer out of the read-only slot while gating remote controls separately', () => {
const source = readSource(SCREEN);
@@ -112,24 +128,13 @@ describe('mobile optimistic composer while session is not ready', () => {
expect(source).toContain('setPresenceVersion((n) => n + 1);\n const presence = updatePresenceAvailability(');
});
- it('blocks outbox dispatch until the session row can actually be sent with', () => {
- const source = readSource(SCREEN);
-
- expect(source).toContain('const outboxDispatchBlockedNow = () => {');
- expect(source).toContain('if (outboxConnectionBlockedNow()) return true;');
- // 「会话在被控端还不存在」走共用判据(见下方的入口收敛测试);派发还额外要求字段
- // 权威(cacheSeeded 行被瘦身截断过)与创建管线已收口。
- expect(source).toContain('if (isRemoteSessionMissing(row)) return true;');
- expect(source).toContain('if (row?.cacheSeeded) return true;');
- expect(source).toContain('return getNewSessionCreationTask(sessionId) !== null;');
- // pump 循环每轮都看当下真相,blocked 时留住条目(不标失败)。
- expect(source).toContain('if (outboxDispatchBlockedNow()) return;');
- // 解禁那一帧重新 pump。
- expect(source).toContain('const outboxDispatchBlocked = !currentSession');
- expect(source).toContain('|| outboxConnectionDispatchBlocked;');
- expect(source).toContain('if (outboxDispatchBlocked) return;\n void pumpOutbox();');
- // 即使 blocked boolean 恰好没变化,新的连接 epoch 也要重新唤醒一次。
- expect(source).toContain('}, [connectionEpoch, outboxDispatchBlocked]);');
+ it('lets the app owner obtain authoritative parameters before dispatch, independently of the page', () => {
+ const bridge = readSource('src/session/MobileOutboxBridge.tsx');
+ expect(bridge).toContain('getNewSessionCreationTask(r.item.sessionId) === null');
+ expect(bridge).toContain('!isDurableOutboxCreationHeld(r.item.sessionId)');
+ expect(bridge).toContain('const session = await maker(r).getSession(r.item.sessionId)');
+ expect(bridge).toContain('if (!session?.workingDir)');
+ expect(bridge).toContain('}, [link.status, link.connectionEpoch])');
});
it('latches every connection recovery edge until authoritative sync succeeds', () => {
@@ -181,29 +186,26 @@ describe('mobile optimistic composer while session is not ready', () => {
expect(syncCatch).not.toContain('? null : current');
});
- it('routes sends through the outbox while blocked and defers the workingDir check', () => {
+ it('routes ordinary online and offline messages through durable acceptance before clearing the composer', () => {
const source = readSource(SCREEN);
-
- expect(source).toContain('const dispatchBlockedAtSend = outboxDispatchBlockedNow();');
- expect(source).toContain('sessionRefsAtSend.length > 0 || uploadsInFlight > 0');
- expect(source).toContain('|| outboxPumpBusyRef.current || dispatchBlockedAtSend');
- // dialogue 会话的 workingDir 由被控端在创建时分配,合成行此刻为空 —— 校验推迟到
- // dispatch(那时会重读 store 拿权威值),否则新建对话发消息会被误判成缺工作目录。
+ expect(source).toContain('const useDurableOutbox = outboxEligible && !earlyLocalCommand && !earlyDesktopCommand && !legacyPlanRequiresLiveDispatch');
expect(source).toContain('if (!dispatchBlockedAtSend && !currentSession.workingDir) {');
+ const branch = source.slice(source.indexOf('if (useLocalOutbox) {'));
+ expect(branch.indexOf('await mobileDurableOutbox.add(record)')).toBeLessThan(branch.indexOf('applyComposerDocument(documentAfterOptimisticClear)'));
});
it('keeps legacy Plan out of deferred delivery without affecting the modern Plan path', () => {
const source = readSource(SCREEN);
const guardStart = source.indexOf('const legacyPlanRequiresLiveDispatch =');
- const optimisticClearStart = source.indexOf('if (text) applyComposerDocument(documentAfterOptimisticClear);');
+ const optimisticClearStart = source.indexOf('if (text && !useDurableOutbox) applyComposerDocument(documentAfterOptimisticClear);');
const outboxStart = source.indexOf('if (useLocalOutbox) {', guardStart);
const guard = source.slice(guardStart, outboxStart);
expect(guardStart).toBeGreaterThan(-1);
expect(guardStart).toBeLessThan(optimisticClearStart);
expect(guard).toContain("runtimeOptions?.planModeSupported !== true");
- expect(guard).toContain('const useLocalOutbox = shouldUseLocalOutbox && !legacyPlanRequiresLiveDispatch;');
- expect(guard).toContain('dispatchBlockedAtSend || outboxRef.current.length > 0 || outboxPumpBusyRef.current');
+ expect(guard).toContain('const useLocalOutbox = useDurableOutbox;');
+ expect(guard).toContain('dispatchBlockedAtSend || outboxRef.current.length > 0');
expect(guard).not.toContain("setError(t('session.menu.aiRenameOffline'));");
expect(source).toContain(
'const recovery = recoverOutboxItemsToComposerDraft([capturedDraftRecoveryItem()], {',
@@ -227,33 +229,15 @@ describe('mobile optimistic composer while session is not ready', () => {
expect(source).toContain("setError(t('session.menu.aiRenameOffline'));");
});
- it('keeps the page outbox on the pre-write side of the enqueue ownership boundary', () => {
+ it('keeps uncertain enqueue ownership in the persistent app ledger', () => {
const source = readSource(SCREEN);
- const outboxStart = source.indexOf('const dispatchOutboxItem = async (item: MobileOutboxItem) => {');
- const directStart = source.indexOf('const queuedDraft = buildQueuedTextMessage(');
- const directEnd = source.indexOf('// 消息已由 A 路径落定', directStart);
- const outboxDispatch = source.slice(outboxStart, directStart);
- const directRecovery = source.slice(directStart, directEnd);
-
- expect(source).toContain('const waitForConnection = (');
- expect(source).toContain('const waiting = outboxItemWaitingForConnection(item);');
- expect(source).toContain("if (result === 'deferred' || result === 'stopped') return;");
- expect(source).toContain("return 'stopped' as const;");
- expect(source).toContain('const safeToRetry = isSafelyUnsentOutboxEnqueueError(err);');
- expect(source).toContain('if (safeToRetry) {\n waitForConnection(err);');
- // 只有权威 projection / 已持久 user 行能证明已接收。没有权威证据时,outbox
- // 回到既有失败/重试 owner,直发恢复草稿,不能留下无持久 owner 的转圈行。
- expect(source).toContain('const accepted = fresh.pendingQueue.some(');
- expect(outboxDispatch).toContain('failItem(formatRemoteError(err));');
- expect(outboxDispatch).not.toContain('acceptanceUnknown');
- expect(source).not.toContain('shouldWaitForOutboxEnqueueRecovery');
- expect(source).toContain('isAutoRecoveringSessionReferencePreparationError(err)');
- expect(directRecovery).not.toContain('buildOutboxItem({');
- expect(directRecovery).not.toContain('salvageOutboxItem(');
- expect(directRecovery).not.toContain('updateOutbox(');
- expect(directRecovery).not.toContain('acceptanceUnknown');
- expect(directRecovery).toContain('restoreDirectSendDraftAfterFailure();');
- expect(directRecovery).toContain('在线直发一旦开始 enqueue 就不再转入本 PR 的页面 outbox');
+ const bridge = readSource('src/session/MobileOutboxBridge.tsx');
+ const delivery = readSource('src/session/durableOutboxDelivery.ts');
+ expect(source).not.toContain('const dispatchOutboxItem =');
+ expect(bridge).toContain('preSend: guardRecord');
+ expect(delivery).toMatch(/await update\(\{\s*state: ["']sending["'],\s*enqueueStarted: true,\s*error: undefined\s*\}\)/);
+ expect(delivery).toContain('record.retrySafe && projection.inputDeliveryVersion === 1');
+ expect(delivery).not.toContain('createOutboxClientId');
});
it('keeps retrying authoritative recovery syncs with bounded backoff', () => {
@@ -302,41 +286,27 @@ describe('mobile optimistic composer while session is not ready', () => {
expect(source).toContain('if (!sendScopeStillAlive()) {\n recoverCapturedDraftForScopeExit();');
expect(source).toContain('await waitForPastePlaceholdersSettled();\n if (!sendScopeStillAlive()) {');
expect(source).toContain('const { failedCount } = await waitForPendingUploads();\n if (!sendScopeStillAlive()) {');
- expect(source).toContain('if (outboxSessionAliveRef.current !== item.sessionId) return \'stopped\' as const;');
+ expect(source).toContain('if (!sendScopeStillAlive() || !isMobileAuthOwnerCurrent(ownerAtSend)) return;');
});
- it('recovers the first message and the follow-ups together, in order', () => {
- // 「首条回输入框 + 后续留在 outbox」是不可恢复的:重试失败的 outbox 条目会把后续消息
- // 发到首条前面,重发首条又会追加到失败条目之后被挡住,原顺序拼不回来(review P1)。
- // 两者必须一起、按序进同一份草稿,首条在前。
- const source = readSource(SCREEN);
- const branchStart = source.indexOf("if (status === 'enqueue-failed') {");
- const branchEnd = source.indexOf('void load();', branchStart);
- const branch = source.slice(branchStart, branchEnd);
-
- expect(branch).toContain("takeOutboxForSession(sessionId, 'release-to-tray')");
- expect(branch).toContain('restoreRecoverableItemsToDraft(sessionId, recoverables)');
- // 首条排在后续消息之前。
- expect(branch.indexOf('text: restoredText,')).toBeLessThan(branch.indexOf('...followUps,'));
- // 取走 outbox 必须发生在 dismiss 之前:dismiss 会解禁派发门。
- expect(branch.indexOf('takeOutboxForSession'))
- .toBeLessThan(branch.indexOf('dismissNewSessionCreation(sessionId)'));
- // 附件走统一收尾;task 已被消费的竞态分支同样要恢复附件(原先只恢复了文本)。
- expect(branch).toContain('adoptRecoveredAttachments(creationTask.attachments, followUps)');
- expect(branch).toContain('adoptRecoveredAttachments([], followUps)');
+ it('persists the creation head before allowing follow-ups, preserving message identities on failure', () => {
+ const creation = readSource('app/sessions/new.tsx');
+ const pipeline = readSource('src/session/newSessionCreation.ts');
+ expect(creation.indexOf('await mobileDurableOutbox.add(firstRecord)')).toBeLessThan(creation.indexOf('startNewSessionCreation({'));
+ expect(creation).toContain('firstMessageClientId,');
+ expect(pipeline).toContain('const firstMessageClientId = params.firstMessageClientId ?? createUuid()');
+ const handoff = pipeline.slice(pipeline.indexOf('if (params.transport.handoffFirstMessage) {'), pipeline.indexOf('let queued = queuedDraft'));
+ expect(handoff.indexOf('await params.transport.handoffFirstMessage(queuedDraft)')).toBeLessThan(handoff.indexOf('finishTask(task)'));
+ expect(handoff).not.toContain('input.enqueue');
});
- it('hands in-flight uploads back to the tray instead of cancelling them', () => {
- // 留在本页时,在途 / 失败的上传任务必须交还 composer 托盘:取消重传是错的——用户已经
- // 等过一次上传,粘贴来源的本地文件此时可能已被回收,连重选都做不到(review P1)。
+ it('copies attachment bytes before committing the ownership handoff', () => {
const source = readSource(SCREEN);
- const fnStart = source.indexOf('const takeOutboxForSession = (');
- const fnEnd = source.indexOf('\n };', fnStart);
- const fn = source.slice(fnStart, fnEnd);
- expect(fn).toContain("uploads: 'release-to-tray' | 'cancel',");
- expect(fn).toContain('releaseClaimedUploads(pendingLocalIds);');
- // cancel 分支必须把「没能保住多少」报给调用方,不能悄悄取消。
- expect(fn).toContain('cancelledUploadCount: pendingLocalIds.length');
+ const branch = source.slice(source.indexOf('const handoff = await beginOutboxAttachmentHandoff()'));
+ expect(branch.indexOf('await handoff.prepare()')).toBeLessThan(branch.indexOf('await retainOutboxFile'));
+ expect(branch.indexOf('await retainOutboxFile')).toBeLessThan(branch.indexOf('await mobileDurableOutbox.add(record)'));
+ expect(branch.indexOf('await mobileDurableOutbox.add(record)')).toBeLessThan(branch.indexOf('handoff.release(true)'));
+ expect(branch).toContain('handoff.release(committed)');
});
it('carries follow-ups back to the new-session screen when creation itself failed', () => {
@@ -470,7 +440,7 @@ describe('mobile optimistic composer while session is not ready', () => {
// 2) 会话设置 RPC 的硬门(统一入口,覆盖全部 runControlAction 调用点)。
expect(source).toContain('if (!canUseRemoteSessionControls) return false;\n setControlBusy(true);');
// 3) 消息派发:复合判据,「不存在」是它的子集。
- expect(source).toContain('if (isRemoteSessionMissing(row)) return true;');
+ expect(source).toContain('outboxConnectionBlockedNow() || isRemoteSessionMissing(row)');
expect(source).not.toContain('const sessionSettingsLocked = currentSession?.pendingLocalCreation === true;');
});
@@ -481,7 +451,7 @@ describe('mobile optimistic composer while session is not ready', () => {
const source = readSource(SCREEN);
const gate = source.indexOf('commandNeedsRemoteSession(earlyLocalCommand, earlyDesktopCommand)');
expect(gate).toBeGreaterThan(-1);
- const clear = source.indexOf('if (text) applyComposerDocument(documentAfterOptimisticClear);');
+ const clear = source.indexOf('if (text && !useDurableOutbox) applyComposerDocument(documentAfterOptimisticClear);');
expect(gate).toBeLessThan(clear);
const branch = source.slice(gate, clear);
expect(branch).toContain('isRemoteSessionMissing(readSessionRowNow())');
diff --git a/apps/mobile/src/__tests__/sendEnqueueRetry.test.ts b/apps/mobile/src/__tests__/sendEnqueueRetry.test.ts
index 7c679e3373..3648d4a3ce 100644
--- a/apps/mobile/src/__tests__/sendEnqueueRetry.test.ts
+++ b/apps/mobile/src/__tests__/sendEnqueueRetry.test.ts
@@ -29,12 +29,15 @@ describe('send enqueue weak-network retry ordering', () => {
return loops;
};
- it('重试门槛必须要求可安全重发的传输错误且非 in-flight(send 与 outbox 两条路径)', () => {
+ it('重试门槛必须要求可安全重发的传输错误且非 in-flight(兼容直发路径)', () => {
expect(source).toContain("import { isInFlightDeviceLinkError, isSharedTaskPeer } from '@cindy/device-link';");
expect(source).toContain("code === 'NOT_CONNECTED' || code === 'BACKPRESSURE'");
expect(source).toContain("formatted.includes('[BACKPRESSURE]')");
const loops = extractRetryLoops();
- expect(loops).toHaveLength(2);
+ expect(loops).toHaveLength(1);
+ const delivery = readFileSync(resolve(process.cwd(), 'src/session/durableOutboxDelivery.ts'), 'utf8');
+ expect(delivery).toContain('record.retrySafe && projection.inputDeliveryVersion === 1');
+ expect(delivery.indexOf('const projection = await deps.projection(record)')).toBeLessThan(delivery.indexOf('await deps.enqueue(record)'));
for (const loopBody of loops) {
expect(loopBody).toContain('|| isInFlightDeviceLinkError(err)');
expect(loopBody).toContain('|| !isRetryableEnqueueTransportError(err)');
diff --git a/apps/mobile/src/__tests__/sendingQueueBadge.test.ts b/apps/mobile/src/__tests__/sendingQueueBadge.test.ts
index e122ade699..0a15779b1e 100644
--- a/apps/mobile/src/__tests__/sendingQueueBadge.test.ts
+++ b/apps/mobile/src/__tests__/sendingQueueBadge.test.ts
@@ -36,15 +36,11 @@ describe('mobile sending queue badge', () => {
const source = readSource(SCREEN);
expect(source).toContain('sendingClientIds: sendingQueueBadgeClientIds,');
- // 直发路径与 outbox 交接路径各 mark 一次,各自在 finally 收掉。
- expect(source.match(/markQueueItemSending\(queued\);/g)).toHaveLength(2);
- // Both send entries reserve the user slot before publishing the optimistic
- // queue (and before enqueue can deliver an assistant event).
- expect(source.match(/markQueueItemSending\(queued\);\s+remoteSessionStore\.setInputProjectionOptimistically/g)).toHaveLength(2);
- // Only enqueue reserves a slot; queue recovery must not infer a boundary
- // from either current messages or a previous committed render.
- expect(source.match(/appendOptimisticUserMessage\(/g)).toHaveLength(1);
- expect(source.match(/clearQueueItemSending\(queued, enqueueAccepted, projectionBeforeSend\);/g)).toHaveLength(2);
+ expect(source).toContain("record.state !== 'host-owned'");
+ expect(source).toContain('sending.add(record.item.clientId)');
+ // 兼容直发路径用临时标记;持久发送直接从 app 级记录派生。
+ expect(source.match(/markQueueItemSending\(queued\);/g)).toHaveLength(1);
+ expect(source.match(/clearQueueItemSending\(queued, enqueueAccepted, projectionBeforeSend\);/g)).toHaveLength(1);
expect(source).toContain('} finally {\n // 成功、对账认定已入队、回滚 throw 三条路径都算「不再在途」');
// 新建会话乐观管线在跑时,首条消息同样是「已上屏未确认」。
expect(source).toContain("creationTask?.status === 'running'");
diff --git a/apps/mobile/src/__tests__/sessionMessageMemoryWiring.test.ts b/apps/mobile/src/__tests__/sessionMessageMemoryWiring.test.ts
index b8699cba5d..de5214f496 100644
--- a/apps/mobile/src/__tests__/sessionMessageMemoryWiring.test.ts
+++ b/apps/mobile/src/__tests__/sessionMessageMemoryWiring.test.ts
@@ -86,9 +86,11 @@ describe('任务消息内存治理页面接线', () => {
expect(screen).toContain('hasOlderMessages && !isScheduleDetail');
expect(screen).toContain('canLoadEarlier={(historyView.snapshot.ready ? historyView.snapshot.hasMore : hasOlderMessages && messages.length > 0) && !isScheduleDetail}');
expect(screen).toContain('remoteSessionStore.acquireSessionMessageWork(sessionId, pageHasMessageWork)');
- expect(screen).toContain('remoteSessionStore.acquireSessionMessageWork(item.sessionId, true)');
+ const bridge = source('src/session/MobileOutboxBridge.tsx');
+ expect(bridge).toMatch(/remoteSessionStore\.acquireSessionMessageWork\(\s*record\.item\.sessionId,\s*true,?\s*\)/);
+ expect(bridge).toContain('for (const lease of leases.values()) lease.release()');
expect(screen).toContain('remoteSessionStore.acquireSessionMessageWork(sessionId, true)');
- expect(screen.match(/messageWorkLease\.release\(\);/g)).toHaveLength(2);
+ expect(screen.match(/messageWorkLease\.release\(\);/g)).toHaveLength(1);
for (const signal of [
'outboxItems.length > 0',
'pendingUploads.length > 0',
diff --git a/apps/mobile/src/i18n/locales/en/session.json b/apps/mobile/src/i18n/locales/en/session.json
index ef0c4ad25d..48b6588246 100644
--- a/apps/mobile/src/i18n/locales/en/session.json
+++ b/apps/mobile/src/i18n/locales/en/session.json
@@ -503,5 +503,14 @@
"noExtraDirsSummary": "No additional directories",
"attachmentUploadFailed": "Attachment upload failed; retry or delete this message.",
"authGateHint": "{{agent}} has no connected model provider on this computer, so sending will fail. Set it up in {{appName}} on the computer under Settings → Model Providers."
+ },
+ "outbox": {
+ "legacyPlanRecovery": "This computer cannot restore saved messages in Plan mode. Turn off Plan mode or update Cindy on the computer, then retry.",
+ "creationRecoveryRequired": "Retry creating this task before deleting its first message. That message keeps the recovery details for your later messages.",
+ "confirmationRequired": "This computer cannot confirm whether the message was received. Check its history or update Cindy before retrying.",
+ "taskCleared": "This task was cleared after you sent the message. The saved message has been kept for you to review.",
+ "restoreFailed": "Saved messages could not be restored. They have not been deleted. Restart the app and try again.",
+ "recoveryTarget": "Keep the original computer while recovering this task. Its later messages are still saved.",
+ "taskAlreadyCreated": "This task already exists on the computer. Its saved messages will resume there."
}
}
diff --git a/apps/mobile/src/i18n/locales/ja/session.json b/apps/mobile/src/i18n/locales/ja/session.json
index a1c1fa7122..b9239027b0 100644
--- a/apps/mobile/src/i18n/locales/ja/session.json
+++ b/apps/mobile/src/i18n/locales/ja/session.json
@@ -503,5 +503,14 @@
"noExtraDirsSummary": "追加ディレクトリはありません",
"attachmentUploadFailed": "添付のアップロードに失敗しました。再試行するか、このメッセージを削除してください。",
"authGateHint": "{{agent}} はこのパソコンに接続済みのモデルプロバイダーがないため、送信は失敗します。パソコンの {{appName}} で「設定 → モデルプロバイダー」を設定してください。"
+ },
+ "outbox": {
+ "legacyPlanRecovery": "このパソコンではプランモードで保存済みメッセージを復元できません。プランモードをオフにするか、パソコンの Cindy を更新して再試行してください。",
+ "creationRecoveryRequired": "先頭のメッセージを削除する前に、セッションの作成を再試行してください。このメッセージには後続メッセージの復元に必要な情報が保存されています。",
+ "confirmationRequired": "このコンピューターではメッセージの受信を確認できません。履歴を確認するか、Cindy を更新してから再試行してください。",
+ "taskCleared": "送信後にこのセッションがクリアされました。メッセージはスマートフォンに保存されています。内容を確認してください。",
+ "restoreFailed": "送信待ちメッセージを復元できませんでした。保存済みの内容は削除されていません。アプリを再起動して再試行してください。",
+ "recoveryTarget": "このセッションを復元する際は元のコンピューターを使用してください。後続のメッセージは保存されています。",
+ "taskAlreadyCreated": "このセッションはコンピューターに作成済みです。保存されたメッセージは元のセッションで送信を再開します。"
}
}
diff --git a/apps/mobile/src/i18n/locales/ko/session.json b/apps/mobile/src/i18n/locales/ko/session.json
index 1a6af3f763..25831a5ed4 100644
--- a/apps/mobile/src/i18n/locales/ko/session.json
+++ b/apps/mobile/src/i18n/locales/ko/session.json
@@ -499,5 +499,14 @@
"noExtraDirsSummary": "추가 디렉터리 없음",
"attachmentUploadFailed": "첨부 업로드에 실패했습니다. 다시 시도하거나 이 메시지를 삭제하세요.",
"authGateHint": "이 컴퓨터에 {{agent}}에 연결된 모델 제공자가 없어 전송이 실패합니다. 컴퓨터의 {{appName}}에서 '설정 → 모델 제공자'를 설정하세요."
+ },
+ "outbox": {
+ "legacyPlanRecovery": "이 컴퓨터에서는 계획 모드로 저장된 메시지를 복원할 수 없습니다. 계획 모드를 끄거나 컴퓨터의 Cindy를 업데이트한 후 다시 시도해 주세요.",
+ "creationRecoveryRequired": "첫 메시지를 삭제하기 전에 세션 생성을 다시 시도하세요. 이 메시지에는 후속 메시지를 복원하는 데 필요한 정보가 저장되어 있습니다.",
+ "confirmationRequired": "이 컴퓨터에서 메시지 수신 여부를 확인할 수 없습니다. 기록을 확인하거나 컴퓨터의 Cindy를 업데이트한 후 다시 시도하세요.",
+ "taskCleared": "전송 후 이 세션이 비워졌습니다. 메시지는 휴대폰에 저장되어 있으니 확인해 주세요.",
+ "restoreFailed": "전송 대기 메시지를 복원하지 못했습니다. 저장된 내용은 삭제되지 않았습니다. 앱을 다시 시작하고 재시도하세요.",
+ "recoveryTarget": "이 세션을 복원할 때는 기존 컴퓨터를 사용해 주세요. 후속 메시지는 저장되어 있습니다.",
+ "taskAlreadyCreated": "이 세션은 컴퓨터에 이미 생성되어 있습니다. 저장된 메시지는 기존 세션에서 전송을 재개합니다."
}
}
diff --git a/apps/mobile/src/i18n/locales/zh-CN/session.json b/apps/mobile/src/i18n/locales/zh-CN/session.json
index 6e0394256a..c196fe2978 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/session.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/session.json
@@ -499,5 +499,14 @@
"noExtraDirsSummary": "当前没有附加目录",
"attachmentUploadFailed": "附件上传失败,可重试或删除这条消息。",
"authGateHint": "{{agent}} 在这台电脑上还没有已连接的模型供应商,发送会失败。请在电脑端 {{appName}} 的「设置 → 模型供应商」完成配置。"
+ },
+ "outbox": {
+ "legacyPlanRecovery": "这台电脑暂不支持在计划模式下恢复待发消息。请关闭计划模式,或更新电脑上的 Cindy 后重试",
+ "creationRecoveryRequired": "请先重试创建任务,再删除首条消息;这条消息还保存着后续消息所需的任务恢复信息。",
+ "confirmationRequired": "电脑暂时无法确认是否收到这条消息。请核对消息记录,或更新电脑上的 Cindy 后重试。",
+ "taskCleared": "发送后,这个任务已被清空。消息仍保存在手机上,请核对后处理。",
+ "restoreFailed": "暂时无法恢复待发消息,已保存的内容没有删除。请重启 App 后重试。",
+ "recoveryTarget": "恢复这个任务时请保留原来的电脑,后续消息仍保存在手机上。",
+ "taskAlreadyCreated": "电脑上已创建这个任务,已保存的消息会在原任务中继续发送。"
}
}
diff --git a/apps/mobile/src/i18n/locales/zh-TW/session.json b/apps/mobile/src/i18n/locales/zh-TW/session.json
index 055c128632..47b5476910 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/session.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/session.json
@@ -503,5 +503,14 @@
"noExtraDirsSummary": "當前沒有附加目錄",
"attachmentUploadFailed": "附件上傳失敗,可重試或刪除這條訊息。",
"authGateHint": "{{agent}} 在這臺電腦上還沒有已連線的模型供應商,傳送會失敗。請在電腦端 {{appName}} 的「設定 → 模型供應商」完成配置。"
+ },
+ "outbox": {
+ "legacyPlanRecovery": "這臺電腦暫不支援在計畫模式下恢復待傳訊息。請關閉計畫模式,或更新電腦上的 Cindy 後重試",
+ "creationRecoveryRequired": "請先重試建立任務,再刪除首則訊息;這則訊息仍保存著後續訊息所需的任務恢復資訊。",
+ "confirmationRequired": "電腦暫時無法確認是否收到這則訊息。請核對訊息記錄,或更新電腦上的 Cindy 後重試。",
+ "taskCleared": "傳送後,這個任務已被清空。訊息仍保存在手機上,請核對後處理。",
+ "restoreFailed": "暫時無法恢復待傳訊息,已保存的內容沒有刪除。請重新啟動 App 後重試。",
+ "recoveryTarget": "恢復這個任務時請保留原來的電腦,後續訊息仍保存在手機上。",
+ "taskAlreadyCreated": "電腦上已建立這個任務,已保存的訊息會在原任務中繼續傳送。"
}
}
diff --git a/apps/mobile/src/session/MobileOutboxBridge.tsx b/apps/mobile/src/session/MobileOutboxBridge.tsx
new file mode 100644
index 0000000000..5b123a245a
--- /dev/null
+++ b/apps/mobile/src/session/MobileOutboxBridge.tsx
@@ -0,0 +1,347 @@
+import { useEffect, useRef, useSyncExternalStore } from "react";
+import { Alert, AppState } from "react-native";
+import { useAuth } from "@/auth/AuthContext";
+import {
+ getMobileAuthOwner,
+ isMobileAuthOwnerCurrent,
+ subscribeMobileAuthOwner,
+} from "@/auth/authOwnerGeneration";
+import { useDeviceLink } from "@/device-link/DeviceLinkContext";
+import { parseSharedTaskPeer } from '@cindy/device-link';
+import {
+ createMobileMakerTransport,
+ type RemoteInvoke,
+} from "@/device-link/mobileMakerTransport";
+import {
+ formatRemoteError,
+ isAutoRecoveringRemoteError,
+} from "@/device-link/remoteStatus";
+import { i18n } from "@/i18n";
+import {
+ createDurableOutboxDelivery,
+ type DeliveryProjection,
+} from "./durableOutboxDelivery";
+import {
+ mobileDurableOutbox,
+ isDurableOutboxCreationHeld,
+ discardOutboxUploads,
+ cleanupOutboxResources,
+} from "./mobileDurableOutbox";
+import {
+ durableOutboxUploadUri,
+ initializeComposerAttachmentStage,
+ initializeOutboxFiles,
+} from "./durableOutboxFiles";
+import {
+ uploadMobileAttachmentFromFile,
+ discardMobileUploadedAttachment,
+} from "./mobileAttachmentUpload";
+import { buildQueuedTextMessage } from "./inputProjection";
+import { outboxItemAttachments } from "./sessionOutbox";
+import { sessionFromCreateResult } from "./newSession";
+import { getNewSessionCreationTask } from "./newSessionCreation";
+import {
+ MobileSessionReferenceError,
+ prepareMobileQueuedSessionReferences,
+} from "./sessionReferences";
+import { remoteSessionStore } from "./remoteSessionStore";
+import { isDurableOutboxSettled, type DurableOutboxRecord } from "./durableOutbox";
+import type { InputProjection } from "./types";
+
+/** Runs only while the OS gives the app execution time; foreground/reconnect resume the same ledger. */
+export function MobileOutboxBridge() {
+ const auth = useAuth();
+ const link = useDeviceLink();
+ const latest = useRef({ auth, link });
+ latest.current = { auth, link };
+ const owner = useSyncExternalStore(subscribeMobileAuthOwner, getMobileAuthOwner, getMobileAuthOwner);
+ const accountId = auth.isAuthenticated && auth.user?.id?.trim() === owner.accountId ? owner.accountKey : "";
+ const runnerRef = useRef<ReturnType<
+ typeof createDurableOutboxDelivery
+ > | null>(null);
+ useEffect(() => {
+ try {
+ initializeComposerAttachmentStage();
+ } catch {
+ // A later retain retries before writing; stage cleanup must not block existing outbox delivery.
+ }
+ let active = true;
+ const isCurrent = () =>
+ active &&
+ !!accountId &&
+ owner.accountKey === accountId &&
+ isMobileAuthOwnerCurrent(owner);
+ const guard = () => {
+ if (!isCurrent()) throw new Error("OUTBOX_OWNER_CHANGED");
+ };
+ const invoke: RemoteInvoke = async (deviceId, channel, args) => {
+ guard();
+ const result = await latest.current.link.invoke(deviceId, channel, args, {
+ preSend: guard,
+ });
+ guard();
+ return result as never;
+ };
+ const invokeOwned =
+ (record: DurableOutboxRecord): RemoteInvoke =>
+ async (deviceId, channel, args) => {
+ const guardRecord = () => {
+ guard();
+ if (!mobileDurableOutbox.getSnapshot().includes(record))
+ throw new Error("OUTBOX_STALE_WRITE");
+ };
+ guardRecord();
+ const result = await latest.current.link.invoke(
+ deviceId,
+ channel,
+ args,
+ { preSend: guardRecord },
+ );
+ guardRecord();
+ return result as never;
+ };
+ const maker = (r: DurableOutboxRecord) =>
+ createMobileMakerTransport({
+ deviceId: r.deviceId,
+ invoke: invokeOwned(r),
+ });
+ const epochs = new Map<string, { authority: number; remote: number }>();
+ const leases = new Map<
+ string,
+ ReturnType<typeof remoteSessionStore.acquireSessionMessageWork>
+ >();
+ const leaseKey = (r: DurableOutboxRecord) =>
+ JSON.stringify([r.deviceId, r.item.sessionId]);
+ const refreshLeases = () => {
+ if (!isCurrent()) return;
+ const keys = new Set<string>();
+ for (const record of mobileDurableOutbox.getSnapshot()) {
+ if (isDurableOutboxSettled(record)) continue;
+ if (
+ record.creation &&
+ !remoteSessionStore
+ .getSessions()
+ .some((s) => s.id === record.item.sessionId)
+ ) {
+ remoteSessionStore.upsertDeviceSession(
+ record.deviceId,
+ record.creation.deviceName,
+ sessionFromCreateResult(
+ { sessionId: record.item.sessionId },
+ {
+ ...record.creation.draft,
+ attachments: outboxItemAttachments(record.item),
+ },
+ ),
+ );
+ }
+ const key = leaseKey(record);
+ keys.add(key);
+ if (!leases.has(key))
+ leases.set(
+ key,
+ remoteSessionStore.acquireSessionMessageWork(
+ record.item.sessionId,
+ true,
+ ),
+ );
+ }
+ for (const [key, lease] of leases)
+ if (!keys.has(key)) {
+ lease.release();
+ leases.delete(key);
+ }
+ };
+ const delivery = createDurableOutboxDelivery({
+ store: mobileDurableOutbox,
+ isCurrent,
+ canRun: (r) =>
+ AppState.currentState !== "background" &&
+ AppState.currentState !== "inactive" &&
+ (isDurableOutboxSettled(r) ||
+ (!r.suspended &&
+ !isDurableOutboxCreationHeld(r.item.sessionId) &&
+ latest.current.link.status === "online" &&
+ latest.current.link.getPresenceAvailability(r.deviceId) !== false &&
+ getNewSessionCreationTask(r.item.sessionId) === null)),
+ projection: async (r) => {
+ epochs.set(leaseKey(r), {
+ authority: remoteSessionStore.captureInputProjectionAuthorityEpoch(
+ r.item.sessionId,
+ ),
+ remote: remoteSessionStore.captureInputProjectionRemoteEpoch(
+ r.item.sessionId,
+ ),
+ });
+ return invoke<DeliveryProjection>(
+ r.deviceId,
+ "maker:input:get-projection",
+ [
+ r.item.sessionId,
+ {
+ deliveryClientIds: [r.item.clientId],
+ },
+ ],
+ );
+ },
+ session: (r) => maker(r).getSession(r.item.sessionId),
+ applyProjection: (r, projection) => {
+ guard();
+ const epoch = epochs.get(leaseKey(r));
+ if (epoch)
+ remoteSessionStore.setInputProjectionIfCurrent(
+ r.item.sessionId,
+ projection,
+ epoch.authority,
+ epoch.remote,
+ );
+ },
+ prepare: async (r) => {
+ const session = await maker(r).getSession(r.item.sessionId);
+ guard();
+ if (!session?.workingDir)
+ throw new Error(i18n.t("session.screen.missingWorkingDir"));
+ const item = r.item;
+ const rebuilt = buildQueuedTextMessage(
+ { ...session, permissionMode: item.permissionModeAtSend },
+ item.text,
+ new Date(r.createdAt),
+ item.clientId,
+ {
+ attachments: outboxItemAttachments(item),
+ planMode: item.planModeAtSend,
+ quotesEncoded: item.quotesEncoded,
+ agentReferences: item.agentReferences,
+ pastedTextRanges: item.pastedTextRanges,
+ slashCommandRanges: item.slashCommandRanges,
+ },
+ );
+ return prepareMobileQueuedSessionReferences(
+ {
+ ...rebuilt,
+ ...(r.template
+ ? {
+ ...r.template,
+ files: rebuilt.files,
+ persistedContent: rebuilt.persistedContent,
+ chatMessage: rebuilt.chatMessage,
+ }
+ : {}),
+ ...(item.sessionRefs?.length
+ ? { sessionRefs: item.sessionRefs }
+ : {}),
+ },
+ invokeOwned(r),
+ remoteSessionStore.getSessionDeviceId,
+ r.deviceId,
+ );
+ },
+ upload: async (r, upload) => {
+ const token = await latest.current.auth.getAccessToken();
+ guard();
+ if (!mobileDurableOutbox.getSnapshot().includes(r))
+ throw new Error("OUTBOX_STALE_WRITE");
+ const attachment = await uploadMobileAttachmentFromFile(
+ upload,
+ durableOutboxUploadUri(r, upload),
+ { token, sharedTaskId: parseSharedTaskPeer(r.deviceId)?.sharedTaskId },
+ );
+ if (!isCurrent() || !mobileDurableOutbox.getSnapshot().includes(r)) {
+ // Use the captured credential for this old owner's object, never a new account's token.
+ discardMobileUploadedAttachment(attachment, {
+ getToken: async () => token,
+ });
+ throw new Error("OUTBOX_OWNER_CHANGED");
+ }
+ return upload.annotated
+ ? { ...attachment, annotated: true }
+ : attachment;
+ },
+ enqueue: (r) =>
+ invokeOwned(r)<InputProjection>(r.deviceId, "maker:input:enqueue", [
+ r.item.sessionId,
+ r.prepared,
+ {
+ sendAtMs: r.sendAtMs,
+ ...(r.clearBoundaryMs !== undefined
+ ? { expectedClearBoundaryMs: r.clearBoundaryMs }
+ : {}),
+ },
+ ]),
+ cancel: async (r) => {
+ const result = await invokeOwned(r)<{
+ inputDeliveryCancelled?: boolean;
+ }>(r.deviceId, "maker:input:remove", [
+ r.item.sessionId,
+ r.item.clientId,
+ { durableDelivery: true },
+ ]);
+ return result.inputDeliveryCancelled === true;
+ },
+ history: async (r) => {
+ const authority = remoteSessionStore.captureSessionMessageAuthority(
+ r.item.sessionId,
+ );
+ const messages = await maker(r).aroundMessagesByClientId(
+ r.item.sessionId,
+ r.item.clientId,
+ { radius: 1 },
+ );
+ guard();
+ const found = messages.some(
+ (m) => m.clientId === r.item.clientId && m.role === "user",
+ );
+ if (found)
+ remoteSessionStore.mergeMessages(r.item.sessionId, messages, {
+ authority,
+ });
+ return found;
+ },
+ cleanup: (record, cancelled) => cleanupOutboxResources(record, owner, () => latest.current.auth.getAccessToken(), cancelled),
+ discardUploads: (record, attachments) => discardOutboxUploads(record, owner, () => latest.current.auth.getAccessToken(), attachments),
+ mediaFailed: (error) =>
+ formatRemoteError(error).includes("DEVICE_LINK_MEDIA_TRANSFER_FAILED"),
+ retryable: (error) =>
+ isAutoRecoveringRemoteError(error) ||
+ (error instanceof MobileSessionReferenceError &&
+ error.code === "SESSION_REFERENCE_OFFLINE"),
+ describe: formatRemoteError,
+ confirmationMessage: i18n.t("session.outbox.confirmationRequired"),
+ clearedMessage: i18n.t("session.outbox.taskCleared"),
+ });
+ runnerRef.current = delivery;
+ const run = () => {
+ refreshLeases();
+ // Scavenging failure blocks new copies, not already-owned messages' delivery.
+ void initializeOutboxFiles().catch(() => undefined).then(() => delivery.run()).catch(() => undefined);
+ };
+ void mobileDurableOutbox
+ .activate(accountId)
+ .then(run)
+ .catch(() => {
+ if (isCurrent()) Alert.alert(i18n.t("session.outbox.restoreFailed"));
+ });
+ const off = mobileDurableOutbox.subscribe(run);
+ const timer = setInterval(run, 2_000);
+ const appState = AppState.addEventListener("change", (state) => {
+ if (state === "active") {
+ delivery.wake();
+ run();
+ }
+ });
+ return () => {
+ active = false;
+ delivery.stop();
+ if (runnerRef.current === delivery) runnerRef.current = null;
+ off();
+ clearInterval(timer);
+ appState.remove();
+ for (const lease of leases.values()) lease.release();
+ };
+ }, [accountId, owner]);
+ useEffect(() => {
+ runnerRef.current?.wake();
+ void runnerRef.current?.run().catch(() => undefined);
+ }, [link.status, link.connectionEpoch]);
+ return null;
+}
diff --git a/apps/mobile/src/session/composerDraftStore.ts b/apps/mobile/src/session/composerDraftStore.ts
index 5a383bc238..dd05e349e7 100644
--- a/apps/mobile/src/session/composerDraftStore.ts
+++ b/apps/mobile/src/session/composerDraftStore.ts
@@ -1,5 +1,5 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
-import { parseStoredComposerDocument, type ComposerDocument } from '@/session/composerDocument';
+import { composerDocumentsEqual, parseStoredComposerDocument, composerDocumentProjectedText, type ComposerDocument } from '@/session/composerDocument';
const STORAGE_KEY_PREFIX = 'xdt.mobileComposerDraft.v1';
const DOCUMENT_STORAGE_KEY_PREFIX = 'xdt.mobileComposerDocument.v1';
@@ -179,6 +179,54 @@ export async function flushComposerDraftWrites(sessionId?: string): Promise<void
await drainPendingStorageOperations(normalizedSessionId);
}
+/** Finish a committed send's draft handoff in the existing per-session write chain.
+ * Failures propagate so the outbox keeps its recovery proof. Later user edits win.
+ */
+export async function reconcileCommittedComposerDraft(
+ sessionId: string,
+ handoff: { before: ComposerDocument; after: ComposerDocument },
+ guard: () => void,
+): Promise<void> {
+ const id = normalizeSessionId(sessionId);
+ guard();
+ await flushComposerDraftWrites(id);
+ await enqueueStorageOperation(id, async () => {
+ guard();
+ const documentKey = documentStorageKeyForSession(id);
+ const textKey = storageKeyForSession(id);
+ const raw = await AsyncStorage.getItem(documentKey);
+ const text = await AsyncStorage.getItem(textKey);
+ guard();
+ const stored = raw ? parseStoredComposerDocument(JSON.parse(raw)) : null;
+ if (raw && !stored) throw new Error('COMPOSER_DRAFT_INVALID');
+ const memory = documentDrafts.get(id);
+ const next = memory && !composerDocumentsEqual(memory, handoff.before)
+ ? memory : stored && !composerDocumentsEqual(stored, handoff.before)
+ ? stored : handoff.after;
+ const replaceDocument = !!stored && composerDocumentsEqual(stored, handoff.before);
+ const beforeText = composerDocumentProjectedText(handoff.before);
+ const nextText = drafts.get(id);
+ const replacementText = nextText !== undefined && nextText !== beforeText
+ ? nextText : composerDocumentProjectedText(next);
+ if (memory && composerDocumentsEqual(memory, handoff.before)) {
+ documentDrafts.set(id, next);
+ cancelPendingDocumentPersist(id);
+ }
+ if (nextText === beforeText) {
+ drafts.set(id, replacementText);
+ cancelPendingPersist(id);
+ }
+ if (replaceDocument) {
+ await AsyncStorage.setItem(documentKey, JSON.stringify(next));
+ guard();
+ }
+ if (text === beforeText) {
+ await AsyncStorage.setItem(textKey, replacementText);
+ guard();
+ }
+ }, true);
+}
+
function normalizeSessionId(sessionId: string): string {
return sessionId.trim();
}
@@ -258,19 +306,20 @@ async function persistDocumentIfCurrent(
function enqueueStorageOperation(
normalizedSessionId: string,
operation: () => Promise<void>,
+ propagateError = false,
): Promise<void> {
const previous = pendingStorageOperations.get(normalizedSessionId) ?? Promise.resolve();
- const next = previous
+ const result = previous
.catch(() => undefined)
- .then(operation)
- .catch(() => undefined);
+ .then(operation);
+ const next = result.catch(() => undefined);
pendingStorageOperations.set(normalizedSessionId, next);
void next.finally(() => {
if (pendingStorageOperations.get(normalizedSessionId) === next) {
pendingStorageOperations.delete(normalizedSessionId);
}
});
- return next;
+ return propagateError ? result : next;
}
async function drainPendingStorageOperations(normalizedSessionId?: string): Promise<void> {
diff --git a/apps/mobile/src/session/durableOutbox.ts b/apps/mobile/src/session/durableOutbox.ts
new file mode 100644
index 0000000000..c42cab939f
--- /dev/null
+++ b/apps/mobile/src/session/durableOutbox.ts
@@ -0,0 +1,280 @@
+import type { NewSessionDraft } from "./newSession";
+import type { ComposerDocument } from './composerDocument';
+import type { MobileOutboxItem } from "./sessionOutbox";
+import type { QueuedRemoteMessage, RemoteSerializedAttachment } from "./types";
+
+export interface DurableUpload {
+ slot: number;
+ fileName: string;
+ name: string;
+ mimeType?: string;
+ kind: "image" | "file";
+ size: number;
+ annotated?: boolean;
+}
+
+export interface DurableOutboxRecord {
+ version: 1;
+ /** Canonical realm-qualified auth accountKey; unqualified pre-release rows are never claimed. */
+ accountId: string;
+ deviceId: string;
+ item: MobileOutboxItem;
+ createdAt: number;
+ state: "queued" | "sending" | "confirming" | "host-owned" | "failed";
+ uploads: DurableUpload[];
+ prepared?: QueuedRemoteMessage;
+ /** Persisted before enqueue; absent on older records means unknown, not unsent. */
+ enqueueStarted?: boolean;
+ draftHandoff?: { before: ComposerDocument; after: ComposerDocument };
+ clearBoundaryMs?: number | null;
+ /** Only hosts advertising durable delivery may receive an uncertain retry. */
+ retrySafe?: boolean;
+ error?: string;
+ cancelRequested?: boolean;
+ /** Delivery is settled; retain the ledger solely until local cleanup succeeds. */
+ cleanupOutcome?: "accepted" | "cancelled";
+ sendAtMs?: number;
+ suspended?: boolean;
+ template?: QueuedRemoteMessage;
+ refreshUploads?: boolean;
+ creation?: {
+ draft: NewSessionDraft;
+ deviceName: string;
+ planModeArm: boolean;
+ restorePermissionMode: string | null;
+ };
+}
+
+export interface OutboxStorage {
+ getAllKeys(): Promise<readonly string[]>;
+ getItem(key: string): Promise<string | null>;
+ setItem(key: string, value: string): Promise<void>;
+ removeItem(key: string): Promise<void>;
+}
+
+export function isDurableOutboxSettled(record: DurableOutboxRecord): boolean {
+ return record.cleanupOutcome !== undefined;
+}
+
+/** Preparation is local; only a persisted pre-enqueue proof permits offline disposal.
+ * Legacy records without that proof must also lack all previous-send evidence.
+ */
+export function isDurableOutboxUnsent(record: DurableOutboxRecord): boolean {
+ return record.enqueueStarted === false || (record.enqueueStarted === undefined
+ && !record.prepared && record.sendAtMs === undefined);
+}
+
+export const DURABLE_OUTBOX_PREFIX = "cindy.mobile.outbox.v1.";
+const PREFIX = DURABLE_OUTBOX_PREFIX;
+const EMPTY: readonly DurableOutboxRecord[] = Object.freeze([]);
+const keyFor = (
+ r: Pick<DurableOutboxRecord, "accountId" | "deviceId" | "item">,
+) =>
+ PREFIX +
+ [r.accountId, r.deviceId, r.item.sessionId, r.item.clientId]
+ .map(encodeURIComponent)
+ .join("/");
+
+/** Write-through message ownership. Views are published only after the durable write succeeds. */
+export function createDurableOutbox(storage: OutboxStorage, reconcileDraft?: (
+ record: DurableOutboxRecord, guard: () => void,
+) => Promise<void>) {
+ let accountId = "";
+ let generation = 0;
+ let records: readonly DurableOutboxRecord[] = EMPTY;
+ let writes: Promise<unknown> = Promise.resolve();
+ let ready: Promise<void> = Promise.resolve();
+ let activationFailed = false;
+ const listeners = new Set<() => void>();
+ const emit = () => {
+ for (const listener of listeners) listener();
+ };
+ const serialize = <T>(op: () => Promise<T>): Promise<T> => {
+ const result = writes.then(op);
+ writes = result.catch(() => undefined);
+ return result;
+ };
+ const assertOwner = (owner: string, epoch: number) => {
+ if (!owner || owner !== accountId || epoch !== generation)
+ throw new Error("OUTBOX_OWNER_CHANGED");
+ };
+ const mutate = async (
+ record: DurableOutboxRecord,
+ next: DurableOutboxRecord | null,
+ adding = false,
+ ): Promise<DurableOutboxRecord | null> => {
+ const epoch = generation;
+ await store.ready();
+ return serialize(async () => {
+ assertOwner(record.accountId, epoch);
+ const current = records.find((r) => keyFor(r) === keyFor(record));
+ if (adding ? current !== undefined : current !== record)
+ throw new Error("OUTBOX_STALE_WRITE");
+ if (next) await storage.setItem(keyFor(record), JSON.stringify(next));
+ else await storage.removeItem(keyFor(record));
+ // The disk write is already committed, even if logout raced its completion.
+ // Report success to the old caller so it does not delete files now owned by that ledger.
+ if (record.accountId !== accountId || epoch !== generation) return next;
+ records = next
+ ? [...records.filter((r) => keyFor(r) !== keyFor(record)), next].sort(
+ (a, b) => a.createdAt - b.createdAt,
+ )
+ : records.filter((r) => keyFor(r) !== keyFor(record));
+ emit();
+ return next;
+ });
+ };
+ const store = {
+ subscribe(listener: () => void) {
+ listeners.add(listener);
+ return () => {
+ listeners.delete(listener);
+ };
+ },
+ getSnapshot: () => records,
+ getAccountId: () => accountId,
+ async reconcileDrafts(sessionId?: string): Promise<void> {
+ const owner = accountId;
+ const epoch = generation;
+ await store.ready();
+ if (!reconcileDraft) return;
+ await serialize(async () => {
+ const guard = () => assertOwner(owner, epoch);
+ guard();
+ for (const record of records) {
+ if (!record.draftHandoff || (sessionId !== undefined && record.item.sessionId !== sessionId)) continue;
+ await reconcileDraft(record, guard);
+ guard();
+ const next = { ...record, draftHandoff: undefined };
+ await storage.setItem(keyFor(record), JSON.stringify(next));
+ guard();
+ records = records.map((r) => r === record ? next : r);
+ emit();
+ }
+ });
+ },
+ activate(owner: string): Promise<void> {
+ if (owner === accountId && !activationFailed) return ready;
+ accountId = owner;
+ const epoch = ++generation;
+ activationFailed = false;
+ records = EMPTY;
+ emit();
+ ready = serialize(async () => {
+ if (!owner) return;
+ const keys = (await storage.getAllKeys()).filter((key) =>
+ key.startsWith(PREFIX + encodeURIComponent(owner) + "/"),
+ );
+ const loaded: DurableOutboxRecord[] = [];
+ for (const key of keys) {
+ const raw = await storage.getItem(key);
+ if (!raw) continue;
+ const record = JSON.parse(raw) as DurableOutboxRecord;
+ // Corruption must be visible; never overwrite or silently drop unsent work.
+ if (
+ record.version !== 1 ||
+ record.accountId !== owner ||
+ !record.deviceId ||
+ !record.item?.sessionId ||
+ !record.item.clientId ||
+ keyFor(record) !== key ||
+ !Array.isArray(record.uploads) ||
+ (record.cleanupOutcome !== undefined &&
+ record.cleanupOutcome !== 'accepted' && record.cleanupOutcome !== 'cancelled') ||
+ ![
+ "queued",
+ "sending",
+ "confirming",
+ "host-owned",
+ "failed",
+ ].includes(record.state) ||
+ !Number.isFinite(record.createdAt) ||
+ !Array.isArray(record.item.attachmentSlots)
+ )
+ throw new Error("OUTBOX_STORAGE_INVALID");
+ loaded.push(record);
+ }
+ assertOwner(owner, epoch);
+ records = loaded.sort((a, b) => a.createdAt - b.createdAt);
+ emit();
+ }).catch((error: unknown) => {
+ if (owner === accountId && epoch === generation) activationFailed = true;
+ throw error;
+ });
+ return ready;
+ },
+ async add(record: DurableOutboxRecord) {
+ if (!record.accountId || !record.deviceId)
+ throw new Error("OUTBOX_OWNER_REQUIRED");
+ await store.ready();
+ if (records.some((r) => keyFor(r) === keyFor(record)))
+ throw new Error("OUTBOX_DUPLICATE_ID");
+ await mutate(record, record, true);
+ },
+ update: (
+ record: DurableOutboxRecord,
+ patch: Partial<DurableOutboxRecord>,
+ ) =>
+ mutate(record, {
+ ...record,
+ ...patch,
+ accountId: record.accountId,
+ deviceId: record.deviceId,
+ }) as Promise<DurableOutboxRecord>,
+ remove: (record: DurableOutboxRecord) => mutate(record, null),
+ ready: (): Promise<void> => store.activate(accountId),
+ };
+ return store;
+}
+
+export type DurableOutboxStore = ReturnType<typeof createDurableOutbox>;
+
+/** Synchronous page observer: reserve a transcript slot before the sender's await resumes. */
+export function observeDurableOutboxSending(
+ store: DurableOutboxStore,
+ deviceId: string,
+ sessionId: string,
+ onSending: (record: DurableOutboxRecord) => void,
+ onSettled: (clientId: string) => void,
+ accountId = store.getAccountId(),
+): () => void {
+ const scoped = () => store.getSnapshot().filter((r) => !isDurableOutboxSettled(r) && r.accountId === accountId
+ && r.deviceId === deviceId && r.item.sessionId === sessionId);
+ let previous = new Map(scoped().map((r) => [r.item.clientId, r]));
+ const seen = new Set([...previous.values()].filter((r) => r.sendAtMs !== undefined
+ || r.state !== 'queued').map((r) => r.item.clientId));
+ return store.subscribe(() => {
+ const next = new Map(scoped().map((r) => [r.item.clientId, r]));
+ for (const [id, record] of next) {
+ if (record.state === 'sending' && record.prepared && !seen.has(id)
+ && previous.get(id)?.state === 'queued') {
+ seen.add(id);
+ onSending(record);
+ }
+ }
+ for (const [id, record] of previous) {
+ if (record.state === 'sending' && next.get(id)?.state !== 'sending') onSettled(id);
+ }
+ previous = next;
+ });
+}
+
+/** Fill a durable upload slot without changing the message ID or attachment ordering. */
+export function withDurableUpload(
+ record: DurableOutboxRecord,
+ slot: number,
+ attachment: RemoteSerializedAttachment,
+): MobileOutboxItem {
+ return {
+ ...record.item,
+ attachmentSlots: record.item.attachmentSlots.map((existing, index) =>
+ index === slot ? attachment : existing,
+ ),
+ waitingIds: record.item.waitingIds.filter(
+ (id) => record.item.slotByLocalId[id] !== slot,
+ ),
+ failedIds: record.item.failedIds.filter(
+ (id) => record.item.slotByLocalId[id] !== slot,
+ ),
+ };
+}
diff --git a/apps/mobile/src/session/durableOutboxDelivery.ts b/apps/mobile/src/session/durableOutboxDelivery.ts
new file mode 100644
index 0000000000..3d451f4e82
--- /dev/null
+++ b/apps/mobile/src/session/durableOutboxDelivery.ts
@@ -0,0 +1,341 @@
+import type { InputDeliveryProjection } from "@cindy/device-link";
+import { isExplicitRemoteNotFoundError } from "./newSessionWorktree";
+import {
+ createDurableOutbox,
+ isDurableOutboxSettled,
+ isDurableOutboxUnsent,
+ type DurableOutboxRecord,
+ type DurableUpload,
+} from "./durableOutbox";
+import type {
+ InputProjection,
+ QueuedRemoteMessage,
+ RemoteSerializedAttachment,
+} from "./types";
+
+export type DeliveryProjection = InputProjection &
+ InputDeliveryProjection & { clearBoundaryMs?: number | null };
+export interface DurableOutboxDeliveryDeps {
+ store: ReturnType<typeof createDurableOutbox>;
+ isCurrent(): boolean;
+ canRun(record: DurableOutboxRecord): boolean;
+ projection(record: DurableOutboxRecord): Promise<DeliveryProjection>;
+ session(record: DurableOutboxRecord): Promise<{ id: string; status: string } | null>;
+ prepare(record: DurableOutboxRecord): Promise<QueuedRemoteMessage>;
+ upload(
+ record: DurableOutboxRecord,
+ upload: DurableUpload,
+ ): Promise<RemoteSerializedAttachment>;
+ enqueue(record: DurableOutboxRecord): Promise<InputProjection>;
+ cancel(record: DurableOutboxRecord): Promise<boolean>;
+ history(record: DurableOutboxRecord): Promise<boolean>;
+ applyProjection(
+ record: DurableOutboxRecord,
+ projection: InputProjection,
+ ): void;
+ cleanup(record: DurableOutboxRecord, cancelled: boolean): Promise<void>;
+ discardUploads(record: DurableOutboxRecord, attachments: RemoteSerializedAttachment[]): void;
+ accepted?(record: DurableOutboxRecord): Promise<void>;
+ mediaFailed?(error: unknown): boolean;
+ retryable(error: unknown): boolean;
+ describe(error: unknown): string;
+ confirmationMessage: string;
+ clearedMessage: string;
+}
+
+/** One owner for writes; pages only add records or request retry/cancellation. */
+export function createDurableOutboxDelivery(deps: DurableOutboxDeliveryDeps) {
+ let running = false;
+ let stopped = false;
+ let cursor = 0;
+ const due = new Map<string, number>();
+ const attempts = new Map<string, number>();
+ const id = (r: DurableOutboxRecord) =>
+ JSON.stringify([r.deviceId, r.item.sessionId, r.item.clientId]);
+ const current = (r: DurableOutboxRecord) =>
+ !stopped && deps.isCurrent() && deps.store.getSnapshot().includes(r);
+ const hasDurableOwnership = (r: DurableOutboxRecord) =>
+ r.state === "host-owned" && r.retrySafe === true;
+ async function deliver(initial: DurableOutboxRecord) {
+ let record = initial;
+ due.set(id(record), Date.now() + 5_000);
+ const update = async (patch: Partial<DurableOutboxRecord>) => {
+ if (!current(record)) throw new Error("OUTBOX_STALE_WRITE");
+ record = await deps.store.update(record, patch);
+ };
+ const finish = async (cancelled = false) => {
+ if (!current(record)) return;
+ if (!isDurableOutboxSettled(record)) {
+ await update({ state: 'host-owned', cleanupOutcome: cancelled ? 'cancelled' : 'accepted', error: undefined });
+ }
+ if (!current(record)) return;
+ await deps.cleanup(record, record.cleanupOutcome === 'cancelled');
+ if (!current(record)) return;
+ await deps.store.remove(record);
+ due.delete(id(record));
+ attempts.delete(id(record));
+ };
+ try {
+ if (record.draftHandoff) {
+ await deps.store.reconcileDrafts(record.item.sessionId);
+ const reconciled = deps.store.getSnapshot().find((r) => id(r) === id(record));
+ if (!reconciled || !current(reconciled)) return;
+ record = reconciled;
+ }
+ // Persisted completion never re-enters delivery, even after missing files or lost host history.
+ if (isDurableOutboxSettled(record)) return await finish();
+ let projection: DeliveryProjection;
+ try {
+ projection = await deps.projection(record);
+ } catch (error) {
+ if (!current(record)) return;
+ if (isExplicitRemoteNotFoundError(error)) {
+ // NOT_FOUND also covers hidden tasks and tasks not created yet. Only a
+ // positive tombstone for this exact task authorizes terminal cleanup.
+ const session = await deps.session(record);
+ if (!current(record)) return;
+ if (session?.id === record.item.sessionId && session.status === "deleted") {
+ // Local preparation is not a send. Older prepared rows remain
+ // uncertain; only an explicit pre-enqueue record proves ownership.
+ return await finish(isDurableOutboxUnsent(record));
+ }
+ }
+ throw error;
+ }
+ if (!current(record)) return;
+ deps.applyProjection(record, projection);
+ const receipt = projection.deliveryReceipts?.find(
+ (r) => r.clientId === record.item.clientId,
+ );
+ const state =
+ receipt?.state ??
+ (projection.pendingQueue.some(
+ (r) => r.clientId === record.item.clientId,
+ )
+ ? "pending"
+ : "unknown");
+ // A legacy queue projection or enqueue response only proves in-memory acceptance.
+ const durableOwnership =
+ hasDurableOwnership(record) ||
+ (projection.inputDeliveryVersion === 1 &&
+ (receipt?.state === "pending" || receipt?.state === "accepted"));
+ if (record.cancelRequested) {
+ if (isDurableOutboxUnsent(record) && state === "unknown")
+ return await finish(true);
+ if (projection.inputDeliveryVersion === 1) {
+ const cancelled = await deps.cancel(record);
+ if (!current(record)) return;
+ if (cancelled) await finish(true);
+ else {
+ await deps.accepted?.(record);
+ await update({
+ state: "host-owned",
+ retrySafe: true,
+ cancelRequested: false,
+ error: undefined,
+ });
+ }
+ } else if (state === 'removed') {
+ await finish();
+ } else if (state === "pending") {
+ // Legacy hosts cannot seal a not-yet-arrived enqueue. Keep uncertain cancellation visible.
+ await update({ state: "failed", error: deps.confirmationMessage });
+ } else if (await deps.history(record)) {
+ if (current(record)) await finish();
+ } else if (current(record)) {
+ await update({ state: "failed", error: deps.confirmationMessage });
+ }
+ return;
+ }
+ if (state === "removed") return await finish();
+ if (
+ record.clearBoundaryMs !== undefined &&
+ projection.clearBoundaryMs !== undefined &&
+ record.clearBoundaryMs !== projection.clearBoundaryMs
+ ) {
+ if (durableOwnership)
+ return await finish();
+ await update({ state: "failed", error: deps.clearedMessage });
+ return;
+ }
+ if (durableOwnership) {
+ if (record.state !== "host-owned") await deps.accepted?.(record);
+ if (!current(record)) return;
+ if (await deps.history(record)) {
+ if (current(record)) await finish();
+ return;
+ }
+ if (!current(record)) return;
+ if (!hasDurableOwnership(record))
+ await update({ state: "host-owned", retrySafe: true, error: undefined });
+ due.set(id(record), Date.now() + 5_000);
+ return;
+ }
+ // Even old hosts may already have persisted a user row after the enqueue receipt was lost.
+ if ((record.prepared || state === "pending" || state === "accepted") && (await deps.history(record))) {
+ if (current(record)) await finish();
+ return;
+ }
+ if (!current(record) || record.state === "failed") return;
+ if (state === "pending" || state === "accepted" || record.state === "host-owned") {
+ await update({ state: state === "pending" ? "confirming" : "failed", error: deps.confirmationMessage });
+ return;
+ }
+ if (
+ record.prepared &&
+ (record.state === "sending" || record.state === "confirming") &&
+ !record.refreshUploads &&
+ !(record.retrySafe && projection.inputDeliveryVersion === 1)
+ ) {
+ await update({ state: "failed", error: deps.confirmationMessage });
+ return;
+ }
+ if (record.refreshUploads && record.uploads.length) {
+ const superseded = record.item.attachmentSlots.filter((attachment, slot): attachment is RemoteSerializedAttachment =>
+ attachment !== null && record.uploads.some((upload) => upload.slot === slot));
+ await update({
+ template: record.prepared ?? record.template,
+ prepared: undefined,
+ refreshUploads: false,
+ item: {
+ ...record.item,
+ attachmentSlots: record.item.attachmentSlots.map((slot, index) =>
+ record.uploads.some((u) => u.slot === index) ? null : slot,
+ ),
+ },
+ });
+ if (!current(record)) return;
+ // Commit the replacement boundary first: a failed ledger write still owns the old references.
+ deps.discardUploads(record, superseded);
+ }
+ if (!record.prepared) {
+ for (const upload of record.uploads) {
+ if (record.item.attachmentSlots[upload.slot]) continue;
+ const attachment = await deps.upload(record, upload);
+ let retained = false;
+ try {
+ if (!current(record)) return;
+ await update({
+ item: {
+ ...record.item,
+ attachmentSlots: record.item.attachmentSlots.map((old, slot) =>
+ slot === upload.slot ? attachment : old,
+ ),
+ waitingIds: record.item.waitingIds.filter(
+ (localId) => record.item.slotByLocalId[localId] !== upload.slot,
+ ),
+ failedIds: record.item.failedIds.filter(
+ (localId) => record.item.slotByLocalId[localId] !== upload.slot,
+ ),
+ },
+ });
+ retained = true;
+ } finally {
+ // Until the ledger owns it, this attempt owns the remote object, including late completion.
+ if (!retained) deps.discardUploads(record, [attachment]);
+ }
+ }
+ const prepared = await deps.prepare(record);
+ if (!current(record)) return;
+ await update({
+ prepared: {
+ ...prepared,
+ // Snapshot Plan on this input, never arm the session during preparation.
+ ...(record.creation ? {
+ createOpts: { ...prepared.createOpts, planMode: record.creation.planModeArm },
+ } : {}),
+ ...(projection.inputDeliveryVersion === 1
+ ? { durableDelivery: true }
+ : {}),
+ },
+ retrySafe: projection.inputDeliveryVersion === 1,
+ enqueueStarted: record.enqueueStarted ?? (record.sendAtMs === undefined ? false : undefined),
+ clearBoundaryMs: projection.clearBoundaryMs ?? record.clearBoundaryMs,
+ sendAtMs: record.sendAtMs ?? Date.now(),
+ });
+ }
+ // This write precedes every external enqueue. Crash recovery therefore knows it must reconcile.
+ await update({ state: "sending", enqueueStarted: true, error: undefined });
+ const result = await deps.enqueue(record);
+ if (!current(record)) return;
+ deps.applyProjection(record, result);
+ const durableEnqueue = record.prepared?.durableDelivery === true &&
+ projection.inputDeliveryVersion === 1;
+ if (durableEnqueue) await deps.accepted?.(record);
+ await update(durableEnqueue
+ ? { state: "host-owned" }
+ : { state: "confirming", error: deps.confirmationMessage });
+ attempts.delete(id(record));
+ due.set(id(record), Date.now() + 1_000);
+ } catch (error) {
+ if (!current(record)) return;
+ const count = (attempts.get(id(record)) ?? 0) + 1;
+ attempts.set(id(record), count);
+ due.set(
+ id(record),
+ Date.now() + Math.min(30_000, 1_000 * 2 ** Math.min(count, 5)),
+ );
+ // Never turn an uncertain write into a fresh message or discard its ID.
+ await update({
+ state:
+ isDurableOutboxSettled(record)
+ ? record.state
+ : record.state === "sending"
+ ? "confirming"
+ : deps.retryable(error)
+ ? record.state
+ : "failed",
+ error: deps.describe(error),
+ ...(!isDurableOutboxSettled(record) && deps.mediaFailed?.(error) && record.uploads.length
+ ? { refreshUploads: true }
+ : {}),
+ }).catch(() => undefined);
+ }
+ }
+ return {
+ stop() {
+ stopped = true;
+ },
+ wake() {
+ due.clear();
+ },
+ async run() {
+ if (running || stopped || !deps.isCurrent()) return;
+ running = true;
+ try {
+ await deps.store.ready();
+ if (stopped || !deps.isCurrent()) return;
+ const groups = new Map<string, DurableOutboxRecord[]>();
+ for (const record of deps.store.getSnapshot()) {
+ const key = JSON.stringify([record.deviceId, record.item.sessionId]);
+ const group = groups.get(key) ?? [];
+ group.push(record);
+ groups.set(key, group);
+ }
+ // Session FIFO, while one unavailable computer never blocks a different task.
+ const candidates = [...groups.values()]
+ .flatMap((group) => {
+ const handedOff = (r: DurableOutboxRecord) => hasDurableOwnership(r) || isDurableOutboxSettled(r);
+ const head = group.find((r) => !handedOff(r));
+ return [
+ ...(head ? [head] : []),
+ ...group.filter(handedOff),
+ ];
+ })
+ .filter((r) => deps.canRun(r) && (due.get(id(r)) ?? 0) <= Date.now());
+ // Bound aggregate replay as well as concurrency; reconnecting many tasks must not
+ // recreate a relay backpressure burst. Round robin prevents one failed head starving peers.
+ const work: DurableOutboxRecord[] = [];
+ for (let n = 0; n < Math.min(2, candidates.length); n++) {
+ work.push(candidates[(cursor + n) % candidates.length]!);
+ }
+ cursor = candidates.length
+ ? (cursor + work.length) % candidates.length
+ : 0;
+ await Promise.all(work.map(deliver));
+ } finally {
+ running = false;
+ }
+ },
+ };
+}
diff --git a/apps/mobile/src/session/durableOutboxFiles.ts b/apps/mobile/src/session/durableOutboxFiles.ts
new file mode 100644
index 0000000000..91f510f8a8
--- /dev/null
+++ b/apps/mobile/src/session/durableOutboxFiles.ts
@@ -0,0 +1,152 @@
+import * as FileSystem from "expo-file-system/legacy";
+import { Directory } from "expo-file-system";
+import AsyncStorage from '@react-native-async-storage/async-storage';
+import { DURABLE_OUTBOX_PREFIX, type DurableOutboxRecord, type DurableUpload } from "./durableOutbox";
+import type { MobileLocalAttachmentUploadCandidate } from "./mobileLocalAttachmentUpload";
+import { isAttachmentOssRef } from './attachmentOssRef';
+
+/** Desktop path references already have their source on the controlled device. */
+export function outboxAttachmentNeedsLocalBytes(attachment: { path: string }): boolean {
+ return isAttachmentOssRef(attachment.path);
+}
+
+function segment(value: string): string {
+ return encodeURIComponent(value).replace(/\./g, "%2E");
+}
+export function durableOutboxDirectory(
+ record: Pick<DurableOutboxRecord, "accountId" | "deviceId" | "item">,
+): string {
+ if (!FileSystem.documentDirectory)
+ throw new Error("OUTBOX_STORAGE_UNAVAILABLE");
+ return `${FileSystem.documentDirectory}message-outbox/${[record.accountId, record.deviceId, record.item.sessionId, record.item.clientId].map(segment).join("/")}/`;
+}
+export function durableOutboxUploadUri(
+ record: DurableOutboxRecord,
+ upload: DurableUpload,
+): string {
+ if (!/^slot-\d+(?:-[a-z0-9]+)?\.[a-z0-9]{1,12}$/.test(upload.fileName))
+ throw new Error("OUTBOX_FILE_INVALID");
+ return durableOutboxDirectory(record) + upload.fileName;
+}
+export async function retainOutboxFile(
+ record: DurableOutboxRecord,
+ slot: number,
+ source: MobileLocalAttachmentUploadCandidate,
+): Promise<DurableUpload> {
+ await initializeOutboxFiles();
+ const extension =
+ source.name.match(/\.([a-z0-9]{1,12})$/i)?.[1]?.toLowerCase() ?? "bin";
+ const upload: DurableUpload = {
+ slot,
+ fileName: `slot-${slot}-${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}.${extension}`,
+ name: source.name,
+ mimeType: source.mimeType,
+ kind: source.kind,
+ size: source.size,
+ ...(source.annotation ? { annotated: true } : {}),
+ };
+ await FileSystem.makeDirectoryAsync(durableOutboxDirectory(record), {
+ intermediates: true,
+ });
+ const target = durableOutboxUploadUri(record, upload);
+ return { ...upload, size: await copyRetainedBytes(source.uri, target, source.size) };
+}
+
+/** Keep the once marker across Fast Refresh: mounted composers can still own stage files. */
+const runtime = globalThis as typeof globalThis & {
+ __cindyOutboxStageInitialized?: boolean;
+ __cindyOutboxFilesInitialized?: Promise<void>;
+};
+
+/** Before any new copies, reconcile previous-runtime files against ALL accounts' ledgers.
+ * No current-runtime writer runs until this completes; keep the promise over Fast Refresh.
+ */
+export function initializeOutboxFiles(): Promise<void> {
+ if (runtime.__cindyOutboxFilesInitialized) return runtime.__cindyOutboxFilesInitialized;
+ const pending = (async () => {
+ if (!FileSystem.documentDirectory) throw new Error('OUTBOX_STORAGE_UNAVAILABLE');
+ const root = `${FileSystem.documentDirectory}message-outbox/`;
+ const retained = new Set<string>();
+ const keys = await AsyncStorage.getAllKeys();
+ for (const key of keys.filter((key) => key.startsWith(DURABLE_OUTBOX_PREFIX))) {
+ const raw = await AsyncStorage.getItem(key);
+ if (raw === null) continue;
+ const record = JSON.parse(raw) as DurableOutboxRecord;
+ if (record.version !== 1 || !record.accountId || !record.deviceId
+ || !record.item?.sessionId || !record.item.clientId || !Array.isArray(record.uploads)) {
+ throw new Error('OUTBOX_STORAGE_INVALID');
+ }
+ for (const upload of record.uploads) retained.add(durableOutboxUploadUri(record, upload));
+ }
+ // Read/validate every ledger before deleting anything. Unknown storage never means empty.
+ const visit = async (directory: string, depth: number): Promise<void> => {
+ const info = await FileSystem.getInfoAsync(directory);
+ if (!info.exists || !info.isDirectory) return;
+ for (const name of await FileSystem.readDirectoryAsync(directory)) {
+ if (!name || name === '.' || name === '..' || /[\\/]/.test(name)) continue;
+ const uri = directory + name;
+ if (depth < 4) await visit(uri + '/', depth + 1);
+ else if (/^slot-\d+(?:-[a-z0-9]+)?\.[a-z0-9]{1,12}$/.test(name) && !retained.has(uri)) {
+ await FileSystem.deleteAsync(uri, { idempotent: true });
+ }
+ }
+ };
+ await visit(root, 0);
+ })();
+ runtime.__cindyOutboxFilesInitialized = pending;
+ void pending.catch(() => {
+ if (runtime.__cindyOutboxFilesInitialized === pending) delete runtime.__cindyOutboxFilesInitialized;
+ });
+ return pending;
+}
+export function initializeComposerAttachmentStage(): void {
+ if (runtime.__cindyOutboxStageInitialized) return;
+ if (!FileSystem.documentDirectory) throw new Error('OUTBOX_STORAGE_UNAVAILABLE');
+ const directory = new Directory(`${FileSystem.documentDirectory}outbox-attachment-stage/`);
+ // No await: old-runtime cleanup must finish before any current composer may write.
+ if (directory.exists) directory.delete();
+ runtime.__cindyOutboxStageInitialized = true;
+}
+
+/** Composer-owned PUT bytes must survive OS cache eviction until outbox handoff or disposal. */
+export async function retainComposerAttachmentFile(owner: string, attachmentId: string, uri: string, size: number): Promise<string> {
+ if (!FileSystem.documentDirectory) throw new Error('OUTBOX_STORAGE_UNAVAILABLE');
+ initializeComposerAttachmentStage();
+ const directory = `${FileSystem.documentDirectory}outbox-attachment-stage/${segment(owner)}/`;
+ await FileSystem.makeDirectoryAsync(directory, { intermediates: true });
+ const target = directory + segment(attachmentId);
+ await copyRetainedBytes(uri, target, size);
+ return target;
+}
+
+async function copyRetainedBytes(uri: string, target: string, size: number): Promise<number> {
+ try {
+ await FileSystem.copyAsync({ from: uri, to: target });
+ const stat = await FileSystem.getInfoAsync(target);
+ if (
+ !stat.exists ||
+ stat.isDirectory ||
+ stat.size <= 0 ||
+ (size > 0 && stat.size !== size)
+ ) {
+ throw new Error("OUTBOX_FILE_COPY_FAILED");
+ }
+ return stat.size;
+ } catch (error) {
+ await FileSystem.deleteAsync(target, { idempotent: true }).catch(() => undefined);
+ throw error;
+ }
+}
+/** Roll back only this revision's copies; recovery may share the directory with older bytes. */
+export async function removeRetainedOutboxFiles(record: DurableOutboxRecord): Promise<void> {
+ await Promise.all(record.uploads.map((upload) =>
+ FileSystem.deleteAsync(durableOutboxUploadUri(record, upload), { idempotent: true }),
+ ));
+}
+export async function removeOutboxFiles(
+ record: DurableOutboxRecord,
+): Promise<void> {
+ await FileSystem.deleteAsync(durableOutboxDirectory(record), {
+ idempotent: true,
+ });
+}
diff --git a/apps/mobile/src/session/inputProjection.ts b/apps/mobile/src/session/inputProjection.ts
index 445e6e58b8..b3a126d7ec 100644
--- a/apps/mobile/src/session/inputProjection.ts
+++ b/apps/mobile/src/session/inputProjection.ts
@@ -127,6 +127,7 @@ export function buildQueuedTextMessage(
clientId = createUuid(),
options: {
attachments?: readonly RemoteSerializedAttachment[];
+ planMode?: boolean;
quotesEncoded?: boolean;
agentReferences?: AgentInputReference[];
pastedTextRanges?: Array<{ start: number; end: number; display: string }>;
@@ -178,6 +179,7 @@ export function buildQueuedTextMessage(
},
createOpts: {
agentKind,
+ ...(options.planMode !== undefined ? { planMode: options.planMode } : {}),
workingDir,
model: session.model,
effort,
diff --git a/apps/mobile/src/session/mobileDurableOutbox.ts b/apps/mobile/src/session/mobileDurableOutbox.ts
new file mode 100644
index 0000000000..3e8553956d
--- /dev/null
+++ b/apps/mobile/src/session/mobileDurableOutbox.ts
@@ -0,0 +1,100 @@
+import AsyncStorage from "@react-native-async-storage/async-storage";
+import { getMobileAuthOwner, isMobileAuthOwnerCurrent, type MobileAuthOwnerGeneration } from '@/auth/authOwnerGeneration';
+import { createDurableOutbox, isDurableOutboxSettled, type DurableOutboxRecord } from "./durableOutbox";
+import { durableOutboxUploadUri, removeOutboxFiles } from "./durableOutboxFiles";
+import { outboxItemAttachments, type MobileOutboxItem } from "./sessionOutbox";
+import { discardMobileUploadedAttachment } from "./mobileAttachmentUpload";
+import type { RemoteSerializedAttachment } from "./types";
+import { reconcileCommittedComposerDraft } from './composerDraftStore';
+
+export const mobileDurableOutbox = createDurableOutbox(AsyncStorage, async (record, guard) => {
+ if (!record.draftHandoff) return;
+ const owner = getMobileAuthOwner();
+ const check = () => {
+ guard();
+ if (owner.accountKey !== record.accountId || !isMobileAuthOwnerCurrent(owner)) {
+ throw new Error('OUTBOX_OWNER_CHANGED');
+ }
+ };
+ await reconcileCommittedComposerDraft(record.item.sessionId, record.draftHandoff, check);
+});
+export async function reconcileMobileOutboxDrafts(sessionId: string): Promise<void> {
+ const owner = getMobileAuthOwner();
+ if (!owner.accountKey) return;
+ await mobileDurableOutbox.activate(owner.accountKey);
+ if (!isMobileAuthOwnerCurrent(owner)) throw new Error('OUTBOX_OWNER_CHANGED');
+ await mobileDurableOutbox.reconcileDrafts(sessionId);
+}
+/** Local filesystem failures must not suppress disposal of confirmed-cancelled uploads. */
+export async function cleanupOutboxResources(
+ record: DurableOutboxRecord,
+ owner: MobileAuthOwnerGeneration,
+ getToken: () => Promise<string | null>,
+ cancelled: boolean,
+): Promise<void> {
+ try {
+ await removeOutboxFiles(record);
+ } finally {
+ if (cancelled) discardOutboxUploads(record, owner, getToken);
+ }
+}
+/** Hide old-owner rows even before the bridge's React effect activates the next ledger. */
+export function getCurrentMobileOutboxRecords(): readonly DurableOutboxRecord[] {
+ const key = getMobileAuthOwner().accountKey;
+ return mobileDurableOutbox.getSnapshot().filter((record) => record.accountId === key && !isDurableOutboxSettled(record));
+}
+/** Call only for confirmed cancellation, superseded references, or an upload never handed to the ledger. */
+export function discardOutboxUploads(
+ record: DurableOutboxRecord,
+ owner: MobileAuthOwnerGeneration,
+ getToken: () => Promise<string | null>,
+ attachments: readonly RemoteSerializedAttachment[] = outboxItemAttachments(record.item),
+): void {
+ if (record.accountId !== owner.accountKey) return;
+ for (const attachment of attachments) {
+ discardMobileUploadedAttachment(attachment, { getToken: async () => {
+ if (!isMobileAuthOwnerCurrent(owner)) return null;
+ const token = await getToken();
+ return isMobileAuthOwnerCurrent(owner) ? token : null;
+ } });
+ }
+}
+export function durableOutboxDisplayItem(
+ record: DurableOutboxRecord,
+): MobileOutboxItem {
+ return {
+ ...record.item,
+ phase:
+ record.state === "failed"
+ ? "failed"
+ : record.state === "sending" ||
+ record.state === "confirming" ||
+ record.state === "host-owned"
+ ? "dispatching"
+ : "uploading",
+ enqueueError: record.error ?? null,
+ slotMeta: record.item.slotMeta.map((meta, slot) => {
+ const upload = record.uploads.find((u) => u.slot === slot);
+ return upload
+ ? { ...meta, previewUri: durableOutboxUploadUri(record, upload) }
+ : meta;
+ }),
+ };
+}
+
+// Synchronous reservation covers the disk-write -> live creation task registration window.
+const creationHolds = new Map<string, number>();
+export function holdDurableOutboxCreation(sessionId: string): () => void {
+ creationHolds.set(sessionId, (creationHolds.get(sessionId) ?? 0) + 1);
+ let released = false;
+ return () => {
+ if (released) return;
+ released = true;
+ const count = (creationHolds.get(sessionId) ?? 1) - 1;
+ if (count) creationHolds.set(sessionId, count);
+ else creationHolds.delete(sessionId);
+ };
+}
+export function isDurableOutboxCreationHeld(sessionId: string): boolean {
+ return creationHolds.has(sessionId);
+}
diff --git a/apps/mobile/src/session/mobileLocalAttachmentUpload.ts b/apps/mobile/src/session/mobileLocalAttachmentUpload.ts
index 2fb882b2c1..877eb05b0f 100644
--- a/apps/mobile/src/session/mobileLocalAttachmentUpload.ts
+++ b/apps/mobile/src/session/mobileLocalAttachmentUpload.ts
@@ -108,7 +108,7 @@ export interface MobileLocalAttachmentUploadDeps {
opts: { token: string; signal?: AbortSignal },
): Promise<RemoteSerializedAttachment>;
/** 已上传但不再被引用的对象回收(discardMobileUploadedAttachment,best-effort)。 */
- discard(attachment: RemoteSerializedAttachment): void;
+ discard(attachment: RemoteSerializedAttachment, token?: string | null): void;
/** pending 列表变化(宿主 setState 驱动托盘;已 claim 的任务不在其中)。 */
onPendingChange(pending: readonly PendingLocalAttachmentUpload[]): void;
/**
@@ -129,7 +129,20 @@ export interface MobileLocalAttachmentUploadDeps {
onFailed(error: unknown, localId: string, candidate: MobileLocalAttachmentUploadCandidate): void;
}
+export interface PreparedOutboxAttachment {
+ localId: string;
+ source: MobileLocalAttachmentUploadCandidate;
+}
+export interface MobileAttachmentHandoff {
+ prepare(): Promise<PreparedOutboxAttachment[]>;
+ /** Commit cancels the old PUT; its late result is discarded by this controller. */
+ release(commit: boolean): void;
+}
+
export interface MobileLocalAttachmentUploadController {
+ beginHandoff(): MobileAttachmentHandoff;
+ isRetainingUri(uri: string): boolean;
+ waitForDelivering(): Promise<void>;
/**
* 把 picker 产出批量入队并立即出现在 pending 列表;后台按并发上限上传。
* token 允许传 Promise:调用方**不要**先 await getAccessToken() 再 enqueue——那个等待窗
@@ -224,6 +237,10 @@ interface UploadTask {
abort: AbortController;
/** 本任务已接触的自有临时 uri;无 cleanupLocalUris 时只记账、不做删除。 */
localUris: Set<string>;
+ prepared?: Promise<MobileLocalAttachmentUploadCandidate>;
+ handoff?: { promise: Promise<void>; resolve(): void };
+ delivering?: boolean;
+ resolvedSource?: MobileLocalAttachmentUploadCandidate;
outcome: Promise<TaskOutcome>;
resolveOutcome: (outcome: TaskOutcome) => void;
}
@@ -273,6 +290,11 @@ export function createMobileLocalAttachmentUploadController(
}
function cleanupTaskLocalUris(task: UploadTask, keepOriginal: boolean): void {
+ if (task.handoff) {
+ void task.handoff.promise.then(() => cleanupTaskLocalUris(task, keepOriginal));
+ return;
+ }
+ if (keepOriginal) task.prepared = undefined;
const cleanup = task.candidate.cleanupLocalUris;
if (!cleanup) return;
const originalUri = task.candidate.uri;
@@ -281,6 +303,63 @@ export function createMobileLocalAttachmentUploadController(
if (uris.length > 0) void cleanup(uris).catch(() => undefined);
}
+ function prepareTaskSource(task: UploadTask): Promise<MobileLocalAttachmentUploadCandidate> {
+ if (task.prepared) return task.prepared;
+ // Preparation is shared with a durable handoff, which can run before token refresh.
+ // Give that owner the same bounded wait; a late result never mutates a newer retry.
+ let expired = false;
+ let preparation!: Promise<MobileLocalAttachmentUploadCandidate>;
+ let rejectTimeout!: (error: Error) => void;
+ const timeout = new Promise<never>((_resolve, reject) => { rejectTimeout = reject; });
+ const timer = setTimeout(() => {
+ expired = true;
+ rejectTimeout(new Error(i18n.t('composer.upload.timeout')));
+ }, 180_000);
+ const step = <T>(value: Promise<T>): Promise<T> => Promise.race([
+ value.then((result) => {
+ if (expired || task.prepared !== preparation || (task.discarded && !task.handoff)) {
+ const uri = (result as { uri?: string })?.uri;
+ if (uri && uri !== task.candidate.uri) void task.candidate.cleanupLocalUris?.([uri]).catch(() => undefined);
+ throw new Error(i18n.t('composer.upload.cancelled'));
+ }
+ return result;
+ }), timeout,
+ ]);
+ preparation = (async () => {
+ try {
+ // 先跑 candidate 自带的就位钩子(相册换址 / HEIC 转码),结果覆盖进管线输入。
+ let source = task.candidate;
+ if (source.resolve) {
+ source = { ...source, ...(await step(source.resolve())) };
+ }
+ task.resolvedSource = source;
+ task.localUris.add(source.uri);
+ // 只有图片需要降采样;文件(pdf / office / 文本)与已优化产物原样直传。
+ const prepared = source.kind === 'image' && !source.skipPreprocess
+ ? await step(deps.preprocess({
+ uri: source.uri,
+ name: source.name,
+ mimeType: source.mimeType,
+ size: source.size,
+ width: source.width,
+ height: source.height,
+ }))
+ : {
+ uri: source.uri,
+ name: source.name,
+ mimeType: source.mimeType,
+ size: source.size,
+ };
+ task.localUris.add(prepared.uri);
+ const size = prepared.size > 0 ? prepared.size : await step(deps.statSize(prepared.uri));
+ deps.assertSize(size, task.candidate);
+ return { ...source, ...prepared, size, resolve: undefined, skipPreprocess: true };
+ } finally { clearTimeout(timer); }
+ })();
+ task.prepared = preparation;
+ return preparation;
+ }
+
async function runTask(task: UploadTask): Promise<void> {
// 先让出一拍:保证任务至少异步落定——pending 帧可见、waitForIdle 统计口径一致,
// 同步 throw(如已知 size 的超限校验)不会在 enqueue 调用栈里就把任务清掉。
@@ -305,15 +384,12 @@ export function createMobileLocalAttachmentUploadController(
}),
interrupted,
]);
- const cleanupLateFile = (result: { uri?: string }) => {
- if (result.uri && result.uri !== task.candidate.uri) {
- void task.candidate.cleanupLocalUris?.([result.uri]).catch(() => undefined);
- }
- };
+ let uploadedAttachment: RemoteSerializedAttachment | undefined;
+ let uploadToken: string | null = null;
try {
if (signal.aborted) onAbort();
// token 先就位(可能仍在网络 refresh):拿不到就快速失败,不浪费后面的转码/降采样。
- const token = await step(task.token);
+ const token = uploadToken = await step(task.token);
if (!token) {
throw new Error(task.candidate.kind === 'image'
? i18n.t('composer.upload.sessionExpiredImage')
@@ -324,45 +400,25 @@ export function createMobileLocalAttachmentUploadController(
outcome = 'discarded';
return;
}
- // 先跑 candidate 自带的就位钩子(相册换址 / HEIC 转码),结果覆盖进管线输入。
- let source = task.candidate;
- if (source.resolve) {
- source = { ...source, ...(await step(source.resolve(), cleanupLateFile)) };
- }
- task.localUris.add(source.uri);
- // 只有图片需要降采样;文件(pdf / office / 文本)与已优化产物原样直传。
- const prepared = source.kind === 'image' && !source.skipPreprocess
- ? await step(deps.preprocess({
- uri: source.uri,
- name: source.name,
- mimeType: source.mimeType,
- size: source.size,
- width: source.width,
- height: source.height,
- }), cleanupLateFile)
- : {
- uri: source.uri,
- name: source.name,
- mimeType: source.mimeType,
- size: source.size,
- };
- task.localUris.add(prepared.uri);
- const size = prepared.size > 0 ? prepared.size : await step(deps.statSize(prepared.uri));
- deps.assertSize(size, task.candidate);
+ const prepared = await step(prepareTaskSource(task));
+ const source = task.resolvedSource ?? prepared;
+ const size = prepared.size;
// 取消检查点 2:资产就位 / 降采样(大图慢路径)期间被 X 掉的任务在发起 PUT 前短路
// ——PUT 一旦开始便不可中止,只能事后 best-effort 删除,这里拦住就不产生 OSS 孤儿风险。
if (task.discarded) {
outcome = 'discarded';
return;
}
- const attachment = await step(deps.upload(
+ const attachment = uploadedAttachment = await step(deps.upload(
{ name: prepared.name, size, mimeType: prepared.mimeType || undefined, ...(source.sharedTaskId ? { sharedTaskId: source.sharedTaskId } : {}) },
prepared.uri,
{ token, signal },
- ), deps.discard);
+ ), (late) => deps.discard(late, token));
+ if (task.handoff) await task.handoff.promise;
+ task.delivering = true;
if (task.discarded) {
// 上传成功但用户已 X 掉 / 页面已退出:回收中转对象,不回调宿主。
- deps.discard(attachment);
+ deps.discard(attachment, token);
outcome = 'discarded';
} else {
// 回传就位后的 candidate(kind / sourceId 随 spread 保留):resolve 型任务
@@ -375,17 +431,19 @@ export function createMobileLocalAttachmentUploadController(
task.localId,
[...task.localUris],
() => !disposed && !task.discarded && !signal.aborted,
- )), () => deps.discard(attachment));
+ )), () => deps.discard(attachment, token));
if (disposed || task.discarded) {
// onUploaded 可能为粘贴图片等待持久缩略图;等待期间退屏 / removeAll
// 时不能再把附件写回旧页面,且已经上传的 OSS 对象仍须回收。
- deps.discard(attachment);
+ deps.discard(attachment, token);
outcome = 'discarded';
} else {
outcome = 'uploaded';
}
}
} catch (err) {
+ if (uploadedAttachment) deps.discard(uploadedAttachment, uploadToken);
+ if (task.handoff) await task.handoff.promise;
if (task.discarded) {
outcome = 'discarded';
} else {
@@ -395,6 +453,8 @@ export function createMobileLocalAttachmentUploadController(
} finally {
clearTimeout(timer);
signal.removeEventListener('abort', onAbort);
+ if (task.handoff) await task.handoff.promise;
+ task.delivering = false;
if (outcome === 'failed' && !disposed) {
// 失败卡保留在托盘(state=failed,可 retry / remove),不再从 map 删除——
// 弱网下「图直接消失 + 一条 toast」逼用户重新找图重选,原地重试才是对的。
@@ -415,6 +475,45 @@ export function createMobileLocalAttachmentUploadController(
}
return {
+ async waitForDelivering() {
+ await Promise.all([...tasks.values()].filter((task) => task.delivering).map((task) => task.outcome));
+ },
+ isRetainingUri(uri) {
+ return [...tasks.values()].some((task) => task.handoff && task.localUris.has(uri));
+ },
+ beginHandoff() {
+ if ([...tasks.values()].some((task) => task.delivering)) throw new Error('ATTACHMENT_DELIVERING');
+ const captured = [...tasks.values()].filter((task) => !task.discarded && !task.claimed && !task.delivering);
+ for (const task of captured) {
+ if (task.handoff) throw new Error('ATTACHMENT_HANDOFF_BUSY');
+ let resolve!: () => void;
+ const promise = new Promise<void>((done) => { resolve = done; });
+ task.handoff = { promise, resolve };
+ }
+ let released = false;
+ return {
+ prepare: () => Promise.all(captured.map(async (task) => ({ localId: task.localId, source: await prepareTaskSource(task) }))),
+ release(commit) {
+ if (released) return;
+ released = true;
+ for (const task of captured) {
+ const handoff = task.handoff;
+ if (commit) {
+ task.discarded = true;
+ task.abort.abort();
+ if (task.state !== 'running') {
+ tasks.delete(task.localId);
+ task.resolveOutcome('discarded');
+ }
+ }
+ task.handoff = undefined;
+ handoff?.resolve();
+ if (commit) cleanupTaskLocalUris(task, false);
+ }
+ notifyPending();
+ },
+ };
+ },
enqueue(candidates, opts) {
if (disposed || candidates.length === 0) return;
for (const candidate of candidates) {
@@ -466,6 +565,7 @@ export function createMobileLocalAttachmentUploadController(
// token 用调用方给的新鲜值(失败卡可能停留很久,旧凭证大概率已过期)。
const renewed = createOutcome();
task.state = 'queued';
+ task.delivering = false;
task.token = opts.token;
task.abort = new AbortController();
task.outcome = renewed.outcome;
diff --git a/apps/mobile/src/session/newSessionCreation.ts b/apps/mobile/src/session/newSessionCreation.ts
index fd72c5dd27..ccb23ec1de 100644
--- a/apps/mobile/src/session/newSessionCreation.ts
+++ b/apps/mobile/src/session/newSessionCreation.ts
@@ -64,6 +64,7 @@ export type NewSessionCreationStatus = 'running' | 'create-failed' | 'enqueue-fa
export interface NewSessionCreationTransport {
maker: MobileMakerTransport;
+ handoffFirstMessage?: (item: QueuedRemoteMessage) => Promise<void>;
openLink: (deviceId: string) => Promise<unknown>;
subscribe: (owner: string, deviceId: string, topics: string[]) => Promise<void>;
/** 手机控制端在首条消息越过 device-link 前读取各引用来源的可信历史快照。 */
@@ -73,6 +74,7 @@ export interface NewSessionCreationTransport {
export interface NewSessionCreationParams {
/** 从按下发送起计时,跨页面交接不重置慢发送提示。 */
startedAt?: number;
+ firstMessageClientId?: string;
sessionId: string;
deviceId: string;
deviceName: string;
@@ -269,7 +271,7 @@ function synthesizeSession(params: NewSessionCreationParams, draftOverride?: New
*/
export function startNewSessionCreation(params: NewSessionCreationParams): void {
if (params.isCurrentOwner && !params.isCurrentOwner()) return;
- const firstMessageClientId = createUuid();
+ const firstMessageClientId = params.firstMessageClientId ?? createUuid();
const firstMessageSessionRefs = extractMobileSessionReferences(
params.draft.firstMessage,
remoteSessionStore.getSessionDeviceId,
@@ -986,7 +988,7 @@ async function runPipeline(task: InternalTask): Promise<void> {
freshSession = null;
}
- if (params.planModeArm) {
+ if (params.planModeArm && !params.transport.handoffFirstMessage) {
// 新协议:入队首条消息前武装计划模式,失败降级为普通发送(对齐原 create())。
assertTaskOwnerCurrent(task);
try {
@@ -1026,6 +1028,18 @@ async function runPipeline(task: InternalTask): Promise<void> {
task.firstMessageClientId,
{ attachments: [...params.attachments] },
), task.firstMessageSessionRefs);
+ if (params.transport.handoffFirstMessage) {
+ try {
+ await params.transport.handoffFirstMessage(queuedDraft);
+ assertTaskOwnerCurrent(task);
+ remoteSessionStore.applySessionPatch(params.deviceId, sessionId, { pendingLocalCreation: false });
+ finishTask(task);
+ } catch (error) {
+ if (isStaleNewSessionOwnerError(error)) throw error;
+ failTask(task, 'enqueue-failed', formatRemoteError(error));
+ }
+ return;
+ }
let queued = queuedDraft;
if (params.transport.prepareQueuedMessage) {
try {
diff --git a/apps/mobile/src/session/sessionOutbox.ts b/apps/mobile/src/session/sessionOutbox.ts
index 705aa86a13..b4eb17683e 100644
--- a/apps/mobile/src/session/sessionOutbox.ts
+++ b/apps/mobile/src/session/sessionOutbox.ts
@@ -1,27 +1,7 @@
/**
- * sessionOutbox.ts — 会话页本地待发队列(outbox)的纯状态模型。
- * ---------------------------------------------------------------------------
- * 带附件消息的乐观发送:点发送时附件可能仍在上传,消息不再卡在 composer 等
- * waitForPendingUploads,而是立刻以「outbox 条目」形态进消息流(InlineQueueSection
- * 尾部,气泡带上传进度),后台等附件落定后按 FIFO 逐条真正 enqueue 给被控端。
- *
- * 不变量:
- * - FIFO:只有队首条目可以 dispatch(附件齐 + 无失败),后发消息(含纯文本)在
- * outbox 非空时必须排在其后,保证到达被控端的顺序与用户发送顺序一致;
- * - 失败阻塞:任一条目失败(附件上传失败 / enqueue 失败)时它留在队首挡住后续,
- * 用户重试或删除后队列继续——静默跳过会打乱顺序预期;
- * - 附件槽位:发送时刻已就绪的附件占前段槽位,在途上传按托盘顺序占后段,
- * onUploaded 按 localId 填槽,全部就位后按槽序组装,附件顺序与用户所见一致。
- *
- * 本模块只做纯数据变换(node 可单测);上传路由、enqueue RPC、React state 接线
- * 在 [sessionId].tsx。
- *
- * 生命周期边界:队列只拥有尚未开始 enqueue、或能证明请求尚未发出的条目,并在当前
- * 会话页存活期间自动重连续发。正常切任务 / 退屏由页面 cleanup 把这些正文接回草稿;
- * 一旦 enqueue 已开始,所有权转给既有在线发送 / optimistic projection 路径,回执不确定
- * 的写请求绝不重新降级成会丢 clientId 的草稿。若未来要跨页面或跨进程继续自动重试,
- * 必须单独设计可对账的 outbox owner,不能把草稿库当 write-ahead log(它没有消息边界、
- * 附件任务或远端 acceptance 状态)。
+ * Mobile message snapshots and presentation helpers. App-level persistence and delivery
+ * live in durableOutbox.ts / durableOutboxDelivery.ts; this module has no page ownership.
+ * Recovery helpers remain for legacy direct sends and composer editing.
*/
import { i18n } from '@/i18n';
import type { MobileSessionReference } from '@/session/sessionReferences';
@@ -126,6 +106,8 @@ export interface MobileOutboxItem {
* store 拿到的已是恢复后的值,消息本身必须仍按发送时刻的档位派发。
*/
permissionModeAtSend: string;
+ /** 新协议的单条 Plan 快照;旧记录缺失时保留原协议语义。 */
+ planModeAtSend?: boolean;
/** 附件槽位(按用户可见顺序);null = 对应上传任务尚未落定。 */
attachmentSlots: ReadonlyArray<RemoteSerializedAttachment | null>;
/**
@@ -206,6 +188,7 @@ export function buildOutboxItem(input: {
pastedTextRanges?: Array<{ start: number; end: number; display: string }>;
slashCommandRanges?: Array<{ start: number; end: number }>;
permissionModeAtSend: string;
+ planModeAtSend?: boolean;
/** 发送时刻已就绪的附件(占前段槽位)。 */
readyAttachments: readonly RemoteSerializedAttachment[];
/** 就绪附件的本地预览 uri(与 readyAttachments 对齐;缺失传 null)。 */
@@ -248,6 +231,7 @@ export function buildOutboxItem(input: {
pastedTextRanges: input.pastedTextRanges ?? [],
slashCommandRanges: input.slashCommandRanges ?? [],
permissionModeAtSend: input.permissionModeAtSend,
+ ...(input.planModeAtSend !== undefined ? { planModeAtSend: input.planModeAtSend } : {}),
attachmentSlots: slots,
slotMeta,
slotByLocalId,
diff --git a/apps/mobile/src/session/types.ts b/apps/mobile/src/session/types.ts
index 132df5a02e..f834a5ff84 100644
--- a/apps/mobile/src/session/types.ts
+++ b/apps/mobile/src/session/types.ts
@@ -183,6 +183,7 @@ export interface RemoteSerializedAttachment {
}
export interface QueuedRemoteMessage {
+ durableDelivery?: true;
clientId: string;
text: string;
persistedContent: string;
diff --git a/apps/mobile/src/session/useMobileLocalAttachments.ts b/apps/mobile/src/session/useMobileLocalAttachments.ts
index 4f789a4263..42164e8f76 100644
--- a/apps/mobile/src/session/useMobileLocalAttachments.ts
+++ b/apps/mobile/src/session/useMobileLocalAttachments.ts
@@ -19,6 +19,7 @@ import { useTranslation } from 'react-i18next';
import { Platform } from 'react-native';
import * as DocumentPicker from 'expo-document-picker';
import * as FileSystem from 'expo-file-system/legacy';
+import { retainComposerAttachmentFile } from './durableOutboxFiles';
import * as ImagePicker from 'expo-image-picker';
import { formatRemoteError } from '@/device-link/remoteStatus';
import { canBrowsePhotoLibraryDirectly } from '@/session/photoLibraryPolicy';
@@ -93,6 +94,9 @@ async function deleteLocalUris(uris: readonly string[]): Promise<void> {
}
export interface UseMobileLocalAttachmentsResult {
+ beginOutboxAttachmentHandoff: () => Promise<ReturnType<MobileLocalAttachmentUploadController['beginHandoff']>>;
+ getUploadedSource: (id: string) => MobileLocalAttachmentUploadCandidate | undefined;
+ releaseUploadedSources: (ids: readonly string[]) => void;
/** 上传中的附件(托盘渲染 pending 卡)。 */
pendingUploads: readonly PendingLocalAttachmentUpload[];
/**
@@ -262,6 +266,9 @@ export function useMobileLocalAttachments(
optionsRef.current.onError(t('composer.upload.clipboardReadFailed'));
};
+ const uploadedSourcesRef = useRef(new Map<string, MobileLocalAttachmentUploadCandidate>());
+ const stagingUrisRef = useRef(new Set<string>());
+ const stagingOwnerRef = useRef(`${Date.now()}-${Math.random().toString(36).slice(2)}`);
const controller = useMemo(() => createMobileLocalAttachmentUploadController({
preprocess: preprocessMobileImageForUpload,
statSize: statMobileAttachmentFileSize,
@@ -270,8 +277,8 @@ export function useMobileLocalAttachments(
else assertMobileDocumentSize(size);
},
upload: (candidate, fileUri, opts) => uploadMobileAttachmentFromFile(candidate, fileUri, { ...opts, sharedTaskId: candidate.sharedTaskId }),
- discard: (attachment) => discardMobileUploadedAttachment(attachment, {
- getToken: () => optionsRef.current.getAccessToken(),
+ discard: (attachment, token) => discardMobileUploadedAttachment(attachment, {
+ getToken: () => token === undefined ? optionsRef.current.getAccessToken() : Promise.resolve(token),
}),
onPendingChange: setPendingUploads,
onUploaded: async (attachment, candidate, uploadedUri, localId, localUris, isActive) => {
@@ -310,6 +317,19 @@ export function useMobileLocalAttachments(
for (const uri of localUris) pastedImageLocalUrisRef.current.add(uri);
}
if (!isActive()) return;
+ // Keep the actual PUT bytes for all file kinds until the composer hands them off.
+ // Thumbnail caches are evictable and cannot be the only source of an unsent attachment.
+ const stageUri = await retainComposerAttachmentFile(stagingOwnerRef.current, attachment.id, uploadedUri, attachment.size);
+ stagingUrisRef.current.add(stageUri);
+ if (!isActive()) {
+ await FileSystem.deleteAsync(stageUri, { idempotent: true });
+ stagingUrisRef.current.delete(stageUri);
+ return;
+ }
+ uploadedSourcesRef.current.set(attachment.id, {
+ ...candidate, uri: stageUri, name: attachment.name, mimeType: attachment.mimeType,
+ size: attachment.size, resolve: undefined, skipPreprocess: true, cleanupLocalUris: undefined,
+ });
optionsRef.current.onUploaded(attachment, deliveredCandidate, localId);
if (candidate.cleanupLocalUris) {
// 只有持久缩略图已经接管 composer / sent-message 预览后才删源文件;
@@ -376,7 +396,10 @@ export function useMobileLocalAttachments(
useEffect(() => () => {
controller.dispose();
- const pastedUris = [...pastedImageLocalUrisRef.current];
+ const pastedUris = [...pastedImageLocalUrisRef.current].filter((uri) => !controller.isRetainingUri(uri));
+ void deleteLocalUris([...stagingUrisRef.current]);
+ stagingUrisRef.current.clear();
+ uploadedSourcesRef.current.clear();
pastedImageLocalUrisRef.current.clear();
if (pastedUris.length > 0) void deleteLocalUris(pastedUris);
if (pastePlaceholderTimerRef.current) {
@@ -562,6 +585,25 @@ export function useMobileLocalAttachments(
};
return {
+ beginOutboxAttachmentHandoff: async () => {
+ for (;;) {
+ await controller.waitForDelivering();
+ try { return controller.beginHandoff(); }
+ catch (error) {
+ if (!(error instanceof Error) || error.message !== 'ATTACHMENT_DELIVERING') throw error;
+ }
+ }
+ },
+ getUploadedSource: (id) => uploadedSourcesRef.current.get(id),
+ releaseUploadedSources: (ids) => {
+ for (const id of ids) {
+ const source = uploadedSourcesRef.current.get(id);
+ if (!source) continue;
+ uploadedSourcesRef.current.delete(id);
+ stagingUrisRef.current.delete(source.uri);
+ void deleteLocalUris([source.uri]);
+ }
+ },
pendingUploads,
pastePlaceholderCount,
beginPastePlaceholders,
diff --git a/docs/design-rules/design-inventory.md b/docs/design-rules/design-inventory.md
index 29b70b0458..5664576b1a 100644
--- a/docs/design-rules/design-inventory.md
+++ b/docs/design-rules/design-inventory.md
@@ -51,21 +51,21 @@
| `desktop.window.sidebar` | desktop | 右侧栏独立窗口 | `?sidebarWindow=1` → renderer/sidebar-window-entry.tsx;hash `/sidebar-window` | RightSidebar, RightSidebarShell, SidebarWindowLayout | apps/desktop/src/main/right-sidebar-window/controller.ts, apps/desktop/src/main/right-sidebar-window/ipc.ts, apps/desktop/src/main/right-sidebar-window/registry.ts, apps/desktop/src/main/right-sidebar-window/resolveHostContext.ts, apps/desktop/src/main/right-sidebar-window/settings-store.ts, apps/desktop/src/main/right-sidebar-window/window.ts, apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx, apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx, apps/desktop/src/renderer/features/right-sidebar/EmptyState.tsx, apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBodyErrorBoundary.tsx, apps/desktop/src/renderer/features/right-sidebar/hooks/useBrowserWebview.ts, apps/desktop/src/renderer/features/right-sidebar/hooks/useNativePopupSurface.ts, apps/desktop/src/renderer/features/right-sidebar/iosSimulatorPluginAvailability.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserPartition.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserWebviewPool.ts, apps/desktop/src/renderer/features/right-sidebar/lib/detachedSidebarRouting.ts, apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts, apps/desktop/src/renderer/features/right-sidebar/lib/iosSimulatorFocusBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/lastTurnChangedFiles.ts, apps/desktop/src/renderer/features/right-sidebar/lib/nativePopupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openBackgroundTasksTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarFileBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openRoutinesTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openSubagentsTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTerminalShortcut.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTurnReview.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupRouter.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/rsbBrowserBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarCommands.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarHostSession.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowProgressTree.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/chatTaskFocusIntent.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/workflowProgressModel.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/CindyMakeTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.css, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/dropExternalFile.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/fileTreeImagePreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/useSessionScopedTreeWidth.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/iosSimulatorH264Decoder.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersAttentionIcon.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/actions.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/closeDecision.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/ResourceUsageBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/resource-usage.css, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/subscription.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/ImageDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/MarkdownDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/PlainUnifiedDiff.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/diffRows.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/highlight.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/inlineDiff.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/useDiffHighlights.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/ReviewTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/diffExpansionPreference.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/fileTree.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/gitApplyCommand.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/markdownPreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useLastTurnFilter.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewGitState.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewSource.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/routines/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/ConversationStream.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/DetailView.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/RunList.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentToolCard.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentChangeFence.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentConversation.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentFormat.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/TerminalTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/lib/xtermPool.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/browserCommentEditorDraft.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/lib/parseOmnibox.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useBrowserComment.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useLocalHtmlAutoReload.ts, apps/desktop/src/renderer/features/right-sidebar/registry.ts, apps/desktop/src/renderer/features/right-sidebar/store.ts, apps/desktop/src/renderer/features/right-sidebar/types.ts, apps/desktop/src/renderer/sidebar-window-entry.tsx, apps/desktop/src/renderer/styles/generated/tokens.css, apps/desktop/src/renderer/styles/globals.css | 103 | 45 | 180 |
| `desktop.window.voice-dictionary-toast` | desktop | 语音词典 Toast 窗 | `?view=voice-input-dictionary-toast` → main-entry.tsx → VoiceInputDictionaryToast | VoiceInputDictionaryToast | apps/desktop/src/renderer/voice-input/VoiceInputDictionaryToast.tsx | 6 | 0 | 2 |
| `desktop.window.voice-overlay` | desktop | 语音输入浮窗 | `?view=voice-input-overlay` → main-entry.tsx → VoiceInputOverlay | VoiceInputOverlay, VoiceInputStatusNotice | apps/desktop/src/main/voice-input/global.ts, apps/desktop/src/renderer/styles/generated/tokens.css, apps/desktop/src/renderer/styles/globals.css, apps/desktop/src/renderer/voice-input/VoiceInputOverlay.tsx, apps/desktop/src/renderer/voice-input/VoiceInputStatusNotice.tsx | 69 | 38 | 19 |
-| `mobile.account-deletion` | mobile | 账号注销 | app/account-deletion.tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, account-deletion, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/account-deletion.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 58 |
-| `mobile.auth` | mobile | 登录与添加账号 | app/(auth)/login.tsx / app/add-account.tsx | AccountSwitcherSheet, AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, IncomingShareBridge, LoginCaptchaWebView, LoginNativeButton, LoginNativeButton.ios, LoginSkinControls, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, StartupSplashOverlay, SystemNavigationBack, 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/LoginNativeButton.ios.tsx, apps/mobile/src/components/LoginNativeButton.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SystemNavigationBack.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 211 | 80 |
-| `mobile.automations` | mobile | 自动化 | app/automations/[deviceId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, 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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 74 |
-| `mobile.chat.new` | mobile | 新建任务 | app/sessions/new.tsx | AdaptiveWindow, 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, FileTypeIcon, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, 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, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, NewTaskSelectionSheet, NewTaskSelectionSheet.ios, PaperPlaneIcon, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, 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/FileTypeIcon.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.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/NativeResidentHistory.tsx, apps/mobile/src/session/NewTaskSelectionSheet.ios.tsx, apps/mobile/src/session/NewTaskSelectionSheet.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 236 | 113 |
-| `mobile.chat.session` | mobile | 任务内容与输入 | app/sessions/[sessionId].tsx | AccountSwitcherSheet, AdaptiveWindow, AndroidUpdateSheet, AnnotationBurnInWebView, AppText, AuthContext, AuthorizationMessageCard, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ChatFileChipMenuSheet, CompanionAutomationNativeView, CompanionAutomationNativeView.ios, CompanionAutomationSheet, CompanionChoice, CompanionCreateNativeView, CompanionCreateNativeView.ios, CompanionHeader, CompanionMessageActions, CompanionMessageCard, CompanionModelChain, CompanionNativeContent.ios, CompanionNavigationDrawer, CompanionPortraitPicker, CompanionProfileArtifacts, CompanionProfileNativeView, CompanionProfileNativeView.ios, CompanionProfileSheet, CompanionSettingsRow, CompanionSettingsRow.ios, CompanionSheet, CompanionSheet.ios, CompanionWorkingStatus, 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, FileTypeIcon, FoldTouchpad, HomeChromeDrawer, HomeChromeFrost, HomeEntryProvider, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeListVisuals, HomeModeSwitch, HomeNativeStackHeader, HomeNewTaskButton, HomeProjectMachineLabel, HomeSearchBar, HomeSurface, ImageLightbox, IncomingShareBridge, InlineQueueSection, InlineQuoteChip, InlineReferenceChip, InteractionPanel, LoginNativeButton, LoginNativeButton.ios, MarkdownBlockContent, MessageActionSheet, MessageRenderer, MobileAgentMark, MobileAgentSwitcher, MobileBoundaryNotice, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobileModelPickerList.ios, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, MobileVendorIcon, ModalContentArea, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PaperPlaneIcon, PendingSendBubble, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PluginInvocationHeader, PromptRecommendation, PushNotificationsBridge, QuietSyncIndicator, QuoteCapsule, RecentMessageHistories, RemoteAccessGuide, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteTaskSuggestions, RenameSessionModal, ResidentHomeList, RewindPreviewPanel, SentInlineAtomBody, SessionActionSheet, SessionDetailsNative, SessionDetailsNative.ios, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionListDrawer, SessionMenuSheet, SessionOptionsExpoSheet, SessionResourceCards, SessionSearchNative, SessionSearchNative.ios, SessionTailBanner, SessionUsageSummary, ShareImageNativeButton, ShareImageNativeButton.ios, ShareMessageCheckbox, ShareSelectAllButton, ShareSelectionBar, SharedTaskEndedState, SharedTaskScreen, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, StreamingStatusText, SwipeableSessionRow, SwipeableSessionRow.ios, SystemNavigationBack, TaskTags, TaskTagsSheet, TeammateList, TeammatePicker, ThemeProvider, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, VoiceRecordingPill, [sessionId], _layout, gestureHandler, mathWebView, mediaPlayerWebView, mermaidWebView, peerFileTransport, useLocale, useSharedTaskConfirmation | 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/FileTypeIcon.tsx, apps/mobile/src/components/LoginNativeButton.ios.tsx, apps/mobile/src/components/LoginNativeButton.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/RemoteAccessGuide.tsx, apps/mobile/src/components/RemoteCompanionAvatar.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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/chrome/SystemNavigationBack.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.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/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/AuthorizationMessageCard.tsx, apps/mobile/src/session/AutomationTimerIcon.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ChatFileChipMenuSheet.tsx, apps/mobile/src/session/CompanionAutomationNativeView.ios.tsx, apps/mobile/src/session/CompanionAutomationNativeView.tsx, apps/mobile/src/session/CompanionAutomationSheet.tsx, apps/mobile/src/session/CompanionChoice.tsx, apps/mobile/src/session/CompanionCreateNativeView.ios.tsx, apps/mobile/src/session/CompanionCreateNativeView.tsx, apps/mobile/src/session/CompanionHeader.tsx, apps/mobile/src/session/CompanionMessageActions.tsx, apps/mobile/src/session/CompanionMessageCard.tsx, apps/mobile/src/session/CompanionModelChain.tsx, apps/mobile/src/session/CompanionNativeContent.ios.tsx, apps/mobile/src/session/CompanionNavigationDrawer.tsx, apps/mobile/src/session/CompanionPortraitPicker.tsx, apps/mobile/src/session/CompanionProfileArtifacts.tsx, apps/mobile/src/session/CompanionProfileNativeView.ios.tsx, apps/mobile/src/session/CompanionProfileNativeView.tsx, apps/mobile/src/session/CompanionProfileSheet.tsx, apps/mobile/src/session/CompanionSettingsRow.ios.tsx, apps/mobile/src/session/CompanionSettingsRow.tsx, apps/mobile/src/session/CompanionSheet.ios.tsx, apps/mobile/src/session/CompanionSheet.tsx, apps/mobile/src/session/CompanionWorkingStatus.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/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.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeListVisuals.tsx, apps/mobile/src/session/HomeModeSwitch.tsx, apps/mobile/src/session/HomeNewTaskButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/HomeSurface.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/NativeResidentHistory.tsx, apps/mobile/src/session/PendingSendBubble.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/PluginInvocationHeader.tsx, apps/mobile/src/session/PromptRecommendation.tsx, apps/mobile/src/session/QuoteCapsule.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/RewindPreviewPanel.tsx, apps/mobile/src/session/SentInlineAtomBody.tsx, apps/mobile/src/session/SessionActionSheet.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/SessionOptionsExpoSheet.tsx, apps/mobile/src/session/SessionResourceCards.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/SharedTaskEndedState.tsx, apps/mobile/src/session/SharedTaskScreen.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/SwipeableSessionRow.ios.tsx, apps/mobile/src/session/SwipeableSessionRow.tsx, apps/mobile/src/session/TaskTags.tsx, apps/mobile/src/session/TaskTagsSheet.tsx, apps/mobile/src/session/TeammateList.tsx, apps/mobile/src/session/TeammatePicker.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/session/useSharedTaskConfirmation.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 | 7 | 237 | 298 |
-| `mobile.chat.sharing` | mobile | 共享任务邀请与成员 | app/shared-session.tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SharedTaskEndedState, SharedTaskScreen, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, peerFileTransport, shared-session, useLocale, useSharedTaskConfirmation | apps/mobile/app/_layout.tsx, apps/mobile/app/shared-session.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SharedTaskEndedState.tsx, apps/mobile/src/session/SharedTaskScreen.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/useSharedTaskConfirmation.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 | 204 | 61 |
-| `mobile.companions.direct` | mobile | 伙伴私聊回看 | app/companions/direct/[threadId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, 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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 53 |
-| `mobile.device-management` | mobile | 设备管理 | app/devices/manage.tsx / app/devices/manage/[deviceId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceInformationFields, DeviceInformationFields.ios, DeviceLinkContext, DeviceManagementDialogs, DeviceManagementList, DeviceManagementList.ios, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, ModalContentArea, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RenameDeviceModal, ResidentHomeList, 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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RenameDeviceModal.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 56 |
-| `mobile.devices` | mobile | 主机详情 | app/devices/[deviceId].tsx | AccountSwitcherSheet, AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ConversationSearchFilterSheet, DeviceLinkContext, FoldTouchpad, HomeChromeDrawer, HomeChromeFrost, HomeEntryProvider, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeListVisuals, HomeModeSwitch, HomeNativeStackHeader, HomeNewTaskButton, HomeProjectMachineLabel, HomeSearchBar, HomeSurface, IncomingShareBridge, LoginNativeButton, LoginNativeButton.ios, MobileAgentMark, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, MobileVendorIcon, ModalContentArea, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteAccessGuide, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteTaskSuggestions, RenameSessionModal, ResidentHomeList, SessionActionSheet, SessionDetailsNative, SessionDetailsNative.ios, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionOptionsExpoSheet, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, SwipeableSessionRow, SwipeableSessionRow.ios, TaskTags, ThemeProvider, [deviceId], _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/[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/LoginNativeButton.ios.tsx, apps/mobile/src/components/LoginNativeButton.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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/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/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.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeListVisuals.tsx, apps/mobile/src/session/HomeModeSwitch.tsx, apps/mobile/src/session/HomeNewTaskButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/HomeSurface.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SessionActionSheet.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/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/session/TaskTags.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 | 204 | 113 |
-| `mobile.files` | mobile | 任务文件与预览 | app/files/[sessionId].tsx / app/files/preview/[sessionId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FileTypeIcon, FileTypeTile, FoldTouchpad, HomeEntryProvider, HtmlBrowserChrome, HtmlBrowserChrome.ios, HtmlFileReader, HtmlWebsiteBrowser, ImageLightbox, IncomingShareBridge, MarkdownFileReader, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, ModalContentArea, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, StartupSplashOverlay, SystemNavigationBack, ThemeProvider, [sessionId], _layout, gestureHandler, mediaPlayerWebView, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/files/[sessionId].tsx, apps/mobile/app/files/preview/[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/FileTypeIcon.tsx, apps/mobile/src/components/FileTypeTile.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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SystemNavigationBack.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.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/RemoteDesktopWindows.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/HtmlBrowserChrome.ios.tsx, apps/mobile/src/session/HtmlBrowserChrome.tsx, apps/mobile/src/session/HtmlFileReader.tsx, apps/mobile/src/session/HtmlWebsiteBrowser.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MarkdownFileReader.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/mathWebViewHtml.ts, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.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 | 0 | 236 | 79 |
-| `mobile.home` | mobile | 主机与资源首页 | app/index.tsx / app/devices/index.tsx | AccountSwitcherSheet, AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, AutomationTimerIcon, BlurBackdrop, CenteredScreen, CompanionCreateNativeView, CompanionCreateNativeView.ios, CompanionModelChain, CompanionNativeContent.ios, CompanionPortraitPicker, CompanionProfileArtifacts, CompanionProfileNativeView, CompanionProfileNativeView.ios, CompanionProfileSheet, CompanionSettingsRow, CompanionSettingsRow.ios, CompanionSheet, CompanionSheet.ios, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ConversationSearchFilterSheet, DeviceLinkContext, FoldTouchpad, HomeChromeDrawer, HomeChromeFrost, HomeEntryProvider, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeListVisuals, HomeModePanes, HomeModeSwitch, HomeNativeStackHeader, HomeNewTaskButton, HomeProjectMachineLabel, HomeSearchBar, HomeSurface, IncomingShareBridge, LoginNativeButton, LoginNativeButton.ios, MobileAgentMark, MobileAgentSwitcher, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobileModelPickerList.ios, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, MobileVendorIcon, ModalContentArea, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteAccessGuide, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteTaskSuggestions, RenameSessionModal, ResidentHomeList, SessionActionSheet, SessionDetailsNative, SessionDetailsNative.ios, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionOptionsExpoSheet, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, SwipeableSessionRow, SwipeableSessionRow.ios, TaskTags, TeammateCreateButton, TeammateHomeScreen, TeammateList, ThemeProvider, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, _layout, gestureHandler, index, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/index.tsx, apps/mobile/app/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/LoginNativeButton.ios.tsx, apps/mobile/src/components/LoginNativeButton.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/RemoteCompanionAvatar.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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/CompanionCreateNativeView.ios.tsx, apps/mobile/src/session/CompanionCreateNativeView.tsx, apps/mobile/src/session/CompanionModelChain.tsx, apps/mobile/src/session/CompanionNativeContent.ios.tsx, apps/mobile/src/session/CompanionPortraitPicker.tsx, apps/mobile/src/session/CompanionProfileArtifacts.tsx, apps/mobile/src/session/CompanionProfileNativeView.ios.tsx, apps/mobile/src/session/CompanionProfileNativeView.tsx, apps/mobile/src/session/CompanionProfileSheet.tsx, apps/mobile/src/session/CompanionSettingsRow.ios.tsx, apps/mobile/src/session/CompanionSettingsRow.tsx, apps/mobile/src/session/CompanionSheet.ios.tsx, apps/mobile/src/session/CompanionSheet.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/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.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeListVisuals.tsx, apps/mobile/src/session/HomeModePanes.tsx, apps/mobile/src/session/HomeModeSwitch.tsx, apps/mobile/src/session/HomeNewTaskButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/HomeSurface.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileAgentSwitcher.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/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SessionActionSheet.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/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/session/TaskTags.tsx, apps/mobile/src/session/TeammateCreateButton.tsx, apps/mobile/src/session/TeammateHomeScreen.tsx, apps/mobile/src/session/TeammateList.tsx, apps/mobile/src/session/UnifiedModelPickerSheet.tsx, apps/mobile/src/session/UnifiedModelPickerView.ios.tsx, apps/mobile/src/session/UnifiedModelPickerView.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 | 204 | 134 |
-| `mobile.overlay.connection-startup` | mobile | 根布局挂载的启动与连接反馈 | app/_layout.tsx → StartupSplashOverlay / ConnectionNoticeProvider;各页面 ConnectionBanner | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ConnectionNoticeProvider, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 50 |
-| `mobile.remote-desktop` | mobile | 远程桌面 | app/devices/desktop/[deviceId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/desktop/[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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 50 |
-| `mobile.resources` | mobile | 远程资源列表与详情 | app/resources/[collectionId].tsx / app/resources/[collectionId]/[resourceId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, TeammateList, ThemeProvider, [collectionId], [resourceId], _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/resources/[collectionId].tsx, apps/mobile/app/resources/[collectionId]/[resourceId].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/RemoteCompanionAvatar.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/TeammateList.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 | 204 | 61 |
-| `mobile.settings` | mobile | 设置(含调试与日志上传可见入口) | app/settings.tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileChoicePickerList, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, peerFileTransport, settings, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/settings.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileChoicePickerList.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 59 |
+| `mobile.account-deletion` | mobile | 账号注销 | app/account-deletion.tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, account-deletion, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/account-deletion.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 58 |
+| `mobile.auth` | mobile | 登录与添加账号 | app/(auth)/login.tsx / app/add-account.tsx | AccountSwitcherSheet, AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, IncomingShareBridge, LoginCaptchaWebView, LoginNativeButton, LoginNativeButton.ios, LoginSkinControls, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, StartupSplashOverlay, SystemNavigationBack, 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/LoginNativeButton.ios.tsx, apps/mobile/src/components/LoginNativeButton.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SystemNavigationBack.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 211 | 80 |
+| `mobile.automations` | mobile | 自动化 | app/automations/[deviceId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, 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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 74 |
+| `mobile.chat.new` | mobile | 新建任务 | app/sessions/new.tsx | AdaptiveWindow, 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, FileTypeIcon, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, ImageLightbox, IncomingShareBridge, MobileAgentMark, MobileAgentSwitcher, MobileChoicePickerList, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobileModelPickerList.ios, MobileOutboxBridge, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, MobileVendorIcon, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, NewTaskSelectionSheet, NewTaskSelectionSheet.ios, PaperPlaneIcon, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, 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/FileTypeIcon.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.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/MobileOutboxBridge.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/NativeResidentHistory.tsx, apps/mobile/src/session/NewTaskSelectionSheet.ios.tsx, apps/mobile/src/session/NewTaskSelectionSheet.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 236 | 113 |
+| `mobile.chat.session` | mobile | 任务内容与输入 | app/sessions/[sessionId].tsx | AccountSwitcherSheet, AdaptiveWindow, AndroidUpdateSheet, AnnotationBurnInWebView, AppText, AuthContext, AuthorizationMessageCard, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ChatFileChipMenuSheet, CompanionAutomationNativeView, CompanionAutomationNativeView.ios, CompanionAutomationSheet, CompanionChoice, CompanionCreateNativeView, CompanionCreateNativeView.ios, CompanionHeader, CompanionMessageActions, CompanionMessageCard, CompanionModelChain, CompanionNativeContent.ios, CompanionNavigationDrawer, CompanionPortraitPicker, CompanionProfileArtifacts, CompanionProfileNativeView, CompanionProfileNativeView.ios, CompanionProfileSheet, CompanionSettingsRow, CompanionSettingsRow.ios, CompanionSheet, CompanionSheet.ios, CompanionWorkingStatus, 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, FileTypeIcon, FoldTouchpad, HomeChromeDrawer, HomeChromeFrost, HomeEntryProvider, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeListVisuals, HomeModeSwitch, HomeNativeStackHeader, HomeNewTaskButton, HomeProjectMachineLabel, HomeSearchBar, HomeSurface, ImageLightbox, IncomingShareBridge, InlineQueueSection, InlineQuoteChip, InlineReferenceChip, InteractionPanel, LoginNativeButton, LoginNativeButton.ios, MarkdownBlockContent, MessageActionSheet, MessageRenderer, MobileAgentMark, MobileAgentSwitcher, MobileBoundaryNotice, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobileModelPickerList.ios, MobileOutboxBridge, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, MobileVendorIcon, ModalContentArea, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PaperPlaneIcon, PendingSendBubble, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PluginInvocationHeader, PromptRecommendation, PushNotificationsBridge, QuietSyncIndicator, QuoteCapsule, RecentMessageHistories, RemoteAccessGuide, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteTaskSuggestions, RenameSessionModal, ResidentHomeList, RewindPreviewPanel, SentInlineAtomBody, SessionActionSheet, SessionDetailsNative, SessionDetailsNative.ios, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionListDrawer, SessionMenuSheet, SessionOptionsExpoSheet, SessionResourceCards, SessionSearchNative, SessionSearchNative.ios, SessionTailBanner, SessionUsageSummary, ShareImageNativeButton, ShareImageNativeButton.ios, ShareMessageCheckbox, ShareSelectAllButton, ShareSelectionBar, SharedTaskEndedState, SharedTaskScreen, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, StreamingStatusText, SwipeableSessionRow, SwipeableSessionRow.ios, SystemNavigationBack, TaskTags, TaskTagsSheet, TeammateList, TeammatePicker, ThemeProvider, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, VoiceRecordingPill, [sessionId], _layout, gestureHandler, mathWebView, mediaPlayerWebView, mermaidWebView, peerFileTransport, useLocale, useSharedTaskConfirmation | 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/FileTypeIcon.tsx, apps/mobile/src/components/LoginNativeButton.ios.tsx, apps/mobile/src/components/LoginNativeButton.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/RemoteAccessGuide.tsx, apps/mobile/src/components/RemoteCompanionAvatar.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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/chrome/SystemNavigationBack.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.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/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/AuthorizationMessageCard.tsx, apps/mobile/src/session/AutomationTimerIcon.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ChatFileChipMenuSheet.tsx, apps/mobile/src/session/CompanionAutomationNativeView.ios.tsx, apps/mobile/src/session/CompanionAutomationNativeView.tsx, apps/mobile/src/session/CompanionAutomationSheet.tsx, apps/mobile/src/session/CompanionChoice.tsx, apps/mobile/src/session/CompanionCreateNativeView.ios.tsx, apps/mobile/src/session/CompanionCreateNativeView.tsx, apps/mobile/src/session/CompanionHeader.tsx, apps/mobile/src/session/CompanionMessageActions.tsx, apps/mobile/src/session/CompanionMessageCard.tsx, apps/mobile/src/session/CompanionModelChain.tsx, apps/mobile/src/session/CompanionNativeContent.ios.tsx, apps/mobile/src/session/CompanionNavigationDrawer.tsx, apps/mobile/src/session/CompanionPortraitPicker.tsx, apps/mobile/src/session/CompanionProfileArtifacts.tsx, apps/mobile/src/session/CompanionProfileNativeView.ios.tsx, apps/mobile/src/session/CompanionProfileNativeView.tsx, apps/mobile/src/session/CompanionProfileSheet.tsx, apps/mobile/src/session/CompanionSettingsRow.ios.tsx, apps/mobile/src/session/CompanionSettingsRow.tsx, apps/mobile/src/session/CompanionSheet.ios.tsx, apps/mobile/src/session/CompanionSheet.tsx, apps/mobile/src/session/CompanionWorkingStatus.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/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.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeListVisuals.tsx, apps/mobile/src/session/HomeModeSwitch.tsx, apps/mobile/src/session/HomeNewTaskButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/HomeSurface.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/MobileOutboxBridge.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/NativeResidentHistory.tsx, apps/mobile/src/session/PendingSendBubble.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/PluginInvocationHeader.tsx, apps/mobile/src/session/PromptRecommendation.tsx, apps/mobile/src/session/QuoteCapsule.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/RewindPreviewPanel.tsx, apps/mobile/src/session/SentInlineAtomBody.tsx, apps/mobile/src/session/SessionActionSheet.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/SessionOptionsExpoSheet.tsx, apps/mobile/src/session/SessionResourceCards.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/SharedTaskEndedState.tsx, apps/mobile/src/session/SharedTaskScreen.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/SwipeableSessionRow.ios.tsx, apps/mobile/src/session/SwipeableSessionRow.tsx, apps/mobile/src/session/TaskTags.tsx, apps/mobile/src/session/TaskTagsSheet.tsx, apps/mobile/src/session/TeammateList.tsx, apps/mobile/src/session/TeammatePicker.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/session/useSharedTaskConfirmation.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 | 7 | 237 | 298 |
+| `mobile.chat.sharing` | mobile | 共享任务邀请与成员 | app/shared-session.tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SharedTaskEndedState, SharedTaskScreen, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, peerFileTransport, shared-session, useLocale, useSharedTaskConfirmation | apps/mobile/app/_layout.tsx, apps/mobile/app/shared-session.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SharedTaskEndedState.tsx, apps/mobile/src/session/SharedTaskScreen.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/useSharedTaskConfirmation.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 | 204 | 61 |
+| `mobile.companions.direct` | mobile | 伙伴私聊回看 | app/companions/direct/[threadId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, 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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 53 |
+| `mobile.device-management` | mobile | 设备管理 | app/devices/manage.tsx / app/devices/manage/[deviceId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceInformationFields, DeviceInformationFields.ios, DeviceLinkContext, DeviceManagementDialogs, DeviceManagementList, DeviceManagementList.ios, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, ModalContentArea, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RenameDeviceModal, ResidentHomeList, 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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RenameDeviceModal.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 56 |
+| `mobile.devices` | mobile | 主机详情 | app/devices/[deviceId].tsx | AccountSwitcherSheet, AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ConversationSearchFilterSheet, DeviceLinkContext, FoldTouchpad, HomeChromeDrawer, HomeChromeFrost, HomeEntryProvider, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeListVisuals, HomeModeSwitch, HomeNativeStackHeader, HomeNewTaskButton, HomeProjectMachineLabel, HomeSearchBar, HomeSurface, IncomingShareBridge, LoginNativeButton, LoginNativeButton.ios, MobileAgentMark, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, MobileVendorIcon, ModalContentArea, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteAccessGuide, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteTaskSuggestions, RenameSessionModal, ResidentHomeList, SessionActionSheet, SessionDetailsNative, SessionDetailsNative.ios, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionOptionsExpoSheet, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, SwipeableSessionRow, SwipeableSessionRow.ios, TaskTags, ThemeProvider, [deviceId], _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/[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/LoginNativeButton.ios.tsx, apps/mobile/src/components/LoginNativeButton.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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/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/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.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeListVisuals.tsx, apps/mobile/src/session/HomeModeSwitch.tsx, apps/mobile/src/session/HomeNewTaskButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/HomeSurface.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SessionActionSheet.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/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/session/TaskTags.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 | 204 | 113 |
+| `mobile.files` | mobile | 任务文件与预览 | app/files/[sessionId].tsx / app/files/preview/[sessionId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FileTypeIcon, FileTypeTile, FoldTouchpad, HomeEntryProvider, HtmlBrowserChrome, HtmlBrowserChrome.ios, HtmlFileReader, HtmlWebsiteBrowser, ImageLightbox, IncomingShareBridge, MarkdownFileReader, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, ModalContentArea, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, StartupSplashOverlay, SystemNavigationBack, ThemeProvider, [sessionId], _layout, gestureHandler, mediaPlayerWebView, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/files/[sessionId].tsx, apps/mobile/app/files/preview/[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/FileTypeIcon.tsx, apps/mobile/src/components/FileTypeTile.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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SystemNavigationBack.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.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/RemoteDesktopWindows.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/HtmlBrowserChrome.ios.tsx, apps/mobile/src/session/HtmlBrowserChrome.tsx, apps/mobile/src/session/HtmlFileReader.tsx, apps/mobile/src/session/HtmlWebsiteBrowser.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MarkdownFileReader.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/mathWebViewHtml.ts, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.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 | 0 | 236 | 79 |
+| `mobile.home` | mobile | 主机与资源首页 | app/index.tsx / app/devices/index.tsx | AccountSwitcherSheet, AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, AutomationTimerIcon, BlurBackdrop, CenteredScreen, CompanionCreateNativeView, CompanionCreateNativeView.ios, CompanionModelChain, CompanionNativeContent.ios, CompanionPortraitPicker, CompanionProfileArtifacts, CompanionProfileNativeView, CompanionProfileNativeView.ios, CompanionProfileSheet, CompanionSettingsRow, CompanionSettingsRow.ios, CompanionSheet, CompanionSheet.ios, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ConversationSearchFilterSheet, DeviceLinkContext, FoldTouchpad, HomeChromeDrawer, HomeChromeFrost, HomeEntryProvider, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeListVisuals, HomeModePanes, HomeModeSwitch, HomeNativeStackHeader, HomeNewTaskButton, HomeProjectMachineLabel, HomeSearchBar, HomeSurface, IncomingShareBridge, LoginNativeButton, LoginNativeButton.ios, MobileAgentMark, MobileAgentSwitcher, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobileModelPickerList.ios, MobileOutboxBridge, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, MobileVendorIcon, ModalContentArea, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteAccessGuide, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteTaskSuggestions, RenameSessionModal, ResidentHomeList, SessionActionSheet, SessionDetailsNative, SessionDetailsNative.ios, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionOptionsExpoSheet, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, SwipeableSessionRow, SwipeableSessionRow.ios, TaskTags, TeammateCreateButton, TeammateHomeScreen, TeammateList, ThemeProvider, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, _layout, gestureHandler, index, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/index.tsx, apps/mobile/app/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/LoginNativeButton.ios.tsx, apps/mobile/src/components/LoginNativeButton.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/RemoteCompanionAvatar.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/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/CompanionCreateNativeView.ios.tsx, apps/mobile/src/session/CompanionCreateNativeView.tsx, apps/mobile/src/session/CompanionModelChain.tsx, apps/mobile/src/session/CompanionNativeContent.ios.tsx, apps/mobile/src/session/CompanionPortraitPicker.tsx, apps/mobile/src/session/CompanionProfileArtifacts.tsx, apps/mobile/src/session/CompanionProfileNativeView.ios.tsx, apps/mobile/src/session/CompanionProfileNativeView.tsx, apps/mobile/src/session/CompanionProfileSheet.tsx, apps/mobile/src/session/CompanionSettingsRow.ios.tsx, apps/mobile/src/session/CompanionSettingsRow.tsx, apps/mobile/src/session/CompanionSheet.ios.tsx, apps/mobile/src/session/CompanionSheet.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/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.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeListVisuals.tsx, apps/mobile/src/session/HomeModePanes.tsx, apps/mobile/src/session/HomeModeSwitch.tsx, apps/mobile/src/session/HomeNewTaskButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/HomeSurface.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileAgentSwitcher.tsx, apps/mobile/src/session/MobileModelPickerList.ios.tsx, apps/mobile/src/session/MobileModelPickerList.tsx, apps/mobile/src/session/MobileOutboxBridge.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/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SessionActionSheet.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/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/session/TaskTags.tsx, apps/mobile/src/session/TeammateCreateButton.tsx, apps/mobile/src/session/TeammateHomeScreen.tsx, apps/mobile/src/session/TeammateList.tsx, apps/mobile/src/session/UnifiedModelPickerSheet.tsx, apps/mobile/src/session/UnifiedModelPickerView.ios.tsx, apps/mobile/src/session/UnifiedModelPickerView.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 | 204 | 134 |
+| `mobile.overlay.connection-startup` | mobile | 根布局挂载的启动与连接反馈 | app/_layout.tsx → StartupSplashOverlay / ConnectionNoticeProvider;各页面 ConnectionBanner | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ConnectionNoticeProvider, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 50 |
+| `mobile.remote-desktop` | mobile | 远程桌面 | app/devices/desktop/[deviceId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/desktop/[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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 50 |
+| `mobile.resources` | mobile | 远程资源列表与详情 | app/resources/[collectionId].tsx / app/resources/[collectionId]/[resourceId].tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, TeammateList, ThemeProvider, [collectionId], [resourceId], _layout, gestureHandler, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/resources/[collectionId].tsx, apps/mobile/app/resources/[collectionId]/[resourceId].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/RemoteCompanionAvatar.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/TeammateList.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 | 204 | 61 |
+| `mobile.settings` | mobile | 设置(含调试与日志上传可见入口) | app/settings.tsx | AdaptiveWindow, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, IncomingShareBridge, MobileChoicePickerList, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeChromeBackButton.ios, NativeChromeButton.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, ResidentHomeList, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, peerFileTransport, settings, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/settings.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/AdaptiveWindow.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.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/FoldTouchpad.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/RemoteDesktopWindows.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/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileChoicePickerList.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/ResidentHomeList.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 | 204 | 59 |
### 生产路由覆盖
diff --git a/packages/device-link/src/__tests__/inputDelivery.test.ts b/packages/device-link/src/__tests__/inputDelivery.test.ts
new file mode 100644
index 0000000000..d6dd468e91
--- /dev/null
+++ b/packages/device-link/src/__tests__/inputDelivery.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, it } from "vitest";
+import { readInputDeliveryClientIds } from "../inputDelivery.js";
+
+describe("optional input delivery receipt requests", () => {
+ it("leaves legacy callers unchanged and preserves original client IDs", () => {
+ expect(readInputDeliveryClientIds(undefined)).toBeUndefined();
+ expect(readInputDeliveryClientIds({})).toBeUndefined();
+ expect(
+ readInputDeliveryClientIds({ deliveryClientIds: ["a", "b", "a"] }),
+ ).toEqual(["a", "b"]);
+ });
+ it("bounds receipt reads and rejects malformed IDs instead of truncating the request", () => {
+ for (const deliveryClientIds of [
+ null,
+ "id",
+ [""],
+ [42],
+ ["a".repeat(257)],
+ Array(65).fill("id"),
+ ]) {
+ expect(() => readInputDeliveryClientIds({ deliveryClientIds })).toThrow();
+ }
+ expect(readInputDeliveryClientIds({ deliveryClientIds: [] })).toEqual([]);
+ });
+});
diff --git a/packages/device-link/src/index.ts b/packages/device-link/src/index.ts
index 623923715e..395ba5f5a6 100644
--- a/packages/device-link/src/index.ts
+++ b/packages/device-link/src/index.ts
@@ -48,3 +48,4 @@ export * from "./pluginSecretSubmission.js";
export * from "./pluginConnectionSubmission.js";
export * from "./pluginDeviceAuthorization.js";
export * from "./pluginOauthAuthentication.js";
+export * from "./inputDelivery.js";
diff --git a/packages/device-link/src/inputDelivery.ts b/packages/device-link/src/inputDelivery.ts
new file mode 100644
index 0000000000..0681e447fa
--- /dev/null
+++ b/packages/device-link/src/inputDelivery.ts
@@ -0,0 +1,33 @@
+/** Optional payload extension of maker:input:get-projection; old hosts omit it. */
+export type InputDeliveryState = "pending" | "accepted" | "removed" | "unknown";
+export interface InputDeliveryReceipt {
+ clientId: string;
+ state: InputDeliveryState;
+}
+export interface InputDeliveryProjection {
+ inputDeliveryVersion?: 1;
+ deliveryReceipts?: InputDeliveryReceipt[];
+}
+
+/** Bound work before querying durable delivery state. No message content is returned. */
+export function readInputDeliveryClientIds(
+ options: unknown,
+): string[] | undefined {
+ if (
+ !options ||
+ typeof options !== "object" ||
+ !("deliveryClientIds" in options)
+ )
+ return undefined;
+ const ids = (options as { deliveryClientIds?: unknown }).deliveryClientIds;
+ if (
+ !Array.isArray(ids) ||
+ ids.length > 64 ||
+ ids.some((id) => typeof id !== "string" || !id || id.length > 256)
+ ) {
+ throw new Error(
+ "deliveryClientIds must contain at most 64 nonempty IDs (256 characters each)",
+ );
+ }
+ return [...new Set(ids as string[])];
+}