Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([worktree-remove-helper]): preserve agent-id wording in rm/prune sub-failure logs
[._.]/ Adam Eivyef39320895c7
diff --git a/server/services/worktreeManager.forceRemove.test.js b/server/services/worktreeManager.forceRemove.test.jsindex 181fd51acf..758e998913 100644--- a/server/services/worktreeManager.forceRemove.test.js+++ b/server/services/worktreeManager.forceRemove.test.js@@ -72,4 +72,21 @@ describe('forceRemoveWorktreeDir', () => {await forceRemoveWorktreeDir('/repo', '/repo/wt', { label: 'L', log: 'all' });expect(console.log).toHaveBeenCalledTimes(3);});++ it("subject identifies the rm/prune sub-failures (defaults to the path, overridable to an agent id)", async () => {+ // Default subject = worktreePath.+ execGit.mockRejectedValueOnce(new Error('boom')).mockRejectedValueOnce(new Error('prune boom'));+ rm.mockRejectedValue(new Error('rm boom'));+ await forceRemoveWorktreeDir('/repo', '/repo/wt', { label: 'L', log: 'all' });+ expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Manual rm failed for worktree /repo/wt'));+ expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Worktree prune failed for /repo/wt'));++ // Override subject → the agent id appears instead (preserves pre-extraction wording).+ console.log.mockClear();+ execGit.mockRejectedValueOnce(new Error('boom')).mockRejectedValueOnce(new Error('prune boom'));+ rm.mockRejectedValue(new Error('rm boom'));+ await forceRemoveWorktreeDir('/repo', '/repo/wt', { label: 'L', log: 'all', subject: 'agent-42' });+ expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Manual rm failed for worktree agent-42'));+ expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Worktree prune failed for agent-42'));+ });});diff --git a/server/services/worktreeManager.js b/server/services/worktreeManager.jsindex 9f8ef2a613..eee631420e 100644--- a/server/services/worktreeManager.js+++ b/server/services/worktreeManager.js@@ -41,16 +41,21 @@ const AUTO_GENERATED_LOCKFILES = ['package-lock.json', 'yarn.lock', 'pnpm-lock.y* `label` is absent (nothing logs). The two flags the four callers needed —* "label + log everything" and "label + log remove only" and "silent" — are* the three states here; there was never a "log without a label" caller.+ * @param {string} [opts.subject] - identifier embedded in the rm/prune+ * sub-failure messages (only used when `log:'all'`). Defaults to+ * `worktreePath`; the agent-cleanup callers pass their agent id so the+ * message wording stays byte-identical to the pre-extraction logs an operator+ * may grep for (e.g. `… for worktree <agentId>`).*/-export async function forceRemoveWorktreeDir(repo, worktreePath, { label, log = 'remove' } = {}) {+export async function forceRemoveWorktreeDir(repo, worktreePath, { label, log = 'remove', subject = worktreePath } = {}) {const logAll = label && log === 'all';await execGit(['worktree', 'remove', worktreePath, '--force'], repo).catch(async (err) => {if (label) console.log(`⚠️ ${label}: ${err.message}`);await rm(worktreePath, { recursive: true, force: true }).catch((rmErr) => {- if (logAll) console.log(`⚠️ Manual rm failed for worktree ${worktreePath}: ${rmErr.message}`);+ if (logAll) console.log(`⚠️ Manual rm failed for worktree ${subject}: ${rmErr.message}`);});await execGit(['worktree', 'prune'], repo).catch((pruneErr) => {- if (logAll) console.log(`⚠️ Worktree prune failed for ${worktreePath}: ${pruneErr.message}`);+ if (logAll) console.log(`⚠️ Worktree prune failed for ${subject}: ${pruneErr.message}`);});});}@@ -327,6 +332,7 @@ export async function removeWorktree(agentId, sourceWorkspace, branchName, optioawait forceRemoveWorktreeDir(sourceWorkspace, worktreePath, {label: `Worktree remove failed for ${agentId}, falling back to manual cleanup`,log: 'all',+ subject: agentId,});// Preserve branch when (a) merge was attempted, failed, and has unmerged commits,@@ -421,6 +427,7 @@ export async function removePersistentWorktree(featureAgentId, sourceWorkspace,await forceRemoveWorktreeDir(sourceWorkspace, worktreePath, {label: `Persistent worktree remove failed for ${featureAgentId}, falling back`,log: 'all',+ subject: featureAgentId,});await execGit(['branch', '-D', branchName], sourceWorkspace).catch(err => {