The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Swarm: a project delete skips starts stuck over an hour, and names what still holds it (#2871)
Dee62baa40a586b
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex dfdbca3f3..2c0d7ea97 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -1629,7 +1629,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,for (const start of state.starts ?? []) {if (start.request.buddySession?.projectId === project.id && !start.harnessId && !start.error) start.error = 'Its project was deleted.'}- deleteProject(state, actor, command.projectId, orphaned)+ deleteProject(state, actor, command.projectId, orphaned, context.now)// No machine keeps it any more; one kept only for it now serves none (machines.ts machineProjectRefusal).for (const pool of state.machines ?? []) if (pool.projects) pool.projects = pool.projects.filter(id => id !== project.id)breakdiff --git a/backend/src/superTabs/projects.test.ts b/backend/src/superTabs/projects.test.tsindex c2ed20449..2ad7bebbd 100644--- a/backend/src/superTabs/projects.test.ts+++ b/backend/src/superTabs/projects.test.ts@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto'import { describe, expect, it } from 'vitest'import { applyCommand, commandSchema, type Command, type CommandContext } from './commands.js'import { activeWork, agentOnly, awaitingWorkers, createSuperTab, fail, SuperTabError, visibleState, workerIndex, type Actor, type Agent, type Conversation, type MessageDraft, type SuperTabState, type WorkStatus } from './model.js'-import { canReadAgent, canWatchAgent, confidentialSession, groupProject, ledProject, markConfidential, projectOf, projectsOf, readConversation, requireSingleRegistration, sessionKey, skillModeOf, skillSetOf, watchersLost, workRequesterId, requestedByLine, type OtherRegistrations, type SwarmProject } from './projects.js'+import { canReadAgent, canWatchAgent, confidentialSession, groupProject, ledProject, markConfidential, projectOf, projectsOf, readConversation, requireSingleRegistration, sessionKey, skillModeOf, skillSetOf, watchersLost, workRequesterId, requestedByLine, STUCK_START_MS, type OtherRegistrations, type SwarmProject } from './projects.js'import { mayDrive } from './terminal.js'const owner: Actor = { kind: 'person', userId: 'owner', email: '[email protected]' }@@ -241,6 +241,21 @@ describe('projects inside an invite-only swarm', () => {expect(f.state.starts).toEqual([])})+ it('deletes past starts stuck over an hour, and names what still holds a refused delete', () => {+ const f = setup(), p = f.project()+ const conversationId = f.task(p.projectId)+ const request = { conversationId, machineId: 'machine', engine: 'codex', name: 'Builder', cwd: '/work', worktree: true,+ requirements: { memoryBytes: 0, diskBytes: 0, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } }+ const queued = String(f.run({ type: 'agent.start', request }).startId)+ const settling = String(f.run({ type: 'agent.start', request: { ...request, name: 'Checker' } }).startId)+ Object.assign(f.state.starts!.find(s => s.id === settling)!, { dispatched: true, dispatchedAt: 1000, poolGeneration: 'pool', harnessId: 'native', poolSettled: false })+ f.add(conversationId, 'native', false)+ expect(() => f.run({ type: 'project.delete', projectId: p.projectId })).toThrow('pending agent starts before deleting it: Builder in “Work”, Checker in “Work”.')+ f.run({ type: 'project.delete', projectId: p.projectId }, owner, { now: 1000 + STUCK_START_MS + 1 })+ expect(projectsOf(f.state).map(p => p.id)).toEqual(['lead'])+ expect(f.state.starts!.some(s => s.id === queued || s.id === settling)).toBe(false)+ })+it('still refuses a dispatched start in an archived task: its machine may be starting the agent', () => {const f = setup(), p = f.project()const conversationId = f.task(p.projectId)diff --git a/backend/src/superTabs/projects.ts b/backend/src/superTabs/projects.tsindex ecf55080a..9823f12fb 100644--- a/backend/src/superTabs/projects.ts+++ b/backend/src/superTabs/projects.ts@@ -1,5 +1,5 @@import { createHash } from 'node:crypto'-import { activeWork, agent, agentRole, author, conversation, fail, isLeads, leadsRemoved, nextConversationNumber, person, type Actor, type Agent, type AgentStartRequest, type Conversation, type Person, type SuperTabState } from './model.js'+import { activeWork, agent, agentRole, author, conversation, fail, isLeads, leadsRemoved, nextConversationNumber, person, type Actor, type Agent, type AgentStart, type AgentStartRequest, type Conversation, type Person, type SuperTabState } from './model.js'import type { SwarmRule } from './rules.js'import { buddyReads, isBuddy, isBuddyChat, isSwarmBuddy, isSwarmBuddyChat } from './buddies.js'@@ -469,12 +469,16 @@ export function manageProject(state: SuperTabState, actor: Actor, projectId: strreturn projectOf(state, projectId)}+/** How long a start may stay pending before a project delete treats it as stuck: well past the 15 minutes the sweep gives a+ * dispatched start to prepare (liveness.ts START_PREPARE_MS). */+export const STUCK_START_MS = 60 * 60_000+/** Removes coordination only; the command removes the project's agents first.* Pending starts must be reconciled first; terminal-history privacy bindings remain permanent. [orphaned] names the* contributed starts still settling whose agent was already removed before this delete: only their machine settles one,* and it closed that agent's session when it was removed, so none of them ever settles (2026-11-04: 17 such starts on four* Macs, from agents stopped while a project was cleaned up, kept its owner from deleting it). */-export function deleteProject(state: SuperTabState, actor: Actor, projectId: string, orphaned: ReadonlySet<string> = new Set()): void {+export function deleteProject(state: SuperTabState, actor: Actor, projectId: string, orphaned: ReadonlySet<string> = new Set(), now?: number): void {const project = manageProject(state, actor, projectId)// A person's one Buddy chat belongs to no project and stays; that project's sessions in it go with their agents.const groups = state.conversations.filter(c => !isLeads(c) && !isSwarmBuddyChat(c) && groupProject(state, c).id === project.id)@@ -483,12 +487,24 @@ export function deleteProject(state: SuperTabState, actor: Actor, projectId: str// blocks the delete; it goes with the project's other starts below. On 2026-11-03 one queued two days earlier kept an// owner from deleting a cleaned-up project, and no command could settle it.const archived = new Set(groups.filter(c => c.archived).map(c => c.id))- if (state.starts?.some(s => groupIds.has(s.request.conversationId) && !s.error &&+ // A start still pending an hour after it was last asked for is stuck, not starting: the sweep fails a dispatched one+ // within 15 minutes (liveness.ts), so nothing is mid-start there. It goes with the project. On 2026-11-04 the owner was+ // still refused after both fixes above, by starts no read showed them.+ const stuck = (s: AgentStart) => now !== undefined && now - (s.dispatchedAt ?? s.requestedAt ?? 0) > STUCK_START_MS+ const pending = (state.starts ?? []).filter(s => groupIds.has(s.request.conversationId) && !s.error && !stuck(s) &&!(!s.dispatched && !s.harnessId && archived.has(s.request.conversationId)) &&- (!s.harnessId || s.poolGeneration && !s.poolSettled && !orphaned.has(s.id)))) {- fail('STARTS_PENDING', 'Resolve this project’s pending agent starts before deleting it.')+ (!s.harnessId || s.poolGeneration && !s.poolSettled && !orphaned.has(s.id)))+ // Each refusal names what holds it, so its owner can act on it: the ones before named nothing, and no read showed them.+ const titled = (id: string) => groups.find(c => c.id === id)?.title || 'the project chat'+ if (pending.length) {+ fail('STARTS_PENDING', `Resolve this project’s pending agent starts before deleting it: ${pending.slice(0, 3)+ .map(s => `${s.request.name} in “${titled(s.request.conversationId)}”`).join(', ')}${pending.length > 3 ? ` and ${pending.length - 3} more` : ''}.`)+ }+ const active = groups.filter(activeWork)+ if (active.length) {+ fail('WORK_ACTIVE', `Resolve this project’s active work before deleting it: ${active.slice(0, 3).map(c => `“${titled(c.id)}”`).join(', ')}${+ active.length > 3 ? ` and ${active.length - 3} more` : ''}.`)}- if (groups.some(activeWork)) fail('WORK_ACTIVE', 'Resolve this project’s active work before deleting it.')state.retiredConversationNumber = nextConversationNumber(state) - 1state.projects = state.projects!.filter(p => p.id !== project.id)state.rules = state.rules?.filter(r => r.projectId !== project.id)