Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 重连后重新探测 worktree 资格
Kafeifei86048afd2bc4
diff --git a/apps/mobile/app/sessions/new.tsx b/apps/mobile/app/sessions/new.tsxindex 96b0a286af..c86d11a6c0 100644--- a/apps/mobile/app/sessions/new.tsx+++ b/apps/mobile/app/sessions/new.tsx@@ -336,6 +336,7 @@ export default function NewRemoteSessionScreen() {subscribe,status: deviceLinkStatus,connectionEpoch,+ presenceVersion,} = useDeviceLink();const routeDeviceFallback = useMemo<NewSessionDeviceOption | null>(() => routeDeviceId ? { deviceId: routeDeviceId, name: routeDeviceName || routeDeviceId } : null,@@ -1512,14 +1513,17 @@ export default function NewRemoteSessionScreen() {})();}, [draft.agentKind, draft.permissionMode, patchDraft]);- // —— worktree 资格探测:目录 / 设备变化即重探(seq 防竞态,旧结果作废)。+ // —— worktree 资格探测:目录 / 设备 / 链路变化即重探(seq 防竞态,旧结果作废)。// CHANNEL_NOT_ALLOWED(老被控端)→ unsupported 整行隐藏;其余失败保留行但禁用。useEffect(() => {const cwd = draft.workspaceKind === 'project' ? draft.workingDir.trim() : '';const seq = ++worktreeDetectSeqRef.current;const target = { deviceId: selectedDeviceId ?? '', workingDir: cwd };setWorktreeProbe({ target, eligibility: { status: 'probing' } });- if (!selectedDeviceId || !cwd) return;+ // Relay 离线时不把预期的 NOT_CONNECTED 固化成 detect-failed;online /+ // connectionEpoch / presenceVersion 变化后自动重探,覆盖手机重连和工作端+ // 重新上线两种路径。+ if (!selectedDeviceId || !cwd || deviceLinkStatus !== 'online') return;void withTransientRemoteRetry(async () => {await openLink(selectedDeviceId);return maker.worktree.detectCwd(cwd);@@ -1538,7 +1542,16 @@ export default function NewRemoteSessionScreen() {eligibility: worktreeEligibilityFromError(err),});});- }, [selectedDeviceId, draft.workspaceKind, draft.workingDir, maker, openLink]);+ }, [+ connectionEpoch,+ deviceLinkStatus,+ presenceVersion,+ selectedDeviceId,+ draft.workspaceKind,+ draft.workingDir,+ maker,+ openLink,+ ]);// —— worktree 勾选播种:选中设备后读工作端 get-new-maker-defaults 的 worktreeEnabled// (vendor 无关,agentKind 只是通道入参,经 ref 读当前值,不因切 agent 重播)。diff --git a/apps/mobile/src/__tests__/newSession.test.ts b/apps/mobile/src/__tests__/newSession.test.tsindex 32d050733b..09e680eb6d 100644--- a/apps/mobile/src/__tests__/newSession.test.ts+++ b/apps/mobile/src/__tests__/newSession.test.ts@@ -1042,6 +1042,23 @@ describe('new session worktree wiring (source locks)', () => {expect(newSource).toContain('void maker.applyNewMakerWorktreePref(next).catch(() => undefined);');});+ it('re-probes worktree eligibility when the relay or workstation reconnects', () => {+ expect(newSource).toContain(+ "if (!selectedDeviceId || !cwd || deviceLinkStatus !== 'online') return;",+ );+ const detectEffect = newSource.indexOf(+ 'return maker.worktree.detectCwd(cwd);',+ );+ const preferenceEffect = newSource.indexOf(+ 'const worktreeSeedAgentKindRef',+ detectEffect,+ );+ const detectBlock = newSource.slice(detectEffect, preferenceEffect);+ expect(detectBlock).toContain('connectionEpoch,');+ expect(detectBlock).toContain('deviceLinkStatus,');+ expect(detectBlock).toContain('presenceVersion,');+ });+it('settles an unowned cleanup obligation before creating another worktree', () => {const recovery = newSource.indexOf('const recovery = await recoverPendingPrecreatedWorktrees(worktreeAccountId, {',