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
4 changes: 3 additions & 1 deletion apps/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
- Resting the pointer on a floor names its function, its lines and how many times it was read and written.
- Line data comes from Claude Code's edit and read results and from the Code-XR IDE's agent locations; a step without it lights the whole building, as before.
- Agents fly UFOs: each agent is a flying saucer in its colour, cruising above the tallest building and below the legends, so it is always in sight.
- Buildings are at most 0.55 m tall, so the UFOs fly at the height of a standing viewer's eyes.
- It glides from file to file at its altitude; the trail draws the flight path in the sky.
- Over the building it works on it lights a tractor beam and a halo on the roof (read colour on a read), following the building while it grows.
- Subagents fly a little lower than the main agent, so several UFOs never overlap; they are born from the main UFO and fly back to it when done.
- The UFO dresses for what it is doing: the action's colour plus an accessory. Reading glasses on a read, a magnifying glass on a search, a hard hat on an edit (green on a new file), a beacon on a run (red if it fails), thought orbs while thinking, an hourglass while waiting for permission, antennas on a delegate. The rim and the name tag keep the agent's colour.
- The UFO dresses for what it is doing: the action's colour plus an accessory. Reading glasses on a read, a magnifying glass on a search, a hard hat on an edit (green on a new file), a beacon on a run (red if it fails), thought orbs while thinking, an hourglass while waiting for permission, antennas on a delegate. The rim ring and its lights change with it; the name tag keeps the agent's colour.
- Each leg of the flight path is drawn in the colour of the action the UFO flew there to do.
- Legends above the city: the building card, and the function card on top when you point at a floor, float above the tallest building with a line down to what they describe, so they no longer hide the buildings around them.
- Click a building to pin its card; it stays while you look at others and follows the playhead. Click it again to remove it.
- The label of the current step floats in the same band.
Expand Down
3 changes: 2 additions & 1 deletion apps/vscode-extension/src/core/agent-flow/agentFlowModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ export interface AgentFlowSessionInfo {
export const AGENT_FLOW_SCHEMA_VERSION = 1;

/** The table box the city is laid out in (metres), the dependency graph's box. */
export const AGENT_FLOW_TABLE = Object.freeze({ width: 4.7, depth: 2.35, maxHeight: 0.9, minHeight: 0.04 });
/** Table size in metres; maxHeight keeps the skyline under a standing viewer's eye line (runtime CITY mirrors it). */
export const AGENT_FLOW_TABLE = Object.freeze({ width: 4.7, depth: 2.35, maxHeight: 0.55, minHeight: 0.04 });

export interface AgentFlowDataset {
schemaVersion: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
var points = [];
var colors = [];
var live = (v.workers || []).filter(function (worker) { return worker?.hop && !worker.hop.silent; }).map(function (worker) {
return { from: worker.hop.from, to: worker.hop.to, color: worker.color, upTo: worker.hop.eased };
return { from: worker.hop.from, to: worker.hop.to, color: worker.hop.color || worker.color, upTo: worker.hop.eased };
});
v.trail.hops.slice(-TRAIL_HOPS).concat(live).forEach(function (hop) {
var last = points[points.length - 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
var ROOT_ID = 'codexrAgentFlowRoot';
var ROOT_POSITION = { x: 0, y: 0.935, z: -18 };
// The city box (AGENT_FLOW_TABLE in agentFlowModels.ts) and the visible table.
var CITY = { width: 4.7, depth: 2.35, maxHeight: 0.9, minHeight: 0.04 };
// maxHeight keeps the skyline under a standing viewer's eye line (the table
// top is 0.935 m up), so the UFO lane above it is at eye height.
var CITY = { width: 4.7, depth: 2.35, maxHeight: 0.55, minHeight: 0.04 };
var SURFACE = { width: 6.514, depth: 4.118 };
// The timeline is a lectern along the front edge (the side facing the
// viewer, +z), tilted toward the user: flat on the table it would be read at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
actor: lane.index, lane: lane, color: lane.color, group: group, body: body, ring: ring, lights: lights, glow: glow, tag: tag, beam: beam,
scale: scale, rest: null, hop: null, phase: lane.index * 1.7, present: false, pop: 1, dissolve: null,
props: [], propKey: '', spot: null, beamColor: lane.color, bank: { x: 0, z: 0 },
materials: { paint: paint, glass: glass, under: under }, skin: { key: '', color: lane.color, from: null, t: 1, outfits: {} }
materials: { paint: paint, glass: glass, under: under, ring: ringMaterial, lamp: lampMaterial, glow: glow.material }, skin: { key: '', color: lane.color, from: null, t: 1, outfits: {} }
};
}

Expand Down Expand Up @@ -417,7 +417,8 @@
if (!step || step.target.type === 'none') { continue; }
var spot = spotForStep(v, i, memo);
var from = previous[step.actor] || (step.actorPrev !== null ? spotForStep(v, step.actorPrev, memo) : startSpot(v, step.actor, memo));
if (spot && from) { hops.push({ from: lift(from), to: lift(spot), color: actorColor(step.actor) }); }
// Each leg of the flight in the colour of what the UFO flew there to do.
if (spot && from) { hops.push({ from: lift(from), to: lift(spot), color: actionColor(v, step) }); }
previous[step.actor] = spot;
}
v.trail.hops = hops.slice(-TRAIL_HOPS);
Expand Down Expand Up @@ -471,16 +472,16 @@
}
if (!spot) { return; }
if (!state.motion || samePoint(worker.rest, spot)) {
if (worker.rest && !samePoint(worker.rest, spot) && stepping) { pushTrailHop(v, lift(worker.rest), lift(spot), worker.color); }
if (worker.rest && !samePoint(worker.rest, spot) && stepping) { pushTrailHop(v, lift(worker.rest), lift(spot), actionColor(v, info.step) || worker.color); }
worker.rest = spot;
setWorkerPosition(worker, spot);
return;
}
if (stepping) {
waited = true;
startHop(v, worker, spot, durationMs, onDone, false);
startHop(v, worker, spot, durationMs, onDone, false, actionColor(v, info.step));
} else {
startHop(v, worker, spot, durationMs * 1.4, null, false);
startHop(v, worker, spot, durationMs * 1.4, null, false, actionColor(v, info.step));
}
});
refreshTrail(v);
Expand All @@ -491,9 +492,9 @@
}
}

function startHop(v, worker, to, durationMs, onDone, silent) {
function startHop(v, worker, to, durationMs, onDone, silent, color) {
var from = worker.rest || to;
worker.hop = { from: from, to: to, t: 0, eased: 0, dur: Math.max(140, durationMs), onDone: onDone, silent: !!silent, liftFrom: lift(from), liftTo: lift(to) };
worker.hop = { from: from, to: to, t: 0, eased: 0, dur: Math.max(140, durationMs), onDone: onDone, silent: !!silent, liftFrom: lift(from), liftTo: lift(to), color: color || worker.color };
}

function tickWorkers(v, dt, timeMs, camera) {
Expand Down Expand Up @@ -522,7 +523,7 @@
worker.hop = null;
worker.rest = hop.to;
if (!hop.silent) {
pushTrailHop(v, hop.liftFrom, hop.liftTo, worker.color);
pushTrailHop(v, hop.liftFrom, hop.liftTo, hop.color);
}
if (hop.onDone) {
var step = v.cityState?.current;
Expand Down Expand Up @@ -817,8 +818,12 @@
if (kind === 'execute') { return { kind: 'execute', color: step.failed ? COLORS.executeFailed : COLORS.executeOk }; }
if (kind === 'write') {
// Writing a new file: the same green as its foundation and scaffold.
// Decided from the step itself (no earlier write to the file), so the
// live skin and a trail rebuilt after a seek agree.
var created = (step.files || []).some(function (fileIndex) {
return v.files[fileIndex]?.created && (v.cityState?.files?.[fileIndex]?.touches.writes || 0) <= 1;
if (!v.files[fileIndex]?.created) { return false; }
var shares = v.timeline?.writePlan?.[fileIndex]?.shares || {};
return !Object.keys(shares).some(function (key) { return Number(key) < step.index; });
});
return { kind: 'write', color: created ? COLORS.created : COLORS.write };
}
Expand Down Expand Up @@ -947,6 +952,11 @@
return { group: group, tick: tick };
}

/** The colour of the action a step does (its skin colour): rings, trail. */
function actionColor(v, step) {
return step ? skinFor(v, { color: actorColor(step.actor) }, step).color : null;
}

/** Dresses a worker for a step (or idle): action colour plus accessory. */
function setWorkerSkin(v, worker, step) {
var skin = skinFor(v, worker, step);
Expand Down Expand Up @@ -984,6 +994,11 @@
worker.materials.glass.color.set(mixHex(hex, '#ffffff', 0.55));
worker.materials.glass.emissive.set(hex);
worker.materials.under.color.set(mixHex(hex, '#ffffff', 0.25));
// The rim ring, its lamps and the glow follow the action too; the agent
// keeps its own colour on the name tag's stripe.
worker.materials.ring.color.set(hex);
worker.materials.lamp.color.set(mixHex(hex, '#ffffff', 0.4));
worker.materials.glow.color.set(hex);
}

function tickSkin(worker, dt, timeMs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// the playhead does; `v.skyExtra` lets a layer that lifts geometry above
// the roofs (the floor accordion) push them up.

var SKY = { ufoLift: 0.18, legendLift: 0.45 };
var SKY = { ufoLift: 0.12, legendLift: 0.45 };

function skylineY(v) {
var top = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@
};
}

/**
* A dataset built with taller buildings than the city allows (an older
* server, or a saved export) is scaled down to CITY.maxHeight, keeping
* the proportions between buildings, so the city always stays below the
* UFO lane and the viewer's eye line.
*/
function fitHeights(files) {
var tallest = files.reduce(function (top, file) { return Math.max(top, file.h); }, 0);
if (!(tallest > CITY.maxHeight)) { return; }
var k = (CITY.maxHeight - CITY.minHeight) / Math.max(1e-6, tallest - CITY.minHeight);
files.forEach(function (file) { file.h = CITY.minHeight + (file.h - CITY.minHeight) * k; });
}

/**
* Files a step removes, as indexes. `step.deleted` may list indexes or
* paths; without it a file flagged deleted is removed by its last step
Expand Down Expand Up @@ -86,6 +99,7 @@
function normalizeDataset(raw) {
if (!raw || typeof raw !== 'object' || !Array.isArray(raw.files)) { return null; }
var files = raw.files.map(normalizeFile);
fitHeights(files);
var fileCount = files.length;
var validFile = function (index) { return Number.isInteger(index) && index >= 0 && index < fileCount; };
var steps = (Array.isArray(raw.steps) ? raw.steps : [])
Expand Down
15 changes: 15 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 @@ -164,6 +164,8 @@ async function runScenario(browser, port) {
}
});
assert.equal(sky.workers.length, 3, 'three UFOs in the air');
const legColours = await page.evaluate(() => new Set(window.CodeXRAgentFlowRuntime.__testing.getView().trail.hops.map((hop) => String(hop.color).toLowerCase())).size);
assert.ok(legColours >= 2, `trail legs take the colour of their action (${legColours} colours)`);
sky.workers.forEach((ufo) => {
assert.ok(ufo.y > sky.skyline + 0.05, `UFO above the skyline (${ufo.y.toFixed(3)} vs ${sky.skyline.toFixed(3)})`);
assert.ok(ufo.y < sky.skyline + 0.45, 'UFO below the legend layer');
Expand All @@ -178,6 +180,14 @@ async function runScenario(browser, port) {
await lookAtLocal({ x: roof.x, y: target.y * 0.6, z: roof.z }, { x: 0.15, y: 0.05, z: 2.1 });
await sleep(900);
await shot(page, '18-ufo-sky-layers');
// Seen from a standing viewer's eyes (A-Frame's 1.6 m camera; the table
// top is 0.935 m up): the main UFO cruises about at eye height.
const EYE = 1.6 - 0.935;
const mainUfo = sky.workers.reduce((top, ufo) => (ufo.y > top.y ? ufo : top), sky.workers[0]);
assert.ok(Math.abs(mainUfo.y - EYE) < 0.2, `the UFO flies near eye height (${mainUfo.y.toFixed(3)} vs ${EYE.toFixed(3)})`);
await lookAtLocal({ x: 0, y: EYE, z: 0 }, { x: 0, y: 0, z: 2.4 });
await sleep(900);
await shot(page, '20-ufo-eye-level');

// (a3) Skins: the UFO dresses for each action (colour + accessory).
// Shown on the main UFO, one action at a time, then put back.
Expand Down Expand Up @@ -208,6 +218,11 @@ async function runScenario(browser, port) {
assert.ok(dressed.outfit, `the ${kind} skin wears its accessory`);
await lookAtLocal({ x: main.x, y: main.y + 0.03, z: main.z }, { x: 0.13, y: 0.07, z: 0.3 });
await sleep(700);
const ring = await page.evaluate(() => {
const worker = window.CodeXRAgentFlowRuntime.__testing.getView().workers[0];
return { ring: '#' + worker.materials.ring.color.getHexString(), skin: String(worker.skin.color).toLowerCase() };
});
assert.equal(ring.ring, ring.skin, `the ${kind} skin also paints the rim ring`);
await shot(page, `19-skin-${kind}${failed ? '-failed' : ''}`);
}
await page.evaluate(() => {
Expand Down
2 changes: 1 addition & 1 deletion docs/agent-flow/legends.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Story Code-XR#419 (epic #319). Proposed by Adrián on 2026-12-02 after testing t
| Band | Height | Used by |
|---|---|---|
| Skyline | `skylineY(v)`: highest roof of the session (final, current or growing height) + `v.skyExtra` | reference |
| UFO lane | `ufoAltitude(v)` = skyline + 0.18 | the worker's saucer (UFO thread, PRs #421/#422) |
| UFO lane | `ufoAltitude(v)` = skyline + 0.12 | the worker's saucer (UFO thread, PRs #421/#422) |
| Legends | `legendAltitude(v)` = skyline + 0.45 | bottom edge of every legend card and of the current-step label |

The skyline counts every building at its tallest, so the bands do not jump while the playhead moves. A layer that lifts geometry above the roofs (the floor accordion, #412) sets `v.skyExtra` to push the bands up.
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 @@ -172,7 +172,7 @@ Design: [ufo.md](ufo.md).
7. Function floors still light the floor the agent works on.
8. With reduced motion on, saucers do not spin or bob and the beam is static.
9. Code-XR IDE: the same with a chat agent ("Watch in XR").
10. Skins: step through a session and check the UFO's outfit per action (cyan + glasses on a read, violet + magnifier on a search, orange hard hat on an edit and green on a new file, green beacon on a run and red if it fails, orbs while thinking, hourglass while waiting, antennas on a delegate). The rim ring and the name tag keep the agent's colour.
10. Skins: step through a session and check the UFO's outfit per action (cyan + glasses on a read, violet + magnifier on a search, orange hard hat on an edit and green on a new file, green beacon on a run and red if it fails, orbs while thinking, hourglass while waiting, antennas on a delegate). The rim ring changes with the action; the name tag's stripe keeps the agent's colour. Each leg of the trail has the colour of the action at its end.

## Legends above the city (hover, click to pin)

Expand Down
17 changes: 14 additions & 3 deletions docs/agent-flow/ufo.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@ above the city, in table-local Y:
| Layer | Height |
|---|---|
| Legends (step label, legend cards) | `legendAltitude(v)` = skyline + 0.45 m, bottom edge |
| UFOs and their name tags | `ufoAltitude(v)` = skyline + 0.18 m |
| UFOs and their name tags | `ufoAltitude(v)` = skyline + 0.12 m |
| City | `skylineY(v)` = highest roof of the session (final, current or growing-to height, plus `v.skyExtra`) |

The main UFO flies at `ufoAltitude`; subagents fly 3, 6 or 9 cm lower (three
layers), so saucers crossing each other never meet. The name tag sits over
the dome and the thought bubble / permission sign beside it, all under the
legend layer.

### Heights (2-dec, Adrián: fly at the viewer's height)

The table top is 0.935 m up and A-Frame's camera stands at 1.6 m. Buildings
are capped at 0.55 m (`AGENT_FLOW_TABLE.maxHeight` in core and `CITY.maxHeight`
in the runtime, kept equal; a dataset built with taller buildings is scaled
down by `fitHeights` in `timelineModel.js`), so roofs end around 1.5 m and the
main UFO cruises about at eye height (~1.6 m). The harness checks the main
UFO is within 0.2 m of eye height and takes `20-ufo-eye-level.png`.

## Behaviour

- `spotForStep` returns the cruise point over the target plus `ground`: what
Expand All @@ -42,8 +51,10 @@ legend layer.

## Skins: one outfit per action (Code-XR#423)

Hull and dome take the action's colour; the rim ring and the name tag keep
the agent's colour, so several agents still read apart.
Hull, dome, rim ring, rim lamps and glow take the action's colour (Adrián,
2-dec); the agent keeps its own colour on the name tag's stripe, so several
agents still read apart. Each leg of the trail is drawn in the colour of
the action the UFO flew there to do (`actionColor`), live and after a seek.

| Action | Colour | Accessory |
|---|---|---|
Expand Down