From e8d714b20032117d9b6a332371772479f23b90d2 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 14:29:33 +0000 Subject: [PATCH 1/2] Agent Flow: a file with no height at the opened step no longer stands as a 1 m box (#319) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adrián saw a big grey-violet block in the middle of the city in the demo video. It is templates/components/livepanel/charts.js, the file the sample session deletes with git rm. An InstancedMesh starts every instance at the identity matrix, and setBuildingHeight returns early when the height does not change, so a file whose height is 0 at the step the session opens on (deleted by then, or not created yet) was never written: it stood as a unit box at the city's origin for the whole session. buildBuildings now starts every building at the zero matrix, like the roofs, ghosts and floors already did. The harness asserts that every file with no height at the end of the sample session is hidden. --- .../agent-flow/agentFlowRuntime/cityScene.js | 7 ++++++- .../test/runners/run-agent-flow-harness.cjs | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/cityScene.js b/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/cityScene.js index c8b12620..2fbc6560 100644 --- a/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/cityScene.js +++ b/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/cityScene.js @@ -124,13 +124,18 @@ c.baseY[index] = (c.outside[index] ? 1 : containingDepth(file, c.districts)) * PLATE_STEP; } }); + c.zero = new T.Matrix4().makeScale(0.00001, 0.00001, 0.00001); + // An InstancedMesh starts every instance at the identity matrix: a 1 m box at + // the city's origin. A file with no height at the opened step (deleted by the + // session, or not created yet) is never written by setBuildingHeight, so it + // would stand there as a huge block. Every building starts hidden instead. + for (var b = 0; b < count; b += 1) { mesh.setMatrixAt(b, c.zero); } if (!c.files.length) { mesh.count = 0; } c.buildings = mesh; // Roof tints: a thin cap per building, hidden (zero scale) until tinted. var roofs = new T.InstancedMesh(track(c, new T.BoxGeometry(1, 1, 1)), track(c, new T.MeshBasicMaterial({ color: '#ffffff' })), count); roofs.name = 'agentFlowRoofs'; roofs.instanceMatrix.setUsage?.(T.DynamicDrawUsage); - c.zero = new T.Matrix4().makeScale(0.00001, 0.00001, 0.00001); for (var i = 0; i < count; i += 1) { roofs.setMatrixAt(i, c.zero); roofs.setColorAt(i, c.color.set('#ffffff')); } c.group.add(roofs); c.roofs = roofs; diff --git a/apps/vscode-extension/test/runners/run-agent-flow-harness.cjs b/apps/vscode-extension/test/runners/run-agent-flow-harness.cjs index 4598b8de..c850ac83 100644 --- a/apps/vscode-extension/test/runners/run-agent-flow-harness.cjs +++ b/apps/vscode-extension/test/runners/run-agent-flow-harness.cjs @@ -130,6 +130,23 @@ async function runScenario(browser, port) { assert.equal(state.actors, sample.actors.length, 'one worker lane per actor'); assert.ok(state.workers.length >= 1, 'the main worker stands on the table'); assert.ok(state.trailPoints > 2, 'the trail is drawn'); + // A file with no height at the opened step is hidden, not left at the + // InstancedMesh default (identity: a 1 m box at the city's origin). + const unbuiltScales = () => page.evaluate(() => { + const T = window.AFRAME.THREE; + const view = window.CodeXRAgentFlowRuntime.__testing.getView(); + const mesh = view.city.state.buildings; + const matrix = new T.Matrix4(); + const scale = new T.Vector3(); + return view.files.map((file, index) => index).filter((index) => view.city.getHeight(index) <= 0.0005).map((index) => { + mesh.getMatrixAt(index, matrix); + matrix.decompose(new T.Vector3(), new T.Quaternion(), scale); + return { path: view.files[index].path, scale: Math.max(scale.x, scale.y, scale.z) }; + }); + }); + let unbuilt = await unbuiltScales(); + assert.ok(unbuilt.some((entry) => entry.path.endsWith('livepanel/charts.js')), 'the file deleted by the session has no height at its end'); + unbuilt.forEach((entry) => assert.ok(entry.scale < 0.001, `${entry.path} is hidden at the end of the session (scale ${entry.scale})`)); const lookAtLocal = (point, offset) => page.evaluate(([p, o]) => window.CodeXRAgentFlowHarness.lookAtLocal(p, o), [point, offset]); const stepTo = async (index, settleMs) => { From c8704ad0831d22dc9bfbcdb0ddff3cabb7cce42e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 15:51:47 +0000 Subject: [PATCH 2/2] Agent Flow: a subagent's UFO appears with its first step, not with the delegate (#319) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adrián, watching the demo video: on a delegate, the main UFO and both subagents' UFOs sat in a pile at the same spot, their name tags on top of each other. workersAt made a subagent present from the delegate step that spawned it, and until its first step startSpot parked it 3 cm beside the main worker. A subagent is now present from its own first step: during the delegates only the main UFO flies (in its delegate outfit), and each subagent pops out of it, with the beam, when it starts working. Unit test updated (absent before its first step, each subagent appearing on its own first step). Test guide row updated. --- .../agent-flow/agentFlowRuntime/timelineModel.js | 10 +++++++--- .../test/analysis/agentFlowRuntime.test.cjs | 7 +++++-- docs/agent-flow/test-guide.md | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/timelineModel.js b/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/timelineModel.js index 6258bca7..400df825 100644 --- a/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/timelineModel.js +++ b/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/timelineModel.js @@ -315,8 +315,12 @@ } /** - * Where every worker is at the playhead. A worker is present from its spawn - * (main: always) until its last step is over; its current action is its + * Where every worker is at the playhead. A worker is present from its first + * step (main: always) until its last step is over. A subagent is not shown + * between the delegate that spawns it and its first step: it would only + * hover idle on top of the main UFO, a pile of saucers with overlapping + * name tags (Adrián, demo video). It pops out of the main UFO when it starts + * working instead; its current action is its * latest step at or before the playhead, and that action is ongoing until * the same worker's next step starts (or, for its final step, while the * playhead is on it or the step is still running). @@ -329,7 +333,7 @@ if (lane.steps[i] <= at) { current = lane.steps[i]; break; } } var step = current >= 0 ? timeline.steps[current] : null; - var start = lane.kind === 'main' ? -Infinity : (lane.spawnIndex >= 0 ? lane.spawnIndex : lane.firstIndex); + var start = lane.kind === 'main' ? -Infinity : lane.firstIndex; var ended = lane.kind !== 'main' && lane.lastIndex >= 0 && at > lane.lastIndex && timeline.steps[lane.lastIndex].status !== 'running'; var present = timeline.count > 0 && (lane.kind === 'main' || (start >= 0 && at >= start && !ended)); diff --git a/apps/vscode-extension/test/analysis/agentFlowRuntime.test.cjs b/apps/vscode-extension/test/analysis/agentFlowRuntime.test.cjs index 0d9f79dd..cb94ae23 100644 --- a/apps/vscode-extension/test/analysis/agentFlowRuntime.test.cjs +++ b/apps/vscode-extension/test/analysis/agentFlowRuntime.test.cjs @@ -226,9 +226,12 @@ test('actors: workers get lanes, spawn at their delegate step and work in parall // Mid-session three workers are busy at once. const mid = api.workersAt(timeline, 7); assert.deepEqual(plain(mid.map((worker) => [worker.present, worker.active, worker.stepIndex])), [[true, true, 6], [true, true, 5], [true, true, 7]]); - // Before its first step a spawned worker is present but idle; before its spawn it is absent. - assert.deepEqual(plain(api.workersAt(timeline, 2).map((worker) => [worker.present, worker.active])), [[true, true], [true, false], [true, false]]); + // A spawned worker appears with its first step, not with the delegate: until then only the main UFO flies. + assert.deepEqual(plain(api.workersAt(timeline, 2).map((worker) => [worker.present, worker.active])), [[true, true], [false, false], [false, false]]); assert.equal(api.workersAt(timeline, 0)[1].present, false); + // Each subagent pops out on its own first step: one at step 3, the second at step 4. + assert.deepEqual(plain(api.workersAt(timeline, 3).map((worker) => worker.present)), [true, true, false]); + assert.deepEqual(plain(api.workersAt(timeline, 4).map((worker) => worker.present)), [true, true, true]); // A finished subagent leaves the table. assert.deepEqual(plain(api.workersAt(timeline, 11).map((worker) => worker.present)), [true, false, false]); // A dataset from before multi-agent tracing gets one synthesized main actor. diff --git a/docs/agent-flow/test-guide.md b/docs/agent-flow/test-guide.md index d3509a8b..dfc3a6d0 100644 --- a/docs/agent-flow/test-guide.md +++ b/docs/agent-flow/test-guide.md @@ -48,7 +48,7 @@ emerald, each sub-agent in its own colour. Check each action while it plays: | What the agent did | What you should see | |---|---| -| Handed a task to a sub-agent (Claude Code's Agent/Task tool) | A beam from the main worker, and a new smaller worker that pops out and works in parallel; when its work ends it flies back and dissolves | +| Handed a task to a sub-agent (Claude Code's Agent/Task tool) | The main UFO puts on its delegate outfit. The sub-agent's own UFO pops out of it with a beam when the sub-agent takes its first step (never earlier, so saucers never pile up on the main one) and works in parallel; when its work ends it flies back and dissolves | | Read a file | The worker stands on the roof and sweeps a cyan scanning cone down the facade; the roof stays tinted cyan | | Searched (grep, glob, find) | A violet radar ripple on the table, and beacons popping up on the matched buildings | | Edited a file | Scaffolding and a small crane on the building, orange floors stacking up by the added lines (a red slice drops off for removed lines) |