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
address review: void/catch spawnMergeRecoveryTask, delete remote branch on no-commits cleanup
Adam Eivy3836c97798cb
diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.jsindex a020ed6a11..b1cd152ef3 100644--- a/server/services/agentLifecycle.js+++ b/server/services/agentLifecycle.js@@ -1059,7 +1059,9 @@ export async function handleAgentCompletion(agentId, exitCode, success, durationemitLog('warn', `Failed to create cleanup warning notification: ${err.message}`, { agentId });});- spawnMergeRecoveryTask(cleanupWarnings, agentId, task, appName, currentAgent?.metadata?.sourceWorkspace);+ void spawnMergeRecoveryTask(cleanupWarnings, agentId, task, appName, currentAgent?.metadata?.sourceWorkspace).catch(err => {+ emitLog('warn', `Failed to spawn merge recovery task: ${err.message}`, { agentId, taskId: task?.id });+ });}}@@ -1119,8 +1121,12 @@ export async function cleanupAgentWorktree(agentId, success, { openPR = false, d// "No commits between X and Y" means the agent made no code changes.// Clean up the worktree silently — nothing to review or merge.+ // Also delete the remote branch (it was pushed before PR creation).if (reason.includes('No commits between')) {emitLog('info', `🌳 No commits on ${worktreeBranch} vs ${targetBranch} — agent made no changes, cleaning up`, { agentId });+ await git.deleteBranch(sourceWorkspace, worktreeBranch, { remote: true }).catch(err => {+ emitLog('warn', `🌳 Remote branch delete failed for ${worktreeBranch}: ${err.message}`, { agentId });+ });await removeWorktree(agentId, sourceWorkspace, worktreeBranch, { merge: false }).catch(err => {emitLog('warn', `🌳 Worktree cleanup failed for ${agentId}: ${err.message}`, { agentId });});diff --git a/server/services/cleanupAgentWorktree.test.js b/server/services/cleanupAgentWorktree.test.jsindex 797a80cb9a..2596007bd1 100644--- a/server/services/cleanupAgentWorktree.test.js+++ b/server/services/cleanupAgentWorktree.test.js@@ -159,7 +159,8 @@ vi.mock('./git.js', () => ({push: vi.fn(),getRepoBranches: vi.fn(),createPR: vi.fn(),- generatePRDescription: vi.fn()+ generatePRDescription: vi.fn(),+ deleteBranch: vi.fn().mockResolvedValue(undefined)}));vi.mock('./runner.js', () => ({@@ -259,7 +260,8 @@ describe('cleanupAgentWorktree - openPR path', () => {const warnings = await cleanupAgentWorktree('agent-1', true, { openPR: true, description: 'Test task' });expect(git.createPR).toHaveBeenCalled();- // Agent made no changes — clean up silently without a warning+ // Agent made no changes — delete remote branch and clean up silently without a warning+ expect(git.deleteBranch).toHaveBeenCalledWith('/mock/workspace', 'cos/task-abc123', { remote: true });expect(removeWorktree).toHaveBeenCalledWith('agent-1', '/mock/workspace', 'cos/task-abc123', { merge: false });expect(warnings).toHaveLength(0);});