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(cos): stop auto-creating worktrees for managed app tasks without Branch+PR toggle
[._.]/ Adam Eivy5a29ccb21a05
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.jsindex a9226fe6a6..dcc5593f54 100644--- a/server/services/subAgentSpawner.js+++ b/server/services/subAgentSpawner.js@@ -1459,12 +1459,11 @@ export async function spawnAgentForTask(task) {}}- // Determine worktree usage: explicit user flag takes priority, then auto-detection.+ // Determine worktree usage: explicit user flag takes priority, then conflict-based auto-detection.// The useWorktree metadata flag is set from the task creation UI checkbox.- // When true, always create a worktree (branch + PR). When not set, fall back to- // existing auto-detection (managed apps = worktree, non-managed = conflict-based).+ // When true, always create a worktree (branch + PR). When not set, only create a+ // worktree if conflict is detected with other running agents.let worktreeInfo = null;- const isManagedApp = !!task.metadata?.app;const explicitWorktree = task.metadata?.useWorktree === 'true' || task.metadata?.useWorktree === true;// Feature agent tasks: use persistent worktree instead of creating a new one@@ -1509,27 +1508,6 @@ export async function spawnAgentForTask(task) {return null;});- if (worktreeInfo) {- workspacePath = worktreeInfo.worktreePath;- emitLog('success', `🌳 Agent ${agentId} will work in worktree: ${worktreeInfo.branchName} (base: ${worktreeInfo.baseBranch})`, {- agentId, worktreePath: worktreeInfo.worktreePath, branchName: worktreeInfo.branchName, baseBranch: worktreeInfo.baseBranch- });- }- } else if (isManagedApp && !jiraBranchName) {- // Managed apps: auto-detect — always use a worktree based on the latest default branch- // to prevent cross-agent contamination (dirty state, stale branches, other agents' commits).- const { baseBranch: detectedBase } = await git.getRepoBranches(workspacePath).catch(() => ({ baseBranch: null }));- emitLog('info', `🌳 Managed app task ${task.id} — creating isolated worktree from ${detectedBase || 'default branch'}`, {- taskId: task.id, app: task.metadata.app, baseBranch: detectedBase- });-- worktreeInfo = await createWorktree(agentId, workspacePath, task.id, {- baseBranch: detectedBase || undefined- }).catch(err => {- emitLog('warn', `🌳 Worktree creation failed, using shared workspace: ${err.message}`, { taskId: task.id });- return null;- });-if (worktreeInfo) {workspacePath = worktreeInfo.worktreePath;emitLog('success', `🌳 Agent ${agentId} will work in worktree: ${worktreeInfo.branchName} (base: ${worktreeInfo.baseBranch})`, {@@ -1537,7 +1515,7 @@ export async function spawnAgentForTask(task) {});}} else if (!jiraBranchName) {- // Non-managed (PortOS) tasks: use worktree only when conflict is detected+ // No explicit worktree requested: use worktree only when conflict is detectedconst { getAgents } = await import('./cos.js');const allAgents = await getAgents();const runningAgents = allAgents.filter(a => a.status === 'running');