From d625079c4d784034fe538a13ebb53e73ffa6877c Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Tue, 16 Jun 2026 15:20:55 -0700 Subject: [PATCH] Disable first-work folder rename (#5535) --- src/main/agent-hooks/first-work-branch-rename.test.ts | 11 +++++++++++ src/main/index.ts | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/agent-hooks/first-work-branch-rename.test.ts b/src/main/agent-hooks/first-work-branch-rename.test.ts index fedd84b59..712d65341 100644 --- a/src/main/agent-hooks/first-work-branch-rename.test.ts +++ b/src/main/agent-hooks/first-work-branch-rename.test.ts @@ -103,6 +103,17 @@ describe('maybeAutoRenameBranchOnFirstWork', () => { expect(renameWorktreeFolder).toHaveBeenCalledWith(WORKTREE_ID, 'fix-auth') }) + it('keeps branch and display rename working when folder rename is disabled', async () => { + const { deps, onRenamed, setDisplayName } = makeDeps({ renameWorktreeFolder: undefined }) + await maybeAutoRenameBranchOnFirstWork(workingEvent(), deps) + expect(gitExecFileAsyncMock).toHaveBeenCalledWith( + ['branch', '-m', 'you/fix-auth'], + expect.objectContaining({ cwd: '/repo/wt' }) + ) + expect(setDisplayName).toHaveBeenCalledWith(WORKTREE_ID, 'Fix auth') + expect(onRenamed).toHaveBeenCalledWith(REPO_ID) + }) + it('skips the redundant branch-rename notify when the folder rename succeeded', async () => { // The folder rename already pushed a worktrees:changed carrying the id mapping, // so onRenamed would only trigger a second, redundant renderer re-list. diff --git a/src/main/index.ts b/src/main/index.ts index aa86038de..e36d09342 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -197,7 +197,7 @@ if (appImageCliRedirect.redirected) { // worktree id change via migrateWorktreeIdentity + a rename-aware worktrees:changed // handler, so an old->new id change is no longer mistaken for a deletion. Flip off // to disable the on-disk move (branch + display rename still happen) if needed. -const ENABLE_FIRST_WORK_FOLDER_RENAME = true +const ENABLE_FIRST_WORK_FOLDER_RENAME = false // Why: the store/runtime singletons live here in index.ts; injecting them keeps // the rename orchestrator free of module-level state and unit-testable.