Skip to content

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.

A person's one Buddy starts again, and the Buddy pickers say when a machine is paused (#2497)

Jacob Pham32d5b204a980
diff --git a/cli/e2e/harness/fleet.ts b/cli/e2e/harness/fleet.ts
index 333d909f9..02222081b 100644
--- a/cli/e2e/harness/fleet.ts
+++ b/cli/e2e/harness/fleet.ts
@@ -86,8 +86,8 @@ export async function writeE2ee(daemon: IsolatedDaemon, files: Record<string, un
}
/** A daemon for one machine of the account, signed in to the fake backend and nothing else. */
-export async function signedInDaemon(backend: FakeBackend, spec: FakeMachine, env: Record<string, string> = {}, scriptPath?: string): Promise<IsolatedDaemon> {
- const daemon = await IsolatedDaemon.create({ ...(scriptPath ? { scriptPath } : {}), env: { ...remoteSettings(backend), ADAPTER_COMPUTER_ID: spec.computerId, ...env } })
+export async function signedInDaemon(backend: FakeBackend, spec: FakeMachine, env: Record<string, string> = {}, scriptPath?: string, trustPrompt?: boolean): Promise<IsolatedDaemon> {
+ const daemon = await IsolatedDaemon.create({ ...(scriptPath ? { scriptPath } : {}), ...(trustPrompt ? { trustPrompt } : {}), env: { ...remoteSettings(backend), ADAPTER_COMPUTER_ID: spec.computerId, ...env } })
// The daemon inherits the runner's environment, where a registry or a proxy may be named. None of
// them is anywhere a fleet daemon may go.
for (const [key, value] of Object.entries(daemon.env)) {
diff --git a/cli/e2e/superTabSwarmBuddy.e2e.ts b/cli/e2e/superTabSwarmBuddy.e2e.ts
new file mode 100644
index 000000000..cb92a785f
--- /dev/null
+++ b/cli/e2e/superTabSwarmBuddy.e2e.ts
@@ -0,0 +1,74 @@
+/** A person's one Buddy started on their own machine in the Swarm, on the real native protocol: a private daemon, tmux and
+ * data dir, a fake Claude engine and the fake backend. It has no project, so nothing is cloned and no GitHub token is asked
+ * for, and the folder its start names is never made: 2026-11-02, each of those failed every such start while unit tests,
+ * which faked the steps either side, passed. */
+import { execFileSync } from 'node:child_process'
+import { existsSync, mkdirSync, readdirSync, writeFileSync } from 'node:fs'
+import { join } from 'node:path'
+import { afterEach, expect, it, onTestFailed } from 'vitest'
+import { LocalClient } from './harness/client.js'
+import { until, type IsolatedDaemon } from './harness/daemon.js'
+import { FakeBackend } from './harness/fakeBackend.js'
+import { signedInDaemon } from './harness/fleet.js'
+import { overOldRoutes } from './harness/swarmReads.js'
+
+const TAB = 'buddy-tab'
+const ME = { machineId: 'd3'.repeat(16), computerId: 'one-buddy-fixture', name: 'Buddy fixture', token: 'fixture-buddy-token', account: 'person', email: '[email protected]' }
+let relay: FakeBackend | undefined, daemon: IsolatedDaemon | undefined, client: LocalClient | undefined
+afterEach(async () => {
+ client?.close(); client = undefined
+ await daemon?.close(); daemon = undefined
+ await relay?.close(); relay = undefined
+})
+
+it('starts in a folder of its own, from the checkouts here, with no token and nothing cloned', async () => {
+ const backend = await FakeBackend.start(); relay = backend
+ backend.addMachine(ME)
+ // As a real engine does: it asks about a folder it has no answer for, in a terminal no Swarm view shows.
+ const d = await signedInDaemon(backend, ME, { ANTHROPIC_API_KEY: 'fixture-only' }, undefined, true); daemon = d
+ writeFileSync(join(d.env.HOME!, '.claude.json'), '{}')
+ const project = join(d.projectsDir, 'api'); mkdirSync(project, { recursive: true })
+ const git = (...args: string[]) => execFileSync('git', ['-c', 'user.name=Fixture', '-c', '[email protected]', ...args], { cwd: project, stdio: 'ignore' })
+ git('init', '-q'); writeFileSync(join(project, 'README.md'), 'fixture\n'); git('add', '.'); git('commit', '-qm', 'fixture')
+ const cwd = join(d.env.HOME!, 'harnesses', 'swarms', TAB)
+ const pool = { machineId: ME.machineId, generation: 'grant-1', cwd, scope: 'swarm', engines: ['claude'], maxAgents: 2, paused: false }
+ const start: Record<string, any> = { id: 'start-buddy', poolGeneration: 'grant-1', creationId: 'super-start-buddy', dispatched: false, harnessId: null, error: null,
+ request: { conversationId: 'buddy-chat', machineId: ME.machineId, engine: 'claude', name: "person's Buddy", cwd: `${cwd}/.buddy-person`, worktree: false,
+ requirements: { memoryBytes: 0, diskBytes: 1, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false },
+ buddyOf: { personId: 'person', generation: 'g' }, buddyScope: 'swarm', buddyProjects: [{ id: 'p1', name: 'API', cwd: project }] } }
+ const agents: Array<Record<string, any>> = [], asked: string[] = []
+ backend.superTabs = overOldRoutes(async (method, raw, body) => {
+ const path = new URL(raw, backend.httpUrl).pathname
+ if (path.endsWith('/github-token')) { asked.push(path); throw Object.assign(new Error('This start has no project folder to prepare.'), { status: 404, code: 'NOT_FOUND' }) }
+ if (path.endsWith('/pools')) return { data: [{ tabId: TAB, machine: pool, projects: [], starts: [], buddyStarts: start.harnessId && start.poolSettled ? [] : [start], githubApp: true, harnessIds: agents.map(a => a.harnessId) }] }
+ if (path.includes('/hosts/') && path.includes('/starts/')) {
+ if (method === 'GET') return { data: start }
+ const c = body.command
+ if (c.type === 'agent.startDispatch') start.dispatched = true
+ else if (c.type === 'agent.started') { start.harnessId = c.harnessId; agents.push({ id: 'buddy', machineId: ME.machineId, harnessId: c.harnessId, buddyScope: 'swarm', configuration: c.configuration }) }
+ else if (c.type === 'agent.startSettled') start.poolSettled = true
+ else if (c.type === 'agent.startFailed') start.error = c.error
+ return { data: { result: {} } }
+ }
+ if (path.includes('/hosts/')) return { data: [] }
+ if (path.includes('/machines/')) return { data: { revision: 1 } }
+ if (path === `/api/super-tabs/${TAB}`) return { data: { state: { id: TAB, agents, projects: [], conversations: [] }, revision: 1 } }
+ if (path.endsWith('/deliveries') || path.endsWith('/grids')) return { data: [] }
+ throw new Error(`Unexpected request ${path}`)
+ })
+ onTestFailed(() => console.log(d.log().split('\n').slice(-80).join('\n')))
+ await d.start()
+ await until('the machine connected', () => backend.nodeUp(ME.machineId), 30000)
+ client = await LocalClient.connect(d, { machineId: ME.machineId })
+ await client.request('super_tabs', { action: 'wake' }, 30000)
+ await until('its Buddy started', () => {
+ expect(start.error).toBeNull()
+ return start.harnessId
+ }, 90000, 250)
+ expect(asked).toEqual([])
+ expect((await client.request('agents_list')).agents.map((a: Record<string, any>) => a.id)).toContain(start.harnessId)
+ const homes = join(d.env.HOME!, 'harnesses', 'worktrees', 'buddy-home'), folders = readdirSync(homes)
+ expect(folders).toHaveLength(1)
+ expect(existsSync(join(homes, folders[0]!, 'projects', 'API', 'README.md'))).toBe(true)
+ expect(existsSync(start.request.cwd)).toBe(false)
+})
diff --git a/cli/src/engines/kit/folderTrust.ts b/cli/src/engines/kit/folderTrust.ts
index 8e31353b1..5b7eb5b5c 100644
--- a/cli/src/engines/kit/folderTrust.ts
+++ b/cli/src/engines/kit/folderTrust.ts
@@ -10,7 +10,8 @@
* earlier contributions repaired after an update. It never authorizes the person's other repositories.
* The other is a Swarm agent in the Swarm's full mode in the checkout of its remote project's own repository, or in a
* worktree of the repository the person picked for it in this machine's own window (core/agents/launches.ts
- * `swarmCheckout`). Any other existing folder stays the person's question.
+ * `swarmCheckout`). A person's one Buddy's folder is Harness's own, and its launch reads no project's settings
+ * (superTabs/buddyHome.ts `trustBuddyHome`). Any other existing folder stays the person's question.
* The callers decide (core/agents/create.ts, launches.ts). A worktree only inherits the answer its source
* repo already has.
*
diff --git a/cli/src/superTabs/buddyHome.spec.ts b/cli/src/superTabs/buddyHome.spec.ts
index ea8699f81..1c94f5ae2 100644
--- a/cli/src/superTabs/buddyHome.spec.ts
+++ b/cli/src/superTabs/buddyHome.spec.ts
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync,
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
-import { buddyProjectsOf, folderName, prepareBuddyHome, pruneBuddyHome, removeBuddyHome } from './buddyHome.js'
+import { buddyProjectsOf, folderName, prepareBuddyHome, pruneBuddyHome, removeBuddyHome, trustBuddyHome } from './buddyHome.js'
// A person's one Buddy's folder (spec 2026-10-31-one-buddy-per-swarm, Folder): one worktree per project checkout on the
// machine, each from its own checkout, and a lost project's out before the next turn. Real git, in a throwaway folder.
@@ -28,6 +28,24 @@ function root(): string {
}
describe('a person\'s one Buddy\'s folder', () => {
+ it('answers Claude Code\'s folder question for it, and leaves any other engine to ask', async () => {
+ const claude = root(), home = join(root(), 'home'), config = join(claude, '.claude.json')
+ mkdirSync(home)
+ writeFileSync(config, '{}')
+ const moved = process.env.CLAUDE_CONFIG_DIR
+ process.env.CLAUDE_CONFIG_DIR = claude
+ try {
+ await trustBuddyHome(home, 'codex')
+ expect(readFileSync(config, 'utf8')).toBe('{}')
+ await trustBuddyHome(home, 'claude')
+ const saved = Object.values(JSON.parse(readFileSync(config, 'utf8')).projects as Record<string, { hasTrustDialogAccepted: boolean }>)
+ expect(saved.map(p => p.hasTrustDialogAccepted)).toEqual([true])
+ } finally {
+ if (moved === undefined) delete process.env.CLAUDE_CONFIG_DIR
+ else process.env.CLAUDE_CONFIG_DIR = moved
+ }
+ })
+
it('holds a worktree of each project checkout on this machine, each its own project\'s, and names the ones not here', async () => {
const r = root(), web = checkout(r, 'web-src'), app = checkout(r, 'app-src'), home = join(r, 'home')
const result = await prepareBuddyHome(home, [{ id: 'web', name: 'Web', cwd: web }, { id: 'app', name: 'App', cwd: app },
diff --git a/cli/src/superTabs/buddyHome.ts b/cli/src/superTabs/buddyHome.ts
index 93ca71038..94e007b50 100644
--- a/cli/src/superTabs/buddyHome.ts
+++ b/cli/src/superTabs/buddyHome.ts
@@ -10,6 +10,8 @@ import { execFile } from 'node:child_process'
import { existsSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
import { promisify } from 'node:util'
+import { launchEnvironment } from '../engines/kit/launchExecutable.js'
+import { folderTrust } from '../engines/launchPrep.js'
import { insideGitCheckout } from '../lib/gitProject.js'
const run = promisify(execFile)
@@ -108,6 +110,20 @@ export async function pruneBuddyHome(home: string, readable: ReadonlySet<string>
return gone.map(r => r.name)
}
+/**
+ * Answers Claude Code's question about [home], in the file it reads, as its launch would otherwise wait on it. That question
+ * is asked in a terminal no Swarm view shows, so the Buddy sat at it until its start timed out (MacBookPro2021, 2026-11-02).
+ * This is an exception to "never a folder with content" (engines/kit/folderTrust.ts): the folder is Harness's, made for the
+ * start its person pressed, and what the question guards against cannot happen in it. A Buddy launches with
+ * `--setting-sources local --strict-mcp-config`, so no project's files configure it, and the folder goes with the Buddy.
+ * A Buddy on another engine has none of this to rely on, so it still asks. A failure here only leaves the question.
+ */
+export async function trustBuddyHome(home: string, engine: unknown): Promise<void> {
+ if (engine !== 'claude') return
+ try { folderTrust('claude', undefined, await launchEnvironment() ?? undefined)?.record(home) }
+ catch (error) { console.warn(`[super-tabs] could not answer the folder question for a Buddy: ${(error as Error).message}`) }
+}
+
/** Takes every worktree out of [home] and removes it: its Buddy ended. */
export async function removeBuddyHome(home: string): Promise<void> {
// Through a link nothing is removed but the link itself (rm never follows one inside the folder it removes).
diff --git a/cli/src/superTabs/projectFolder.spec.ts b/cli/src/superTabs/projectFolder.spec.ts
index c0803cfa5..58f35fb08 100644
--- a/cli/src/superTabs/projectFolder.spec.ts
+++ b/cli/src/superTabs/projectFolder.spec.ts
@@ -35,6 +35,16 @@ describe('per-project checkouts on a contributed swarm machine', () => {
await f.run()
expect(f.prepare).not.toHaveBeenCalled()
})
+ it('finds a project session of a person\'s one Buddy chat by the project it names, as that chat is in no project\'s list', async () => {
+ const f = fixture()
+ Object.assign(f.start.request, { conversationId: 'swarm-buddy-chat', buddySession: { thread: 'root', projectId: 'project-a' } })
+ await f.run()
+ expect(f.prepare).toHaveBeenCalledOnce()
+ // Its project alone: a session naming a project this machine was not told of prepares nothing, whatever its chat.
+ Object.assign(f.start.request, { conversationId: 'work', buddySession: { thread: 'root', projectId: 'project-b' } })
+ await expect(f.run()).rejects.toThrow('no authorized project')
+ expect(f.prepare).toHaveBeenCalledOnce()
+ })
it('does not widen a legacy contribution or substitute a different filesystem path', async () => {
const f = fixture()
f.row.machine.scope = ''
@@ -147,6 +157,20 @@ describe('preparing another person\'s start with the Harness GitHub App', () =>
expect(noApp.backend).not.toHaveBeenCalled()
})
+ it('prepares nothing for a person\'s one Buddy, which has no project: no token, no clone, no fetch', async () => {
+ // 2026-11-02: the token call was refused with "This start has no project folder to prepare", which failed the start.
+ const app = hosted(new SuperTabHostError('NOT_FOUND', 'This start has no project folder to prepare.', 404))
+ Object.assign(app.start.request, { buddyScope: 'swarm', buddyOf: { personId: 'owner', generation: 'g' } })
+ expect(await app.ready()).toBeNull()
+ expect(app.backend).not.toHaveBeenCalled()
+ expect(app.prepare).not.toHaveBeenCalled()
+ expect(app.fetch).not.toHaveBeenCalled()
+ // Without the app it failed too, as a start of no project this machine was authorized for.
+ delete (app.row as { githubApp?: boolean }).githubApp
+ expect(await app.ready()).toBeNull()
+ expect(app.prepare).not.toHaveBeenCalled()
+ })
+
it('in a team account, always asks for a token, and fails without one rather than using any other login', async () => {
const team = hosted()
expect(await team.ready(true)).toEqual({ requester: '[email protected]' })
diff --git a/cli/src/superTabs/projectFolder.ts b/cli/src/superTabs/projectFolder.ts
index 605fcdf4f..a61eb5670 100644
--- a/cli/src/superTabs/projectFolder.ts
+++ b/cli/src/superTabs/projectFolder.ts
@@ -72,11 +72,14 @@ async function revokeQuietly(token: string, revoke = revokeGitHubToken): Promise
export async function prepareSwarmStart(core: CoreApi, row: Json, start: Json,
deps: { backend: Backend; team: boolean; prepare?: typeof prepareProjectFolder; fetch?: typeof fetchDefaultBranch; revoke?: (token: string) => Promise<void> }):
Promise<{ requester: string } | null> {
+ const request = object(start.request)
+ // A person's one Buddy has no project: its launch makes its folder from the checkouts already here and fetches nothing
+ // (buddyHome.ts). Asking for a token anyway was refused with a 404, which failed every such start (2026-11-02).
+ if (request.buddyScope === 'swarm') return null
const github = await startGitHub(core, row, start, deps)
const gitEnv = github ? swarmGitPrepareEnv(github.token) : undefined
try {
if (object(row.machine).scope === 'swarm') await prepareSwarmProject(core, row, start, deps.prepare, gitEnv)
- const request = object(start.request)
if (gitEnv && request.worktree === true && typeof request.cwd === 'string' && isAbsolute(request.cwd)) {
await (deps.fetch ?? fetchDefaultBranch)(resolve(request.cwd), gitEnv)
}
@@ -100,8 +103,10 @@ export async function prepareSwarmProject(core: CoreApi, row: Json, start: Json,
const pool = object(row.machine)
if (pool.scope !== 'swarm' || start.dispatched) return
const request = object(start.request)
+ // A project session of a person's one Buddy chat names its project: that chat is in no project's list (backend hostRows.ts).
+ const session = object(request.buddySession).projectId
const project = (Array.isArray(row.projects) ? row.projects.map(object) : [])
- .find(p => Array.isArray(p.conversationIds) && p.conversationIds.includes(request.conversationId))
+ .find(p => session ? p.id === session : Array.isArray(p.conversationIds) && p.conversationIds.includes(request.conversationId))
if (!project || !identifier(project.id) || !identifier(row.tabId)) throw new Error('This start has no authorized project.')
const repository = object(project.repository)
const expectedRoot = swarmCloneRoot(core.dataDir, row.tabId, pool.cwd)
diff --git a/cli/src/superTabs/start.spec.ts b/cli/src/superTabs/start.spec.ts
index a0dff292a..82e9aa1f2 100644
--- a/cli/src/superTabs/start.spec.ts
+++ b/cli/src/superTabs/start.spec.ts
@@ -1,13 +1,15 @@
import { describe, expect, it, vi } from 'vitest'
import { join } from 'node:path'
-import { existsSync } from 'node:fs'
-import { homedir } from 'node:os'
+import { existsSync, mkdtempSync, rmSync } from 'node:fs'
+import { homedir, tmpdir } from 'node:os'
import { BUDDY_SESSION_ENGINE, HEAVY_NOT_RECORDED, HEAVY_REFUSED, inspectCapacity, MODEL_REPORT_WAIT_MS, startAgent } from './start.js'
import { buildEngineCommandArgv } from '../lib/engineLaunch.js'
+import { readCapacityDisk } from './disk.js'
import { SuperTabHostError } from './wire.js'
const teamDaemon = vi.hoisted(() => ({ value: false, relayed: true, offered: null as null | { slugs: string[]; listed: string[] } }))
vi.mock('./teamDaemon.js', async (original) => ({ ...await original<object>(), isTeamDaemon: () => teamDaemon.value }))
vi.mock('../team/relay.js', async (original) => ({ ...await original<object>(), teamRelayed: () => teamDaemon.relayed, offeredCodexModels: async () => teamDaemon.offered }))
+vi.mock('./buddyHome.js', async (original) => ({ ...await original<object>(), prepareBuddyHome: async () => ({ ready: [], missing: [] }), trustBuddyHome: async () => {} }))
const where = { port: 14001, machineId: 'lead-machine', dataDir: '/fixture' }
/** A queued start is watched before the Lead moves on (startAgent); these tests read the queued answer at once. */
const noPause = async () => {}
@@ -325,6 +327,26 @@ it.each(['claude', 'codex'])('starts a %s Buddy with the built-in swarm-buddy sk
expect(payload.prompt).not.toContain('swarm-dev')
})
+it('admits a person\'s one Buddy by the disk its folder is made on, as the folder its start names is never made', async () => {
+ // The real disk reading, on a folder that is not there: measured as it stands it is refused, and the Buddy never starts (2026-11-02).
+ const root = mkdtempSync(join(tmpdir(), 'swarm-buddy-disk-'))
+ try {
+ const f = fixture(), answer = f.request.getMockImplementation()!
+ f.request.mockImplementation(async (type, payload = {}, ms) => {
+ if (type !== 'super_tabs' || !['capacity', 'reserveCapacity'].includes(String(payload.action))) return answer(type, payload, ms)
+ const disk = await readCapacityDisk(String(payload.cwd), payload.worktree === true, root).catch(() => null)
+ if (payload.action === 'reserveCapacity') return disk ? answer(type, payload, ms) : { error: 'CAPACITY_UNAVAILABLE', detail: 'The destination disk capacity could not be verified.' }
+ return { ok: true, resources: { cpuPercent: 20, memoryTotalBytes: 1000, memoryUsedBytes: 100, projectDiskFreeBytes: disk?.freeBytes ?? null }, tools: { git: true }, devices: {} }
+ })
+ f.start.request = { ...f.start.request, cwd: join(root, 'swarm', '.buddy-peer'), worktree: false, buddyScope: 'swarm', buddyOf: { personId: 'peer', generation: 'g' } } as typeof f.start.request
+ const result = await startAgent({ action: 'start', tabId: 'tab', operationId: 'one-buddy', request: f.start.request }, f.scoped, where, f.open)
+ expect(result.error).not.toBe('CAPACITY_UNAVAILABLE')
+ const payload = f.request.mock.calls.find(call => call[0] === 'agent_create')![1]!
+ expect(payload.cwd).toContain(join('worktrees', 'buddy-home'))
+ expect(payload.projectSource).toBeUndefined()
+ } finally { rmSync(root, { recursive: true, force: true }) }
+})
+
it.each(['claude'])('starts a %s thread session as a Buddy in every way, told its thread and to answer only there, with no message text', async engine => {
const plain = fixture()
plain.start.request = { ...plain.start.request, engine, buddyOf: { personId: 'peer', generation: 'g' } } as typeof plain.start.request
diff --git a/cli/src/superTabs/start.ts b/cli/src/superTabs/start.ts
index 072bf3e9e..82a90fa16 100644
--- a/cli/src/superTabs/start.ts
+++ b/cli/src/superTabs/start.ts
@@ -10,7 +10,7 @@ import { permissionModeFlags } from '../lib/engineLaunch.js'
import type { AgentEngine } from '../engines/types.js'
import { isSwarmSkillMode, swarmSkillUse, wireRole, type SwarmSkillMode } from '../lib/swarmSkills.js'
import { isTeamDaemon, pmEngineHome } from './teamDaemon.js'
-import { BUDDY_HOMES, buddyProjectsOf, prepareBuddyHome } from './buddyHome.js'
+import { BUDDY_HOMES, buddyProjectsOf, prepareBuddyHome, trustBuddyHome } from './buddyHome.js'
import { markBuddyNarrow } from '../lib/buddyGuard.js'
import { projectsRoot } from '../lib/projectFolder.js'
import { worktreeFolderName } from '../lib/agentNames.js'
@@ -110,6 +110,11 @@ export function buddySessionThread(request: Json): string | null {
return typeof thread === 'string' && /^[A-Za-z0-9_-]{1,160}$/.test(thread) ? thread : null
}
+/** Whether a start's folder is made in Harness's worktrees folder, whose disk then admits it (disk.ts). A person's one Buddy's
+ * `cwd` only admits its start at the backend and is never made here: measured as it stands, a folder that is not there
+ * refused every such start (2026-11-02). */
+const madeInWorktrees = (request: Json) => request.worktree === true || request.buddyScope === 'swarm'
+
export async function inspectCapacity(target: Daemon, request: Json) {
const wanted = object(request.requirements)
const requirements: Requirements = {
@@ -119,7 +124,7 @@ export async function inspectCapacity(target: Daemon, request: Json) {
quotaRequired: wanted.quotaRequired === true,
}
const [capability, engines, usage] = await Promise.allSettled([
- target.request('super_tabs', { action: 'capacity', cwd: request.cwd, worktree: request.worktree === true, tools: requirements.tools, devices: requirements.devices }, 20_000),
+ target.request('super_tabs', { action: 'capacity', cwd: request.cwd, worktree: madeInWorktrees(request), tools: requirements.tools, devices: requirements.devices }, 20_000),
target.request('engines_probe', { engines: [request.engine] }, 20_000),
target.request('usage_read', {}, 20_000),
])
@@ -342,7 +347,7 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:
}
if (!resources.allowed) return { error: 'CAPACITY_UNAVAILABLE', startId, ...resources }
const reservation = await target.request('super_tabs', { action: 'reserveCapacity', creationId,
- cwd: request.cwd, worktree: request.worktree === true, requirements: request.requirements }, 20_000).catch(() => null)
+ cwd: request.cwd, worktree: madeInWorktrees(request), requirements: request.requirements }, 20_000).catch(() => null)
if (!reservation || (reservation.ok === true && reservation.reservationId !== creationId)) {
return { error: 'START_UNCERTAIN', startId, creationId,
detail: 'The machine did not confirm its capacity reservation. Keep this start ID and resume it; nothing was dispatched.' }
@@ -377,6 +382,7 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:
// backend's folder for it only admits the start.
const homeFolder = swarmBuddy ? joinPath(projectsRoot(), 'worktrees', BUDDY_HOMES, worktreeFolderName(`super-tab/${startId}`)) : null
const home = homeFolder ? await prepareBuddyHome(homeFolder, buddyProjectsOf(request)) : null
+ if (homeFolder) await trustBuddyHome(homeFolder, request.engine)
// A Buddy of one project launches with no wide guard: its folder is marked before its launch (lib/buddyGuard.ts).
if (buddy && request.buddyNarrow === true) markBuddyNarrow(worktreeFolderName(`super-tab/${startId}`))
// A project's Product Manager (backend leadStart.ts): the Lead of its project's conversation once it runs.
diff --git a/desktop/lib/super_tabs/buddy_machines.dart b/desktop/lib/super_tabs/buddy_machines.dart
index a1d020fa9..4b28a2e91 100644
--- a/desktop/lib/super_tabs/buddy_machines.dart
+++ b/desktop/lib/super_tabs/buddy_machines.dart
@@ -14,8 +14,15 @@ import 'machines.dart';
/// A machine a Buddy may run on, as the pickers list it: one of the reader's
/// own. One outside the Swarm ([inSwarm] false) stays theirs: the server
/// records it for their Buddies alone and never adds it to the Swarm (Dee,
-/// 10-29). An [offline] one is listed but cannot be picked.
-typedef BuddyMachine = ({String id, String name, bool inSwarm, bool offline});
+/// 10-29). An [offline] one, or one [paused] in the Swarm, is listed but cannot
+/// be picked: the server refuses new work there (backend machines.ts).
+typedef BuddyMachine = ({
+ String id,
+ String name,
+ bool inSwarm,
+ bool offline,
+ bool paused,
+});
/// The menu's group of the reader's own machines. The picker has only its
/// headings, machine names and 'offline': no notes (Dee, 10-29).
@@ -23,6 +30,14 @@ const kBuddyOwnMachines = 'Your machines';
/// Why a row cannot be picked, as the sidebar says a Buddy is 'not started'.
const kBuddyMachineOffline = 'offline';
+const kBuddyMachinePaused = 'paused';
+
+/// Why [m] cannot be picked in words, or null when it can.
+String? buddyMachineBlock(BuddyMachine m) => m.offline
+ ? kBuddyMachineOffline
+ : m.paused
+ ? kBuddyMachinePaused
+ : null;
/// The reader's own machines a Buddy may run on, like a Lead, whatever its
/// engine (Ken, 10-28): those signed in to their account, in the Swarm or not,
@@ -46,6 +61,7 @@ List<BuddyMachine> buddyMachines(SuperTabController c, {AppNotifier? app}) {
// Not in the account's list (yet): only a fresh Swarm reading says it
// is there, else it is offline until one does (review of #2240).
offline: app?.stateOf(id)?.isOffline ?? _silent(m),
+ paused: m['paused'] == true,
);
}
String? here;
@@ -65,25 +81,28 @@ List<BuddyMachine> buddyMachines(SuperTabController c, {AppNotifier? app}) {
name: name,
inSwarm: listed != null,
offline: s.isOffline,
+ paused: listed?.paused ?? false,
);
}
final all = byId.values.toList();
- int rank(BuddyMachine m) => m.id == here ? 0 : (m.offline ? 2 : 1);
+ int rank(BuddyMachine m) =>
+ m.id == here ? 0 : (buddyMachineBlock(m) == null ? 1 : 2);
// A stable sort: within a rank, the Swarm's order, then the account's.
return [
for (final r in [0, 1, 2]) ...all.where((m) => rank(m) == r),
];
}
-/// The machine of [machines] that [chosen] names while it is online, else the
-/// first online one; null when none is.
-BuddyMachine? pickedBuddyMachine(List<BuddyMachine> machines, String? chosen) =>
- machines.where((m) => m.id == chosen && !m.offline).firstOrNull ??
- machines.where((m) => !m.offline).firstOrNull;
+/// The machine of [machines] that [chosen] names while it can be picked, else
+/// the first that can; null when none can.
+BuddyMachine? pickedBuddyMachine(List<BuddyMachine> machines, String? chosen) {
+ final open = machines.where((m) => buddyMachineBlock(m) == null);
+ return open.where((m) => m.id == chosen).firstOrNull ?? open.firstOrNull;
+}
/// The Machine field of the Buddy pickers: the reader's machines under a
-/// heading that says who can read the chat, offline ones listed with why
-/// they cannot be picked. Built as the Add machine form's picker is, since a
+/// heading that says who can read the chat, offline and paused ones listed
+/// with why they cannot be picked. Built as the Add machine form's picker is, since a
/// shared select field has no unavailable row. With [fitNames] it is as wide
/// as its longest name rather than the row.
class BuddyMachineField extends StatefulWidget {
@@ -141,41 +160,41 @@ class _BuddyMachineFieldState extends State<BuddyMachineField> {
),
);
- Widget _row(BuddyMachine m, double width, String? focusId) => Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: grid.AppDesktop.menuInset,
- vertical: grid.AppDesktop.listRowGap / 2,
- ),
- child: SizedBox(
- width: width - 2 * grid.AppDesktop.menuInset,
- child: MenuItemButton(
- key: ValueKey('super-buddy-machine-option-${m.id}'),
- autofocus: m.id == focusId,
- overflowAxis: Axis.vertical,
- semanticsLabel: [
- m.name,
- if (m.offline) kBuddyMachineOffline,
- ].join(', '),
- style: ButtonStyle(
- side: const WidgetStatePropertyAll(BorderSide.none),
- padding: WidgetStatePropertyAll(AppMenuRowMetrics.roomy.padding),
+ Widget _row(BuddyMachine m, double width, String? focusId) {
+ final block = buddyMachineBlock(m);
+ return Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.menuInset,
+ vertical: grid.AppDesktop.listRowGap / 2,
+ ),
+ child: SizedBox(
+ width: width - 2 * grid.AppDesktop.menuInset,
+ child: MenuItemButton(
+ key: ValueKey('super-buddy-machine-option-${m.id}'),
+ autofocus: m.id == focusId,
+ overflowAxis: Axis.vertical,
+ semanticsLabel: [m.name, ?block].join(', '),
+ style: ButtonStyle(
+ side: const WidgetStatePropertyAll(BorderSide.none),
+ padding: WidgetStatePropertyAll(AppMenuRowMetrics.roomy.padding),
+ ),
+ onPressed: widget.busy || block != null
+ ? null
+ : () => widget.onChanged(m.id),
+ // In words, never by its grey alone (design system, Color and state).
+ trailingIcon: block != null
+ ? Text(
+ block,
+ style: DesktopChrome.metadata(color: DesktopChrome.muted),
+ )
+ : m.id == widget.value
+ ? const Icon(AppIcons.check, size: grid.AppControl.iconSize)
+ : null,
+ child: Text(m.name, maxLines: 1, overflow: TextOverflow.ellipsis),
),
- onPressed: widget.busy || m.offline
- ? null
- : () => widget.onChanged(m.id),
- // In words, never by its grey alone (design system, Color and state).
- trailingIcon: m.offline
- ? Text(
- kBuddyMachineOffline,
- style: DesktopChrome.metadata(color: DesktopChrome.muted),
- )
- : m.id == widget.value
- ? const Icon(AppIcons.check, size: grid.AppControl.iconSize)
- : null,
- child: Text(m.name, maxLines: 1, overflow: TextOverflow.ellipsis),
),
- ),
- );
+ );
+ }
@override
Widget build(BuildContext context) {
@@ -184,7 +203,11 @@ class _BuddyMachineFieldState extends State<BuddyMachineField> {
.where((m) => m.id == widget.value)
.firstOrNull;
final focusId =
- current?.id ?? widget.machines.where((m) => !m.offline).firstOrNull?.id;
+ current?.id ??
+ widget.machines
+ .where((m) => buddyMachineBlock(m) == null)
+ .firstOrNull
+ ?.id;
final label = current?.name ?? 'Choose a machine';
final style = DesktopChrome.control();
final fitted = widget.fitNames
@@ -340,22 +363,31 @@ class BuddyMachineAdder {
}
/// What the Buddy pickers say when none of the reader's machines can take a
-/// Buddy now: none is signed in to their account, or all are offline.
+/// Buddy now: none is signed in to their account, all are offline, or new work
+/// is paused on those that are not.
const kBuddyNoMachine =
'Your Buddy runs on one of your own computers. Open Harness on one, '
'signed in to your account.';
const kBuddyAllOffline =
'Your machines are offline. Open Harness on one of them to start your '
'Buddy there.';
+const kBuddyAllPaused =
+ 'New work is paused on your machines. Choose Resume new work in Machines '
+ 'to start your Buddy.';
-/// [kBuddyNoMachine] or, with machines listed, [kBuddyAllOffline].
+/// [kBuddyNoMachine], or with machines listed [kBuddyAllPaused] when resuming
+/// one would be enough, else [kBuddyAllOffline].
class BuddyNoMachine extends StatelessWidget {
const BuddyNoMachine({super.key, required this.machines});
final List<BuddyMachine> machines;
@override
Widget build(BuildContext context) => Text(
- machines.isEmpty ? kBuddyNoMachine : kBuddyAllOffline,
+ machines.isEmpty
+ ? kBuddyNoMachine
+ : machines.any((m) => m.paused && !m.offline)
+ ? kBuddyAllPaused
+ : kBuddyAllOffline,
key: const ValueKey('super-buddy-no-machine'),
style: DesktopChrome.metadata(),
);
diff --git a/desktop/test/super_tab_buddy_own_machines_test.dart b/desktop/test/super_tab_buddy_own_machines_test.dart
index bab79587f..77377ceb3 100644
--- a/desktop/test/super_tab_buddy_own_machines_test.dart
+++ b/desktop/test/super_tab_buddy_own_machines_test.dart
@@ -269,6 +269,50 @@ void main() {
await close(tester, f, c);
});
+ // The server refuses it with MACHINE_PAUSED, so the picker says so first.
+ testWidgets('a paused machine says so and cannot be picked', (
+ tester,
+ ) async {
+ final (:f, :c, :mac) = await open(
+ tester,
+ machines: [
+ {...rig(), 'paused': true},
+ ],
+ );
+
+ await tester.tap(barMachine);
+ await tester.pumpAndSettle();
+ expect(tester.widget<MenuItemButton>(option('rig')).onPressed, isNull);
+ expect(
+ find.descendant(
+ of: option('rig'),
+ matching: find.text(kBuddyMachinePaused),
+ ),
+ findsOneWidget,
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ expect(
+ find.descendant(of: barMachine, matching: find.text(mac)),
+ findsOneWidget,
+ );
+ await close(tester, f, c);
+ });
+
+ testWidgets('with every machine paused, says how to resume and cannot '
+ 'start', (tester) async {
+ final (:f, :c, :mac) = await open(
+ tester,
+ machines: [
+ {...rig(), 'machineId': 'm', 'paused': true},
+ ],
+ );
+
+ expect(find.text(kBuddyAllPaused), findsOneWidget);
+ expect(tester.widget<FilledButton>(start).onPressed, isNull);
+ await close(tester, f, c);
+ });
+
testWidgets(
'Start on this Mac prepares it and starts the Buddy with its setup, '
'adding nothing to the Swarm',