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.