Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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));
Expand Down
7 changes: 5 additions & 2 deletions apps/vscode-extension/test/analysis/agentFlowRuntime.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions apps/vscode-extension/test/runners/run-agent-flow-harness.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion docs/agent-flow/test-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
Loading