Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(worktree): keep retrying deferred recycle requests
DavidShen8eb624905d08
diff --git a/apps/desktop/src/main/__tests__/worktreeRecycleMaintenance.test.ts b/apps/desktop/src/main/__tests__/worktreeRecycleMaintenance.test.tsindex 997ef23730..21c75cdd2d 100644--- a/apps/desktop/src/main/__tests__/worktreeRecycleMaintenance.test.ts+++ b/apps/desktop/src/main/__tests__/worktreeRecycleMaintenance.test.ts@@ -120,11 +120,17 @@ describe('durable worktree maintenance', () => {await vi.advanceTimersByTimeAsync(100);expect(closeAndRecycle).toHaveBeenCalledExactlyOnceWith('owner', 'archived');});- it('bounds automatic retries and lets a resource event renew that budget', async () => {- await maintenance.start(); await vi.runAllTimersAsync();- expect(closeAndRecycle).toHaveBeenCalledTimes(8); expect(vi.getTimerCount()).toBe(0);+ it('keeps retrying after the backoff cap and lets a resource event wake it early', async () => {+ await maintenance.start();+ await vi.advanceTimersByTimeAsync(30 * 60_000);+ expect(closeAndRecycle).toHaveBeenCalledTimes(8);+ expect(vi.getTimerCount()).toBe(1);+ await vi.advanceTimersByTimeAsync(30 * 60_000);+ expect(closeAndRecycle).toHaveBeenCalledTimes(9);notifyWorktreeRecycleOpportunity(state.records[0].meta.path);- await vi.advanceTimersByTimeAsync(100); expect(closeAndRecycle).toHaveBeenCalledTimes(9);+ await vi.advanceTimersByTimeAsync(100);+ expect(closeAndRecycle.mock.calls.length).toBeGreaterThan(9);+ expect(vi.getTimerCount()).toBe(1);});it('continues with other resources after one request fails', async () => {state.records.push(record('second')); state.rows.push({ ...state.rows[0], id: 'second' });diff --git a/apps/desktop/src/main/worktree/recycleMaintenance.ts b/apps/desktop/src/main/worktree/recycleMaintenance.tsindex 4d16de7a0b..b8e0a6eeed 100644--- a/apps/desktop/src/main/worktree/recycleMaintenance.ts+++ b/apps/desktop/src/main/worktree/recycleMaintenance.ts@@ -116,8 +116,10 @@ export class WorktreeRecycleMaintenance {if (record.phase === 'restored' || record.phase === 'restoring' || record.meta.ephemeral) return false;const current = store.get(record.meta.sessionId);if (record.phase === 'removed' && !current) return false;- return (!current || worktreeGeneration(current) === record.generation)- && (this.attempts.get(this.key(record))?.count ?? 0) < MAX_ATTEMPTS;+ // Attempts only control backoff. A directory may remain externally locked+ // longer than one backoff window; it must become eligible again when the+ // lock is released or the next deadline arrives.+ return !current || worktreeGeneration(current) === record.generation;}private deadline(record: WorktreeRecycleRecord): number {