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: let a Resolve & Merge follow-up take over a /do:next worktree whose only dirt is untracked files
[._.]/ Adam Eivy591451084137
diff --git a/server/services/agentWorkspacePrep.js b/server/services/agentWorkspacePrep.jsindex 07c3cf0ad4..c34a8f63e7 100644--- a/server/services/agentWorkspacePrep.js+++ b/server/services/agentWorkspacePrep.js@@ -136,7 +136,7 @@ async function adoptWorktreeHoldingBranch({ agentId, workspacePath, branchName,const activeWorkspacePaths = agents.filter(a => activeAgentIds.has(a.id)).map(a => a.workspacePath || a.metadata?.workspacePath);- const released = await releaseIdleSiblingNextHolder(workspacePath, branchName, { activeWorkspacePaths, agents, requestingAgentId: agentId }).catch(err => {+ const released = await releaseIdleSiblingNextHolder(workspacePath, branchName, { activeWorkspacePaths, agents, requestingAgentId: agentId, allowUntracked: true }).catch(err => {emitLog('warn', `🌳 Could not release ${branchName} for task ${taskId}: ${err.message}`, { taskId });return null;});diff --git a/server/services/worktreeManager.js b/server/services/worktreeManager.jsindex 3ef60838bc..a07b9818a1 100644--- a/server/services/worktreeManager.js+++ b/server/services/worktreeManager.js@@ -814,12 +814,15 @@ export const SIBLING_NEXT_HOLDER_IDLE_MS = 10 * 60 * 1000;* Refuses (returns false) unless ALL hold: the branch is `next/…`; the holder is* a linked worktree (never the primary checkout) outside the managed root,* unlocked; the readable registry has no branch/repository owner or running/paused- * agent inside it; nothing in it changed for `idleMs`; the tree is clean, untracked files included; and HEAD is already on+ * agent inside it; nothing in it changed for `idleMs`; the tree is clean, untracked files included+ * (unless `allowUntracked`: a detach leaves untracked files exactly where they are, so a+ * coordinator follow-up may take over a tree whose only dirt is stray untracked files such as+ * Finder "name 2.js" duplicates — tracked or staged changes still refuse); and HEAD is already on* the remote, so nothing is left only in that tree.** @param {string} sourceWorkspace* @param {string} branchName- * @param {{ activeWorkspacePaths?: string[], agents?: object[], requestingAgentId?: string, idleMs?: number, nowMs?: number }} [options]+ * @param {{ activeWorkspacePaths?: string[], agents?: object[], requestingAgentId?: string, idleMs?: number, nowMs?: number, allowUntracked?: boolean }} [options]* @returns {Promise<{ path: string }|null>} the released holder, or null*/export async function releaseIdleSiblingNextHolder(sourceWorkspace, branchName, {@@ -828,6 +831,7 @@ export async function releaseIdleSiblingNextHolder(sourceWorkspace, branchName,requestingAgentId = null,idleMs = SIBLING_NEXT_HOLDER_IDLE_MS,nowMs = Date.now(),+ allowUntracked = false,} = {}) {if (!sourceWorkspace || !branchName?.startsWith('next/')) return null;@@ -855,7 +859,8 @@ export async function releaseIdleSiblingNextHolder(sourceWorkspace, branchName,// Stricter than `classifyWorktreeDirt` on purpose: this tree isn't PortOS's,// so no path counts as disposable scratch.const porcelain = await git(['--no-optional-locks', 'status', '--porcelain', '--untracked-files=all']).catch(() => null);- if (porcelain !== '') return null;+ if (porcelain === null) return null;+ if (allowUntracked ? porcelain.split('\n').some(l => l && !l.startsWith('?? ')) : porcelain !== '') return null;const remoteRef = await git(['rev-parse', '--verify', '--quiet', `${branchName}@{upstream}`]).catch(() => git(['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branchName}`])).catch(() => null);diff --git a/server/services/worktreeManager.releaseNextHolder.test.js b/server/services/worktreeManager.releaseNextHolder.test.jsindex c8eed948b0..dfbdc08330 100644--- a/server/services/worktreeManager.releaseNextHolder.test.js+++ b/server/services/worktreeManager.releaseNextHolder.test.js@@ -74,6 +74,21 @@ describe('releaseIdleSiblingNextHolder', () => {expect(await holderBranch()).toBe(BRANCH);});+ it('lets a coordinator release a tree whose only dirt is untracked files, leaving them in place', async () => {+ await writeFile(join(holder, 'notes 2.txt'), 'draft');+ const released = await releaseIdleSiblingNextHolder(repo, BRANCH, { agents: [], nowMs: LATER(), allowUntracked: true });+ expect(resolve(released.path)).toBe(resolve(holder));+ expect(existsSync(join(holder, 'notes 2.txt'))).toBe(true);+ expect(await holderBranch()).toBe('');+ });++ it('still refuses an untracked-tolerant release when a tracked file changed', async () => {+ await writeFile(join(holder, 'tracked.txt'), 'v1');+ await git(['add', 'tracked.txt'], holder);+ await expect(releaseIdleSiblingNextHolder(repo, BRANCH, { agents: [], nowMs: LATER(), allowUntracked: true })).resolves.toBeNull();+ expect(await holderBranch()).toBe(BRANCH);+ });+it('refuses a tree touched within the idle window', async () => {await expect(releaseIdleSiblingNextHolder(repo, BRANCH, { agents: [] })).resolves.toBeNull();expect(await holderBranch()).toBe(BRANCH);