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): 支持 iOS 分享文件和图片到新任务 (#4335)

Dash40f087c99c84
diff --git a/apps/mobile/app.json b/apps/mobile/app.json
index ab24f58d15..ccf7ea69b9 100644
--- a/apps/mobile/app.json
+++ b/apps/mobile/app.json
@@ -92,6 +92,18 @@
"expo-notifications",
"expo-secure-store",
"expo-web-browser",
+ [
+ "expo-sharing",
+ {
+ "ios": {
+ "enabled": true,
+ "activationRule": {
+ "supportsFileWithMaxCount": 20,
+ "supportsImageWithMaxCount": 20
+ }
+ }
+ }
+ ],
[
"expo-font",
{
@@ -120,6 +132,7 @@
}
}
],
+ "./plugins/with-incoming-share-files",
"./plugins/with-remote-desktop-presentation",
"./plugins/with-foreground-only-audio",
[
diff --git a/apps/mobile/app/+native-intent.ts b/apps/mobile/app/+native-intent.ts
index 5172f8304d..dc005e25cb 100644
--- a/apps/mobile/app/+native-intent.ts
+++ b/apps/mobile/app/+native-intent.ts
@@ -1,8 +1,9 @@
// expo-router 深链拦截。
//
-// auth-server 回调 cindycn://auth / cindy://auth 没有对应路由页,默认会落到 expo-router 的
-// +not-found(「Unmatched Route」白屏),把登录界面盖住。这里把该回调路径重定向到 '/'(index),
-// 让 index 按登录态渲染(未登录→/login,已登录→首页)。
+// auth-server 回调 cindycn://auth / cindy://auth 与 Share Extension 的
+// cindycn://expo-sharing / cindy://expo-sharing 都没有对应路由页,默认会落到
+// expo-router 的 +not-found(「Unmatched Route」白屏)。这里分别把它们重定向到首页与
+// 新建任务页;分享 payload 由根级 IncomingShareBridge 独立领取。
//
// 实际的 PKCE code 交换**不依赖路由**:由 src/auth/AuthContext.tsx 的 Linking.addEventListener /
// getInitialURL 监听器独立捕获原始 URL 并完成(见其 handleDeepLink)。本文件只负责别让路由 404。
@@ -18,8 +19,9 @@ export function redirectSystemPath({ path }: { path: string; initial: boolean })
// path 可能是完整 URL('cindycn://auth?code=...')或路径('/auth?code=...'),统一取出 pathname。
const noScheme = path.replace(/^[a-zA-Z][\w+.-]*:\/\//, '/');
const pathname = noScheme.split('?')[0].split('#')[0].replace(/\/+$/, '') || '/';
- // 命中 OAuth 回调 → 回首页;其余深链(/sessions/xxx、/devices 等)原样放行。
+ // 命中 OAuth 回调 → 回首页;Share Extension → 新建任务;其余深链原样放行。
if (pathname === '/auth') return '/';
+ if (pathname === '/expo-sharing') return '/sessions/new';
return path;
} catch {
return path;
diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx
index 6fd466faa7..90c353e778 100644
--- a/apps/mobile/app/_layout.tsx
+++ b/apps/mobile/app/_layout.tsx
@@ -73,6 +73,7 @@ import {
isPrecreatedWorktreeRegistrationInFlight,
recoverPendingPrecreatedWorktrees,
} from '@/session/precreatedWorktreeRecovery';
+import { IncomingShareBridge } from '@/session/IncomingShareBridge';
function NavigationGate() {
const auth = useAuth();
@@ -139,6 +140,7 @@ function NavigationGate() {
return (
<NavigationThemeProvider value={navigationTheme}>
+ <IncomingShareBridge />
{/* Android 专用:splash 覆盖层仍在时状态栏保持浅色;淡出开始后切回主题样式 */}
{Platform.OS === 'android' ? (
<StatusBar
diff --git a/apps/mobile/app/sessions/new.tsx b/apps/mobile/app/sessions/new.tsx
index a9eede7b59..a1da1a9239 100644
--- a/apps/mobile/app/sessions/new.tsx
+++ b/apps/mobile/app/sessions/new.tsx
@@ -1,7 +1,7 @@
import { isRemoteTaskSuggestionId } from '@/session/remoteTaskSuggestionsModel';
import { stripTrailingPathSeparators } from '@cindy/maker-shared/path-text';
import { takeRefinementContextTail } from '@cindy/voice-input-core';
-import { useLocalSearchParams, useRouter } from 'expo-router';
+import { useIsFocused, useLocalSearchParams, useRouter } from 'expo-router';
import Constants from 'expo-constants';
import { MOBILE_VISUAL_MOCK_ENABLED } from '@/config/env';
import { formatMobileBuildLabel, normalizeBuildInfo } from '@/config/buildInfo';
@@ -89,9 +89,16 @@ import {
} from '@/session/attachments';
import { useAuth } from '@/auth/AuthContext';
import { discardMobileUploadedAttachment } from '@/session/mobileAttachmentUpload';
+import { discardNewSessionUploadedAttachments } from '@/session/newSessionAttachmentCleanup';
import { goBackGuarded } from '@/utils/backGuard';
import { buildMobileImageAttachmentCandidate } from '@/session/mobileImageAttachment';
import { useMobileLocalAttachments } from '@/session/useMobileLocalAttachments';
+import {
+ consumeIncomingShareBatch,
+ deleteIncomingSharedFiles,
+ selectIncomingShareUploadCandidates,
+ useIncomingShareBatch,
+} from '@/session/incomingShare';
import {
AT_RESOURCE_QUERY_DEBOUNCE_MS,
buildComposerPaletteCacheKey,
@@ -174,6 +181,7 @@ import { i18n } from '@/i18n';
import {
getMobileAuthOwner,
isMobileAuthOwnerCurrent,
+ subscribeMobileAuthOwner,
} from '@/auth/authOwnerGeneration';
import { useTranslation } from 'react-i18next';
import {
@@ -676,6 +684,61 @@ export default function NewRemoteSessionScreen() {
onError: setAttachmentError,
onPicked: () => setContextSheetOpen(false),
});
+ useEffect(() => subscribeMobileAuthOwner(() => {
+ // Switching accounts invalidates both queued uploads and already received
+ // attachments, synchronously, before a new account can send this draft.
+ discardNewSessionUploadedAttachments(attachmentsRef.current, auth.getAccessToken);
+ discardAllPendingUploads();
+ attachmentsRef.current = [];
+ setAttachments([]);
+ setAttachmentPreviews({});
+ setMediaAssetAttachments({});
+ setAttachmentError(null);
+ }), [auth.getAccessToken, discardAllPendingUploads]);
+ const incomingShareBatch = useIncomingShareBatch();
+ const isShareTargetFocused = useIsFocused();
+ useEffect(() => {
+ if (!isShareTargetFocused || !auth.isAuthenticated || !incomingShareBatch
+ || getMobileAuthOwner().accountId !== auth.user?.id
+ || !consumeIncomingShareBatch(incomingShareBatch.id)) return;
+ const selection = selectIncomingShareUploadCandidates(incomingShareBatch.payloads);
+ const remainingSlots = Math.max(
+ 0,
+ MOBILE_MAX_ATTACHMENTS
+ - attachmentsRef.current.length
+ - getPendingUploadCount(),
+ );
+ const accepted = selection.candidates.slice(0, remainingSlots);
+ const dropped = selection.candidates.slice(remainingSlots);
+ const cleanupUris = [
+ ...selection.rejectedUris,
+ ...dropped.map((candidate) => candidate.uri),
+ ];
+ if (cleanupUris.length > 0) {
+ void deleteIncomingSharedFiles(cleanupUris).catch(() => undefined);
+ }
+ if (accepted.length > 0) {
+ enqueueUploads(accepted.map((candidate) => ({
+ ...candidate,
+ cleanupLocalUris: deleteIncomingSharedFiles,
+ })), { token: auth.getAccessToken() });
+ }
+ if (dropped.length > 0) {
+ setAttachmentError(i18n.t('composer.upload.maxAttachments', {
+ count: MOBILE_MAX_ATTACHMENTS,
+ }));
+ } else if (selection.rejectedUris.length > 0) {
+ setAttachmentError(i18n.t('composer.upload.fileTypeUnsupported'));
+ } else {
+ setAttachmentError(null);
+ }
+ }, [
+ auth,
+ enqueueUploads,
+ getPendingUploadCount,
+ incomingShareBatch,
+ isShareTargetFocused,
+ ]);
const [slashCommands, setSlashCommands] = useState<MobileSlashCommand[]>([]);
const [slashPaletteLoading, setSlashPaletteLoading] = useState(false);
const [slashPaletteError, setSlashPaletteError] = useState<string | null>(null);
diff --git a/apps/mobile/modules/cindy-incoming-share/expo-module.config.json b/apps/mobile/modules/cindy-incoming-share/expo-module.config.json
new file mode 100644
index 0000000000..a2e697ec82
--- /dev/null
+++ b/apps/mobile/modules/cindy-incoming-share/expo-module.config.json
@@ -0,0 +1,6 @@
+{
+ "platforms": ["apple"],
+ "apple": {
+ "modules": ["CindyIncomingShareModule"]
+ }
+}
diff --git a/apps/mobile/modules/cindy-incoming-share/ios/CindyIncomingShare.podspec b/apps/mobile/modules/cindy-incoming-share/ios/CindyIncomingShare.podspec
new file mode 100644
index 0000000000..6b74144745
--- /dev/null
+++ b/apps/mobile/modules/cindy-incoming-share/ios/CindyIncomingShare.podspec
@@ -0,0 +1,15 @@
+Pod::Spec.new do |s|
+ s.name = 'CindyIncomingShare'
+ s.version = '0.1.0'
+ s.summary = 'Atomic acknowledgement of the iOS incoming share slot.'
+ s.description = s.summary
+ s.license = { :type => 'Apache-2.0' }
+ s.author = 'Cindy'
+ s.homepage = 'https://github.com/makecindy/cindy'
+ s.source = { git: s.homepage }
+ s.platforms = { :ios => '16.4' }
+ s.swift_version = '5.9'
+ s.static_framework = true
+ s.dependency 'ExpoModulesCore'
+ s.source_files = '**/*.swift'
+end
diff --git a/apps/mobile/modules/cindy-incoming-share/ios/CindyIncomingShareModule.swift b/apps/mobile/modules/cindy-incoming-share/ios/CindyIncomingShareModule.swift
new file mode 100644
index 0000000000..c7f7375596
--- /dev/null
+++ b/apps/mobile/modules/cindy-incoming-share/ios/CindyIncomingShareModule.swift
@@ -0,0 +1,25 @@
+import ExpoModulesCore
+
+public final class CindyIncomingShareModule: Module {
+ private var group: String {
+ get throws {
+ guard let value = Bundle.main.object(forInfoDictionaryKey: "ExpoShareIntoAppGroupId") as? String
+ else { throw POSIXError(.ENOENT) }
+ return value
+ }
+ }
+
+ public func definition() -> ModuleDefinition {
+ Name("CindyIncomingShare")
+ Function("readSnapshot") { () throws -> String? in
+ try IncomingShareSlot.withDefaults(group: self.group) { defaults in
+ defaults.data(forKey: IncomingShareSlot.key).flatMap { String(data: $0, encoding: .utf8) }
+ }
+ }
+ Function("clearSnapshot") { (expected: String) throws -> Bool in
+ try IncomingShareSlot.withDefaults(group: self.group) { defaults in
+ try IncomingShareSlot.clear(Data(expected.utf8), from: defaults)
+ }
+ }
+ }
+}
diff --git a/apps/mobile/modules/cindy-incoming-share/ios/IncomingShareSlot.swift b/apps/mobile/modules/cindy-incoming-share/ios/IncomingShareSlot.swift
new file mode 100644
index 0000000000..6291a02e3c
--- /dev/null
+++ b/apps/mobile/modules/cindy-incoming-share/ios/IncomingShareSlot.swift
@@ -0,0 +1,41 @@
+import Foundation
+import Darwin
+
+// Compiled into both the app module and generated share extension. Never unlink
+// the lock file: all processes must continue locking the same inode.
+enum IncomingShareSlot {
+ static let key = "expo-sharing"
+
+ static func withLock<T>(at url: URL, _ operation: () throws -> T) throws -> T {
+ let fd = open(url.path, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)
+ guard fd >= 0 else { throw POSIXError(.EIO) }
+ defer { close(fd) }
+ guard flock(fd, LOCK_EX) == 0 else { throw POSIXError(.EIO) }
+ defer { flock(fd, LOCK_UN) }
+ return try operation()
+ }
+
+ static func withDefaults<T>(group: String, _ operation: (UserDefaults) throws -> T) throws -> T {
+ guard let root = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group),
+ let defaults = UserDefaults(suiteName: group) else { throw POSIXError(.ENOENT) }
+ return try withLock(at: root.appendingPathComponent(".cindy-incoming-share.lock")) {
+ // Refresh the process cache while holding the same lock as the writer.
+ guard defaults.synchronize() else { throw POSIXError(.EIO) }
+ return try operation(defaults)
+ }
+ }
+
+ static func clear(_ expected: Data, from defaults: UserDefaults) throws -> Bool {
+ guard defaults.data(forKey: key) == expected else { return false }
+ defaults.removeObject(forKey: key)
+ guard defaults.synchronize() else { throw POSIXError(.EIO) }
+ return true
+ }
+
+ static func write(_ data: Data, group: String) throws {
+ try withDefaults(group: group) { defaults in
+ defaults.set(data, forKey: key)
+ guard defaults.synchronize() else { throw POSIXError(.EIO) }
+ }
+ }
+}
diff --git a/apps/mobile/plugins/with-incoming-share-files.js b/apps/mobile/plugins/with-incoming-share-files.js
new file mode 100644
index 0000000000..d6e12a3bd1
--- /dev/null
+++ b/apps/mobile/plugins/with-incoming-share-files.js
@@ -0,0 +1,42 @@
+const fs = require('node:fs');
+const path = require('node:path');
+const { withXcodeProject } = require('@expo/config-plugins');
+
+// expo-sharing 57 copies files to AppGroup/<basename>, overwriting same-name
+// files even within one share. Keep each input in its own directory, retaining
+// the basename for display. Do not modify the installed dependency/template.
+function patchShareExtension(source) {
+ const replace = (from, to, count) => {
+ if (source.split(from).length - 1 !== count) {
+ throw new Error('expo-sharing template changed; review incoming-file ownership patch');
+ }
+ source = source.split(from).join(to);
+ };
+ replace(' private func handleShare() {',
+ ' private var shareStarted = false\n\n private func handleShare() {\n guard !shareStarted else { return }\n shareStarted = true', 1);
+ replace(' let destinationURL = containerURL.appendingPathComponent(fileName)',
+ ' let directory = containerURL.appendingPathComponent("cindy-share-" + UUID().uuidString, isDirectory: true)\n let destinationURL = directory.appendingPathComponent(fileName)', 2);
+ replace(' if FileManager.default.fileExists(atPath: destinationURL.path) {\n try FileManager.default.removeItem(at: destinationURL)\n }',
+ ' try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)', 1);
+ replace(' try data.write(to: destinationURL)',
+ ' try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)\n try data.write(to: destinationURL)', 1);
+ replace(' userDefaults.set(encoded, forKey: SHARE_INTO_DEFAULTS_KEY)\n userDefaults.synchronize()',
+ ' do {\n try IncomingShareSlot.write(encoded, group: appGroupId)\n return true\n } catch {\n print("Error: incoming share could not be saved")\n return false\n }', 1);
+ replace(' saveToUserDefaults(payload)',
+ ' guard saveToUserDefaults(payload) else {\n self.close()\n return\n }', 1);
+ replace(' private func saveToUserDefaults(_ payload: [SharePayload]) {',
+ ' private func saveToUserDefaults(_ payload: [SharePayload]) -> Bool {', 1);
+ replace(' guard let userDefaults = UserDefaults(suiteName: appGroupId) else {\n print("Error: Expo-sharing could not initialize UserDefaults with group: \\(appGroupId)")\n return\n }', '', 1);
+ replace(' print("Error: Expo-sharing has failed to serialize shared data to JSON")',
+ ' print("Error: Expo-sharing has failed to serialize shared data to JSON")\n return false', 1);
+ return source + '\n' + fs.readFileSync(path.join(__dirname,
+ '../modules/cindy-incoming-share/ios/IncomingShareSlot.swift'), 'utf8');
+}
+
+module.exports = config => withXcodeProject(config, mod => {
+ // Xcode mods run after expo-sharing's dangerous mod writes the fresh template.
+ const file = path.join(mod.modRequest.platformProjectRoot, 'expo-sharing-extension', 'ShareIntoViewController.swift');
+ fs.writeFileSync(file, patchShareExtension(fs.readFileSync(file, 'utf8')));
+ return mod;
+});
+module.exports.patchShareExtension = patchShareExtension;
diff --git a/apps/mobile/scripts/test-incoming-share-slot.swift b/apps/mobile/scripts/test-incoming-share-slot.swift
new file mode 100644
index 0000000000..bb5542f319
--- /dev/null
+++ b/apps/mobile/scripts/test-incoming-share-slot.swift
@@ -0,0 +1,67 @@
+// Compile alongside modules/cindy-incoming-share/ios/IncomingShareSlot.swift.
+import Foundation
+import Darwin
+
+@main
+enum IncomingShareSlotTest {
+ static func main() throws {
+ let arguments = CommandLine.arguments
+ if arguments.count > 1 {
+ let lock = URL(fileURLWithPath: arguments[1])
+ // Prove that the other process cannot enter the compare/clear window.
+ let fd = open(lock.path, O_RDWR)
+ precondition(fd >= 0)
+ precondition(flock(fd, LOCK_EX | LOCK_NB) == -1 && errno == EWOULDBLOCK)
+ close(fd)
+ FileHandle.standardOutput.write(Data([1]))
+ try IncomingShareSlot.withLock(at: lock) {
+ let defaults = UserDefaults(suiteName: arguments[2])!
+ precondition(defaults.synchronize())
+ defaults.set(Data("B".utf8), forKey: IncomingShareSlot.key)
+ precondition(defaults.synchronize())
+ }
+ return
+ }
+
+ let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
+ try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)
+ defer { try? FileManager.default.removeItem(at: root) }
+ let suite = "cindy-share-test-" + UUID().uuidString
+ let defaults = UserDefaults(suiteName: suite)!
+ defer { defaults.removePersistentDomain(forName: suite); defaults.synchronize() }
+ let lock = root.appendingPathComponent("slot.lock")
+ let a = Data("A".utf8)
+ let b = Data("B".utf8)
+ defaults.set(a, forKey: IncomingShareSlot.key)
+ precondition(defaults.synchronize())
+
+ let writer = Process()
+ writer.executableURL = URL(fileURLWithPath: arguments[0])
+ writer.arguments = [lock.path, suite]
+ let ready = Pipe()
+ writer.standardOutput = ready
+ try IncomingShareSlot.withLock(at: lock) {
+ precondition(defaults.data(forKey: IncomingShareSlot.key) == a)
+ try writer.run()
+ precondition(ready.fileHandleForReading.readData(ofLength: 1) == Data([1]))
+ // B has attempted to write after comparison. It must wait for clearing A.
+ let cleared = try IncomingShareSlot.clear(a, from: defaults)
+ precondition(cleared)
+ }
+ writer.waitUntilExit()
+ precondition(writer.terminationStatus == 0)
+ try IncomingShareSlot.withLock(at: lock) {
+ precondition(defaults.synchronize())
+ precondition(defaults.data(forKey: IncomingShareSlot.key) == b)
+ let staleCleared = try IncomingShareSlot.clear(a, from: defaults)
+ precondition(!staleCleared && defaults.data(forKey: IncomingShareSlot.key) == b)
+ let currentCleared = try IncomingShareSlot.clear(b, from: defaults)
+ let duplicateCleared = try IncomingShareSlot.clear(b, from: defaults)
+ precondition(currentCleared && !duplicateCleared)
+ }
+ // An error must release the lock as well.
+ do { try IncomingShareSlot.withLock(at: lock) { throw POSIXError(.EIO) } } catch {}
+ try IncomingShareSlot.withLock(at: lock) {}
+ print("PASS: cross-process exclusion, stale/current/duplicate acknowledgement, error unlock")
+ }
+}
diff --git a/apps/mobile/src/__tests__/incomingShare.test.ts b/apps/mobile/src/__tests__/incomingShare.test.ts
new file mode 100644
index 0000000000..9935140bec
--- /dev/null
+++ b/apps/mobile/src/__tests__/incomingShare.test.ts
@@ -0,0 +1,330 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import type { ResolvedSharePayload } from 'expo-sharing';
+import { getMobileAuthOwner, invalidateMobileAuthOwnerForSwitch, isMobileAuthOwnerCurrent, setMobileAuthOwner, __testing as authOwnerTesting } from '@/auth/authOwnerGeneration';
+
+import {
+ __resetIncomingShareForTest,
+ consumeIncomingShareBatch,
+ incomingShareBatchId,
+ selectIncomingShareUploadCandidates,
+ stageIncomingShareBatch,
+ receiveIncomingShare,
+ watchIncomingShareAccount,
+} from '@/session/incomingShare';
+
+const convertToJpeg = vi.fn(async (uri: string) => `${uri}.jpg`);
+const deleteAsync = vi.hoisted(() => vi.fn(async () => undefined));
+vi.mock('expo-file-system/legacy', () => ({ deleteAsync }));
+
+vi.mock('@/session/pastedImageAttachment', async (importOriginal) => {
+ const original = await importOriginal<typeof import('@/session/pastedImageAttachment')>();
+ return {
+ ...original,
+ resolvePastedImageAsset: async (uri: string, index: number) => {
+ const classified = original.classifyPastedImageUri(uri);
+ if (classified.needsJpegConversion) {
+ return {
+ uri: await convertToJpeg(uri),
+ fileName: `pasted-image-${index + 1}.jpg`,
+ mimeType: 'image/jpeg',
+ };
+ }
+ return original.resolvePastedImageAsset(uri, index);
+ },
+ };
+});
+
+function payload(
+ patch: Partial<ResolvedSharePayload>,
+): ResolvedSharePayload {
+ return {
+ value: 'file:///shared/report.pdf',
+ shareType: 'file',
+ mimeType: 'application/pdf',
+ contentUri: 'file:///shared/report.pdf',
+ contentType: 'file',
+ contentMimeType: 'application/pdf',
+ originalName: 'report.pdf',
+ contentSize: 1024,
+ ...patch,
+ } as ResolvedSharePayload;
+}
+
+describe('incoming Share Extension payloads', () => {
+ beforeEach(() => {
+ __resetIncomingShareForTest();
+ authOwnerTesting.reset();
+ setMobileAuthOwner('account-a');
+ deleteAsync.mockClear();
+ convertToJpeg.mockClear();
+ });
+
+ it('converts non-sendable iOS image formats before entering the attachment uploader', async () => {
+ const result = selectIncomingShareUploadCandidates([
+ payload({
+ value: 'file:///shared/IMG_0001.HEIC',
+ shareType: 'image',
+ mimeType: 'image/heic',
+ contentUri: 'file:///shared/IMG_0001.HEIC',
+ contentType: 'image',
+ contentMimeType: 'image/heic',
+ originalName: 'IMG_0001.HEIC',
+ }),
+ ]);
+
+ expect(result.candidates).toHaveLength(1);
+ expect(result.candidates[0]).toMatchObject({
+ kind: 'image',
+ name: 'IMG_0001.HEIC',
+ mimeType: 'image/heic',
+ });
+ await expect(result.candidates[0]!.resolve!()).resolves.toEqual({
+ uri: 'file:///shared/IMG_0001.HEIC.jpg',
+ name: 'IMG_0001.jpg',
+ mimeType: 'image/jpeg',
+ size: 0,
+ skipPreprocess: true,
+ });
+ expect(convertToJpeg).toHaveBeenCalledWith('file:///shared/IMG_0001.HEIC');
+ });
+
+ it('converts supported files and images into the existing attachment upload candidates', () => {
+ const result = selectIncomingShareUploadCandidates([
+ payload({}),
+ payload({
+ value: 'file:///shared/screenshot.png',
+ shareType: 'image',
+ mimeType: 'image/png',
+ contentUri: 'file:///shared/screenshot.png',
+ contentType: 'image',
+ contentMimeType: 'image/png',
+ originalName: 'screenshot.png',
+ contentSize: 2048,
+ }),
+ ]);
+
+ expect(result).toEqual({
+ candidates: [
+ {
+ kind: 'file',
+ uri: 'file:///shared/report.pdf',
+ name: 'report.pdf',
+ size: 1024,
+ mimeType: 'application/pdf',
+ },
+ {
+ kind: 'image',
+ uri: 'file:///shared/screenshot.png',
+ name: 'screenshot.png',
+ size: 2048,
+ mimeType: 'image/png',
+ },
+ ],
+ rejectedUris: [],
+ });
+ });
+
+ it('falls back to a decoded URI basename and rejects unsupported attachment types', () => {
+ const result = selectIncomingShareUploadCandidates([
+ payload({
+ contentUri: 'file:///shared/My%20Notes.md',
+ originalName: null,
+ contentSize: null,
+ contentMimeType: null,
+ mimeType: 'text/markdown',
+ }),
+ payload({
+ value: 'file:///shared/archive.zip',
+ contentUri: 'file:///shared/archive.zip',
+ originalName: 'archive.zip',
+ }),
+ ]);
+
+ expect(result.candidates).toEqual([{
+ kind: 'file',
+ uri: 'file:///shared/My%20Notes.md',
+ name: 'My Notes.md',
+ size: 0,
+ mimeType: 'text/markdown',
+ }]);
+ expect(result.rejectedUris).toEqual(['file:///shared/archive.zip']);
+ });
+
+ it('keeps a batch until the matching consumer acknowledges it exactly once', () => {
+ const acknowledge = vi.fn();
+ const shared = [payload({})];
+ const first = stageIncomingShareBatch(shared, acknowledge);
+ const duplicate = stageIncomingShareBatch(shared, vi.fn());
+
+ expect(first?.id).toBe(incomingShareBatchId(shared));
+ expect(duplicate).toBe(first);
+ expect(consumeIncomingShareBatch('wrong-id')).toBe(false);
+ expect(acknowledge).not.toHaveBeenCalled();
+ expect(consumeIncomingShareBatch(first!.id)).toBe(true);
+ expect(acknowledge).toHaveBeenCalledTimes(1);
+ expect(consumeIncomingShareBatch(first!.id)).toBe(false);
+ });
+
+ it('retains successive shares during login and does not clear the newer native slot', () => {
+ setMobileAuthOwner(null);
+ let raw = [{ value: 'file:///group/cindy-share-a/report.pdf', shareType: 'file' as const }];
+ const native = { getSharedPayloads: () => raw, clearSharedPayloads: vi.fn((expected) => {
+ if (expected === raw) raw = [];
+ }) };
+ receiveIncomingShare(native);
+ const first = stageIncomingShareBatch([payload({
+ value: raw[0]!.value, contentUri: raw[0]!.value, mimeType: undefined,
+ contentMimeType: null, contentSize: null,
+ })], vi.fn())!;
+ raw = [{ value: 'file:///group/cindy-share-b/report.pdf', shareType: 'file' }];
+ receiveIncomingShare(native);
+ receiveIncomingShare(native);
+ expect(consumeIncomingShareBatch(first.id)).toBe(false);
+ setMobileAuthOwner('account-a');
+ expect(consumeIncomingShareBatch(first.id)).toBe(true);
+ expect(native.clearSharedPayloads).toHaveBeenCalledTimes(1);
+ expect(consumeIncomingShareBatch(first.id)).toBe(false);
+ const secondId = incomingShareBatchId([payload({
+ value: raw[0]!.value, contentUri: raw[0]!.value, mimeType: undefined,
+ contentMimeType: null, contentSize: null,
+ })]);
+ expect(consumeIncomingShareBatch(secondId)).toBe(true);
+ expect(native.clearSharedPayloads).toHaveBeenCalledTimes(2);
+ });
+
+ it('never treats remote URLs as local upload/cleanup targets', () => {
+ expect(selectIncomingShareUploadCandidates([payload({ contentUri: 'https://example.com/report.pdf' })]))
+ .toEqual({ candidates: [], rejectedUris: [] });
+ });
+
+ it.each(['switch', 'logout', 'same-account-relogin', 'realm-switch'])('discards received shares on %s', async (transition) => {
+ const acknowledge = vi.fn();
+ const batch = stageIncomingShareBatch([payload({})], acknowledge)!;
+ if (transition === 'switch') setMobileAuthOwner('account-b');
+ else if (transition === 'realm-switch') setMobileAuthOwner('account-a', 'cn');
+ else {
+ setMobileAuthOwner(null);
+ if (transition === 'same-account-relogin') setMobileAuthOwner('account-a');
+ }
+ expect(consumeIncomingShareBatch(batch.id)).toBe(false);
+ expect(acknowledge).toHaveBeenCalledTimes(1);
+ await vi.waitFor(() => expect(deleteAsync).toHaveBeenCalledWith('file:///shared/report.pdf', { idempotent: true }));
+ });
+
+ it('keeps shares across a same-account refresh, but not first-login then switch', () => {
+ const batch = stageIncomingShareBatch([payload({})], vi.fn())!;
+ setMobileAuthOwner('account-a');
+ expect(consumeIncomingShareBatch(batch.id)).toBe(true);
+ setMobileAuthOwner(null);
+ const loggedOutBatch = stageIncomingShareBatch([payload({})], vi.fn())!;
+ setMobileAuthOwner('account-a');
+ setMobileAuthOwner('account-b');
+ expect(consumeIncomingShareBatch(loggedOutBatch.id)).toBe(false);
+ });
+
+ it('clears an unobserved native slot on switch and allows new shares for the new account', () => {
+ let raw = [{ value: 'file:///shared/report.pdf', shareType: 'file' as const }];
+ const native = { getSharedPayloads: () => raw, clearSharedPayloads: vi.fn(() => { raw = []; }) };
+ const stop = watchIncomingShareAccount(native);
+ setMobileAuthOwner('account-b');
+ expect(raw).toEqual([]);
+ raw = [{ value: 'file:///shared/new.pdf', shareType: 'file' }];
+ receiveIncomingShare(native);
+ const batch = stageIncomingShareBatch([payload({
+ value: raw[0]!.value, contentUri: raw[0]!.value, originalName: 'new.pdf',
+ contentSize: null, contentMimeType: null, mimeType: undefined,
+ })], vi.fn())!;
+ expect(batch.owner.accountId).toBe('account-b');
+ expect(consumeIncomingShareBatch(batch.id)).toBe(true);
+ expect(raw).toEqual([]);
+ stop();
+ });
+
+ it('does not reassign native files when login and switch happen during module loading', () => {
+ setMobileAuthOwner(null);
+ const initialOwner = getMobileAuthOwner();
+ setMobileAuthOwner('account-a');
+ setMobileAuthOwner('account-b');
+ const native = { getSharedPayloads: () => [], clearSharedPayloads: vi.fn() };
+ const stop = watchIncomingShareAccount(native, initialOwner);
+ expect(native.clearSharedPayloads).toHaveBeenCalledOnce();
+ stop();
+ });
+
+ it.each(['rollback', 'commit', 'realm', 'logout', 'logout-relogin'])(
+ 'settles unclaimed JS and native shares after switch %s without weakening cancellation',
+ async (outcome) => {
+ const before = getMobileAuthOwner();
+ let raw = [{ value: 'file:///shared/report.pdf', shareType: 'file' as const }];
+ const native = { getSharedPayloads: () => raw, clearSharedPayloads: vi.fn(() => { raw = []; }) };
+ const stop = watchIncomingShareAccount(native);
+ const acknowledge = vi.fn();
+ const batch = stageIncomingShareBatch([payload({})], acknowledge)!;
+ invalidateMobileAuthOwnerForSwitch();
+ expect(getMobileAuthOwner()).toMatchObject({ accountId: '', accountKey: '', switching: true });
+ expect(isMobileAuthOwnerCurrent(before)).toBe(false);
+ expect(consumeIncomingShareBatch(batch.id)).toBe(false);
+ expect(acknowledge).not.toHaveBeenCalled();
+ expect(native.clearSharedPayloads).not.toHaveBeenCalled();
+ await Promise.resolve();
+ expect(deleteAsync).not.toHaveBeenCalled();
+
+ if (outcome === 'rollback') setMobileAuthOwner('account-a');
+ else if (outcome === 'commit') setMobileAuthOwner('account-b');
+ else if (outcome === 'realm') setMobileAuthOwner('account-a', 'cn');
+ else {
+ setMobileAuthOwner(null);
+ if (outcome === 'logout-relogin') setMobileAuthOwner('account-a');
+ }
+ expect(getMobileAuthOwner().switching).toBeUndefined();
+ // Restoring a share must not revalidate any old auth-scoped operation.
+ expect(isMobileAuthOwnerCurrent(before)).toBe(false);
+ if (outcome === 'rollback') {
+ expect(native.clearSharedPayloads).not.toHaveBeenCalled();
+ expect(acknowledge).not.toHaveBeenCalled();
+ expect(consumeIncomingShareBatch(batch.id)).toBe(true);
+ expect(consumeIncomingShareBatch(batch.id)).toBe(false);
+ expect(acknowledge).toHaveBeenCalledOnce();
+ expect(deleteAsync).not.toHaveBeenCalled();
+ } else {
+ expect(raw).toEqual([]);
+ expect(consumeIncomingShareBatch(batch.id)).toBe(false);
+ expect(acknowledge).toHaveBeenCalledOnce();
+ await vi.waitFor(() => expect(deleteAsync).toHaveBeenCalled());
+ }
+ stop();
+ },
+ );
+
+ it.each(['rollback', 'commit'])('leaves shares arriving during a switch in native storage until %s', (outcome) => {
+ let raw = [{ value: 'file:///shared/report.pdf', shareType: 'file' as const }];
+ const native = { getSharedPayloads: () => raw, clearSharedPayloads: vi.fn(() => { raw = []; }) };
+ const stop = watchIncomingShareAccount(native);
+ invalidateMobileAuthOwnerForSwitch();
+ expect(stageIncomingShareBatch([payload({})], vi.fn())).toBeNull();
+ receiveIncomingShare(native);
+ expect(native.clearSharedPayloads).not.toHaveBeenCalled();
+ setMobileAuthOwner(outcome === 'rollback' ? 'account-a' : 'account-b');
+ if (outcome === 'rollback') {
+ receiveIncomingShare(native);
+ const batch = stageIncomingShareBatch([payload({})], vi.fn())!;
+ expect(batch.owner.accountId).toBe('account-a');
+ // receive uses raw metadata, so consume that batch first.
+ const rawId = incomingShareBatchId([payload({ mimeType: undefined, contentMimeType: null, contentSize: null })]);
+ expect(consumeIncomingShareBatch(rawId)).toBe(true);
+ }
+ expect(raw).toEqual([]);
+ stop();
+ });
+
+ it.each(['account-a', 'account-b'])('fails closed when the native watcher first mounts mid-switch, settling to %s', (account) => {
+ invalidateMobileAuthOwnerForSwitch();
+ const initial = getMobileAuthOwner();
+ const native = { getSharedPayloads: () => [], clearSharedPayloads: vi.fn() };
+ const stop = watchIncomingShareAccount(native, initial);
+ expect(native.clearSharedPayloads).not.toHaveBeenCalled();
+ setMobileAuthOwner(account);
+ expect(native.clearSharedPayloads).toHaveBeenCalledOnce();
+ stop();
+ });
+});
diff --git a/apps/mobile/src/__tests__/incomingShareBridge.test.ts b/apps/mobile/src/__tests__/incomingShareBridge.test.ts
new file mode 100644
index 0000000000..2585017f64
--- /dev/null
+++ b/apps/mobile/src/__tests__/incomingShareBridge.test.ts
@@ -0,0 +1,84 @@
+import { beforeEach, expect, it, vi } from 'vitest';
+import { IncomingShareBridge } from '@/session/IncomingShareBridge';
+
+const mock = vi.hoisted(() => ({
+ effects: [] as Array<() => (() => void) | void>,
+ cleanup: vi.fn(), receive: vi.fn(), stop: vi.fn(),
+ ownerChanged: undefined as (() => void) | undefined,
+ switching: false, appState: 'active', unsubscribe: vi.fn(),
+}));
+vi.mock('react', () => ({ useEffect: (effect: () => void) => mock.effects.push(effect) }));
+vi.mock('react-native', () => ({
+ Platform: { OS: 'ios' },
+ AppState: { get currentState() { return mock.appState; }, addEventListener: () => ({ remove: vi.fn() }) },
+ Linking: { addEventListener: () => ({ remove: vi.fn() }) },
+}));
+vi.mock('expo-router', () => ({ useRouter: () => ({}), useSegments: () => [] }));
+vi.mock('@/auth/AuthContext', () => ({ useAuth: () => ({}) }));
+vi.mock('@/auth/authOwnerGeneration', () => ({
+ getMobileAuthOwner: () => ({ switching: mock.switching }),
+ subscribeMobileAuthOwner: (listener: () => void) => { mock.ownerChanged = listener; return mock.unsubscribe; },
+}));
+vi.mock('@/session/incomingShare', () => ({
+ receiveIncomingShare: mock.receive, useIncomingShareBatch: () => null,
+ watchIncomingShareAccount: () => mock.stop,
+}));
+vi.mock('@/session/incomingShareNative', () => ({}));
+vi.mock('@/session/incomingShareCleanup', () => ({ cleanupExpiredIncomingShares: mock.cleanup }));
+
+beforeEach(() => {
+ mock.effects.length = 0; mock.ownerChanged = undefined;
+ mock.switching = false; mock.appState = 'active'; vi.clearAllMocks();
+});
+
+it('finishes expiry before reading the native slot', async () => {
+ let finish!: () => void;
+ mock.cleanup.mockReturnValue(new Promise<void>((resolve) => { finish = resolve; }));
+ IncomingShareBridge();
+ const unmount = mock.effects[0]!();
+ await vi.waitFor(() => expect(mock.cleanup).toHaveBeenCalledOnce());
+ expect(mock.receive).not.toHaveBeenCalled();
+ finish();
+ await vi.waitFor(() => expect(mock.receive).toHaveBeenCalledOnce());
+ unmount?.();
+});
+
+it('does not stage after the bridge unmounts during cleanup', async () => {
+ let finish!: () => void;
+ mock.cleanup.mockReturnValue(new Promise<void>((resolve) => { finish = resolve; }));
+ IncomingShareBridge();
+ const unmount = mock.effects[0]!();
+ await vi.waitFor(() => expect(mock.cleanup).toHaveBeenCalledOnce());
+ unmount?.();
+ finish();
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ expect(mock.receive).not.toHaveBeenCalled();
+ expect(mock.stop).toHaveBeenCalledOnce();
+});
+
+it('keeps receiving if cleanup is unavailable in an older binary', async () => {
+ mock.cleanup.mockRejectedValue(new Error('unavailable'));
+ IncomingShareBridge();
+ const unmount = mock.effects[0]!();
+ await vi.waitFor(() => expect(mock.receive).toHaveBeenCalledOnce());
+ unmount?.();
+});
+
+it('refreshes shares when a switch settles in foreground, and unsubscribes on unmount', async () => {
+ mock.cleanup.mockResolvedValue(undefined);
+ IncomingShareBridge();
+ const unmount = mock.effects[0]!();
+ await vi.waitFor(() => expect(mock.receive).toHaveBeenCalledOnce());
+ mock.switching = true;
+ mock.ownerChanged!();
+ expect(mock.cleanup).toHaveBeenCalledOnce();
+ mock.switching = false;
+ mock.appState = 'background';
+ mock.ownerChanged!();
+ expect(mock.cleanup).toHaveBeenCalledOnce();
+ mock.appState = 'active';
+ mock.ownerChanged!();
+ await vi.waitFor(() => expect(mock.receive).toHaveBeenCalledTimes(2));
+ unmount?.();
+ expect(mock.unsubscribe).toHaveBeenCalledOnce();
+});
diff --git a/apps/mobile/src/__tests__/incomingShareCleanup.test.ts b/apps/mobile/src/__tests__/incomingShareCleanup.test.ts
new file mode 100644
index 0000000000..67b80e3f3f
--- /dev/null
+++ b/apps/mobile/src/__tests__/incomingShareCleanup.test.ts
@@ -0,0 +1,61 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { cleanupExpiredIncomingShares } from '@/session/incomingShareCleanup';
+
+const fs = vi.hoisted(() => {
+ class Directory {
+ uri: string;
+ constructor(public name: string, public created?: number) {
+ this.uri = `file:///app-group/${name}`;
+ }
+ info() { return { creationTime: this.created }; }
+ }
+ return { Directory, roots: {} as Record<string, { list: () => unknown[] }>, delete: vi.fn() };
+});
+vi.mock('expo-file-system', () => ({ Directory: fs.Directory, Paths: { appleSharedContainers: fs.roots } }));
+vi.mock('expo-file-system/legacy', () => ({ deleteAsync: fs.delete }));
+
+const week = 7 * 24 * 60 * 60 * 1000;
+const now = 10 * week;
+const name = 'cindy-share-12345678-1234-1234-1234-123456789abc';
+
+describe('incoming share copy expiry', () => {
+ beforeEach(() => {
+ for (const key of Object.keys(fs.roots)) delete fs.roots[key];
+ fs.delete.mockReset().mockResolvedValue(undefined);
+ });
+
+ it('reclaims orphan copies at seven days without needing a native payload or mailbox', async () => {
+ const expired = new fs.Directory(name, now - week);
+ fs.roots.sharing = { list: () => [expired] };
+ await cleanupExpiredIncomingShares(now);
+ expect(fs.delete).toHaveBeenCalledExactlyOnceWith(expired.uri, { idempotent: true });
+ });
+
+ it('preserves fresh directories even when their imported files are old', async () => {
+ fs.roots.sharing = { list: () => [new fs.Directory(name, now - week + 1), new fs.Directory(name, now)] };
+ await cleanupExpiredIncomingShares(now);
+ expect(fs.delete).not.toHaveBeenCalled();
+ });
+
+ it('never deletes unrelated directories, plain files, or entries of unknown or future age', async () => {
+ fs.roots.sharing = { list: () => [
+ new fs.Directory('Library', 1), new fs.Directory('cindy-share-not-a-uuid', 1),
+ new fs.Directory(`prefix-${name}`, 1), new fs.Directory(`${name}/nested`, 1),
+ { name, uri: 'file:///original.pdf', info: () => ({ creationTime: 1 }) },
+ ...[undefined, NaN, Infinity, 0, now + week].map((created) => new fs.Directory(name, created)),
+ ] };
+ await cleanupExpiredIncomingShares(now);
+ expect(fs.delete).not.toHaveBeenCalled();
+ });
+
+ it('continues past inaccessible roots and failed deletes and retries on the next foreground', async () => {
+ fs.roots.unavailable = { list: () => { throw new Error('unavailable'); } };
+ const expired = new fs.Directory(name, 1);
+ fs.roots.sharing = { list: () => [expired, new fs.Directory(name.toUpperCase(), 1)] };
+ fs.delete.mockRejectedValueOnce(new Error('busy'));
+ await expect(cleanupExpiredIncomingShares(now)).resolves.toBeUndefined();
+ expect(fs.delete).toHaveBeenCalledTimes(2);
+ await cleanupExpiredIncomingShares(now);
+ expect(fs.delete).toHaveBeenCalledTimes(4);
+ });
+});
diff --git a/apps/mobile/src/__tests__/incomingShareNative.test.ts b/apps/mobile/src/__tests__/incomingShareNative.test.ts
new file mode 100644
index 0000000000..aa26b8f2e4
--- /dev/null
+++ b/apps/mobile/src/__tests__/incomingShareNative.test.ts
@@ -0,0 +1,25 @@
+import { beforeEach, expect, it, vi } from 'vitest';
+
+const native = vi.hoisted(() => ({ readSnapshot: vi.fn(), clearSnapshot: vi.fn() }));
+vi.mock('expo-modules-core', () => ({ requireOptionalNativeModule: () => native }));
+import { getSharedPayloads, clearSharedPayloads } from '@/session/incomingShareNative';
+
+beforeEach(() => vi.clearAllMocks());
+
+it('acknowledges the exact captured bytes, not a subsequent read or re-encoded payload', () => {
+ const first = '[ { "type":"file", "value":"file:///a/report.pdf", "mimeType":"application/pdf" } ]';
+ native.readSnapshot.mockReturnValueOnce(first).mockReturnValueOnce('[]');
+ const payloads = getSharedPayloads();
+ expect(payloads).toEqual([{ shareType: 'file', value: 'file:///a/report.pdf', mimeType: 'application/pdf' }]);
+ getSharedPayloads();
+ clearSharedPayloads(payloads);
+ expect(native.clearSnapshot).toHaveBeenCalledWith(first);
+ expect(native.readSnapshot).toHaveBeenCalledTimes(2);
+});
+
+it('never clears a slot for an unknown array or missing native snapshot', () => {
+ native.readSnapshot.mockReturnValue(null);
+ clearSharedPayloads(getSharedPayloads());
+ clearSharedPayloads([]);
+ expect(native.clearSnapshot).not.toHaveBeenCalled();
+});
diff --git a/apps/mobile/src/__tests__/incomingShareNativePlugin.test.ts b/apps/mobile/src/__tests__/incomingShareNativePlugin.test.ts
new file mode 100644
index 0000000000..7fb6a16b31
--- /dev/null
+++ b/apps/mobile/src/__tests__/incomingShareNativePlugin.test.ts
@@ -0,0 +1,29 @@
+import { createRequire } from 'node:module';
+import { readFileSync } from 'node:fs';
+import { dirname, join } from 'node:path';
+import { describe, expect, it } from 'vitest';
+
+const require = createRequire(import.meta.url);
+const { patchShareExtension } = require('../../plugins/with-incoming-share-files.js');
+const template = readFileSync(join(dirname(require.resolve('expo-sharing/package.json')),
+ 'plugin/template-files/ios/ShareIntoViewController.swift'), 'utf8');
+
+describe('incoming share native file ownership', () => {
+ it('isolates both file-copy and raw-image paths without changing display names', () => {
+ const patched = patchShareExtension(template);
+ expect(patched.match(/"cindy-share-" \+ UUID\(\).uuidString/g)).toHaveLength(2);
+ expect(patched.match(/createDirectory\(at: directory/g)).toHaveLength(2);
+ expect(patched.match(/directory.appendingPathComponent\(fileName\)/g)).toHaveLength(2);
+ expect(patched).not.toContain('removeItem(at: destinationURL)');
+ expect(patched).toContain('guard !shareStarted else { return }');
+ expect(patched).toContain('try IncomingShareSlot.write(encoded, group: appGroupId)');
+ expect(patched).toContain('guard saveToUserDefaults(payload) else');
+ expect(patched).toContain('enum IncomingShareSlot');
+ expect(patched).not.toContain('userDefaults.set(encoded');
+ });
+
+ it('fails prebuild when upstream changes the copy contract', () => {
+ expect(() => patchShareExtension(template.replaceAll('containerURL.appendingPathComponent(fileName)', 'newCopyStrategy()')))
+ .toThrow('expo-sharing template changed');
+ });
+});
diff --git a/apps/mobile/src/__tests__/mobileAuthServerLogin.test.ts b/apps/mobile/src/__tests__/mobileAuthServerLogin.test.ts
index 7c22fe4de5..1ceb165dd0 100644
--- a/apps/mobile/src/__tests__/mobileAuthServerLogin.test.ts
+++ b/apps/mobile/src/__tests__/mobileAuthServerLogin.test.ts
@@ -531,6 +531,17 @@ describe('mobile auth-server login', () => {
expect(switchBody).not.toContain('const oldSession = initialVault');
});
+ it('distinguishes reversible switch invalidation from committed logout before async cleanup', () => {
+ const source = readFileSync(resolve(process.cwd(), 'src/auth/AuthContext.tsx'), 'utf8');
+ const switchStart = source.indexOf('const clearAccountScopedRuntimeForSwitch = useCallback');
+ const switchBody = source.slice(switchStart, source.indexOf('const clearAuthError', switchStart));
+ expect(switchBody.indexOf('invalidateMobileAuthOwnerForSwitch();')).toBeGreaterThan(-1);
+ expect(switchBody.indexOf('invalidateMobileAuthOwnerForSwitch();')).toBeLessThan(switchBody.indexOf('await Promise.all'));
+ const logoutStart = source.indexOf('const clearLocalSession = useCallback');
+ const logout = source.slice(logoutStart);
+ expect(logout.indexOf('setMobileAuthOwner(null);')).toBeLessThan(logout.indexOf('await unregisterPushTokenBestEffort'));
+ });
+
it('clears the previous identity deletion receipt inside saved-account activation', () => {
const authSource = readFileSync(
resolve(process.cwd(), 'src/auth/AuthContext.tsx'),
diff --git a/apps/mobile/src/__tests__/nativeIntent.test.ts b/apps/mobile/src/__tests__/nativeIntent.test.ts
new file mode 100644
index 0000000000..51b36a6cbe
--- /dev/null
+++ b/apps/mobile/src/__tests__/nativeIntent.test.ts
@@ -0,0 +1,27 @@
+import { describe, expect, it } from 'vitest';
+
+import { redirectSystemPath } from '../../app/+native-intent';
+
+describe('mobile native deep-link redirects', () => {
+ it('routes the Share Extension handoff into a new conversation', () => {
+ expect(redirectSystemPath({
+ path: 'cindycn://expo-sharing',
+ initial: true,
+ })).toBe('/sessions/new');
+ expect(redirectSystemPath({
+ path: '/expo-sharing?source=share-extension',
+ initial: false,
+ })).toBe('/sessions/new');
+ });
+
+ it('preserves existing auth and ordinary deep-link behavior', () => {
+ expect(redirectSystemPath({
+ path: 'cindy://auth?code=abc',
+ initial: true,
+ })).toBe('/');
+ expect(redirectSystemPath({
+ path: '/sessions/session-1',
+ initial: false,
+ })).toBe('/sessions/session-1');
+ });
+});
diff --git a/apps/mobile/src/__tests__/newSessionAttachmentCleanup.test.ts b/apps/mobile/src/__tests__/newSessionAttachmentCleanup.test.ts
new file mode 100644
index 0000000000..d2dd9a3969
--- /dev/null
+++ b/apps/mobile/src/__tests__/newSessionAttachmentCleanup.test.ts
@@ -0,0 +1,40 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { setMobileAuthOwner, __testing } from '@/auth/authOwnerGeneration';
+import { discardNewSessionUploadedAttachments } from '@/session/newSessionAttachmentCleanup';
+
+const discard = vi.hoisted(() => vi.fn());
+vi.mock('@/session/mobileAttachmentUpload', () => ({ discardMobileUploadedAttachment: discard }));
+
+describe('new task attachment cleanup on account change', () => {
+ beforeEach(() => { __testing.reset(); discard.mockReset(); });
+
+ it('reclaims every completed upload with one eagerly captured outgoing token', async () => {
+ setMobileAuthOwner('a');
+ setMobileAuthOwner(null);
+ const attachments = [{ path: 'one' }, { path: 'two' }];
+ const getToken = vi.fn(async () => 'outgoing-token');
+ discardNewSessionUploadedAttachments(attachments, getToken);
+ expect(getToken).toHaveBeenCalledOnce();
+ expect(discard.mock.calls.map(([attachment]) => attachment)).toEqual(attachments);
+ for (const [, options] of discard.mock.calls) {
+ await expect(options.getToken()).resolves.toBe('outgoing-token');
+ }
+ });
+
+ it('does not use credentials across a later account or realm transition', async () => {
+ let resolve!: (token: string) => void;
+ const token = new Promise<string>((done) => { resolve = done; });
+ discardNewSessionUploadedAttachments([{ path: 'one' }], () => token);
+ setMobileAuthOwner('b', 'cn');
+ resolve('late-token');
+ await expect(discard.mock.calls[0]![1].getToken()).resolves.toBeNull();
+ });
+
+ it('does not fetch credentials for an empty draft and tolerates credential failure', async () => {
+ const getToken = vi.fn(async () => { throw new Error('expired'); });
+ discardNewSessionUploadedAttachments([], getToken);
+ expect(getToken).not.toHaveBeenCalled();
+ discardNewSessionUploadedAttachments([{ path: 'one' }], getToken);
+ await expect(discard.mock.calls[0]![1].getToken()).resolves.toBeNull();
+ });
+});
diff --git a/apps/mobile/src/auth/AuthContext.tsx b/apps/mobile/src/auth/AuthContext.tsx
index 916d5e5e43..8e5053d30f 100644
--- a/apps/mobile/src/auth/AuthContext.tsx
+++ b/apps/mobile/src/auth/AuthContext.tsx
@@ -121,7 +121,7 @@ import { resetAgentCapabilitiesCache } from '@/session/agentCapabilitiesCache';
import { resetComposerPaletteCache } from '@/session/composerPaletteCache';
import { clearRemoteResourceCache } from '@/device-link/remoteResourceCache';
import { clearCachedHomeListSnapshot } from '@/session/mobileHomeListCache';
-import { setMobileAuthOwner } from '@/auth/authOwnerGeneration';
+import { invalidateMobileAuthOwnerForSwitch, setMobileAuthOwner } from '@/auth/authOwnerGeneration';
import { updateCredentialAccessToken } from '@/remote-desktop/credentialIdentity';
import { clearCachedSessionMessages } from '@/session/mobileSessionMessageCache';
import { clearHistoryDisk } from '@/session/remoteHistoryDiskCache';
@@ -853,7 +853,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
}, [refreshSavedAccountsSnapshot]);
const clearAccountScopedRuntimeForSwitch = useCallback(async () => {
- setMobileAuthOwner(null);
+ invalidateMobileAuthOwnerForSwitch();
await Promise.all([
unregisterPushTokenBestEffort(
accessTokenRef.current,
diff --git a/apps/mobile/src/auth/authOwnerGeneration.ts b/apps/mobile/src/auth/authOwnerGeneration.ts
index f2487ae202..0fd5c22d33 100644
--- a/apps/mobile/src/auth/authOwnerGeneration.ts
+++ b/apps/mobile/src/auth/authOwnerGeneration.ts
@@ -6,6 +6,8 @@ export interface MobileAuthOwnerGeneration {
/** Canonical realm-qualified key for new account-scoped storage. */
readonly accountKey: string;
readonly generation: number;
+ /** Temporary empty owner during reversible account-switch cleanup. */
+ readonly switching?: true;
}
const listeners = new Set<() => void>();
@@ -23,14 +25,28 @@ let current: MobileAuthOwnerGeneration = {
export function setMobileAuthOwner(
accountId: string | null | undefined,
realm: AuthRegion = 'global',
+): void {
+ publishMobileAuthOwner(accountId, realm, false);
+}
+
+/** Keep the existing cancellation fence, without declaring a committed logout. */
+export function invalidateMobileAuthOwnerForSwitch(): void {
+ publishMobileAuthOwner(null, 'global', true);
+}
+
+function publishMobileAuthOwner(
+ accountId: string | null | undefined,
+ realm: AuthRegion,
+ switching: boolean,
): void {
const normalized = accountId?.trim() ?? '';
const accountKey = normalized ? accountVaultKey(realm, normalized) : '';
- if (current.accountKey === accountKey) return;
+ if (current.accountKey === accountKey && !!current.switching === switching) return;
current = {
accountId: normalized,
accountKey,
generation: current.generation + 1,
+ ...(switching ? { switching: true as const } : {}),
};
for (const listener of listeners) listener();
}
diff --git a/apps/mobile/src/session/IncomingShareBridge.tsx b/apps/mobile/src/session/IncomingShareBridge.tsx
new file mode 100644
index 0000000000..19b82ead26
--- /dev/null
+++ b/apps/mobile/src/session/IncomingShareBridge.tsx
@@ -0,0 +1,77 @@
+import { useEffect } from 'react';
+import { AppState, Linking, Platform } from 'react-native';
+import { useRouter, useSegments } from 'expo-router';
+
+import { useAuth } from '@/auth/AuthContext';
+import { getMobileAuthOwner, subscribeMobileAuthOwner } from '@/auth/authOwnerGeneration';
+import {
+ receiveIncomingShare,
+ useIncomingShareBatch,
+ watchIncomingShareAccount,
+} from '@/session/incomingShare';
+
+/**
+ * 根级 Share Extension 桥:未登录时先保留 App Group payload;登录、路由都就绪后
+ * 再进入新建任务。真正清除原生 payload 的时机由新建页领取成功后触发。
+ */
+export function IncomingShareBridge() {
+ const auth = useAuth();
+ const router = useRouter();
+ const segments = useSegments();
+ const batch = useIncomingShareBatch();
+ useEffect(() => {
+ if (Platform.OS !== 'ios') return;
+ let active = true;
+ const initialOwner = getMobileAuthOwner();
+ let stopWatchingAccount: (() => void) | undefined;
+ let subscriptions: Array<{ remove(): void }> = [];
+ void import('@/session/incomingShareNative').then((sharing) => {
+ if (!active) return;
+ stopWatchingAccount = watchIncomingShareAccount(sharing, initialOwner);
+ const refresh = () => {
+ void import('@/session/incomingShareCleanup')
+ .then(({ cleanupExpiredIncomingShares }) => cleanupExpiredIncomingShares())
+ .catch(() => undefined)
+ .then(() => {
+ if (!active) return;
+ // Sweep before staging, so an expired native copy cannot start a new
+ // upload concurrently with deletion. Missing copies use the existing
+ // upload error path; the user can share the original again.
+ try {
+ receiveIncomingShare(sharing);
+ } catch {
+ // Inbound sharing is unavailable in older native binaries.
+ }
+ });
+ };
+ subscriptions = [
+ AppState.addEventListener('change', (state) => { if (state === 'active') refresh(); }),
+ Linking.addEventListener('url', refresh),
+ { remove: subscribeMobileAuthOwner(() => {
+ if (!getMobileAuthOwner().switching && AppState.currentState === 'active') refresh();
+ }) },
+ ];
+ refresh();
+ }).catch(() => undefined);
+ return () => {
+ active = false;
+ stopWatchingAccount?.();
+ subscriptions.forEach((subscription) => subscription.remove());
+ };
+ }, []);
+
+ useEffect(() => {
+ if (
+ !batch
+ || !auth.initialized
+ || !auth.isAuthenticated
+ || segments[0] === '(auth)'
+ || segments.join('/') === 'sessions/new'
+ ) {
+ return;
+ }
+ router.navigate('/sessions/new');
+ }, [auth.initialized, auth.isAuthenticated, batch, router, segments]);
+
+ return null;
+}
diff --git a/apps/mobile/src/session/incomingShare.ts b/apps/mobile/src/session/incomingShare.ts
new file mode 100644
index 0000000000..03324bf10e
--- /dev/null
+++ b/apps/mobile/src/session/incomingShare.ts
@@ -0,0 +1,302 @@
+/**
+ * iOS Share Extension → 新建任务附件信箱。
+ *
+ * expo-sharing 把扩展收到的文件复制进 App Group,并在主 App 激活后提供本地
+ * payload。根导航只负责把 payload 放进这个进程内信箱;新建会话页领取后复用现有
+ * MobileLocalAttachmentUpload 管线。原生 payload 在领取成功前不清,避免登录/导航
+ * 期间丢文件。
+ */
+import { useSyncExternalStore } from 'react';
+import type { ResolvedSharePayload, SharePayload } from 'expo-sharing';
+import {
+ getMobileAuthOwner,
+ isMobileAuthOwnerCurrent,
+ subscribeMobileAuthOwner,
+ type MobileAuthOwnerGeneration,
+} from '@/auth/authOwnerGeneration';
+
+import {
+ categorizeMobileAttachment,
+ extractRemoteFileExt,
+ type MobileAttachmentCategory,
+} from '@/session/attachments';
+import type { MobileLocalAttachmentUploadCandidate } from '@/session/mobileLocalAttachmentUpload';
+import { resolvePastedImageAsset } from '@/session/pastedImageAttachment';
+
+export interface IncomingShareBatch {
+ id: string;
+ payloads: readonly ResolvedSharePayload[];
+ acknowledge: () => void;
+ owner: MobileAuthOwnerGeneration;
+}
+
+export interface IncomingShareUploadSelection {
+ candidates: MobileLocalAttachmentUploadCandidate[];
+ rejectedUris: string[];
+}
+
+let currentBatch: IncomingShareBatch | null = null;
+const pendingBatches: IncomingShareBatch[] = [];
+const listeners = new Set<() => void>();
+let unsubscribeOwner: (() => void) | undefined;
+
+export async function deleteIncomingSharedFiles(uris: readonly string[]): Promise<void> {
+ const FileSystem = await import('expo-file-system/legacy');
+ await Promise.all([...new Set(uris)].filter((uri) => uri.startsWith('file://')).map((uri) => (
+ FileSystem.deleteAsync(
+ // Each native input owns one UUID directory; converted images are files.
+ uri.match(/^(file:\/\/.*\/cindy-share-[\da-f-]{36})\/[^/]+$/i)?.[1] ?? uri,
+ { idempotent: true },
+ ).catch(() => undefined)
+ )));
+}
+
+function acknowledgeBatch(batch: IncomingShareBatch): void {
+ try { batch.acknowledge(); } catch {
+ // Older native binaries may not expose the App Group.
+ }
+}
+
+function canRetainShareOwner(
+ owner: MobileAuthOwnerGeneration,
+ current: MobileAuthOwnerGeneration,
+ restored?: MobileAuthOwnerGeneration,
+): boolean {
+ if (owner.switching || current.switching) return false;
+ return (owner.accountKey === current.accountKey && owner.generation === current.generation)
+ || (!owner.accountKey && !!current.accountKey && current.generation === owner.generation + 1)
+ || (!!restored && owner.accountKey === restored.accountKey && owner.generation === restored.generation);
+}
+
+/** Only unclaimed shares wait for a reversible switch; other auth listeners still cancel immediately. */
+function observeIncomingShareOwner(
+ listener: (previous: MobileAuthOwnerGeneration, current: MobileAuthOwnerGeneration,
+ restored?: MobileAuthOwnerGeneration) => void,
+ previous = getMobileAuthOwner(),
+): () => void {
+ let switching = !!previous.switching;
+ const changed = () => {
+ const current = getMobileAuthOwner();
+ if (current.switching) { switching = true; return; }
+ // An observer installed mid-switch has no known source account: fail closed.
+ const restored = switching && !previous.switching && previous.accountKey === current.accountKey
+ ? previous : undefined;
+ listener(previous, current, restored);
+ previous = current;
+ switching = false;
+ };
+ changed();
+ return subscribeMobileAuthOwner(changed);
+}
+
+function updateIncomingShareOwner(
+ _previous: MobileAuthOwnerGeneration,
+ owner: MobileAuthOwnerGeneration,
+ restored?: MobileAuthOwnerGeneration,
+): void {
+ const discarded = pendingBatches.filter((batch) => {
+ return !canRetainShareOwner(batch.owner, owner, restored);
+ });
+ for (const batch of discarded) {
+ pendingBatches.splice(pendingBatches.indexOf(batch), 1);
+ acknowledgeBatch(batch);
+ void deleteIncomingSharedFiles(batch.payloads.map((payload) => payload.contentUri ?? payload.value))
+ .catch(() => undefined);
+ }
+ // New snapshots also wake the focused consumer after a rollback/first login.
+ for (let index = 0; index < pendingBatches.length; index += 1) {
+ const batch = pendingBatches[index]!;
+ if (batch.owner !== owner) pendingBatches[index] = { ...batch, owner };
+ }
+ currentBatch = pendingBatches[0] ?? null;
+ emit();
+}
+
+type IncomingShareNative = {
+ getSharedPayloads(): SharePayload[];
+ clearSharedPayloads(expected: SharePayload[]): void;
+};
+
+/** Also clear a native payload not yet observed by the JS mailbox on logout/switch. */
+export function watchIncomingShareAccount(
+ native: IncomingShareNative,
+ previous = getMobileAuthOwner(),
+): () => void {
+ return observeIncomingShareOwner((previous, current, restored) => {
+ if (!canRetainShareOwner(previous, current, restored)) {
+ try {
+ const raw = native.getSharedPayloads();
+ native.clearSharedPayloads(raw);
+ void deleteIncomingSharedFiles(raw.map((payload) => payload.value)).catch(() => undefined);
+ } catch { /* Sharing is unavailable in older native binaries. */ }
+ }
+ }, previous);
+}
+
+function emit(): void {
+ for (const listener of listeners) listener();
+}
+
+function getSnapshot(): IncomingShareBatch | null {
+ return currentBatch;
+}
+
+function subscribe(listener: () => void): () => void {
+ listeners.add(listener);
+ return () => listeners.delete(listener);
+}
+
+export function useIncomingShareBatch(): IncomingShareBatch | null {
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
+}
+
+export function incomingShareBatchId(payloads: readonly ResolvedSharePayload[]): string {
+ return JSON.stringify(payloads.map((payload) => ({
+ value: payload.value,
+ shareType: payload.shareType,
+ mimeType: payload.mimeType ?? null,
+ contentUri: payload.contentUri,
+ contentType: payload.contentType,
+ contentMimeType: payload.contentMimeType,
+ originalName: payload.originalName,
+ contentSize: payload.contentSize,
+ })));
+}
+
+export function stageIncomingShareBatch(
+ payloads: readonly ResolvedSharePayload[],
+ acknowledge: () => void,
+): IncomingShareBatch | null {
+ if (payloads.length === 0 || getMobileAuthOwner().switching) return null;
+ const id = incomingShareBatchId(payloads);
+ const existing = pendingBatches.find((batch) => batch.id === id);
+ if (existing) return existing;
+ unsubscribeOwner ??= observeIncomingShareOwner(updateIncomingShareOwner);
+ const batch = { id, payloads: [...payloads], acknowledge, owner: getMobileAuthOwner() };
+ pendingBatches.push(batch);
+ currentBatch = pendingBatches[0]!;
+ emit();
+ return batch;
+}
+
+export function consumeIncomingShareBatch(id: string): boolean {
+ if (getMobileAuthOwner().switching || !currentBatch || currentBatch.id !== id
+ || !currentBatch.owner.accountKey || !isMobileAuthOwnerCurrent(currentBatch.owner)) return false;
+ const consumed = currentBatch;
+ pendingBatches.shift();
+ currentBatch = pendingBatches[0] ?? null;
+ emit();
+ acknowledgeBatch(consumed);
+ return true;
+}
+
+/** Raw local files need no asynchronous resolver; the uploader stats their size. */
+export function receiveIncomingShare(native: IncomingShareNative): void {
+ if (getMobileAuthOwner().switching) return;
+ const raw = native.getSharedPayloads();
+ if (raw.length === 0) return;
+ const payloads = raw.map((payload): ResolvedSharePayload => ({
+ ...payload,
+ contentUri: payload.value,
+ contentType: payload.shareType === 'image' ? 'image' : 'file',
+ contentMimeType: payload.mimeType ?? null,
+ originalName: basenameFromUri(payload.value),
+ contentSize: null,
+ }));
+ stageIncomingShareBatch(payloads, () => {
+ // Native compares the captured bytes and clears under the writer's lock.
+ native.clearSharedPayloads(raw);
+ });
+}
+
+function safeDecode(value: string): string {
+ try {
+ return decodeURIComponent(value);
+ } catch {
+ return value;
+ }
+}
+
+function basenameFromUri(uri: string): string {
+ const withoutQuery = uri.split(/[?#]/)[0] ?? uri;
+ const slash = Math.max(withoutQuery.lastIndexOf('/'), withoutQuery.lastIndexOf('\\'));
+ return safeDecode(slash >= 0 ? withoutQuery.slice(slash + 1) : withoutQuery);
+}
+
+function candidateKind(
+ category: MobileAttachmentCategory,
+): MobileLocalAttachmentUploadCandidate['kind'] {
+ return category === 'image' ? 'image' : 'file';
+}
+
+function replaceImageExtension(name: string): string {
+ const ext = extractRemoteFileExt(name);
+ return ext ? `${name.slice(0, -ext.length)}.jpg` : `${name}.jpg`;
+}
+
+export function selectIncomingShareUploadCandidates(
+ payloads: readonly ResolvedSharePayload[],
+): IncomingShareUploadSelection {
+ const candidates: MobileLocalAttachmentUploadCandidate[] = [];
+ const rejectedUris: string[] = [];
+
+ for (const payload of payloads) {
+ const uri = payload.contentUri?.trim()
+ || (payload.shareType === 'file' || payload.shareType === 'image'
+ ? payload.value.trim()
+ : '');
+ if (!uri || !uri.startsWith('file://')) continue;
+
+ const name = payload.originalName?.trim() || basenameFromUri(uri);
+ const category = name ? categorizeMobileAttachment(name) : null;
+ const isImage = payload.contentType === 'image' || payload.shareType === 'image';
+ if (!name || (!category && !isImage)) {
+ rejectedUris.push(uri);
+ continue;
+ }
+
+ const size = typeof payload.contentSize === 'number'
+ && Number.isFinite(payload.contentSize)
+ && payload.contentSize > 0
+ ? payload.contentSize
+ : 0;
+ if (!category && isImage) {
+ const index = candidates.length;
+ candidates.push({
+ kind: 'image',
+ uri,
+ name,
+ size,
+ mimeType: payload.contentMimeType?.trim() || payload.mimeType?.trim() || undefined,
+ resolve: async () => {
+ const resolved = await resolvePastedImageAsset(uri, index);
+ return {
+ uri: resolved.uri,
+ name: replaceImageExtension(name),
+ mimeType: resolved.mimeType,
+ size: 0,
+ skipPreprocess: true,
+ };
+ },
+ });
+ continue;
+ }
+ candidates.push({
+ kind: candidateKind(category!),
+ uri,
+ name,
+ size,
+ mimeType: payload.contentMimeType?.trim() || payload.mimeType?.trim() || undefined,
+ });
+ }
+
+ return { candidates, rejectedUris };
+}
+
+export function __resetIncomingShareForTest(): void {
+ unsubscribeOwner?.();
+ unsubscribeOwner = undefined;
+ currentBatch = null;
+ pendingBatches.length = 0;
+ listeners.clear();
+}
diff --git a/apps/mobile/src/session/incomingShareCleanup.ts b/apps/mobile/src/session/incomingShareCleanup.ts
new file mode 100644
index 0000000000..3632ffa812
--- /dev/null
+++ b/apps/mobile/src/session/incomingShareCleanup.ts
@@ -0,0 +1,32 @@
+import { Directory, Paths } from 'expo-file-system';
+import { deleteAsync } from 'expo-file-system/legacy';
+
+const SHARE_COPY_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
+const SHARE_DIRECTORY = /^cindy-share-[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
+
+/** Reclaim copies orphaned by native-slot replacement or process termination.
+ * Only our direct UUID directories expire, never the user's original files.
+ * Age is the directory's creation time, not the imported file's timestamp.
+ * An expired pending share must be shared again; normal uploads clean up sooner.
+ */
+export async function cleanupExpiredIncomingShares(now = Date.now()): Promise<void> {
+ try {
+ for (const root of Object.values(Paths.appleSharedContainers)) {
+ let entries;
+ try { entries = root.list(); } catch { continue; }
+ for (const entry of entries) {
+ if (!(entry instanceof Directory) || !SHARE_DIRECTORY.test(entry.name)) continue;
+ try {
+ const created = entry.info().creationTime;
+ if (typeof created !== 'number' || !Number.isFinite(created) || created <= 0
+ || now - created < SHARE_COPY_RETENTION_MS) continue;
+ await deleteAsync(entry.uri, { idempotent: true });
+ } catch {
+ // Best effort: inaccessible or concurrently removed entries retry on foreground.
+ }
+ }
+ }
+ } catch {
+ // Older native binaries may not expose App Group containers.
+ }
+}
diff --git a/apps/mobile/src/session/incomingShareNative.ts b/apps/mobile/src/session/incomingShareNative.ts
new file mode 100644
index 0000000000..5c307139ec
--- /dev/null
+++ b/apps/mobile/src/session/incomingShareNative.ts
@@ -0,0 +1,23 @@
+import { requireOptionalNativeModule } from 'expo-modules-core';
+import type { SharePayload } from 'expo-sharing';
+
+const native = requireOptionalNativeModule<{
+ readSnapshot(): string | null;
+ clearSnapshot(expected: string): boolean;
+}>('CindyIncomingShare');
+const snapshots = new WeakMap<SharePayload[], string>();
+
+export function getSharedPayloads(): SharePayload[] {
+ const snapshot = native?.readSnapshot();
+ if (!snapshot) return [];
+ const payloads: SharePayload[] = JSON.parse(snapshot).map((item: { value: string; type: SharePayload['shareType']; mimeType?: string }) => ({
+ value: item.value, shareType: item.type, mimeType: item.mimeType,
+ }));
+ snapshots.set(payloads, snapshot);
+ return payloads;
+}
+
+export function clearSharedPayloads(expected: SharePayload[]): void {
+ const snapshot = snapshots.get(expected);
+ if (snapshot !== undefined) native?.clearSnapshot(snapshot);
+}
diff --git a/apps/mobile/src/session/mobileLocalAttachmentUpload.ts b/apps/mobile/src/session/mobileLocalAttachmentUpload.ts
index 76f60747ee..6dba058a74 100644
--- a/apps/mobile/src/session/mobileLocalAttachmentUpload.ts
+++ b/apps/mobile/src/session/mobileLocalAttachmentUpload.ts
@@ -50,7 +50,8 @@ export interface MobileLocalAttachmentUploadCandidate {
/** resolve 阶段已完成优化编码(如 HEIC 转码+缩边),跳过 preprocess 防二次有损。 */
skipPreprocess?: boolean;
/**
- * 仅由明确拥有输入文件的调用方提供(当前是 WebView 粘贴落盘):
+ * 仅由明确拥有输入文件的调用方提供(当前是 WebView 粘贴落盘与 iOS Share
+ * Extension 复制进 App Group 的文件):
* controller 会把 resolve / preprocess 生成的同任务临时 uri 一并交回清理。
* 系统相册、相机与文件选择器的 uri 不设置此钩子,避免误删宿主管理的文件。
*/
diff --git a/apps/mobile/src/session/newSessionAttachmentCleanup.ts b/apps/mobile/src/session/newSessionAttachmentCleanup.ts
new file mode 100644
index 0000000000..015aacd87f
--- /dev/null
+++ b/apps/mobile/src/session/newSessionAttachmentCleanup.ts
@@ -0,0 +1,23 @@
+import { getMobileAuthOwner, isMobileAuthOwnerCurrent } from '@/auth/authOwnerGeneration';
+import { discardMobileUploadedAttachment } from '@/session/mobileAttachmentUpload';
+
+/** Best-effort reclaim before the account-change callback drops draft references. */
+export function discardNewSessionUploadedAttachments(
+ attachments: readonly { path?: string }[],
+ getToken: () => Promise<string | null>,
+): void {
+ if (attachments.length === 0) return;
+ const ownerAtClear = getMobileAuthOwner();
+ // Start now, while AuthProvider still holds the outgoing account's token.
+ // Never ask a later account for credentials from a deferred cleanup callback.
+ let token: Promise<string | null>;
+ try { token = getToken().catch(() => null); } catch { return; }
+ for (const attachment of attachments) {
+ discardMobileUploadedAttachment(attachment, {
+ getToken: async () => {
+ const captured = await token;
+ return isMobileAuthOwnerCurrent(ownerAtClear) ? captured : null;
+ },
+ });
+ }
+}
diff --git a/docs/design-rules/design-inventory.md b/docs/design-rules/design-inventory.md
index 0d5564a648..8358318d74 100644
--- a/docs/design-rules/design-inventory.md
+++ b/docs/design-rules/design-inventory.md
@@ -51,20 +51,20 @@
| `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 | 101 | 57 | 198 |
| `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 | 67 | 50 | 25 |
-| `mobile.account-deletion` | mobile | 账号注销 | app/account-deletion.tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, account-deletion, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 19 |
-| `mobile.auth` | mobile | 登录与添加账号 | app/(auth)/login.tsx / app/add-account.tsx | AccountSwitcherSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, LoginCaptchaWebView, LoginSkinControls, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, PushNotificationsBridge, QuietSyncIndicator, SheetModal, SheetSurface, StartupSplashOverlay, ThemeProvider, _layout, add-account, gestureHandler, login, useLocale | apps/mobile/app/(auth)/login.tsx, apps/mobile/app/_layout.tsx, apps/mobile/app/add-account.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/LoginCaptchaWebView.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/LoginSkinControls.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/BlurBackdrop.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 | 0 | 177 | 43 |
-| `mobile.automations` | mobile | 自动化 | app/automations/[deviceId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 35 |
-| `mobile.chat.new` | mobile | 新建任务 | app/sessions/new.tsx | AnnotationBurnInWebView, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerAttachmentTray, ComposerKeyboardAvoidingView, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheetGoalView, ContextSheetMediaViews, DeviceLinkContext, HomeNativeStackHeader, ImageLightbox, MobileAgentMark, MobileAgentSwitcher, MobileChoicePickerList, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobilePermissionPickerList, MobilePrimitives, MobileProviderMark, MobileVendorIcon, ModelOptionsSheetView, ModelPickerSheet, NativePullDownMenu, NativeSwitch, PaperPlaneIcon, PlanModeChip, PushNotificationsBridge, QuietSyncIndicator, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, ThemeProvider, VoiceRecordingPill, _layout, gestureHandler, new, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/new.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileVendorIcon.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/ContextSheetGoalView.tsx, apps/mobile/src/session/ContextSheetMediaViews.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/MobileAgentSwitcher.tsx, apps/mobile/src/session/MobileChoicePickerList.tsx, apps/mobile/src/session/MobileComposerInputRow.tsx, apps/mobile/src/session/MobileModelPickerList.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 202 | 72 |
-| `mobile.chat.session` | mobile | 任务内容与输入 | app/sessions/[sessionId].tsx | AnnotationBurnInWebView, AppText, AuthContext, AuthorizationMessageCard, BlurBackdrop, CenteredScreen, ChatFileChipMenuSheet, CompanionMessageCard, ComposerAttachmentTray, ComposerKeyboardAvoidingView, ComposerRichInput, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheetGoalView, ContextSheetMediaViews, ConversationSearchFilterSheet, ConversationShareSvg, ConversationShareWebView, DeviceLinkContext, FailedScheduleNotice, HomeGlassMenuPanel, HomeNativeStackHeader, HomeSearchBar, ImageLightbox, InlineQueueSection, InlineQuoteChip, InlineReferenceChip, InteractionPanel, MarkdownBlockContent, MessageActionSheet, MessageRenderer, MobileAgentMark, MobileAgentSwitcher, MobileBoundaryNotice, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobilePermissionPickerList, MobilePrimitives, MobileProviderMark, ModelOptionsSheetView, ModelPickerSheet, NativePullDownMenu, NativeSwitch, PaperPlaneIcon, PendingSendBubble, PiSessionTreeSheet, PlanModeChip, PushNotificationsBridge, QuietSyncIndicator, QuoteCapsule, RewindPreviewPanel, SentInlineAtomBody, SessionListDrawer, SessionMenuSheet, SessionTailBanner, SessionUsageSummary, ShareMessageCheckbox, ShareSelectAllButton, ShareSelectionBar, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, StreamingStatusText, ThemeProvider, VoiceRecordingPill, [sessionId], _layout, gestureHandler, mathWebView, mediaPlayerWebView, mermaidWebView, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/[sessionId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/AuthorizationMessageCard.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ChatFileChipMenuSheet.tsx, apps/mobile/src/session/CompanionMessageCard.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ComposerRichInput.tsx, apps/mobile/src/session/ContextSheet.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/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/ImageLightbox.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.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/PendingSendBubble.tsx, apps/mobile/src/session/PiSessionTreeSheet.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/QuoteCapsule.tsx, apps/mobile/src/session/RewindPreviewPanel.tsx, apps/mobile/src/session/SentInlineAtomBody.tsx, apps/mobile/src/session/SessionListDrawer.tsx, apps/mobile/src/session/SessionMenuSheet.tsx, apps/mobile/src/session/SessionTailBanner.tsx, apps/mobile/src/session/SessionUsageSummary.tsx, apps/mobile/src/session/ShareMessageCheckbox.tsx, apps/mobile/src/session/ShareSelectAllButton.tsx, apps/mobile/src/session/ShareSelectionBar.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/StreamingStatusText.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/session/composerRichInputHtml.ts, apps/mobile/src/session/conversationShareWebViewHtml.ts, apps/mobile/src/session/mathWebView.tsx, apps/mobile/src/session/mathWebViewHtml.ts, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.ts, apps/mobile/src/session/mermaidWebView.tsx, apps/mobile/src/session/mermaidWebViewHtml.ts, apps/mobile/src/session/selectableMarkdownHtml.ts, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 7 | 203 | 188 |
-| `mobile.companions.direct` | mobile | 伙伴私聊回看 | app/companions/direct/[threadId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [threadId], _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 14 |
-| `mobile.device-management` | mobile | 设备管理 | app/devices/manage.tsx / app/devices/manage/[deviceId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceInformationFields, DeviceInformationFields.ios, DeviceLinkContext, DeviceManagementDialogs, DeviceManagementList, DeviceManagementList.ios, HomeNativeStackHeader, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, RenameDeviceModal, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, manage, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/RenameDeviceModal.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 17 |
-| `mobile.devices` | mobile | 主机详情 | app/devices/[deviceId].tsx | AccountSwitcherSheet, AppText, AuthContext, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, ConversationSearchFilterSheet, DeviceLinkContext, HomeChromeDrawer, HomeChromeFrost, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeNativeStackHeader, HomeProjectMachineLabel, HomeSearchBar, MobileAgentMark, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, MobileVendorIcon, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, RemoteAccessGuide, RemoteTaskSuggestions, RenameSessionModal, SessionActionSheet, SessionOptionsExpoSheet, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, SwipeableSessionRow, SwipeableSessionRow.ios, ThemeProvider, [deviceId], _layout, gestureHandler, index, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/[deviceId].tsx, apps/mobile/app/devices/index.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileVendorIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/RemoteAccessGuide.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/AutomationTimerIcon.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ConversationSearchFilterSheet.tsx, apps/mobile/src/session/HomeChromeDrawer.tsx, apps/mobile/src/session/HomeChromeFrost.tsx, apps/mobile/src/session/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/SessionActionSheet.tsx, apps/mobile/src/session/SessionOptionsExpoSheet.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SwipeableSessionRow.ios.tsx, apps/mobile/src/session/SwipeableSessionRow.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 60 |
-| `mobile.files` | mobile | 任务文件与预览 | app/files/[sessionId].tsx / app/files/preview/[sessionId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HtmlFileReader, ImageLightbox, MarkdownFileReader, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, PushNotificationsBridge, QuietSyncIndicator, StartupSplashOverlay, ThemeProvider, [sessionId], _layout, gestureHandler, mediaPlayerWebView, 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/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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/HtmlFileReader.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/MarkdownFileReader.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 | 0 | 202 | 36 |
-| `mobile.home` | mobile | 主机与资源首页 | app/index.tsx / app/devices/index.tsx | AccountSwitcherSheet, AppText, AuthContext, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, ConversationSearchFilterSheet, DeviceLinkContext, HomeChromeDrawer, HomeChromeFrost, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeNativeStackHeader, HomeProjectMachineLabel, HomeSearchBar, MobileAgentMark, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, MobileVendorIcon, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, RemoteAccessGuide, RemoteTaskSuggestions, RenameSessionModal, SessionActionSheet, SessionOptionsExpoSheet, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, SwipeableSessionRow, SwipeableSessionRow.ios, ThemeProvider, _layout, gestureHandler, index, 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/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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/AutomationTimerIcon.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ConversationSearchFilterSheet.tsx, apps/mobile/src/session/HomeChromeDrawer.tsx, apps/mobile/src/session/HomeChromeFrost.tsx, apps/mobile/src/session/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/SessionActionSheet.tsx, apps/mobile/src/session/SessionOptionsExpoSheet.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SwipeableSessionRow.ios.tsx, apps/mobile/src/session/SwipeableSessionRow.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 56 |
-| `mobile.overlay.connection-startup` | mobile | 根布局挂载的启动与连接反馈 | app/_layout.tsx → StartupSplashOverlay / ConnectionNoticeProvider;各页面 ConnectionBanner | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, ConnectionNoticeProvider, DeviceLinkContext, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, PushNotificationsBridge, QuietSyncIndicator, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 13 |
-| `mobile.remote-desktop` | mobile | 远程桌面 | app/devices/desktop/[deviceId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopIcons, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/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.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/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 41 |
-| `mobile.resources` | mobile | 远程资源列表与详情 | app/resources/[collectionId].tsx / app/resources/[collectionId]/[resourceId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, RemoteCompanionAvatar, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [collectionId], [resourceId], _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 18 |
-| `mobile.settings` | mobile | 设置(含调试与日志上传可见入口) | app/settings.tsx | AppText, AuthContext, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, MobileChoicePickerList, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/MobileChoicePickerList.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 | 0 | 170 | 22 |
+| `mobile.account-deletion` | mobile | 账号注销 | app/account-deletion.tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, account-deletion, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 19 |
+| `mobile.auth` | mobile | 登录与添加账号 | app/(auth)/login.tsx / app/add-account.tsx | AccountSwitcherSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, IncomingShareBridge, LoginCaptchaWebView, LoginSkinControls, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, PushNotificationsBridge, QuietSyncIndicator, SheetModal, SheetSurface, StartupSplashOverlay, ThemeProvider, _layout, add-account, gestureHandler, login, useLocale | apps/mobile/app/(auth)/login.tsx, apps/mobile/app/_layout.tsx, apps/mobile/app/add-account.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/LoginCaptchaWebView.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/LoginSkinControls.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 177 | 43 |
+| `mobile.automations` | mobile | 自动化 | app/automations/[deviceId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 35 |
+| `mobile.chat.new` | mobile | 新建任务 | app/sessions/new.tsx | AnnotationBurnInWebView, AppText, AuthContext, BlurBackdrop, CenteredScreen, ComposerAttachmentTray, ComposerKeyboardAvoidingView, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheetGoalView, ContextSheetMediaViews, DeviceLinkContext, HomeNativeStackHeader, ImageLightbox, IncomingShareBridge, MobileAgentMark, MobileAgentSwitcher, MobileChoicePickerList, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobilePermissionPickerList, MobilePrimitives, MobileProviderMark, MobileVendorIcon, ModelOptionsSheetView, ModelPickerSheet, NativePullDownMenu, NativeSwitch, PaperPlaneIcon, PlanModeChip, PushNotificationsBridge, QuietSyncIndicator, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, ThemeProvider, VoiceRecordingPill, _layout, gestureHandler, new, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/new.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileVendorIcon.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/ContextSheetGoalView.tsx, apps/mobile/src/session/ContextSheetMediaViews.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.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 202 | 72 |
+| `mobile.chat.session` | mobile | 任务内容与输入 | app/sessions/[sessionId].tsx | AnnotationBurnInWebView, AppText, AuthContext, AuthorizationMessageCard, BlurBackdrop, CenteredScreen, ChatFileChipMenuSheet, CompanionMessageCard, ComposerAttachmentTray, ComposerKeyboardAvoidingView, ComposerRichInput, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheetGoalView, ContextSheetMediaViews, ConversationSearchFilterSheet, ConversationShareSvg, ConversationShareWebView, DeviceLinkContext, FailedScheduleNotice, HomeGlassMenuPanel, HomeNativeStackHeader, HomeSearchBar, ImageLightbox, IncomingShareBridge, InlineQueueSection, InlineQuoteChip, InlineReferenceChip, InteractionPanel, MarkdownBlockContent, MessageActionSheet, MessageRenderer, MobileAgentMark, MobileAgentSwitcher, MobileBoundaryNotice, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobilePermissionPickerList, MobilePrimitives, MobileProviderMark, ModelOptionsSheetView, ModelPickerSheet, NativePullDownMenu, NativeSwitch, PaperPlaneIcon, PendingSendBubble, PiSessionTreeSheet, PlanModeChip, PushNotificationsBridge, QuietSyncIndicator, QuoteCapsule, RewindPreviewPanel, SentInlineAtomBody, SessionListDrawer, SessionMenuSheet, SessionTailBanner, SessionUsageSummary, ShareMessageCheckbox, ShareSelectAllButton, ShareSelectionBar, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, StreamingStatusText, ThemeProvider, VoiceRecordingPill, [sessionId], _layout, gestureHandler, mathWebView, mediaPlayerWebView, mermaidWebView, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/[sessionId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/AuthorizationMessageCard.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ChatFileChipMenuSheet.tsx, apps/mobile/src/session/CompanionMessageCard.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ComposerRichInput.tsx, apps/mobile/src/session/ContextSheet.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/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/InlineQueueSection.tsx, apps/mobile/src/session/InlineQuoteChip.tsx, apps/mobile/src/session/InlineReferenceChip.tsx, apps/mobile/src/session/InteractionPanel.tsx, apps/mobile/src/session/MarkdownBlockContent.tsx, apps/mobile/src/session/MessageActionSheet.tsx, apps/mobile/src/session/MessageRenderer.tsx, apps/mobile/src/session/MobileAgentSwitcher.tsx, apps/mobile/src/session/MobileBoundaryNotice.tsx, apps/mobile/src/session/MobileComposerInputRow.tsx, apps/mobile/src/session/MobileModelPickerList.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/PendingSendBubble.tsx, apps/mobile/src/session/PiSessionTreeSheet.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/QuoteCapsule.tsx, apps/mobile/src/session/RewindPreviewPanel.tsx, apps/mobile/src/session/SentInlineAtomBody.tsx, apps/mobile/src/session/SessionListDrawer.tsx, apps/mobile/src/session/SessionMenuSheet.tsx, apps/mobile/src/session/SessionTailBanner.tsx, apps/mobile/src/session/SessionUsageSummary.tsx, apps/mobile/src/session/ShareMessageCheckbox.tsx, apps/mobile/src/session/ShareSelectAllButton.tsx, apps/mobile/src/session/ShareSelectionBar.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/StreamingStatusText.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/session/composerRichInputHtml.ts, apps/mobile/src/session/conversationShareWebViewHtml.ts, apps/mobile/src/session/mathWebView.tsx, apps/mobile/src/session/mathWebViewHtml.ts, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.ts, apps/mobile/src/session/mermaidWebView.tsx, apps/mobile/src/session/mermaidWebViewHtml.ts, apps/mobile/src/session/selectableMarkdownHtml.ts, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 7 | 203 | 188 |
+| `mobile.companions.direct` | mobile | 伙伴私聊回看 | app/companions/direct/[threadId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [threadId], _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 14 |
+| `mobile.device-management` | mobile | 设备管理 | app/devices/manage.tsx / app/devices/manage/[deviceId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceInformationFields, DeviceInformationFields.ios, DeviceLinkContext, DeviceManagementDialogs, DeviceManagementList, DeviceManagementList.ios, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, RenameDeviceModal, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, manage, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/RenameDeviceModal.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 17 |
+| `mobile.devices` | mobile | 主机详情 | app/devices/[deviceId].tsx | AccountSwitcherSheet, AppText, AuthContext, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, ConversationSearchFilterSheet, DeviceLinkContext, HomeChromeDrawer, HomeChromeFrost, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeNativeStackHeader, HomeProjectMachineLabel, HomeSearchBar, IncomingShareBridge, MobileAgentMark, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, MobileVendorIcon, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, RemoteAccessGuide, RemoteTaskSuggestions, RenameSessionModal, SessionActionSheet, SessionOptionsExpoSheet, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, SwipeableSessionRow, SwipeableSessionRow.ios, ThemeProvider, [deviceId], _layout, gestureHandler, index, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/devices/[deviceId].tsx, apps/mobile/app/devices/index.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileVendorIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/RemoteAccessGuide.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/AutomationTimerIcon.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ConversationSearchFilterSheet.tsx, apps/mobile/src/session/HomeChromeDrawer.tsx, apps/mobile/src/session/HomeChromeFrost.tsx, apps/mobile/src/session/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/SessionActionSheet.tsx, apps/mobile/src/session/SessionOptionsExpoSheet.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SwipeableSessionRow.ios.tsx, apps/mobile/src/session/SwipeableSessionRow.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 60 |
+| `mobile.files` | mobile | 任务文件与预览 | app/files/[sessionId].tsx / app/files/preview/[sessionId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HtmlFileReader, ImageLightbox, IncomingShareBridge, MarkdownFileReader, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, PushNotificationsBridge, QuietSyncIndicator, StartupSplashOverlay, ThemeProvider, [sessionId], _layout, gestureHandler, mediaPlayerWebView, 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/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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/HtmlFileReader.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MarkdownFileReader.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 | 0 | 202 | 36 |
+| `mobile.home` | mobile | 主机与资源首页 | app/index.tsx / app/devices/index.tsx | AccountSwitcherSheet, AppText, AuthContext, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, ConversationSearchFilterSheet, DeviceLinkContext, HomeChromeDrawer, HomeChromeFrost, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeNativeStackHeader, HomeProjectMachineLabel, HomeSearchBar, IncomingShareBridge, MobileAgentMark, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, MobileVendorIcon, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, RemoteAccessGuide, RemoteTaskSuggestions, RenameSessionModal, SessionActionSheet, SessionOptionsExpoSheet, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, SwipeableSessionRow, SwipeableSessionRow.ios, ThemeProvider, _layout, gestureHandler, index, 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/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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/AutomationTimerIcon.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ConversationSearchFilterSheet.tsx, apps/mobile/src/session/HomeChromeDrawer.tsx, apps/mobile/src/session/HomeChromeFrost.tsx, apps/mobile/src/session/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/SessionActionSheet.tsx, apps/mobile/src/session/SessionOptionsExpoSheet.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SwipeableSessionRow.ios.tsx, apps/mobile/src/session/SwipeableSessionRow.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 56 |
+| `mobile.overlay.connection-startup` | mobile | 根布局挂载的启动与连接反馈 | app/_layout.tsx → StartupSplashOverlay / ConnectionNoticeProvider;各页面 ConnectionBanner | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, ConnectionNoticeProvider, DeviceLinkContext, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, PushNotificationsBridge, QuietSyncIndicator, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 13 |
+| `mobile.remote-desktop` | mobile | 远程桌面 | app/devices/desktop/[deviceId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopIcons, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, StartupSplashOverlay, ThemeProvider, [deviceId], _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/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.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/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 41 |
+| `mobile.resources` | mobile | 远程资源列表与详情 | app/resources/[collectionId].tsx / app/resources/[collectionId]/[resourceId].tsx | AppText, AuthContext, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, IncomingShareBridge, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, RemoteCompanionAvatar, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [collectionId], [resourceId], _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts | 0 | 170 | 18 |
+| `mobile.settings` | mobile | 设置(含调试与日志上传可见入口) | app/settings.tsx | AppText, AuthContext, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, HomeNativeStackHeader, IncomingShareBridge, MobileChoicePickerList, MobileLoginHandoffContext, MobileLoginHandoffStage, MobilePrimitives, NativePullDownMenu, NativeSwitch, PushNotificationsBridge, QuietSyncIndicator, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, 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/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/MobileChoicePickerList.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 | 0 | 170 | 22 |
### 生产路由覆盖