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
Merge batch 11-07 kC: #3489 #3495 #3491 #3494 #3483 #3504 (#3513)
0xken15401d8991f721
diff --git a/backend/integration/superTabTeam.test.ts b/backend/integration/superTabTeam.test.tsindex e4cfa8d82..c322afe8f 100644--- a/backend/integration/superTabTeam.test.ts+++ b/backend/integration/superTabTeam.test.ts@@ -1348,7 +1348,7 @@ describe('a machine its owner keeps for some projects', () => {// Task #2806 (Scholes, 11-04): a machine's owner lets teammates' work run in their own account there. A guard loosened by the// owner alone: never by the Harness Team account that runs on the same Mac as them, nor by anyone else.describe('teammates\' work in a machine owner\'s own account', () => {- it('is chosen by its owner alone, never by its Team account session, kept across reads and said on the machine', async () => {+ it('is chosen by its owner alone, never by its Team account session, and said only in the route\'s note (#4289)', async () => {const f = await fixture()const choose = (allowed: boolean, user: AuthUser) => run(f.tab, { type: 'machine.ownAccountWork', machineId: 'team-mac', allowed } as Command, user)await expect(choose(true, owner)).rejects.toMatchObject({ code: 'OWNER_REQUIRED' })@@ -1356,12 +1356,13 @@ describe('teammates\' work in a machine owner\'s own account', () => {expect((await store.read(owner, f.tab)).state.machines!.find(m => m.machineId === 'team-mac')!.ownAccountChoice).toBeUndefined()await choose(true, person)const seen = (await store.read(owner, f.tab)).state.machines!.find(m => m.machineId === 'team-mac')!- expect(seen.ownAccountChoice).toMatchObject({ allowed: true, by: person.sub })+ // Swarm v3 has no choice to show: no reader gets the stored field (#4289).+ expect(seen.ownAccountChoice).toBeUndefined()// Whoever routes a teammate's task there reads it.expect((seen as unknown as { teamWork: { ownAccount?: string } }).teamWork.ownAccount).toMatch(/runs teammates' work in .+'s own account\.$/)await choose(false, person)const off = (await store.read(owner, f.tab)).state.machines!.find(m => m.machineId === 'team-mac')!- expect(off.ownAccountChoice).toMatchObject({ allowed: false, by: person.sub })+ expect(off.ownAccountChoice).toBeUndefined()expect((off as unknown as { teamWork: { ownAccount?: string } }).teamWork.ownAccount).toBeUndefined()})})diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.tsindex d949ad5d8..9a304f7e5 100644--- a/backend/src/superTabs/model.ts+++ b/backend/src/superTabs/model.ts@@ -1173,6 +1173,9 @@ export function visibleState(state: SuperTabState, actor: Actor, now = Date.now(}// Rows by day and project that only the leaderboard read uses, and it takes them from the Swarm itself.for (const pool of visible.machines ?? []) delete pool.lentDays+ // Where teammates' work ran was a Team-account choice; Swarm v3 runs every agent as its own person (#4120, #4289). It stays+ // stored for teamWorkRefusal until the Team entries go (#4290), and no reader gets it.+ for (const pool of visible.machines ?? []) delete pool.ownAccountChoice// A Mac's Harness Team account is stored under its Mac's name (machines.ts followAccountName), and read so it named two// entries alike: a lamp start picked the Team account's thinking it was the Mac (task #3060). Every read tells them apart;// the stored name, which renames and the server's own sentences read, stays the Mac's.diff --git a/backend/src/superTabs/ownAccountWork.test.ts b/backend/src/superTabs/ownAccountWork.test.tsindex a77cbab3c..6f76a13bd 100644--- a/backend/src/superTabs/ownAccountWork.test.ts+++ b/backend/src/superTabs/ownAccountWork.test.ts@@ -230,3 +230,16 @@ describe('a Mac\'s Team account entry, as every read shows it', () => {expect(f.machine('gray-team').name).toBe('Gray\'s Mac')})})++describe('the choice in a Swarm read (task #4289)', () => {+ it('reaches no reader, the machine\'s owner included: Swarm v3 has no choice of where teammates\' work runs', () => {+ const f = swarm()+ f.choose(true)+ expect(f.machine('gray-mac').ownAccountChoice).toMatchObject({ allowed: true })+ for (const actor of [gray, owner, mate, f.leadActor]) {+ const read = (visibleState(f.state, actor, NOW).machines ?? []).find(m => m.machineId === 'gray-mac')+ expect(read).toBeDefined()+ expect(read).not.toHaveProperty('ownAccountChoice')+ }+ })+})diff --git a/cli/src/backendSocket.spec.ts b/cli/src/backendSocket.spec.tsindex dea6f13c4..0a4e5086b 100644--- a/cli/src/backendSocket.spec.ts+++ b/cli/src/backendSocket.spec.ts@@ -629,6 +629,14 @@ const wsMock = vi.hoisted(() => {})vi.mock('ws', () => ({ WebSocket: wsMock.MockWebSocket }))+// A creation writes a durable receipt and flushes it to disk synchronously (lib/agentCreationReceipt.ts). On a busy+// Linux runner a flush blocked for seconds and a creation case timed out at 5 s (#4363); macOS barely waits. This spec+// checks what the socket says and counts, not durability (agentCreationReceipt.spec.ts does), so a flush returns at once.+vi.mock('node:fs', async (real) => {+ const fs = await real<typeof import('node:fs')>()+ const fsyncSync = () => {}+ return { ...fs, fsyncSync, default: { ...fs, fsyncSync } }+})// Grid's set-up, which the models service asks for before a move onto a grid model: set up already here,// as on a machine that has used grid before. Never a real install or sign-in from a spec.vi.mock('./lib/gridAttach.js', async (real) => ({diff --git a/cli/src/core/agents/launches.spec.ts b/cli/src/core/agents/launches.spec.tsindex f2a31578b..ab80c3160 100644--- a/cli/src/core/agents/launches.spec.ts+++ b/cli/src/core/agents/launches.spec.ts@@ -26,6 +26,11 @@ import { SWARM_LAUNCH } from '../../superTabs/inCore/launch.js'* they are tested with their own modules, and a test must never write the person's own engine config.*/const root = vi.hoisted(() => ({ projects: '' }))+const host = vi.hoisted(() => ({ win32: false }))+vi.mock('../../engines/kit/windowsFiles.js', async (real) => {+ const actual = await real<typeof import('../../engines/kit/windowsFiles.js')>()+ return { ...actual, hostPlatform: () => host.win32 ? 'win32' : actual.hostPlatform() }+})// The engines' folder trust (engines/launchPrep.ts), one spy per engine.const trust = vi.hoisted(() => ({claudeTrusts: vi.fn((_path: string) => false), codexTrusts: vi.fn((_path: string, _profile?: string | null) => false),@@ -273,6 +278,24 @@ describe('agent_create, refused before any pane exists', () => {expect(vi.mocked(create!).mock.calls[0][0]).toMatchObject({ claudeHome: '/homes/offered' })})+ // #4183: on Windows a profile folder is `C:\\…`; the check that wanted a leading '/' dropped every one, so the agent ran on+ // the default account and reported its quota.+ it('on Windows a drive-letter codexHome or claudeHome reaches the create input, and a POSIX one is dropped', async () => {+ host.win32 = true+ try {+ const { ask, create } = setup()+ await ask({ engine: 'codex', cwd: '/w', codexHome: 'C:\\Users\\u\\.codex-work' })+ await ask({ engine: 'claude', cwd: '/w', claudeHome: 'C:\\Users\\u\\.claude-work' })+ await ask({ engine: 'claude', cwd: '/w', claudeHome: '/Users/u/.claude-work' })+ const inputs = vi.mocked(create!).mock.calls.map(([input]) => input)+ expect(inputs[0]).toMatchObject({ codexHome: 'C:\\Users\\u\\.codex-work' })+ expect(inputs[1]).toMatchObject({ claudeHome: 'C:\\Users\\u\\.claude-work' })+ expect('claudeHome' in inputs[2]).toBe(false)+ } finally {+ host.win32 = false+ }+ })+it('claudeHome reaches the create input', async () => {const { ask, create } = setup()await ask({ engine: 'claude', cwd: '/w', claudeHome: '/homes/claude' })diff --git a/cli/src/core/agents/launches.ts b/cli/src/core/agents/launches.tsindex 9044e6b87..996e71f45 100644--- a/cli/src/core/agents/launches.ts+++ b/cli/src/core/agents/launches.ts@@ -15,6 +15,7 @@ import type { BackendSocket } from '../../backendSocket.js'import type { Asker, SwarmLaunch } from '../api.js'import { installedDsh } from '../../dsh/installed.js'import { DSH_ID_RE, dshSupportedEngines } from '../../dsh/manifest.js'+import { homeIsAbsolute } from '../../engines/kit/homeAdoption.js'import { folderTrust } from '../../engines/launchPrep.js'import type { NativeLaunchResult, NativeLaunchSource } from '../../engines/nativeLaunch.js'import * as opencodeLaunch from '../../engines/launchControl.js'@@ -388,11 +389,11 @@ export function createLaunchRequests({ receipts, createAgent, prepareCreate, preconst missing = await unsupportedLaunchModelFlag(engine, launchModel.launchModel)if (missing) { reply({ error: 'LAUNCH_MODEL_UNSUPPORTED', detail: `The ${engine} on this machine does not support ${missing}; update ${engine} to launch it with a model.` }); return }}- // Same validation the desktop app already applies client-side (`Agent._safeCodexHome`) —- // repeated here because a client's own check is not a guarantee about what actually- // arrives on the wire.+ // Checked here whatever the client checked (`Agent._safeCodexHome` in the desktop app), because a client's own check is+ // not a guarantee about what arrives on the wire. Absolute as this platform spells it: on Windows a drive-letter path,+ // which a leading-'/' check refused, so a linked profile's agent ran on the default account (#4183).const rawCodexHome = typeof payload.codexHome === 'string' ? payload.codexHome : null- const codexHome = rawCodexHome && rawCodexHome.startsWith('/') && rawCodexHome.length <= 4096+ const codexHome = rawCodexHome && homeIsAbsolute(rawCodexHome) && rawCodexHome.length <= 4096&& !/[\x00-\x1f\x7f]/.test(rawCodexHome)? rawCodexHome: null@@ -402,7 +403,7 @@ export function createLaunchRequests({ receipts, createAgent, prepareCreate, pre}// Claude profiles (CLAUDE_CONFIG_DIR) follow the same rule: Claude only, without a grid.const rawClaudeHome = typeof payload.claudeHome === 'string' ? payload.claudeHome : null- const claudeHome = rawClaudeHome && rawClaudeHome.startsWith('/') && rawClaudeHome.length <= 4096+ const claudeHome = rawClaudeHome && homeIsAbsolute(rawClaudeHome) && rawClaudeHome.length <= 4096&& !/[\x00-\x1f\x7f]/.test(rawClaudeHome)? rawClaudeHome: nulldiff --git a/cli/src/dsh/shell.spec.ts b/cli/src/dsh/shell.spec.tsindex ffe58810f..5cce04790 100644--- a/cli/src/dsh/shell.spec.ts+++ b/cli/src/dsh/shell.spec.ts@@ -297,7 +297,9 @@ describe('spawnDshCommand and killProcessGroup', () => {const exited = (child: ChildProcess): Promise<[number | null, NodeJS.Signals | null]> =>new Promise((resolve) => child.once('exit', (code, signal) => resolve([code, signal])))- it('SIGTERMs the whole group, and SIGKILLs what ignores it once the grace is over', async () => {+ // Process groups are POSIX: on Windows the command is spawned without `detached` (ownProcessGroup, docs/windows-rules.md), and+ // its tree is ended at once with no SIGTERM and no grace, which 'on Windows, ends the whole tree…' above covers (#4184).+ it.skipIf(process.platform === 'win32')('SIGTERMs the whole group, and SIGKILLs what ignores it once the grace is over', async () => {const polite = spawnDshCommand('sleep 30', { cwd: dir })await new Promise((resolve) => setTimeout(resolve, 100))const politeExit = exited(polite)diff --git a/cli/src/engines/claude/statusLine.spec.ts b/cli/src/engines/claude/statusLine.spec.tsindex a9aaa9d74..3f48404ba 100644--- a/cli/src/engines/claude/statusLine.spec.ts+++ b/cli/src/engines/claude/statusLine.spec.ts@@ -21,6 +21,8 @@ import { launch as claudeLaunch } from './launch.js'const SCRIPT = fileURLToPath(new URL('../../../hook/statusline.mjs', import.meta.url))const posix = process.platform !== 'win32'+/** How the person's `echo owner-line` ends, run with `shell: true`: cmd.exe on Windows ends a line with CRLF (#4184). */+const OWNER_LINE = posix ? 'owner-line\n' : 'owner-line\r\n'const b64 = (text: string) => Buffer.from(text, 'utf8').toString('base64url')/** What Claude Code 2.1.316 hands its status line command, with the fields the report must never copy. */@@ -60,7 +62,7 @@ function run(args: string[], input: unknown, extraEnv: NodeJS.ProcessEnv = {}) {describe('hook/statusline.mjs', () => {it('records only the five-hour and seven-day windows, then prints the owner\'s own status line', () => {const out = run(['--data', data, '--then', b64('echo owner-line')], STATUS)- expect(out.stdout).toBe('owner-line\n')+ expect(out.stdout).toBe(OWNER_LINE)expect(out.status).toBe(0)const file = reportPath(data, configDir)const text = readFileSync(file, 'utf8')@@ -111,7 +113,7 @@ describe('hook/statusline.mjs', () => {it('writes nothing without rate limits (an API key\'s session), and still prints the owner\'s line', () => {const out = run(['--data', data, '--then', b64('echo owner-line')], { ...STATUS, rate_limits_available: false, rate_limits: null })- expect(out.stdout).toBe('owner-line\n')+ expect(out.stdout).toBe(OWNER_LINE)expect(out.status).toBe(0)expect(existsSync(join(data, 'quota'))).toBe(false)})@@ -119,9 +121,9 @@ describe('hook/statusline.mjs', () => {it('prints the owner\'s line when the report cannot be written, or the input is not JSON', () => {const blocked = join(root, 'a-file')writeFileSync(blocked, 'not a folder')- expect(run(['--data', blocked, '--then', b64('echo owner-line')], STATUS).stdout).toBe('owner-line\n')- expect(run(['--data', data, '--then', b64('echo owner-line')], '{not json').stdout).toBe('owner-line\n')- expect(run(['--then', b64('echo owner-line')], STATUS).stdout).toBe('owner-line\n')+ expect(run(['--data', blocked, '--then', b64('echo owner-line')], STATUS).stdout).toBe(OWNER_LINE)+ expect(run(['--data', data, '--then', b64('echo owner-line')], '{not json').stdout).toBe(OWNER_LINE)+ expect(run(['--then', b64('echo owner-line')], STATUS).stdout).toBe(OWNER_LINE)})it.skipIf(!posix)('hands the owner\'s command the same input, and exits as it does', () => {diff --git a/cli/src/lib/agentTmp.spec.ts b/cli/src/lib/agentTmp.spec.tsindex 982d93a97..1d060c608 100644--- a/cli/src/lib/agentTmp.spec.ts+++ b/cli/src/lib/agentTmp.spec.ts@@ -1,4 +1,5 @@-import { chmodSync, existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync } from 'node:fs'+import { execFileSync } from 'node:child_process'+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'import { join } from 'node:path'import { afterEach, describe, expect, it, vi } from 'vitest'@@ -290,3 +291,44 @@ describe('a Buddy\'s private temporary folder', () => {await vi.waitFor(() => expect(existsSync(join(folder, 'stale'))).toBe(false))})})++describe('a script written to the folder runs as it would in the system\'s', () => {+ // The data folder is under ~/.harness/cli, whose package.json says "type": "module". An extensionless script a spec wrote+ // to TMPDIR (the fake grid) loaded as an ES module and died on require, so specs failed for agents and passed in CI (#4356).+ const DAY = 24 * 60 * 60_000+ const inModulePackage = () => { const root = scratch(); writeFileSync(join(root, 'package.json'), '{"type":"module"}'); return join(root, 'data') }+ const runs = (folder: string) => {+ const script = join(folder, 'fake-grid')+ writeFileSync(script, "#!/usr/bin/env node\nconst { join } = require('node:path')\nprocess.stdout.write(join('a', 'b'))\n")+ return execFileSync(process.execPath, [script], { encoding: 'utf8' })+ }++ it('an extensionless require() script in an agent\'s folder runs', () => {+ expect(runs(agentTmpEnv('claude', undefined, deps(inModulePackage())).TMPDIR!)).toBe(join('a', 'b'))+ })++ it('in a Buddy\'s folder too', () => {+ expect(runs(buddyTmpOf('/work/one', deps(inModulePackage()))!)).toBe(join('a', 'b'))+ })++ it('keeps a package.json already there', () => {+ const data = inModulePackage(), folder = agentTmpFolder(data)+ mkdirSync(folder, { recursive: true, mode: 0o700 })+ writeFileSync(join(folder, 'package.json'), '{"type":"commonjs","name":"kept"}')+ agentTmpEnv('claude', undefined, deps(data))+ expect(readFileSync(join(folder, 'package.json'), 'utf8')).toContain('kept')+ })++ it('no sweep deletes the folders\' own package.json however old; a tool\'s goes like any file', async () => {+ const data = inModulePackage(), folder = agentTmpFolder(data), parent = buddyTmpParent(data)+ agentTmpEnv('claude', undefined, deps(data))+ const buddy = buddyTmpOf('/work/one', deps(data))!+ writeFileSync(join(buddy, 'package.json'), '{"type":"module"}')+ const later = Date.now() + 8 * DAY+ expect(await sweepAgentTmp(folder, later)).toBe(0)+ expect(await sweepBuddyTmp(parent, later)).toBe(1)+ expect(existsSync(join(folder, 'package.json'))).toBe(true)+ expect(existsSync(join(parent, 'package.json'))).toBe(true)+ expect(existsSync(join(buddy, 'package.json'))).toBe(false)+ })+})diff --git a/cli/src/lib/agentTmp.ts b/cli/src/lib/agentTmp.tsindex 84bb8ba14..02bee2768 100644--- a/cli/src/lib/agentTmp.ts+++ b/cli/src/lib/agentTmp.ts@@ -12,7 +12,7 @@* person's private work and must not reach another person's Buddy (buddyTmpOf; docs/plans/2026-11-02-buddy-private-temp-plan.md).*/import { createHash } from 'node:crypto'-import { chmodSync, lstatSync, mkdirSync, realpathSync } from 'node:fs'+import { chmodSync, lstatSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs'import { lstat, readdir, rm, rmdir } from 'node:fs/promises'import { userInfo } from 'node:os'import { basename, dirname, join } from 'node:path'@@ -25,6 +25,10 @@ const KEEP_MS = 7 * 24 * 60 * 60_000const SWEEP_EVERY_MS = 24 * 60 * 60_000/** A Buddy's empty folder is kept this long: it is a live Buddy's TMPDIR while the Buddy runs, however quiet. */const KEEP_EMPTY_BUDDY_MS = 30 * 24 * 60 * 60_000+/** These folders are under ~/.harness/cli, whose package.json says "type": "module": without one of their own, an extensionless+ * script written here (a spec's fake grid) loaded as an ES module and died on require, as it never does in the system's (#4356). */+const PACKAGE = 'package.json'+const COMMONJS = '{"type":"commonjs"}\n'export interface AgentTmpDeps {platform: NodeJS.Platform@@ -83,6 +87,21 @@ export function prepareAgentTmp(folder: string, uid: number | undefined = proces} catch { return false }}+/** Gives [folder] its own CommonJS package.json, keeping one already there. Exclusive create: a link in its place is not followed. */+function markCommonJs(folder: string, deps: AgentTmpDeps): void {+ try { writeFileSync(join(folder, PACKAGE), COMMONJS, { flag: 'wx', mode: 0o600 }) } catch (error) {+ if ((error as NodeJS.ErrnoException).code !== 'EEXIST') {+ deps.log(`could not write ${join(folder, PACKAGE)} (${(error as NodeJS.ErrnoException).code}); scripts there load as ES modules`)+ }+ }+}++/** The package.json markCommonJs wrote, which no sweep deletes however old. Another, a tool's, is swept like any file. */+function isMarker(folder: string, name: string): boolean {+ if (name !== PACKAGE) return false+ try { return readFileSync(join(folder, name), 'utf8') === COMMONJS } catch { return false }+}+/** Whether anything at [path] changed since [cutoff]. Stops at the first that did. What cannot be read counts as changed. The* newer of the two times: `tar`, `cp -p` and `rsync -t` keep an old mtime, so a tool unpacked a minute ago looked 7 days idle* by mtime alone (review of #2546). */@@ -109,7 +128,7 @@ export async function sweepAgentTmp(folder: string, now: number): Promise<numberlet removed = 0for (const name of names) {const path = join(folder, name)- if (await changedSince(path, now - KEEP_MS)) continue+ if (isMarker(folder, name) || await changedSince(path, now - KEEP_MS)) continuetry { await rm(path, { recursive: true, force: true }); removed++ } catch { /* the next sweep tries again */ }}return removed@@ -129,7 +148,7 @@ export async function sweepBuddyTmp(parent: string, now: number): Promise<numberconst path = join(parent, name)try {if (!(await lstat(path)).isDirectory()) {- if (!(await changedSince(path, now - KEEP_MS))) { await rm(path, { force: true }); removed++ }+ if (!isMarker(parent, name) && !(await changedSince(path, now - KEEP_MS))) { await rm(path, { force: true }); removed++ }continue}removed += await sweepAgentTmp(path, now)@@ -166,6 +185,7 @@ export function agentTmpEnv(engine: AgentEngine, role: string | undefined, deps:deps.log(`the private temporary folder ${folder} could not be made private; this agent uses the system's`)return {}}+ markCommonJs(folder, deps)return { TMPDIR: folder }}@@ -181,7 +201,13 @@ export function buddyTmpOf(root: string, deps: AgentTmpDeps = realDeps): stringconst folder = buddyTmpFolder(root, deps.dataDir)// The parent first: making the folder through a link in the parent's place would make it where that link points.// By its real path, as the guard compares real paths: a data folder reached through a link would refuse its own reads.- try { if (prepareAgentTmp(buddyTmpParent(deps.dataDir)) && prepareAgentTmp(folder)) return realpathSync(folder) } catch { /* said below */ }+ // The marker in the parent covers every Buddy's folder, which stays free to empty out and go.+ try {+ if (prepareAgentTmp(buddyTmpParent(deps.dataDir)) && prepareAgentTmp(folder)) {+ markCommonJs(buddyTmpParent(deps.dataDir), deps)+ return realpathSync(folder)+ }+ } catch { /* said below */ }deps.log(`the private temporary folder ${folder} could not be made private; this Buddy uses the system's`)return null}diff --git a/cli/src/lib/claudeProfiles.test.ts b/cli/src/lib/claudeProfiles.test.tsindex 8a7114038..a3007d22b 100644--- a/cli/src/lib/claudeProfiles.test.ts+++ b/cli/src/lib/claudeProfiles.test.ts@@ -7,6 +7,11 @@ import type * as ClaudeProfilesModule from './claudeProfiles.js'let dataDir = ''let home = ''const machineId = 'machine-1'+const host = vi.hoisted(() => ({ win32: false }))+vi.mock('../engines/kit/windowsFiles.js', async original => {+ const actual = await original<typeof import('../engines/kit/windowsFiles.js')>()+ return { ...actual, hostPlatform: () => host.win32 ? 'win32' : actual.hostPlatform() }+})async function loadModule(): Promise<typeof ClaudeProfilesModule> {vi.resetModules()@@ -170,6 +175,19 @@ describe('claudeProfiles', () => {expect(linkClaudeProfile(join(home, 'file'), machineId)).toEqual({ error: 'NOT_FOUND' })})+ // #4183: on Windows a profile folder is `C:\\…`, and the check that wanted a leading '/' refused every one.+ it('on Windows takes a drive-letter folder and refuses a POSIX one', async () => {+ host.win32 = true+ try {+ const { linkClaudeProfile, offerAccount } = await loadModule()+ expect(linkClaudeProfile('Z:\\no\\such\\.claude-work', machineId)).toEqual({ error: 'NOT_FOUND' })+ expect(linkClaudeProfile('/Users/u/.claude-work', machineId)).toEqual({ error: 'INVALID_PATH' })+ expect(offerAccount('claude', 'Z:\\no\\such\\.claude-work', true, { home, environment: {} })).toEqual({ error: 'NOT_FOUND' })+ } finally {+ host.win32 = false+ }+ })+it('profileId is stable, 16 hex and depends on machine, engine and path', async () => {const { profileId } = await loadModule()const id = profileId('m', 'claude', '/a')diff --git a/cli/src/lib/claudeProfiles.ts b/cli/src/lib/claudeProfiles.tsindex 7ed4ae190..6bd430592 100644--- a/cli/src/lib/claudeProfiles.ts+++ b/cli/src/lib/claudeProfiles.ts@@ -16,6 +16,7 @@ import { closeSync, constants, fchmodSync, fsyncSync, openSync, readdirSync, reaimport { homedir } from 'os'import { basename, join, resolve, sep } from 'path'import { env } from '../config/env.js'+import { homeIsAbsolute } from '../engines/kit/homeAdoption.js'import { offeredFolders, recordOffer } from './accountOffers.js'import { defaultCodexHome, listCodexProfiles, resolveCodexProfilePath } from './codexProfiles.js'import { hardenPrivateStateFileIfPresent, readPrivateStateFile, secureStateDirectory } from './secureState.js'@@ -104,7 +105,7 @@ function writeLinkedPaths(paths: Set<string>): void {/** Validate + resolve a folder path the same way for linking and for re-checking a saved one. */function resolveFolder(path: string): string | ClaudeProfileError {- if (!path.startsWith('/') || path.length > 4096 || CONTROL_CHARS_RE.test(path)) return { error: 'INVALID_PATH' }+ if (!homeIsAbsolute(path) || path.length > 4096 || CONTROL_CHARS_RE.test(path)) return { error: 'INVALID_PATH' }try {if (!statSync(path).isDirectory()) return { error: 'NOT_FOUND' }const resolved = realpathSync(path)@@ -191,7 +192,7 @@ export function offerAccount(engine: string, path: string, offered: boolean, options: { home?: string; environment?: Record<string, string | undefined> } = {},): { offered: boolean } | { error: 'INVALID_ENGINE' | 'INVALID_PATH' | 'NOT_FOUND' | 'DEFAULT_ACCOUNT' | 'TOO_MANY' } {if (engine !== 'claude' && engine !== 'codex') return { error: 'INVALID_ENGINE' }- if (!path.startsWith('/') || path.length > 4096 || CONTROL_CHARS_RE.test(path)) return { error: 'INVALID_PATH' }+ if (!homeIsAbsolute(path) || path.length > 4096 || CONTROL_CHARS_RE.test(path)) return { error: 'INVALID_PATH' }const home = options.home ?? homedir()const found = engine === 'claude' ? resolveFolder(path) : (() => { const r = resolveCodexProfilePath(path); return 'error' in r ? r : r.path })()if (typeof found !== 'string') {diff --git a/cli/src/lib/codexProfileDiscovery.test.ts b/cli/src/lib/codexProfileDiscovery.test.tsindex 0c547635f..009d3b1c8 100644--- a/cli/src/lib/codexProfileDiscovery.test.ts+++ b/cli/src/lib/codexProfileDiscovery.test.ts@@ -1,9 +1,15 @@-import { describe, expect, it, afterEach } from 'vitest'+import { describe, expect, it, afterEach, vi } from 'vitest'import { mkdtempSync, mkdirSync, writeFileSync, chmodSync, rmSync, statSync } from 'fs'import { tmpdir } from 'os'import { join } from 'path'import { discoverCodexProfiles } from './codexProfileDiscovery.js'+const host = vi.hoisted(() => ({ win32: false }))+vi.mock('../engines/kit/windowsFiles.js', async original => {+ const actual = await original<typeof import('../engines/kit/windowsFiles.js')>()+ return { ...actual, hostPlatform: () => host.win32 ? 'win32' : actual.hostPlatform() }+})+const dirs: string[] = []function tempHome(): string {@@ -75,6 +81,17 @@ describe('discoverCodexProfiles — CODEX_HOME', () => {expect(found).toContain('/opt/codex-ci')})+ // #4183: on Windows CODEX_HOME is `C:\\…`; the check that wanted a leading '/' dropped it.+ it('honors a drive-letter CODEX_HOME on Windows', () => {+ const home = tempHome()+ host.win32 = true+ try {+ expect(discoverCodexProfiles({ home, environment: { CODEX_HOME: 'C:\\Users\\u\\.codex-work' } })).toContain('C:\\Users\\u\\.codex-work')+ } finally {+ host.win32 = false+ }+ })+it('ignores a relative CODEX_HOME', () => {const home = tempHome()const found = discoverCodexProfiles({ home, environment: { CODEX_HOME: 'relative/codex' } })diff --git a/cli/src/lib/codexProfileDiscovery.ts b/cli/src/lib/codexProfileDiscovery.tsindex 6708eed1b..b3ad3c1e9 100644--- a/cli/src/lib/codexProfileDiscovery.ts+++ b/cli/src/lib/codexProfileDiscovery.ts@@ -10,6 +10,7 @@import { existsSync, openSync, closeSync, readSync, readdirSync, realpathSync, statSync } from 'fs'import { join } from 'path'+import { homeIsAbsolute } from '../engines/kit/homeAdoption.js'const MAX_FILE_BYTES = 64 * 1024const MAX_FILES = 256@@ -67,7 +68,7 @@ class CodexProfileDiscovery {if (value.startsWith('/') || key === 'PATH') variables[key] = value}const inherited = this.environment.CODEX_HOME- if (inherited && inherited.startsWith('/')) this.paths.add(inherited)+ if (inherited && homeIsAbsolute(inherited)) this.paths.add(inherited)const config = this.environment.XDG_CONFIG_HOME || join(this.home, '.config')this.conventionalHomes(this.home)this.conventionalHomes(config)diff --git a/cli/src/lib/codexProfiles.test.ts b/cli/src/lib/codexProfiles.test.tsindex 0116c123e..2e9abe3d3 100644--- a/cli/src/lib/codexProfiles.test.ts+++ b/cli/src/lib/codexProfiles.test.ts@@ -4,6 +4,12 @@ import { tmpdir } from 'os'import { join } from 'path'import type * as CodexProfilesModule from './codexProfiles.js'+const host = vi.hoisted(() => ({ win32: false }))+vi.mock('../engines/kit/windowsFiles.js', async original => {+ const actual = await original<typeof import('../engines/kit/windowsFiles.js')>()+ return { ...actual, hostPlatform: () => host.win32 ? 'win32' : actual.hostPlatform() }+})+let dataDir = ''let home = ''@@ -36,6 +42,18 @@ describe('codexProfiles', () => {expect(resolveCodexProfilePath('relative/codex')).toEqual({ error: 'INVALID_PATH' })})+ // #4183: on Windows a CODEX_HOME is `C:\\…`, and the check that wanted a leading '/' refused every one.+ it('resolveCodexProfilePath on Windows takes a drive-letter folder and refuses a POSIX one', async () => {+ host.win32 = true+ try {+ const { resolveCodexProfilePath } = await loadModule()+ expect(resolveCodexProfilePath('Z:\\no\\such\\.codex-work')).toEqual({ error: 'NOT_FOUND' })+ expect(resolveCodexProfilePath('/Users/u/.codex-work')).toEqual({ error: 'INVALID_PATH' })+ } finally {+ host.win32 = false+ }+ })+it('resolveCodexProfilePath rejects a path with control characters', async () => {const { resolveCodexProfilePath } = await loadModule()expect(resolveCodexProfilePath('/tmp/codex\nhome')).toEqual({ error: 'INVALID_PATH' })diff --git a/cli/src/lib/codexProfiles.ts b/cli/src/lib/codexProfiles.tsindex 73bf915db..4c48aae0c 100644--- a/cli/src/lib/codexProfiles.ts+++ b/cli/src/lib/codexProfiles.ts@@ -14,6 +14,7 @@ import { randomUUID } from 'crypto'import { homedir } from 'os'import { join } from 'path'import { env } from '../config/env.js'+import { homeIsAbsolute } from '../engines/kit/homeAdoption.js'import { discoverCodexProfiles } from './codexProfileDiscovery.js'import { offeredFolders } from './accountOffers.js'import { hardenPrivateStateFileIfPresent, readPrivateStateFile, secureStateDirectory } from './secureState.js'@@ -75,7 +76,7 @@ function writeLinkedPaths(paths: Set<string>): void {/** Validate + resolve a folder path the same way for both linking and re-checking a saved one. */export function resolveCodexProfilePath(path: string): CodexProfile | CodexProfileError {- if (!path.startsWith('/') || path.length > 4096 || CONTROL_CHARS_RE.test(path)) {+ if (!homeIsAbsolute(path) || path.length > 4096 || CONTROL_CHARS_RE.test(path)) {return { error: 'INVALID_PATH' }}let stdiff --git a/cli/src/lib/gridActs.spec.ts b/cli/src/lib/gridActs.spec.tsindex 8578500d8..fd17fdba9 100644--- a/cli/src/lib/gridActs.spec.ts+++ b/cli/src/lib/gridActs.spec.ts@@ -521,6 +521,19 @@ describe('a credentialed read\'s answer', () => {await vi.waitFor(async () => expect(await service.contextWindow(TEAM_REF, 'big-model')).toBe(131072))expect(await service.contextWindow(TEAM_REF, 'odd')).toBeUndefined()})++ // A prewarm's read outlived settled() and the afterEach that awaits it: its fake `grid` was still writing+ // into the fixture's folder when dispose() removed it (ENOTEMPTY, cli-tests shard 2 on PR #3334).+ it('has landed once settled() resolves, so none outlives the test that fired it', async () => {+ answer(TEAM_ID, OVERVIEW, asleep(record(60, [{ name: 'rig', models: ['big-model'] }])))+ await look()+ answer(TEAM_ID, MODELS, { status: 200, body: { data: [{ id: 'big-model', context_window: 32_768 }] } })++ expect(await service.retargetPrewarm(TEAM_REF, 'big-model')).toBe('fired')+ await service.settled()++ expect(await service.contextWindow(TEAM_REF, 'big-model')).toBe(32_768)+ })})describe('what goes stale with no read to say so', () => {diff --git a/cli/src/lib/gridModels.ts b/cli/src/lib/gridModels.tsindex 6531b37fd..9611e5423 100644--- a/cli/src/lib/gridModels.ts+++ b/cli/src/lib/gridModels.ts@@ -212,6 +212,8 @@ export class GridModelsService {private readonly listeners = new Set<() => void>()private readonly presence = new ComputerPresence()private readonly debounce = new PrewarmDebounce()+ /** Prewarm reads still running: nothing waits on them but settled(). */+ private readonly prewarms = new Set<Promise<void>>()private rows: GridRow[] | null = nullprivate changeTimer: NodeJS.Timeout | null = null/** Called off by the next machine list: fires only when none came in time, and the labels lapse. */@@ -230,7 +232,10 @@ export class GridModelsService {/** Resolves once every read already started has landed — for a test, and for a caller that must see* the answer a read it triggered produced. */async settled(): Promise<void> {- await Promise.all([...this.tracked.values()].flatMap((tracked) => [tracked.pending?.catch(() => {}), tracked.waking]))+ await Promise.all([+ ...[...this.tracked.values()].flatMap((tracked) => [tracked.pending?.catch(() => {}), tracked.waking]),+ ...[...this.prewarms].map((read) => read.catch(() => {})),+ ])}/**@@ -574,7 +579,8 @@ export class GridModelsService {private sendPrewarm(tracked: Tracked, purpose: WakePurpose, now: number, access?: RelayAccess): PrewarmOutcome {if (!this.debounce.allows(tracked.id, now)) return 'debounced'this.debounce.mark(tracked.id, now)- void this.credentialedRead(tracked, purpose, access)+ const read = this.credentialedRead(tracked, purpose, access).finally(() => { this.prewarms.delete(read) })+ this.prewarms.add(read)return 'fired'}diff --git a/desktop/lib/core/models.dart b/desktop/lib/core/models.dartindex d06490e96..bbcbc5b9e 100644--- a/desktop/lib/core/models.dart+++ b/desktop/lib/core/models.dart@@ -825,7 +825,10 @@ class Agent {namedAgent: _safeNamedAgent(j['namedAgent']),cloud: j['location'] == 'cloud' ? AgentCloud.fromJson(j['cloud']) : null,launchArgs: j['launchArgs'] is List- ? [for (final w in j['launchArgs'] as List) if (w is String) w]+ ? [+ for (final w in j['launchArgs'] as List)+ if (w is String) w,+ ]: const [],);}@@ -940,9 +943,10 @@ class Agent {return RegExp(r'^[a-zA-Z0-9._-]+$').hasMatch(raw) ? raw : null;}+ // A profile folder as the agent's own machine spells it, which may not be this one's: `/…`, or `C:\…` on Windows (#4183).static String? _safeCodexHome(Object? raw) {if (raw is! String ||- !raw.startsWith('/') ||+ !(raw.startsWith('/') || RegExp(r'^[A-Za-z]:\\').hasMatch(raw)) ||raw.length > 4096 ||RegExp(r'[\x00-\x1f\x7f]').hasMatch(raw)) {return null;diff --git a/desktop/lib/super_tabs/import_agent.dart b/desktop/lib/super_tabs/import_agent.dartindex 866dc9b3d..e259daa92 100644--- a/desktop/lib/super_tabs/import_agent.dart+++ b/desktop/lib/super_tabs/import_agent.dart@@ -30,13 +30,7 @@ String get importComputerWord =>/// Why import is refused when this computer is not in the Swarm.String get kImportNeedsThisComputer =>'Add this $importComputerWord to the Swarm first: the imported agent '- 'continues in its Harness Team account.';--/// Why import is refused when this computer has no Harness Team account in the-/// Swarm: the new agent never runs in the person's own account.-String get kImportNeedsTeamAccount =>- 'Set up Harness Team on this $importComputerWord first: the imported agent '- 'continues there, not in your own account.';+ 'continues on it, as you.';const _engines = {'claude', 'codex'};@@ -81,24 +75,17 @@ List<ImportableAgent> importableAgents(AppNotifier app, SuperTabController c) {}/// Why nothing can be imported into [c]'s Swarm from here, or null when it-/// can: Harness must run on this Mac, and this Mac's Harness Team account-/// must be in the Swarm and take work.+/// can: Harness must run on this Mac, and this Mac must be in the Swarm, where+/// the new agent runs as its person (Swarm v3, #4120).String? importUnavailable(AppNotifier app, SuperTabController c) {final mac = _thisMac(app);if (mac == null) {return 'Import works in Harness on the $importComputerWord where the agent ''runs.';}- final snapshot = c.snapshot;- if (snapshot?.pool(mac.machine.machineId) == null) {- return kImportNeedsThisComputer;- }- final team = snapshot!.teamPoolOf(mac.machine.machineId);- if (team == null) return kImportNeedsTeamAccount;- return switch (team['teamWork']) {- {'allowed': false, 'reason': final String reason} => reason,- _ => null,- };+ return c.snapshot?.pool(mac.machine.machineId) == null+ ? kImportNeedsThisComputer+ : null;}/// The steps of an import, in order, each named where it fails.@@ -273,8 +260,7 @@ Future<ImportHandoff> prepareImportHandoff(/// cli superTabs/start.ts.const kImportStartWait = Duration(minutes: 15);-/// What a start asks of the Team account's machine when nothing more is-/// needed (cli superTabs/capacity.ts START_REQUIREMENTS).+/// What a start asks of this computer when nothing more is needed (cli superTabs/capacity.ts START_REQUIREMENTS).const _startRequirements = {'memoryBytes': 2147483648,'diskBytes': 10737418240,@@ -306,8 +292,8 @@ typedef ImportResult = ({String conversationId, String agentId});/// Imports [agent] into [projectId] of [c]'s Swarm with [handoff], doing what/// [progress] has not done yet: opens a conversation,/// `Continue <agent>'s work`, shares both files in it, starts a new agent-/// there in this Mac's Harness Team account (engine and model as the agent's, role Engineer, in-/// the project's repository), waits up to [startWait] for it to be listed,+/// there on this Mac, as its person (engine and model as the agent's, role+/// Engineer, in the project's folder there), waits up to [startWait] for it to be listed,/// then sends it both files in one message, to it alone. The agent on this/// Mac is never touched. Throws an [ImportFailure] naming the step.Future<ImportResult> importAgent(@@ -325,8 +311,7 @@ Future<ImportResult> importAgent(if (importUnavailable(app, c) case final why?) {throw ImportFailure(next, why, code: 'unavailable');}- final team = c.snapshot!.teamPoolOf(agent.machineId)!;- final teamId = team['machineId'] as String;+ final pool = c.snapshot!.pool(agent.machineId)!;final project = c.snapshot!.projectById(projectId);final name = agent.agent.displayName;final owner =@@ -380,12 +365,11 @@ Future<ImportResult> importAgent(}final model = agent.agent.modelId;- final cwd = project == null ? null : _projectFolder(team, project);+ final cwd = project == null ? null : _projectFolder(pool, project);if (cwd == null) {throw ImportFailure(ImportStep.start,- "This $importComputerWord's Team account has no folder for this project "- 'yet.',+ 'This $importComputerWord has no folder for this project yet.',code: 'no-folder',);}@@ -394,7 +378,7 @@ Future<ImportResult> importAgent('type': 'agent.start','request': {'conversationId': conversation,- 'machineId': teamId,+ 'machineId': agent.machineId,'engine': agent.agent.engine,// Never the session title an automatic name shows (task #2912).'name': superTabAddName(agent.agent),@@ -409,7 +393,7 @@ Future<ImportResult> importAgent(final agentId = progress.agentId ??= await _listed(c,startId,- teamId,+ agent.machineId,startWait,);@@ -510,8 +494,7 @@ Future<String> _listed(wait,onTimeout: () => throw ImportFailure(ImportStep.start,- "The agent has not started yet on this $importComputerWord's Team "- 'account. Import '+ 'The agent has not started yet on this $importComputerWord. Import ''again to keep waiting.',code: 'start-timeout',),diff --git a/desktop/lib/super_tabs/import_agent_dialog.dart b/desktop/lib/super_tabs/import_agent_dialog.dartindex 0a3efdacd..795a3fded 100644--- a/desktop/lib/super_tabs/import_agent_dialog.dart+++ b/desktop/lib/super_tabs/import_agent_dialog.dart@@ -23,7 +23,7 @@ import 'import_agent.dart';import 'model.dart';/// Whether Add agent offers Import: Harness on a Mac or a Windows PC, where its-/// daemon and a Harness Team account are; never the web or Linux.+/// daemon is; never the web or Linux.bool get superTabImportOffered =>!kIsWeb &&(defaultTargetPlatform == TargetPlatform.macOS ||diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dartindex 423d0d25e..2dde28752 100644--- a/desktop/lib/super_tabs/machines.dart+++ b/desktop/lib/super_tabs/machines.dart@@ -1601,11 +1601,6 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {String? contributor,) {if (c.snapshot?.hasTeammates != true) return null;- // Its owner let teammates' work run in their own account (#2806): the Swarm's sentence says so to everyone.- if (shared?['teamWork'] case {'ownAccount': final String own}- when own.trim().isNotEmpty) {- return own.trim();- }final work = (team ?? shared)?['teamWork'];if (work is! Map || work['allowed'] != false) return null;final code = work['code'];@@ -1648,135 +1643,6 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {(removal is! Map || superTabMap(removal)['state'] != 'cleaning');}- /// Whether the signed-in person may choose where teammates' work runs on [machineId] (backend- /// `machine.ownAccountWork`, #2806): only on the Mac they added themselves, never on a Harness Team account's own- /// entry (it names its Mac as its host) and never while the machine is being removed.- bool _canChooseOwnAccount(String machineId) {- if (!c.canWrite) return false;- final pool = c.snapshot?.pool(machineId);- return pool != null &&- pool['contributorId'] == c.accountId &&- pool['hostMachineId'] == null &&- pool['removal'] == null;- }-- /// The owner's choice on [machineId]: teammates' work may run in their own account. Absent until they choose: off.- bool _ownAccountOn(String machineId) =>- switch (c.snapshot?.pool(machineId)?['ownAccountChoice']) {- {'allowed': true} => true,- _ => false,- };-- /// Turns teammates' work in the owner's own account on, after the one warning, or off at once. A refusal says its- /// reason in one line: in the warning while it is open, otherwise below the screen.- Future<void> _setOwnAccount(_MachineView v, {required bool allowed}) async {- final id = v.id;- if (!_canChooseOwnAccount(id)) return;- Future<Map<String, dynamic>?> send() => c.command({- 'type': 'machine.ownAccountWork',- 'machineId': id,- 'allowed': allowed,- });- if (!allowed) {- void say(String line) => ScaffoldMessenger.maybeOf(context)?.showSnackBar(- SnackBar(- key: const ValueKey('super-machine-own-account-refused'),- content: Text(line, maxLines: 1, overflow: TextOverflow.ellipsis),- ),- );- // The controller sends nothing while another action is being sent or waits to be confirmed: say so rather than- // leave the owner thinking it is off (review of #2983).- if (c.saving || c.hasPendingAction) {- say('Another action is still being sent. Try again in a moment.');- return;- }- final result = await send();- if (!mounted || result != null) return;- say(c.operationError ?? 'Could not switch it back. Try again.');- return;- }- final name = superTabMachineName(v.name);- var busy = false, attempted = false;- await showAppDialog<void>(- context: context,- builder: (context) => SuperTabDialogScope(- controller: c,- child: StatefulBuilder(- builder: (context, update) => ListenableBuilder(- listenable: c,- builder: (context, _) {- // This change's reply never came: Retry checks it, as Remove's does.- final checking =- c.pendingCommand?['type'] == 'machine.ownAccountWork' &&- c.pendingCommand?['machineId'] == id;- return PopScope(- canPop: !busy,- child: AlertDialog(- key: const ValueKey('super-machine-own-account-confirm'),- title: const Text("Let teammates' work run in your account?"),- content: SizedBox(- width: 400,- child: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- // Kept per Swarm (task #2993): other Swarms with this Mac keep their own choice.- "Teammates' agents in this Swarm will run as you on $name. They can read your files, your keychain "- 'and your signed-in apps. Agents already running are not moved. Your other Swarms keep their own choice.',- ),- if (attempted && !busy && c.operationError != null) ...[- const SizedBox(height: 12),- Text(- c.operationError!,- key: const ValueKey(- 'super-machine-own-account-reason',- ),- maxLines: 1,- overflow: TextOverflow.ellipsis,- ),- ],- ],- ),- ),- actions: [- TextButton(- autofocus: true,- onPressed: busy ? null : () => Navigator.pop(context),- child: const Text('Cancel'),- ),- FilledButton(- key: const ValueKey('super-machine-own-account-allow'),- onPressed:- busy || c.saving || (!checking && c.hasPendingAction)- ? null- : () async {- update(() {- busy = true;- attempted = true;- });- final result = checking- ? await c.retry()- : await send();- if (!context.mounted) return;- if (result != null) {- Navigator.pop(context);- } else {- update(() => busy = false);- }- },- child: Text(checking ? 'Retry' : 'Let them run'),- ),- ],- ),- );- },- ),- ),- ),- );- }-Future<_RemovalPreview> _removalPreview(String machineId) async {final reply = await c.request('GET',@@ -1964,8 +1830,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {);}- /// A machine row's right-click: its details, for its owner where teammates' work runs (#2806), and Remove from Swarm- /// for whoever may.+ /// A machine row's right-click: its details, and Remove from Swarm for whoever may.Future<void> _menu(_MachineView view, Offset at) async {// The menu's barrier takes the pointer from the row, so a second right-click would bring up the browser's menu// over this one. Off until it closes; dispose lets go too, for a screen that goes with the menu still up.@@ -1977,25 +1842,13 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {choice = await showContextMenuAt<String>(context: context,at: at,- // Wide enough for "Run teammates' work only in the Team account" on one line.- width: _canChooseOwnAccount(view.id) ? 340 : 240,+ width: 240,children: (close) => [AppMenuItem(label: 'Details',leadingSlot: false,onPressed: () => close('details'),),- if (_canChooseOwnAccount(view.id))- AppMenuItem(- key: const ValueKey('super-machine-menu-own-account'),- label: _ownAccountOn(view.id)- ? "Run teammates' work only in the Team account"- : "Let teammates' work run in my account",- leadingSlot: false,- onPressed: () => close(- _ownAccountOn(view.id) ? 'own-account-off' : 'own-account-on',- ),- ),if (_canRemove(view.id))AppMenuItem(key: const ValueKey('super-machine-menu-remove'),@@ -2014,9 +1867,6 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {}if (!mounted) return;if (choice == 'details') await _openDetails(view);- if (choice == 'own-account-on' || choice == 'own-account-off') {- await _setOwnAccount(view, allowed: choice == 'own-account-on');- }if (choice == 'remove' &&_canRemove(view.id) &&_removeReason(view.id) == null) {@@ -3000,7 +2850,6 @@ String? superMachineAllowanceNote(Iterable<String> lines) {String? superTabTeammatesPaused(Object? code) {final why = switch (code) {'MACHINE_OFFLINE' => 'Harness Team account offline',- 'TEAM_ACCOUNT_REQUIRED' => 'not set up',// Its owner's Harness Team account is on it and joins on the Mac's next poll (backend machines.ts, #3122).'TEAM_ACCOUNT_JOINING' => 'Harness Team is joining','PRIVACY_UNCHECKED' => 'privacy not checked yet',diff --git a/desktop/test/codex_profiles_test.dart b/desktop/test/codex_profiles_test.dartindex a29a2b0ac..84c650fd8 100644--- a/desktop/test/codex_profiles_test.dart+++ b/desktop/test/codex_profiles_test.dart@@ -91,4 +91,28 @@ void main() {isNull,);});++ // #4183: an agent on a Windows machine has a `C:\…` profile folder; a check that wanted a leading '/' dropped it, so+ // the agent showed on the default account. The Desktop may run on another platform, so both spellings are kept.+ test('keeps a Windows profile path and drops one that is not absolute', () {+ const codex = r'C:\Users\me\.codex-work';+ const claude = r'C:\Users\me\.claude-work';+ expect(+ Agent.fromJson({'id': 'w', 'engine': 'codex', 'codexHome': codex})+ .codexHome,+ codex,+ );+ expect(+ Agent.fromJson({'id': 'w', 'engine': 'claude', 'claudeHome': claude})+ .claudeHome,+ claude,+ );+ for (final home in [r'relative\.codex', r'\\server\share\.codex', 'C:']) {+ expect(+ Agent.fromJson({'id': 'w', 'engine': 'codex', 'codexHome': home})+ .codexHome,+ isNull,+ );+ }+ });}diff --git a/desktop/test/super_tab_import_agent_test.dart b/desktop/test/super_tab_import_agent_test.dartindex fd9bfe5b5..0d642917e 100644--- a/desktop/test/super_tab_import_agent_test.dart+++ b/desktop/test/super_tab_import_agent_test.dart@@ -115,8 +115,7 @@ Agent _agent('terminal': {'available': true},});-/// The Swarm's server, with this Mac's Team account as the host of the-/// starts it records: it starts each at once, fails it with [hostFails], or+/// The Swarm's server, with this Mac as the host of the starts it records: it starts each at once, fails it with [hostFails], or/// leaves it waiting while [hostStarts] is false.class _Server extends ConversationServer {bool hostStarts = true;@@ -329,38 +328,27 @@ void main() {});group('where the new agent runs', () {- test('this Mac\'s Team account in the Swarm: import is offered', () async {+ // Swarm v3 (#4120, #4289): a new agent runs on its own person's computer,+ // as them; a Team account takes no new agent.+ test('this Mac in the Swarm: import is offered, with no Team account',+ () async {final f = await fixture();expect(importUnavailable(f.app, f.c), isNull);- });-- test('no Team account for this Mac in the Swarm says how to set one up, '- 'and starts nowhere else', () async {- final f = await fixture();f.server.state['machines'] = <dynamic>[f.macPool];await f.c.refresh();- expect(importUnavailable(f.app, f.c), kImportNeedsTeamAccount);- // A Team account of another Mac is not this Mac's.- f.server.state['machines'] = <dynamic>[- f.macPool,- {...f.teamPool, 'hostMachineId': 'laptop'},- ];- await f.c.refresh();- expect(importUnavailable(f.app, f.c), kImportNeedsTeamAccount);+ expect(importUnavailable(f.app, f.c), isNull);});- test('a Team account that takes no work says why', () async {+ test('a Team account that takes no work does not hold import back',+ () async {final f = await fixture();f.teamPool['teamWork'] = {'allowed': false,- 'code': 'PRIVACY_CHECK_FAILED',- 'reason': 'Its Team account failed the privacy check.',+ 'code': 'TEAM_ACCOUNTS_REMOVED',+ 'reason': 'Harness Team accounts are gone.',};await f.c.refresh();- expect(- importUnavailable(f.app, f.c),- 'Its Team account failed the privacy check.',- );+ expect(importUnavailable(f.app, f.c), isNull);});test('this Mac not in the Swarm says to add it', () async {@@ -629,7 +617,7 @@ void main() {});test('opens a conversation, shares both files in it, starts the agent '- 'in this Mac\'s Team account and sends the files to it alone', () async {+ 'on this Mac, as its person, and sends the files to it alone', () async {final (f, agent, handoff) = await prepared();final import = AgentImport();@@ -676,10 +664,10 @@ void main() {'type': 'agent.start','request': {'conversationId': conversation,- 'machineId': 'team-m',+ 'machineId': 'm','engine': 'codex','name': 'fix-fix',- 'cwd': '/Users/Shared/harness-team/swarm/tab/lead',+ 'cwd': '/Users/owner/.harness/swarm/tab/lead','roleName': 'Engineer','worktree': true,'model': 'gpt-5.6-sol',@@ -710,12 +698,12 @@ void main() {expect(f.daemon.calls.first.$3['action'], 'swarmListed');});- test('a project whose repository is the Team account\'s own folder starts '- 'there', () async {+ test('a project whose repository is this Mac\'s own folder starts there',+ () async {final (f, agent, handoff) = await prepared();(f.server.state['projects'] as List).first['repository'] = {- 'machineId': 'team-m',- 'cwd': '/Users/Shared/harness-team/code/openharness',+ 'machineId': 'm',+ 'cwd': '/Users/owner/code/openharness',};await f.c.refresh();await importAgent(@@ -727,7 +715,8 @@ void main() {progress: AgentImport(),);final start = f.server.commands[1].$2['request'] as Map;- expect(start['cwd'], '/Users/Shared/harness-team/code/openharness');+ expect(start['machineId'], 'm');+ expect(start['cwd'], '/Users/owner/code/openharness');});Matcher failedAt(ImportStep step, [Object? words]) => isA<ImportFailure>()@@ -866,7 +855,7 @@ void main() {'id': 'agent-new','projectId': 'lead','name': 'fix-fix',- 'machineId': 'team-m',+ 'machineId': 'm','harnessId': 'h-new','contributorId': 'owner','configuration': {'engine': 'codex'},@@ -906,9 +895,9 @@ void main() {expect(f.server.commands[2].$1, f.server.commands[3].$1);});- test('no Team account for this Mac starts nothing anywhere', () async {+ test('this Mac not in the Swarm starts nothing anywhere', () async {final (f, agent, handoff) = await prepared();- f.server.state['machines'] = <dynamic>[f.macPool];+ f.server.state['machines'] = <dynamic>[f.teamPool];await f.c.refresh();await expectLater(importAgent(@@ -919,7 +908,7 @@ void main() {handoff,progress: AgentImport(),),- throwsA(failedAt(ImportStep.conversation, kImportNeedsTeamAccount)),+ throwsA(failedAt(ImportStep.conversation, kImportNeedsThisComputer)),);expect(f.server.posts, isEmpty);expect(f.server.uploads, isEmpty);@@ -1271,19 +1260,17 @@ void main() {expect(find.text("What openharness's members will read"), findsNothing);}, variant: mac);- // Swarm v3 has no Team accounts (#4221): nothing offers to set one up.- testWidgets('no Team account for this Mac offers no Set up', (- tester,- ) async {+ testWidgets('this Mac not in the Swarm says to add it, and offers no '+ 'Harness Team setup', (tester) async {final f = await roster(tester);f.app.teamAccountHereForTest = true;- f.server.state['machines'] = <dynamic>[f.macPool];+ f.server.state['machines'] = <dynamic>[f.teamPool];await tester.runAsync(f.c.refresh);await tester.pumpAndSettle();await openImport(tester);- expect(find.text(kImportNeedsTeamAccount), findsOneWidget);+ expect(find.text(kImportNeedsThisComputer), findsOneWidget);+ expect(find.textContaining('Team'), findsNothing);expect(find.textContaining('fix-fix'), findsNothing);- expect(find.text('Set up Harness Team'), findsNothing);expect(f.server.posts, isEmpty);}, variant: mac);});diff --git a/desktop/test/super_tab_machine_menu_test.dart b/desktop/test/super_tab_machine_menu_test.dartnew file mode 100644index 000000000..42aa45a90--- /dev/null+++ b/desktop/test/super_tab_machine_menu_test.dart@@ -0,0 +1,153 @@+import 'dart:io';++import 'package:flutter/gestures.dart' show kSecondaryMouseButton;+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/super_tabs/machines.dart';++import 'support/capture.dart';+import 'support/super_tab_fixture.dart';++// Task #4289: Swarm v3 has no Team accounts (#4120). Every agent runs on its own person's computer, as them, so a+// machine's menu offers no choice of where teammates' work runs, and its row says nothing of it.+final shots = Platform.environment['HARNESS_SUPER_TAB_CAPTURE'];++Map<String, dynamic> _machine(+ String id, {+ bool? ownAccountChoice,+ Map<String, dynamic>? teamWork,+}) => {+ 'machineId': id,+ 'name': "Gray's Mac",+ 'contributorId': 'owner',+ 'observation': {'receivedAt': DateTime.now().millisecondsSinceEpoch},+ if (ownAccountChoice != null)+ 'ownAccountChoice': {+ 'allowed': ownAccountChoice,+ 'by': 'owner',+ 'at': '2026-11-04T09:00:00Z',+ },+ 'teamWork': ?teamWork,+};++const _people = [+ {'id': 'owner', 'email': '[email protected]', 'role': 'owner', 'name': 'Gray'},+ {+ 'id': 'scholes',+ 'email': '[email protected]',+ 'role': 'member',+ 'name': 'Scholes',+ },+];++Future<dynamic> _mount(+ WidgetTester tester,+ ConversationServer server, {+ Brightness brightness = Brightness.light,+}) async {+ // The design tokens follow the app's brightness, which main.dart sets from the theme.+ final previous = grid.AppTheme.brightness.value;+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = previous);+ server.state['people'] = _people;+ final c = server.controller();+ await c.refresh();+ await tester.pumpWidget(+ MaterialApp(+ debugShowCheckedModeBanner: false,+ theme: grid.buildAppTheme(brightness: brightness),+ home: Scaffold(+ body: SuperTabMachines(controller: c, onAddAgent: (_) {}),+ ),+ ),+ );+ await tester.pumpAndSettle();+ return c;+}++Future<void> _rightClick(WidgetTester tester, String id) async {+ await tester.tap(+ find.byKey(ValueKey('super-machine-$id')),+ buttons: kSecondaryMouseButton,+ );+ await tester.pumpAndSettle();+}++Future<void> _done(WidgetTester tester, dynamic c) async {+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ c.dispose();+}++void main() {+ setUpAll(() => loadCaptureFonts(shots));++ testWidgets(+ "the owner's menu on their Mac is Details and Remove from Swarm, whatever it chose before",+ (tester) async {+ for (final choice in [null, false, true]) {+ final server = ConversationServer();+ server.state['machines'] = [+ _machine('studio', ownAccountChoice: choice),+ ];+ final c = await _mount(tester, server);+ await _rightClick(tester, 'studio');+ expect(find.text('Details'), findsOneWidget, reason: '$choice');+ expect(find.text('Remove from Swarm'), findsOneWidget);+ expect(+ find.byKey(const ValueKey('super-machine-menu-own-account')),+ findsNothing,+ reason: '$choice',+ );+ expect(find.textContaining("teammates' work"), findsNothing);+ expect(find.textContaining('Team account'), findsNothing);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ await _done(tester, c);+ }+ },+ );++ testWidgets("a row says nothing of where teammates' work runs", (+ tester,+ ) async {+ final server = ConversationServer();+ server.state['machines'] = [+ // An older Swarm's note that its owner let teammates' work run in their own account.+ _machine(+ 'studio',+ ownAccountChoice: true,+ teamWork: {+ 'allowed': true,+ 'ownAccount':+ "Gray's Mac runs teammates' work in Gray's own account.",+ },+ ),+ ];+ final c = await _mount(tester, server);+ expect(find.byKey(const ValueKey('super-machine-studio')), findsOneWidget);+ expect(find.textContaining("teammates' work"), findsNothing);+ expect(find.textContaining('own account'), findsNothing);+ await _done(tester, c);+ });++ testWidgets('screenshots of the menu, light and dark', (tester) async {+ await tester.binding.setSurfaceSize(const Size(900, 560));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ for (final (brightness, name) in [+ (Brightness.light, 'light'),+ (Brightness.dark, 'dark'),+ ]) {+ final server = ConversationServer();+ server.state['machines'] = [_machine('studio', ownAccountChoice: true)];+ final c = await _mount(tester, server, brightness: brightness);+ await _rightClick(tester, 'studio');+ await captureWindow(tester, shots, 'machine-menu-$name');+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ await _done(tester, c);+ }+ }, skip: shots == null);+}diff --git a/desktop/test/super_tab_machine_own_account_test.dart b/desktop/test/super_tab_machine_own_account_test.dartdeleted file mode 100644index b5d8d418a..000000000--- a/desktop/test/super_tab_machine_own_account_test.dart+++ /dev/null@@ -1,421 +0,0 @@-import 'dart:async';-import 'dart:io';--import 'package:flutter/gestures.dart' show kSecondaryMouseButton;-import 'package:flutter/material.dart';-import 'package:flutter/rendering.dart';-import 'package:flutter/services.dart';-import 'package:flutter_test/flutter_test.dart';-import 'package:harness/shared/theme/app_theme.dart' as grid;-import 'package:harness/super_tabs/machines.dart';--import 'support/capture.dart';-import 'support/super_tab_fixture.dart';--// Task #2813 (Scholes, 11-04): the Mac's owner lets teammates' work run in their own account on it, after one warning-// (backend `machine.ownAccountWork`, #2806). Only on the Mac its owner added, never on a Harness Team account's entry.-final shots = Platform.environment['HARNESS_SUPER_TAB_CAPTURE'];--const _allow = ValueKey('super-machine-own-account-allow');-const _item = ValueKey('super-machine-menu-own-account');--Map<String, dynamic> _machine(- String id, {- String contributor = 'owner',- String? host,- bool? allowed,- String? ownAccountLine,-}) => {- 'machineId': id,- 'name': id == 'studio' ? "Gray's Mac" : id,- 'contributorId': contributor,- 'hostMachineId': ?host,- 'observation': {'receivedAt': DateTime.now().millisecondsSinceEpoch},- if (allowed != null)- 'ownAccountChoice': {- 'allowed': allowed,- 'by': contributor,- 'at': '2026-11-04T09:00:00Z',- },- if (ownAccountLine != null)- 'teamWork': {'allowed': true, 'ownAccount': ownAccountLine},-};--List<Map<String, dynamic>> _ownAccountCommands(ConversationServer server) => [- for (final p in server.posts)- if ((p['command'] as Map?)?['type'] == 'machine.ownAccountWork')- Map<String, dynamic>.from(p['command'] as Map),-];--Future<dynamic> _mount(- WidgetTester tester,- ConversationServer server, {- Brightness brightness = Brightness.light,-}) async {- // The design tokens follow the app's brightness, which main.dart sets from the theme.- final previous = grid.AppTheme.brightness.value;- grid.AppTheme.brightness.value = brightness;- addTearDown(() => grid.AppTheme.brightness.value = previous);- final c = server.controller();- await c.refresh();- await tester.pumpWidget(- MaterialApp(- debugShowCheckedModeBanner: false,- theme: grid.buildAppTheme(brightness: brightness),- home: Scaffold(- body: SuperTabMachines(controller: c, onAddAgent: (_) {}),- ),- ),- );- await tester.pumpAndSettle();- return c;-}--Future<void> _rightClick(WidgetTester tester, String id) async {- await tester.tap(- find.byKey(ValueKey('super-machine-$id')),- buttons: kSecondaryMouseButton,- );- await tester.pumpAndSettle();-}--/// Whether [text]'s line is cut short where it is laid out: ellipsized, or narrower than the text needs.-bool _cut(WidgetTester tester, String text) {- final paragraph = tester.renderObject<RenderParagraph>(find.text(text));- final whole = TextPainter(- text: paragraph.text,- textDirection: TextDirection.ltr,- textScaler: paragraph.textScaler,- )..layout();- return paragraph.didExceedMaxLines ||- paragraph.size.width < whole.width - 0.5;-}--Future<void> _done(WidgetTester tester, dynamic c) async {- await tester.pumpWidget(const SizedBox());- await c.flush();- c.dispose();-}--void main() {- setUpAll(() => loadCaptureFonts(shots));-- group("teammates' work in the owner's own account", () {- testWidgets('only the Mac its owner added offers it', (tester) async {- final server = ConversationServer();- server.state['machines'] = [- _machine('studio'),- _machine('pro', contributor: 'scholes'),- // A Harness Team account's own entry, shown on its own row while its Mac is not in this Swarm.- _machine('studio-team', host: 'gray-mac'),- ];- final c = await _mount(tester, server);- await _rightClick(tester, 'studio');- expect(- find.text("Let teammates' work run in my account"),- findsOneWidget,- );- expect(- _cut(tester, "Let teammates' work run in my account"),- isFalse,- reason: 'the item reads whole, not cut short',- );- await tester.sendKeyEvent(LogicalKeyboardKey.escape);- await tester.pumpAndSettle();- for (final other in ['pro', 'studio-team']) {- await _rightClick(tester, other);- expect(find.text('Details'), findsOneWidget, reason: other);- expect(find.byKey(_item), findsNothing, reason: other);- await tester.sendKeyEvent(LogicalKeyboardKey.escape);- await tester.pumpAndSettle();- }- await _done(tester, c);- });-- testWidgets('it warns once, and Cancel, the default, sends nothing', (- tester,- ) async {- final server = ConversationServer();- server.state['machines'] = [_machine('studio')];- final c = await _mount(tester, server);- await _rightClick(tester, 'studio');- await tester.tap(find.byKey(_item));- await tester.pumpAndSettle();- expect(- find.text("Let teammates' work run in your account?"),- findsOneWidget,- );- expect(- find.text(- "Teammates' agents in this Swarm will run as you on Gray's Mac. They can read your files, your keychain "- 'and your signed-in apps. Agents already running are not moved. Your other Swarms keep their own choice.',- ),- findsOneWidget,- );- final cancel = find.widgetWithText(TextButton, 'Cancel');- expect(tester.widget<TextButton>(cancel).autofocus, isTrue);- await tester.tap(cancel);- await tester.pumpAndSettle();- expect(find.byKey(_allow), findsNothing);- expect(_ownAccountCommands(server), isEmpty);- await _done(tester, c);- });-- testWidgets('Let them run sends the choice once', (tester) async {- final server = ConversationServer();- server.state['machines'] = [_machine('studio')];- final c = await _mount(tester, server);- await _rightClick(tester, 'studio');- await tester.tap(find.byKey(_item));- await tester.pumpAndSettle();- await tester.tap(find.byKey(_allow));- await tester.pumpAndSettle();- expect(_ownAccountCommands(server), [- {- 'type': 'machine.ownAccountWork',- 'machineId': 'studio',- 'allowed': true,- },- ]);- expect(find.byKey(_allow), findsNothing);- await _done(tester, c);- });-- testWidgets(- 'once on, it reads Team account only and switches back with no question',- (tester) async {- final server = ConversationServer();- server.state['machines'] = [_machine('studio', allowed: true)];- final c = await _mount(tester, server);- await _rightClick(tester, 'studio');- expect(- find.text("Run teammates' work only in the Team account"),- findsOneWidget,- );- expect(- find.text("Let teammates' work run in my account"),- findsNothing,- );- expect(- _cut(tester, "Run teammates' work only in the Team account"),- isFalse,- reason: 'the item reads whole, not cut short',- );- await tester.tap(find.byKey(_item));- await tester.pumpAndSettle();- expect(- find.text("Let teammates' work run in your account?"),- findsNothing,- );- expect(_ownAccountCommands(server), [- {- 'type': 'machine.ownAccountWork',- 'machineId': 'studio',- 'allowed': false,- },- ]);- await _done(tester, c);- },- );-- testWidgets('a refusal says its reason in one line', (tester) async {- final server = ConversationServer()- ..refuse = {- 'code': 'OWNER_REQUIRED',- 'message':- "Only the machine's owner can change where teammates' work runs.",- }- ..refuseStatus = 403;- server.state['machines'] = [_machine('studio')];- final c = await _mount(tester, server);- await _rightClick(tester, 'studio');- await tester.tap(find.byKey(_item));- await tester.pumpAndSettle();- await tester.tap(find.byKey(_allow));- await tester.pumpAndSettle();- final reason = find.byKey(- const ValueKey('super-machine-own-account-reason'),- );- expect(reason, findsOneWidget);- expect(- tester.widget<Text>(reason).data,- "Only the machine's owner can change where teammates' work runs.",- );- expect(tester.widget<Text>(reason).maxLines, 1);- // The warning stays up with its reason; nothing changed.- expect(find.byKey(_allow), findsOneWidget);- await tester.tap(find.widgetWithText(TextButton, 'Cancel'));- await tester.pumpAndSettle();- await _done(tester, c);- });-- testWidgets('a refused switch back says its reason in one line', (- tester,- ) async {- final server = ConversationServer()- ..refuse = {- 'code': 'MACHINE_REMOVED',- 'message': 'This machine was removed from the Swarm.',- }- ..refuseStatus = 404;- server.state['machines'] = [_machine('studio', allowed: true)];- final c = await _mount(tester, server);- await _rightClick(tester, 'studio');- await tester.tap(find.byKey(_item));- await tester.pumpAndSettle();- final bar = find.byKey(- const ValueKey('super-machine-own-account-refused'),- );- expect(bar, findsOneWidget);- expect(- find.descendant(- of: bar,- matching: find.text('This machine was removed from the Swarm.'),- ),- findsOneWidget,- );- await _done(tester, c);- });-- // Review of #2983 (Avocet4): while another action is still being sent, the controller sends nothing; switching back- // must say so, never leave the owner thinking it is off.- testWidgets('switching back while another action is sending says so', (- tester,- ) async {- final server = ConversationServer();- server.state['machines'] = [_machine('studio', allowed: true)];- final c = await _mount(tester, server);- final hold = Completer<void>();- server.holdCommands = hold;- final other = c.command({- 'type': 'machine.pause',- 'machineId': 'studio',- 'paused': true,- });- await tester.pump();- await _rightClick(tester, 'studio');- await tester.tap(find.byKey(_item));- await tester.pumpAndSettle();- expect(_ownAccountCommands(server), isEmpty);- final bar = find.byKey(- const ValueKey('super-machine-own-account-refused'),- );- expect(bar, findsOneWidget);- expect(- find.descendant(- of: bar,- matching: find.text(- 'Another action is still being sent. Try again in a moment.',- ),- ),- findsOneWidget,- );- hold.complete();- await other;- await tester.pumpAndSettle();- await _done(tester, c);- });-- // Review of #2983 (Avocet4): a reply that never came says "Retry"; the warning offers it.- testWidgets('a lost reply offers Retry in the warning, which confirms it', (- tester,- ) async {- final server = ConversationServer()..loseReply = true;- server.state['machines'] = [_machine('studio')];- final c = await _mount(tester, server);- await _rightClick(tester, 'studio');- await tester.tap(find.byKey(_item));- await tester.pumpAndSettle();- await tester.tap(find.byKey(_allow));- await tester.pumpAndSettle();- expect(- find.byKey(const ValueKey('super-machine-own-account-reason')),- findsOneWidget,- );- final retry = find.byKey(_allow);- expect(- find.descendant(of: retry, matching: find.text('Retry')),- findsOneWidget,- );- expect(tester.widget<FilledButton>(retry).onPressed, isNotNull);- await tester.tap(retry);- await tester.pumpAndSettle();- expect(find.byKey(_allow), findsNothing);- expect(c.hasPendingAction, isFalse);- // The lost send and its Retry are the same command, sent again under its operation id.- expect(_ownAccountCommands(server), isNotEmpty);- expect(- _ownAccountCommands(server),- everyElement({- 'type': 'machine.ownAccountWork',- 'machineId': 'studio',- 'allowed': true,- }),- );- await _done(tester, c);- });-- testWidgets("the row says it runs in the owner's own account", (- tester,- ) async {- final server = ConversationServer();- server.state['people'] = [- {- 'id': 'owner',- 'email': '[email protected]',- 'role': 'owner',- 'name': 'Gray',- },- {- 'id': 'scholes',- 'email': '[email protected]',- 'role': 'member',- 'name': 'Scholes',- },- ];- server.state['machines'] = [- _machine(- 'studio',- allowed: true,- ownAccountLine:- "Gray's Mac runs teammates' work in Gray's own account.",- ),- ];- final c = await _mount(tester, server);- expect(- find.textContaining("runs teammates' work in Gray's own account"),- findsOneWidget,- );- await _done(tester, c);- });-- testWidgets('screenshots for Scholes', (tester) async {- await tester.binding.setSurfaceSize(const Size(900, 560));- addTearDown(() => tester.binding.setSurfaceSize(null));- for (final (brightness, name) in [- (Brightness.light, 'light'),- (Brightness.dark, 'dark'),- ]) {- final server = ConversationServer();- server.state['machines'] = [_machine('studio')];- final c = await _mount(tester, server, brightness: brightness);- await _rightClick(tester, 'studio');- await captureWindow(tester, shots, 'own-account-menu-$name');- await tester.tap(find.byKey(_item));- await tester.pumpAndSettle();- await captureWindow(tester, shots, 'own-account-confirm-$name');- await tester.tap(find.widgetWithText(TextButton, 'Cancel'));- await tester.pumpAndSettle();- await _done(tester, c);- final on = ConversationServer();- on.state['machines'] = [_machine('studio', allowed: true)];- final d = await _mount(tester, on, brightness: brightness);- await _rightClick(tester, 'studio');- await captureWindow(tester, shots, 'own-account-menu-on-$name');- await tester.sendKeyEvent(LogicalKeyboardKey.escape);- await tester.pumpAndSettle();- await _done(tester, d);- }- }, skip: shots == null);- });-}diff --git a/desktop/test/super_tab_team_machine_test.dart b/desktop/test/super_tab_team_machine_test.dartindex 0cc3a7ac4..11c5b3bb8 100644--- a/desktop/test/super_tab_team_machine_test.dart+++ b/desktop/test/super_tab_team_machine_test.dart@@ -221,7 +221,6 @@ void main() {"Teammates' agents paused: privacy check out of date",'PRIVACY_UNCHECKED':"Teammates' agents paused: privacy not checked yet",- 'TEAM_ACCOUNT_REQUIRED': "Teammates' agents paused: not set up",};for (final MapEntry(key: code, value: line) in reasons.entries) {final server = _swarm();@@ -238,16 +237,22 @@ void main() {},);- testWidgets('without a Harness Team account the Mac\'s own refusal says so', (+ // Swarm v3 makes no Team accounts (#4120): a Mac without one is short of nothing, so its row says nothing of it+ // (#4289), for teammates and its owner alike.+ testWidgets('a Mac without a Harness Team account says nothing of one', (tester,) async {final server = _swarm();server.state['machines'] = [_pool('mac', teamWork: _refused('TEAM_ACCOUNT_REQUIRED')),];- final c = await _mount(tester, server);- expect(_problemText(tester, 'mac'), "Teammates' agents paused: not set up");- await _unmount(tester, c);+ for (final account in ['peer', 'owner']) {+ final c = await _mount(tester, server, account: account);+ expect(_row('mac'), findsOneWidget);+ expect(_problem('mac'), findsNothing, reason: account);+ expect(find.textContaining('not set up'), findsNothing, reason: account);+ await _unmount(tester, c);+ }});// Local Team account run, 2026-10-28 (group #646, item 5): a teammate's Lead computer, never added to the Swarm, readdiff --git a/docs/plans/2026-11-07-import-own-computer-plan.md b/docs/plans/2026-11-07-import-own-computer-plan.mdnew file mode 100644index 000000000..0314f52b7--- /dev/null+++ b/docs/plans/2026-11-07-import-own-computer-plan.md@@ -0,0 +1,61 @@+# Import agent on the person's own computer; machine menu without Team-account options (#4289)++> Written by the Engineer, implemented by the Engineer task by task, test first (project instructions, Roles › Engineer).++**Goal:** Import agent starts the imported agent on the person's own computer, as them, now that Swarm v3 refuses+every start in a Team account (#4120). The machine row's menu no longer offers "Run teammates' work only in the Team+account" / "Let teammates' work run in my account", and rows no longer say "Teammates' agents paused: not set up".++**Architecture:** Desktop's Import agent (`desktop/lib/super_tabs/import_agent.dart`) sends `agent.start` for the+Mac's Team-account entry (`teamPoolOf`), which `admitMachineStart` now refuses with `TEAM_ACCOUNTS_REMOVED`. It sends+it for this computer's own entry instead, in that entry's project folder (`projectFolder` rule). The machine menu's+own-account item reads `ownAccountChoice` from the pool; Desktop drops the item and the backend stops sending the+field. The row line maps `TEAM_ACCOUNT_REQUIRED` to "not set up"; Desktop drops that mapping. The backend's own+`TEAM_ACCOUNT_REQUIRED` for ordinary computers is removed by #3472 (#4218), and Add your computers' "not set up" tag+by #3474 (#4221); this plan does not repeat them.++**Tech Stack:** Flutter (Desktop), TypeScript (backend), vitest, flutter_test.++**Spec:** task #4289 brief.++## Global Constraints++- Team code that still reads existing Team entries stays until the Team daemons are stopped (#4280, #4290): privacy+ readings, Team pools, `teamWorkRefusal`, the `machine.ownAccountWork` command (older Desktops may still send it).+- Backend ships first; Desktop from the last 30 days keeps working: a missing `ownAccountChoice` reads as "off".+- No new UI. Light and dark screenshots of the machine menu.++## Review Focus++- The import start lands on this computer's own entry, never a Team entry, in the right folder.+- Nothing in Desktop still reads `ownAccountChoice` or shows "not set up".++## Task 1: Import agent starts on this computer++**Files:** `desktop/lib/super_tabs/import_agent.dart`, `desktop/lib/super_tabs/import_agent_dialog.dart`,+`desktop/test/super_tab_import_agent_test.dart`.++**Interfaces:** `importUnavailable` needs only this computer in the Swarm; `kImportNeedsTeamAccount` goes.+`importAgent` starts on `mac.machine.machineId` with `cwd` from that pool.++- [ ] Test: the start names this computer (`m`) and its Swarm folder, with a Team entry listed beside it; a computer+ with no Team entry is offered Import; Import from the dialog does not offer "Set up Harness Team". Watch it fail.+- [ ] Code: start on this computer; copy without Team accounts; remove the Set up offer. Watch it pass.++## Task 2: the machine menu and rows drop Team-account options++**Files:** `desktop/lib/super_tabs/machines.dart`, `desktop/test/super_tab_machine_own_account_test.dart` (rewritten+as the v3 menu test), tests that pin "not set up".++- [ ] Test: the owner's menu on their own Mac lists Details and Remove from Swarm only, even with an own-account choice+ stored; a row whose pool reads `TEAM_ACCOUNT_REQUIRED` or carries an own-account note shows no teammates line.+ Light and dark screenshots. Watch it fail.+- [ ] Code: remove `_canChooseOwnAccount`, `_ownAccountOn`, `_setOwnAccount` and its warning, the menu item, the+ own-account row line and the `TEAM_ACCOUNT_REQUIRED` mapping. Watch it pass.++## Task 3: the backend stops sending the menu's field++**Files:** `backend/src/superTabs/model.ts` (`visibleState`), a unit test beside it.++- [ ] Test: a Swarm read of a machine with a stored `ownAccountChoice` carries none. Watch it fail.+- [ ] Code: `visibleState` deletes `ownAccountChoice` from each pool. Watch it pass.