Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 详情归档复用列表预检事务
Dasha247924bfa5e
diff --git a/apps/desktop/src/renderer/__tests__/sidebarUpperSingleButton.test.ts b/apps/desktop/src/renderer/__tests__/sidebarUpperSingleButton.test.tsindex 99a8ebd757..d79c389993 100644--- a/apps/desktop/src/renderer/__tests__/sidebarUpperSingleButton.test.ts+++ b/apps/desktop/src/renderer/__tests__/sidebarUpperSingleButton.test.ts@@ -109,39 +109,8 @@ describe('Project 行内 + 也对标统一 New(delayed-create)', () => {});describe('archive dirty-worktree warning', () => {- it('only skips the archive dialog when the preflight confirms the worktree is clean', () => {- // 钉的是预检顺序与放行判据,不是排版:末段用 [\s\S]*? 容忍换行。- // · 菜单归档与行内 archive-now 共用 isArchiveLike 这一条无弹窗路径 ——- // 归档可逆,只有 worktree 有情况或绑定了 active 自动化才升级到 ConfirmDialog;- // · 判据必须是 `preflight !== 'clean'`,**不能**退回布尔的「不是脏的就放行」:- // 预检失败是 'unknown',塌成放行就会静默回收带未提交改动的 worktree- // (greptile review);- // · 走 resolveWorktreeRemovalPreflight(而非直调 fetch)才吃得到菜单打开 /- // 亮出 Confirm 胶囊时的预取,见 worktreeRemovalWarning 的预取缓存;- // · activeSessionId 取 viewedSessionIdRef.current(而非 viewedSessionId)是为了- // 让 handleActionClick 的 useCallback deps 保持稳定,见 sessionRowRenderIsolation- // 的行渲染隔离不变量。- expect(sidebarSource).toMatch(- /if \(isArchiveLike\) \{[\s\S]*?resolveWorktreeRemovalPreflight\([\s\S]*?if \(preflight !== 'clean' \|\| scheduleNames\.length > 0\) \{[\s\S]*?setConfirm\(\{[\s\S]*?action: 'archive',[\s\S]*?dirtyWorktree: preflight === 'dirty',[\s\S]*?scheduleNames,[\s\S]*?\}\);[\s\S]*?return;[\s\S]*?await runSessionAction\(sessionId, 'archive', \{[\s\S]*?activeSessionId: viewedSessionIdRef\.current,[\s\S]*?\}\);/,- );- });-- it('resolves the worktree preflight last, after the attachment gate', () => {- // 预检之后再 await 任何东西都会给 clean 结论留失效窗口(codex review):- // 接管查询必须先结算,worktree 预检是最后一个前置条件。- const archiveBranch = sidebarSource.match(- /if \(isArchiveLike\) \{[\s\S]*?await runSessionAction\(sessionId, 'archive'/,- )?.[0];- expect(archiveBranch).toBeTruthy();- expect(archiveBranch!.indexOf('blockedByAttachment()')).toBeLessThan(- archiveBranch!.indexOf('resolveWorktreeRemovalPreflight('),- );- // 自动化绑定读本地缓存,也排在预检之前。- expect(archiveBranch!.indexOf('loadActiveBoundScheduleNames(')).toBeGreaterThan(-1);- expect(archiveBranch!.indexOf('loadActiveBoundScheduleNames(')).toBeLessThan(- archiveBranch!.indexOf('resolveWorktreeRemovalPreflight('),- );- });+ // Archive decision and ordering are exercised through the production callbacks+ // in sharedTaskArchiveGuard.test.ts, rather than matching a removed dialog branch.it('keeps the delete confirm dialog — deletion is irreversible', () => {expect(sidebarSource).toMatch(diff --git a/apps/desktop/src/renderer/features/cc-agent/__tests__/sharedTaskArchiveGuard.test.ts b/apps/desktop/src/renderer/features/cc-agent/__tests__/sharedTaskArchiveGuard.test.tsindex a87c303a8b..939788a695 100644--- a/apps/desktop/src/renderer/features/cc-agent/__tests__/sharedTaskArchiveGuard.test.ts+++ b/apps/desktop/src/renderer/features/cc-agent/__tests__/sharedTaskArchiveGuard.test.ts@@ -156,15 +156,17 @@ describe('archive preserves the current task until preflight and confirmation ficonst confirmDialog = vi.fn(() => decision.promise);const archiveConfirmDescription = vi.fn(() => 'description');const resolvePreflight = vi.fn(() => preflight.promise);+ const attachment = vi.fn(async () => ({ attached: false }));+ const schedules = vi.fn(async () =>+ new Map(scheduleNames.length > 0 ? [['task', scheduleNames]] : []));const bindings = {- window: { electronAPI: { binding: { resolveSession: async () => ({ attached: false }) } } },+ window: { electronAPI: { binding: { resolveSession: attachment } } },toast: { error: vi.fn(), warning: vi.fn() }, t: (key: string) => key,sessionsById: new Map([['task', session]]), sessionsByIdRef: { current: new Map([['task', session]]) },runningSessionIds: new Set(), attachedSessionIdsRef: { current: new Set() },isRemoteSessionWriteBlocked: () => false, remoteWritesBlocked: false,resolveWorktreeRemovalPreflight: resolvePreflight,- loadActiveBoundScheduleNames: async () =>- new Map(scheduleNames.length > 0 ? [['task', scheduleNames]] : []),+ loadActiveBoundScheduleNames: schedules,archiveConfirmDescription,viewedSessionIdRef: { current: 'task' }, viewedSessionId: 'task',resolveSessionRemovalRedirect: vi.fn(), unarchiveSession: vi.fn(),@@ -186,12 +188,36 @@ describe('archive preserves the current task until preflight and confirmation fi};return {preflight, resolvePreflight, decision, runSessionAction, beginRemoteArchive, confirmDialog, archiveConfirmDescription,+ attachment, schedules,selected: () => selectedTask, visible: () => rowVisible,archive: () => callback(entry.handler, bindings, entrySource)('task', 'archive'),finish: async (confirmed: boolean) => { decision.resolve(confirmed); },};}+ // Unit: replaces the stale sidebar source-order assertions (CI #6863).+ // Holding both earlier checks makes a prematurely sampled clean worktree+ // observable; existing confirmation cases start after those checks settled.+ it('sidebar samples the worktree after attachment and schedule lookup settle', async () => {+ const h = archiveHarness(entrypoints[0]!);+ const attachment = deferred<{ attached: boolean }>();+ const schedules = deferred<Map<string, string[]>>();+ h.attachment.mockReturnValueOnce(attachment.promise);+ h.schedules.mockReturnValueOnce(schedules.promise);+ const pending = h.archive();+ expect(h.attachment).toHaveBeenCalled();+ expect(h.resolvePreflight).not.toHaveBeenCalled();+ attachment.resolve({ attached: false });+ await vi.waitFor(() => expect(h.schedules).toHaveBeenCalled());+ expect(h.resolvePreflight).not.toHaveBeenCalled();+ schedules.resolve(new Map());+ await vi.waitFor(() => expect(h.resolvePreflight).toHaveBeenCalled());+ h.preflight.resolve('clean');+ await pending;+ expect(h.confirmDialog).not.toHaveBeenCalled();+ expect(h.runSessionAction).toHaveBeenCalledWith('task', 'archive', { activeSessionId: 'task' });+ });+for (const entry of entrypoints) {it.each(['clean', 'dirty', 'unknown'] as const)(entry.name + ' keeps selection during %s preflight and cancellation', async (preflight) => {const h = archiveHarness(entry);@@ -209,6 +235,8 @@ describe('archive preserves the current task until preflight and confirmation fiawait vi.waitFor(() => {expect(h.confirmDialog).toHaveBeenCalled();});+ expect(h.archiveConfirmDescription).toHaveBeenCalledWith(expect.anything(),+ expect.objectContaining({ dirtyWorktree: preflight === 'dirty' }));expect(h.selected()).toBe('task');expect(h.visible()).toBe(false);expect(h.runSessionAction).not.toHaveBeenCalled();diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsxindex a1657c2397..a160883d6d 100644--- a/apps/mobile/app/sessions/[sessionId].tsx+++ b/apps/mobile/app/sessions/[sessionId].tsx@@ -624,6 +624,7 @@ import {import { deferScheduleIndexHydration } from '@/session/scheduleIndexDefer';import { sessionMayHaveScheduleRuns } from '@/session/scheduleIndex';import { confirmArchiveWithSchedules, loadActiveBoundScheduleNames } from '@/session/archiveScheduleConfirm';+import { useSessionListActions } from '@/session/useSessionListActions';import { markSessionScheduleRunsRead, unreadRunIdFromProjection } from '@/session/scheduleRunRead';import { useRemoteScheduleEventSnapshot } from '@/scheduler/remoteScheduleEvents';import { buildSessionNativeShellLayout } from '@/session/mobileNativeShellLayout';@@ -9253,20 +9254,33 @@ function SessionScreenContent() {//(sessionMetaWriteGuard / sessionMetaWriteQueue / sessionPendingWrites),// 首页与本页是同组元数据写的两个入口,写序必须跨页面共享(review P1:首页// 置顶在退避中,本页取消置顶——实例级守卫感知不到对方,退避恢复后旧写覆盖- // 新写)。点击当帧 applySessionPatch 即时生效,归档 / 删除立即退回首页,RPC+ // 新写)。归档经列表事务先预览、确认后退出;删除立即退回首页。RPC// 经共享队列串行出网;成功仅在本笔仍是最新写时用回包对账,失败时最新写整体// 还原会话对象(归档 / 删除把行移出了列表,反向 patch 复活不了)、非最新写// requestReseed 收敛,并 Alert 提示(人可能已回到首页,会话页 error 条看不见)。+ const { patchSession: patchSessionFromList } = useSessionListActions({ preferredRpcDeviceId: deviceId });const patchSessionMeta = useCallback((patch: Parameters<typeof maker.patchSessionMeta>[1],+ prepare?: (isCurrent: () => boolean) => Promise<boolean>,) => {const session = currentSession;if (!deviceId || !session) return;+ if (patch.status === 'archived') {+ // 列表与详情共用预览、确认、写序与失败回滚;只在实际提交时退出详情。+ const isCurrent = () => sessionSubscriptionIdentityRef.current === sessionSubscriptionIdentity;+ if (!isCurrent()) return;+ return patchSessionFromList(session, patch, async (isLatest) => {+ const canConfirm = () => isCurrent() && isLatest();+ return canConfirm() && (await (prepare?.(canConfirm) ?? true)) && canConfirm();+ }, goBackToHome).catch((err: unknown) => {+ Alert.alert(t('session.screen.operationFailed'), humanizeRemoteError(err));+ });+ }// 出网沿用本页路由设备;乐观 patch / 回滚 / reseed 落行真实所在的物理 shard(与首页// 同一解析):re-link 后两者可能不同,按路由 id 落 shard 会让归档移行落空、回滚插错 shard。const { rpcDeviceId, shardId } = resolveSessionWriteDevices(sessionId, session, deviceId)?? { rpcDeviceId: deviceId, shardId: deviceId };- const leavesDetailScreen = patch.status === 'archived' || patch.status === 'deleted';+ const leavesDetailScreen = patch.status === 'deleted';if (leavesDetailScreen) {goBackToHome();}@@ -9350,7 +9364,7 @@ function SessionScreenContent() {releasePending();}})();- }, [currentSession, deviceId, goBackToHome, invoke, maker, sessionId]);+ }, [currentSession, deviceId, goBackToHome, invoke, maker, patchSessionFromList, sessionId, sessionSubscriptionIdentity, t]);const previewRewindAtMessage = useCallback(async (clientId: string, draft: MobileMessageDraft) => {if (messageActionBusy) return;@@ -9939,10 +9953,13 @@ function SessionScreenContent() {extraDirBrowser={extraDirBrowser}initialView={menuInitialView}keyboardAvoidingBehavior={nativeShellLayout.keyboardAvoidingBehavior}- onArchive={() => patchSessionMeta({ status: 'archived' })}- confirmArchive={async () => confirmArchiveWithSchedules(t, deviceId- ? await loadActiveBoundScheduleNames({ deviceId, invoke, sessionId, source: sessionSourceForSchedule })- : [])}+ onArchive={(prepare) => { void patchSessionMeta({ status: 'archived' }, prepare); }}+ confirmArchive={async (isCurrent) => {+ const names = deviceId+ ? await loadActiveBoundScheduleNames({ deviceId, invoke, sessionId, source: sessionSourceForSchedule })+ : [];+ return isCurrent() && confirmArchiveWithSchedules(t, names);+ }}onClose={() => setSettingsOpen(false)}onClosed={handleSessionMenuClosed}onDelete={() => patchSessionMeta({ status: 'deleted' })}diff --git a/apps/mobile/src/__tests__/SessionMenuRenameEntry.test.tsx b/apps/mobile/src/__tests__/SessionMenuRenameEntry.test.tsxindex fd5f1920e4..e0d575eef9 100644--- a/apps/mobile/src/__tests__/SessionMenuRenameEntry.test.tsx+++ b/apps/mobile/src/__tests__/SessionMenuRenameEntry.test.tsx@@ -161,18 +161,24 @@ it("opening at rename goes straight to the editor and cancel closes the sheet",it.each([true, false])("archive closes the menu before a delayed decision (%s)", async (confirmed) => {let decide!: (ok: boolean) => void;const decision = new Promise<boolean>((resolve) => { decide = resolve; });- const props = baseProps({ initialView: "menu", onArchive: vi.fn(), confirmArchive: vi.fn(() => decision),+ const commit = vi.fn();+ const onArchive = vi.fn(async (prepare: (isCurrent: () => boolean) => Promise<boolean>) => {+ if (await prepare(() => true)) commit();+ });+ const props = baseProps({ initialView: "menu", onArchive, confirmArchive: vi.fn(() => decision),session: { id: "a", title: "Task", status: "active" } as SessionMenuSheetProps['session'] });const { root, click } = await renderSheet(props);try {await click("session.archiveButton");expect(props.onClose).toHaveBeenCalledOnce();+ expect(onArchive).not.toHaveBeenCalled();expect(props.confirmArchive).not.toHaveBeenCalled();await act(async () => sheetLifecycle.closed?.());expect(props.confirmArchive).toHaveBeenCalledOnce();- expect(props.onArchive).not.toHaveBeenCalled();+ expect(onArchive).toHaveBeenCalledExactlyOnceWith(props.confirmArchive);+ expect(commit).not.toHaveBeenCalled();await act(async () => { decide(confirmed); });- expect(props.onArchive).toHaveBeenCalledTimes(confirmed ? 1 : 0);+ expect(commit).toHaveBeenCalledTimes(confirmed ? 1 : 0);} finally {await act(async () => root.unmount());}diff --git a/apps/mobile/src/__tests__/orphanSessionActions.test.ts b/apps/mobile/src/__tests__/orphanSessionActions.test.tsindex 1ff12eaef2..263526ccea 100644--- a/apps/mobile/src/__tests__/orphanSessionActions.test.ts+++ b/apps/mobile/src/__tests__/orphanSessionActions.test.ts@@ -29,7 +29,8 @@ function callback(file: string, name: string, bindings: Record<string, unknown>)const session = { id: 's1', status: 'active', deviceLinkDeviceId: 'shard', deviceLinkDeviceName: 'PC' };function fixture() {let reject!: (error: Error) => void;- const pending = new Promise((_resolve, fail) => { reject = fail; });+ let resolve!: (value: unknown) => void;+ const pending = new Promise((done, fail) => { resolve = done; reject = fail; });const store = {applySessionPatch: vi.fn(), upsertDeviceSession: vi.fn(), requestReseed: vi.fn(),beginSessionListRemovalPreview: vi.fn(() => vi.fn()),@@ -38,22 +39,71 @@ function fixture() {const release = vi.fn();const isLatest = vi.fn(() => true);const bindings = {- currentSession: session, deviceId: 'rpc', sessionId: session.id,+ currentSession: session, deviceId: 'rpc', sessionId: session.id, preferredRpcDeviceId: 'rpc',resolveSessionWriteDevices: () => ({ rpcDeviceId: 'rpc', shardId: 'shard' }),sessionMetaWriteGuard: { begin: () => ({ isLatest }) },sessionMetaWriteQueue: { enqueue: vi.fn(() => pending) },- sessionPendingWrites: { track: () => release },+ sessionPendingWrites: { track: () => release, consumeMaskedPush: () => false },remoteSessionStore: store, isExplicitRemoteNotFoundError, pickWriteFields, writeGuardFields,goBackToHome: vi.fn(), Alert: { alert: vi.fn() }, humanizeRemoteError: String,animateListChange: undefined, t: (key: string) => key,withNewSessionCreationRemoval: (_sid: string, _device: string, _status: string, remove: () => Promise<unknown>) => remove(),};- return { bindings, reject, store, release, isLatest };+ Object.assign(bindings, {+ patchSessionFromList: callback('src/session/useSessionListActions.ts', 'patchSession', bindings),+ sessionSubscriptionIdentity: 'page', sessionSubscriptionIdentityRef: { current: 'page' },+ });+ return { bindings, resolve, reject, store, release, isLatest };}const gone = () => new Error('[NOT_FOUND] Session does not exist');const tick = () => new Promise((done) => setTimeout(done, 0));describe('orphan task status actions', () => {+ // Unit, PR #6863 r4353910575: the detail menu used to perform confirmation+ // outside the list transaction. Existing list tests missed that entrypoint.+ // Holding its decision must hide the list, retain detail, and navigate only+ // after confirmation; cancellation, a newer status, or leaving the page must+ // release the preview without writing or restoring an old metadata snapshot.+ it.each(['confirm', 'cancel', 'superseded', 'left-page', 'fail'] as const)(+ 'detail archive shares the list transaction during %s', async (outcome) => {+ const f = fixture();+ const identityRef = { current: 'page' as string | null };+ const patchSessionFromList = callback('src/session/useSessionListActions.ts', 'patchSession', f.bindings);+ const patchDetail = callback('app/sessions/[sessionId].tsx', 'patchSessionMeta', {+ ...f.bindings, patchSessionFromList,+ sessionSubscriptionIdentity: 'page', sessionSubscriptionIdentityRef: identityRef,+ });+ let decide!: (ok: boolean) => void;+ const decision = new Promise<boolean>(resolve => { decide = resolve; });+ const request = patchDetail({ status: 'archived' }, () => decision);+ expect(f.store.beginSessionListRemovalPreview).toHaveBeenCalledWith('s1');+ expect(f.store.applySessionPatch).not.toHaveBeenCalled();+ expect(f.bindings.goBackToHome).not.toHaveBeenCalled();+ if (outcome === 'superseded') f.isLatest.mockReturnValue(false);+ if (outcome === 'left-page') identityRef.current = null;+ decide(outcome !== 'cancel');+ if (outcome === 'confirm' || outcome === 'fail') {+ await vi.waitFor(() => expect(f.bindings.sessionMetaWriteQueue.enqueue).toHaveBeenCalledOnce());+ expect(f.bindings.goBackToHome).toHaveBeenCalledOnce();+ if (outcome === 'fail') f.reject(new Error('offline'));+ else f.resolve({ ...session, status: 'archived' });+ }+ await request;+ expect(f.store.beginSessionListRemovalPreview.mock.results[0].value).toHaveBeenCalledOnce();+ if (outcome === 'fail') {+ expect(f.store.upsertDeviceSession).toHaveBeenCalledWith('shard', 'PC', session);+ expect(f.bindings.Alert.alert).toHaveBeenCalled();+ } else {+ expect(f.store.upsertDeviceSession).not.toHaveBeenCalled();+ expect(f.bindings.Alert.alert).not.toHaveBeenCalled();+ }+ if (!['confirm', 'fail'].includes(outcome)) {+ expect(f.bindings.sessionMetaWriteQueue.enqueue).not.toHaveBeenCalled();+ expect(f.bindings.goBackToHome).not.toHaveBeenCalled();+ }+ },+ );+// Unit regression: archive must leave the list while its remote schedule// lookup is pending, without committing before confirmation. Existing cases// exercised only the RPC result, not the pre-write wait/cancel boundary.@@ -191,6 +241,7 @@ describe('orphan task status actions', () => {const f = fixture();const patch = callback('app/sessions/[sessionId].tsx', 'patchSessionMeta', f.bindings);patch({ status });+ await tick();expect(f.bindings.goBackToHome).toHaveBeenCalledTimes(1);// The user may already have opened a different task by the time the RPC fails.f.reject(gone());diff --git a/apps/mobile/src/session/SessionMenuSheet.tsx b/apps/mobile/src/session/SessionMenuSheet.tsxindex 052221abdb..7c551e44d4 100644--- a/apps/mobile/src/session/SessionMenuSheet.tsx+++ b/apps/mobile/src/session/SessionMenuSheet.tsx@@ -168,9 +168,10 @@ export interface SessionMenuSheetProps {worker?: SessionMenuWorkerActions;leavingSharing?: boolean;onTogglePinned(): void;- onArchive(): void;+ /** 由调用方在列表预览事务内等待确认,再提交归档。 */+ onArchive(prepare: (isCurrent: () => boolean) => Promise<boolean>): void;/** 菜单收起后执行归档确认(如绑定了自动化);返回 false 时留在当前任务、不归档。 */- confirmArchive?: () => Promise<boolean>;+ confirmArchive?: (isCurrent: () => boolean) => Promise<boolean>;onRestore(): void;onDelete(): void;onClose(): void;@@ -507,11 +508,7 @@ export function SessionMenuSheet({return;}// 先响应点击收起菜单,关闭动画结束后再查询/弹确认,避免原生 Modal 吞掉 Alert。- pendingArchiveRef.current = () => {- void (confirmArchive?.() ?? Promise.resolve(true)).then((ok) => {- if (ok) onArchive();- });- };+ pendingArchiveRef.current = () => onArchive(confirmArchive ?? (async () => true));onClose();return;case 'delete':diff --git a/apps/mobile/src/session/useSessionListActions.ts b/apps/mobile/src/session/useSessionListActions.tsindex b2a79a09dc..86167fc19a 100644--- a/apps/mobile/src/session/useSessionListActions.ts+++ b/apps/mobile/src/session/useSessionListActions.ts@@ -37,8 +37,12 @@ import { confirmArchiveWithSchedules, loadActiveBoundScheduleNames } from '@/ses* 这类会让行移走或移位的乐观写入与失败回滚经它落地,行的移动与列表让位带动画;* 不传时直接写入。*/-export function useSessionListActions(options?: { animateListChange?: (apply: () => void) => void }) {+export function useSessionListActions(options?: {+ animateListChange?: (apply: () => void) => void;+ preferredRpcDeviceId?: string;+}) {const animateListChange = options?.animateListChange;+ const preferredRpcDeviceId = options?.preferredRpcDeviceId;const { t } = useTranslation();const { invoke } = useDeviceLink();const swipeRegistry = useMemo(() => createSwipeRowRegistry(), []);@@ -51,8 +55,9 @@ export function useSessionListActions(options?: { animateListChange?: (apply: ()session: RemoteSession,patch: SessionMetaPatch,prepare?: (isLatest: () => boolean) => Promise<boolean>,+ onApplied?: () => void,) => {- const devices = resolveSessionWriteDevices(session.id, session);+ const devices = resolveSessionWriteDevices(session.id, session, preferredRpcDeviceId);if (!devices) throw new Error(t('devices.list.error.sessionDeviceNotFound'));const { rpcDeviceId, shardId } = devices;const fields = Object.keys(patch);@@ -73,6 +78,7 @@ export function useSessionListActions(options?: { animateListChange?: (apply: ()const applyOptimistic = () => {if (!write.isLatest()) return;rollbackSession = remoteSessionStore.getSessions().find((s) => s.id === session.id) ?? session;+ onApplied?.();remoteSessionStore.applySessionPatch(shardId, session.id, patch);applied = true;};@@ -167,11 +173,11 @@ export function useSessionListActions(options?: { animateListChange?: (apply: ()releasePending();if (finishPreview) await updateList(finishPreview);}- }, [animateListChange, invoke, t]);+ }, [animateListChange, invoke, preferredRpcDeviceId, t]);const runSwipeAction = useCallback((session: RemoteSession, action: Exclude<SessionSwipeAction, 'rename'>) => {void patchSession(session, swipeActionPatch(action), action === 'archive' ? async (isLatest) => {- const devices = resolveSessionWriteDevices(session.id, session);+ const devices = resolveSessionWriteDevices(session.id, session, preferredRpcDeviceId);const names = devices ? await loadActiveBoundScheduleNames({deviceId: devices.rpcDeviceId, invoke, sessionId: session.id, source: session.source,}) : [];@@ -180,7 +186,7 @@ export function useSessionListActions(options?: { animateListChange?: (apply: ()swipeRegistry.closeOpenRow();Alert.alert(t('devices.list.alert.actionFailed'), humanizeRemoteError(err));});- }, [invoke, patchSession, swipeRegistry, t]);+ }, [invoke, patchSession, preferredRpcDeviceId, swipeRegistry, t]);const applySessionSheetAction = useCallback((session: RemoteSession, action: SessionSwipeAction) => {if (action === 'delete') {@@ -256,6 +262,7 @@ export function useSessionListActions(options?: { animateListChange?: (apply: ()}), [archiveSession, showSessionOptions, swipeRegistry, toggleSessionPinned]);return {+ patchSession,actionSheetSession,archiveSession,closeRenameSession,diff --git a/docs/dev-rules/remote-and-mobile-adaptation.md b/docs/dev-rules/remote-and-mobile-adaptation.mdindex edfef5ee81..ce702e0fb0 100644--- a/docs/dev-rules/remote-and-mobile-adaptation.md+++ b/docs/dev-rules/remote-and-mobile-adaptation.md@@ -51,6 +51,9 @@ Cindy 的产品形态不止本地桌面单机。同一个功能可能运行在在途写入,确认后才取代这些写入并真正移除行。取消时解除隐藏,不拿旧快照覆盖期间已经保存的元数据。详情页在确认通过后再退出。手机详情菜单先收起,关闭动画结束后再查询并弹确认,避免远程等待卡住菜单或原生弹窗被关闭动画吞掉。+手机详情将确认回调交给 `useSessionListActions.patchSession`,与列表共用同一个预览、+写序和失败回滚入口;确认仍有效并开始提交时才退出详情。离页或后续状态操作使旧确认+失效,结算时只解除该次预览,不写回旧状态。实现与回归:Desktop `useSessionLifecycleActions`、`sharedTaskArchiveGuard.test.ts`;Mobile `useSessionListActions`、`SessionMenuSheet`、`orphanSessionActions.test.ts` 与