Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(agents): the coordinator gets a row with its helpers nested [N2,B13]

Corey Olson673deb397a65
diff --git a/src/agent-tree.js b/src/agent-tree.js
index e5f8c9f9..5920dfbf 100644
--- a/src/agent-tree.js
+++ b/src/agent-tree.js
@@ -1,4 +1,5 @@
/** The agents view: each agent with its seats, helpers and holds, from the board and this machine's parent notes [N2,B13]. */
+import { dirname } from 'node:path';
import { COORDINATOR } from './config.js';
import { displayAgentName } from './agent-names.js';
import { seatLinks } from './agent-session.js';
@@ -6,7 +7,7 @@ import * as store from './board.js';
/**
* Every joined agent with its seats, its helpers and what each holds, helpers nested under the agent that opened them
- * [N2,B13]. The parent links are read from this machine's checkouts; a helper whose parent is gone is listed on its own.
+ * [N2,B13]. The parent links are read from this machine's checkouts; the coordinator is listed like any agent, and a helper whose parent is gone is listed on its own.
*
* @param {any} info - the checkout's repository info
* @param {any} config
@@ -14,8 +15,12 @@ import * as store from './board.js';
* @returns {any[]}
*/
export function agentTree(info, config, board) {
- const agents = store.listAgents(board).filter((agent) => agent.agent_lane !== COORDINATOR);
+ const agents = store.listAgents(board);
const { parents, digests } = seatLinks(info, agents);
+ // The coordinator is the main checkout; a board that never declared its seat still shows it once it has opened a helper.
+ if (!agents.some((agent) => agent.agent_id === COORDINATOR) && [...parents.values()].includes(COORDINATOR)) {
+ agents.unshift({ agent_id: COORDINATOR, agent_lane: COORDINATOR, agent_path: dirname(info.commonDir) });
+ }
const held = new Map();
for (const item of store.listItems(board)) {
if (!item.item_owner || !['claimed', 'submitted'].includes(item.item_status)) continue;
diff --git a/test/agent-session.test.js b/test/agent-session.test.js
index 0a78900f..eee3bccc 100644
--- a/test/agent-session.test.js
+++ b/test/agent-session.test.js
@@ -398,8 +398,8 @@ test('a session whose claims cannot be recorded is refused before it moves, neve
});
/** Open a helper seat from the web seat inside an agent session, returning the CLI result and the helper's Git directory. */
-function openHelper(box, session, { agent = true } = {}) {
- const made = box.run(box.web, ['worktree', 'web', '--model', 'Helper Model', '--json'], { session, sessionKey: 'CODEX_THREAD_ID', agent });
+function openHelper(box, session, { agent = true, from = box.web } = {}) {
+ const made = box.run(from, ['worktree', 'web', '--model', 'Helper Model', '--json'], { session, sessionKey: 'CODEX_THREAD_ID', agent });
assert.equal(made.status, 0, `${made.stdout}${made.stderr}`);
const result = JSON.parse(made.stdout);
const gitDir = resolve(result.path, box.git(result.path, 'rev-parse', '--git-dir'));
@@ -442,3 +442,18 @@ test('agents lists each agent with its helpers [N2,B13]', () => {
assert.equal(text.status, 0);
assert.match(text.stdout, new RegExp(`${helper.result.agent}[^\\n]*#1`, 'u'), 'the text view shows the helper and its item');
});
+
+test('agents gives the coordinator a row with the helpers it opened [N2,B13]', () => {
+ const box = project();
+ const helper = openHelper(box, 'codex-thread-coordinator-800', { from: box.repo });
+ assert.equal(JSON.parse(readFileSync(helper.file, 'utf8')).parent, 'coordinator', 'the main checkout is recorded as the parent');
+ const listed = JSON.parse(box.run(box.repo, ['agents', '--json'], { agent: false }).stdout).agents;
+ const top = listed.find((agent) => agent.id === 'coordinator');
+ assert.ok(top, 'the coordinator has its own row');
+ assert.deepEqual(top.helpers.map((agent) => agent.id), [helper.result.agent], 'its helper is nested under it');
+ assert.equal(listed.some((agent) => agent.id === helper.result.agent), false, 'the helper is not a top-level agent');
+ const lines = box.run(box.repo, ['agents'], { agent: false }).stdout.split(/\r?\n/u);
+ const at = lines.findIndex((line) => line.startsWith('coordinator'));
+ assert.ok(at >= 0, 'the text view has a coordinator line');
+ assert.match(lines[at + 1] ?? '', new RegExp(`^ {2}\\S.*${helper.result.agent}|^ {2}.*\\(web lane\\)`, 'u'), 'the helper is indented under it');
+});