Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(worktree): reconcile exact branch authority
Kafeifei626a6035016d
diff --git a/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.ts b/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.tsindex c842944458..c1a9beef88 100644--- a/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.ts+++ b/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.ts@@ -305,6 +305,30 @@ describe('Shared create project picker', () => {expect(newMakerDraftRouteSource).toContain('wtBranchWriteSeqRef.current');});+ it('only commits a branch write after host authority observes that exact requested branch', () => {+ const branchHandler = newMakerDraftRouteSource.slice(+ newMakerDraftRouteSource.indexOf('const handleWtSourceBranchChange = useCallback('),+ newMakerDraftRouteSource.indexOf('const handleWtBaseRepoChange = useCallback('),+ );++ // A successful invoke is not sufficient: its snapshot must both advance+ // the revision seen at write start and contain this exact requested branch.+ expect(branchHandler).toContain('parsedSnapshot!.sourceBranch === normalized');+ expect(branchHandler).toContain('parsedSnapshot!.revision > revisionAtStart');++ // Both the resolved-invalid-payload and rejected/lost-ACK reconciliation+ // paths may use a concurrent push, but only when it confirms the same branch.+ expect((branchHandler.match(/current\.sourceBranch === normalized/g) ?? []).length).toBe(2);+ expect(branchHandler).not.toContain('armWtBranchCommittedValue(parsedSnapshot!.sourceBranch)');+ expect(branchHandler).not.toContain('armWtBranchCommittedValue(current.sourceBranch)');++ // A newer authoritative value for another branch remains the retry floor;+ // it must not release the create fence or replace the user's requested UI.+ expect(branchHandler).not.toContain('wtBranchSyncRef.current = null;');+ expect(branchHandler).toContain('setWtSourceBranch(normalized);');+ expect(branchHandler).toContain('setWtBranchPreferenceError(true);');+ });+it('creates managed worktrees before starting either local or device-link goals', () => {const goal = newMakerDraftRouteSource.slice(newMakerDraftRouteSource.indexOf('const handleCreateGoal = useCallback('),diff --git a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsxindex cc4c87d551..85b9927f55 100644--- a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx@@ -2637,8 +2637,13 @@ export function NewMakerDraftRoute() {.then((snapshot) => {if (writeSeq !== wtBranchWriteSeqRef.current) return;const parsedSnapshot = parseDraftWorktreeBranchSnapshot(snapshot);- if (acceptWtBranchSnapshot(target, snapshot)) {- armWtBranchCommittedValue(parsedSnapshot!.sourceBranch);+ const accepted = acceptWtBranchSnapshot(target, snapshot);+ if (+ accepted+ && parsedSnapshot!.sourceBranch === normalized+ && parsedSnapshot!.revision > revisionAtStart+ ) {+ armWtBranchCommittedValue(normalized);return;}const current = wtBranchSyncRef.current;@@ -2647,16 +2652,16 @@ export function NewMakerDraftRoute() {&& current.deviceId === target.deviceId&& current.baseRepo === target.baseRepo&& current.revision > revisionAtStart- && current.sourceBranch+ && current.sourceBranch === normalized) {- armWtBranchCommittedValue(current.sourceBranch);+ armWtBranchCommittedValue(normalized);return;}- // A resolved invoke with an invalid/wrong-target payload is not a- // confirmed write. Keep Worktree ON fail-closed and let the branch- // half remain interactive for an explicit retry.- wtBranchSyncRef.current = null;- setWtBranchSync(null);+ // A newer snapshot for another branch is still useful as the next+ // retry's revision floor, but it cannot confirm this write. Keep the+ // requested value visible and Worktree ON fail-closed until the user+ // explicitly retries and host authority observes this exact branch.+ setWtSourceBranch(normalized);wtBranchPreferenceErrorRef.current = true;setWtBranchPreferenceError(true);})@@ -2668,9 +2673,9 @@ export function NewMakerDraftRoute() {&& current.deviceId === target.deviceId&& current.baseRepo === target.baseRepo&& current.revision > revisionAtStart- && current.sourceBranch+ && current.sourceBranch === normalized) {- armWtBranchCommittedValue(current.sourceBranch);+ armWtBranchCommittedValue(normalized);return;}// 只有结构化 CHANNEL_NOT_ALLOWED 才允许旧端兼容:本次选择留在@@ -2684,6 +2689,7 @@ export function NewMakerDraftRoute() {}return;}+ setWtSourceBranch(normalized);wtBranchPreferenceErrorRef.current = true;setWtBranchPreferenceError(true);})