From 0fa7f2362fa914eb1c01cf188a44b27b82f4d3b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Dec 2026 16:11:52 +0000 Subject: [PATCH] Agent Flow: city tweens play again, so replay builds new floors in their step The codexr-city component copied the whole city API onto itself, tick included, so A-Frame called city.tick(time, delta) every frame: the clock went in as dt and every height, fade and floor tween finished on the next frame. Replaying a step that writes a new function therefore showed the floor already built. The component now leaves A-Frame's lifecycle names alone; the view still drives the city's tick. The harness samples the new floor every frame during its step and asserts it grows over several frames, and waits for tweens to settle on software GL. --- apps/vscode-extension/CHANGELOG.md | 1 + .../agent-flow/agentFlowRuntime/cityScene.js | 10 ++++++- .../test/runners/run-agent-flow-harness.cjs | 28 +++++++++++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/apps/vscode-extension/CHANGELOG.md b/apps/vscode-extension/CHANGELOG.md index b2e52abe..b6f63186 100644 --- a/apps/vscode-extension/CHANGELOG.md +++ b/apps/vscode-extension/CHANGELOG.md @@ -18,6 +18,7 @@ - Untouched floors keep the building's grey; a floor the agent read or edited keeps a soft tint of that action. - The floors the current step reads or edits light up in the action's colour, with an outline: exactly the functions it works on, not the whole file. - A function the agent writes from scratch gets a new floor, built in front of you when the step plays. + - Replaying the timeline animates the city as it changed: moving back shows the city as it was at that point of the chat, and playing forward grows new floors, raises and lowers buildings and fades neighbours step by step. Before, every growth and fade finished on the next frame. - 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. - 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. 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 5a139911..c8b12620 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 @@ -767,6 +767,8 @@ return bound; } + var AFRAME_LIFECYCLE = ['init', 'update', 'remove', 'tick', 'tock', 'play', 'pause']; + function registerCityComponent() { var aframe = root.AFRAME; if (!aframe?.registerComponent || aframe.components?.[CITY_COMPONENT]) { return; } @@ -776,7 +778,13 @@ if (!c) { return; } var api = c.api || (c.api = bindCityApi(c)); var component = this; - Object.keys(api).forEach(function (name) { component[name] = api[name]; }); + // A-Frame calls a component's tick(time, delta) every frame: copying the + // city's tick(dt, time) there fed it the clock as dt, finishing every + // tween (heights, fades, floors) on the next frame. The view drives the + // city's tick, so lifecycle names stay A-Frame's. + Object.keys(api).forEach(function (name) { + if (AFRAME_LIFECYCLE.indexOf(name) === -1) { component[name] = api[name]; } + }); }, remove: function () { if (this.el.codexrCity && !this.el.codexrCity.external) { cityApi.dispose(this.el.codexrCity); } 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 b3bb48bc..76ef1c4e 100644 --- a/apps/vscode-extension/test/runners/run-agent-flow-harness.cjs +++ b/apps/vscode-extension/test/runners/run-agent-flow-harness.cjs @@ -125,8 +125,9 @@ async function runScenario(browser, port) { await sleep(300); await page.evaluate(() => { window.CodeXRAgentFlowRuntime.stepForward(); }); await waitFor(page, (i) => window.CodeXRAgentFlowRuntime.getState().stepIndex === i, index, 10000); - // Software GL runs at a few frames a second: wait for the hop to land. - await waitFor(page, () => !window.CodeXRAgentFlowRuntime.getState().moving, undefined, 15000); + // Software GL runs at a few frames a second and a frame advances the + // tweens by at most 64 ms: wait for the hop and the growth to land. + await waitFor(page, () => !window.CodeXRAgentFlowRuntime.getState().moving, undefined, 60000); await sleep(settleMs); return snapshot(page); }; @@ -278,7 +279,27 @@ async function runScenario(browser, port) { assert.ok(!floors.rects.includes(floors.names.indexOf('fanInOutRows')), 'a function written later is not built yet'); await shot(page, '13-floors-read-window'); // The edit that writes fanInOutRows builds its floor and lights exactly that one. + // Replayed (not live), the floor still grows in its step: sample its height every frame. + await page.evaluate((s) => { + const view = window.CodeXRAgentFlowRuntime.__testing.getView(); + const index = view.files.findIndex((file) => file.path === s || file.path.endsWith('/' + s)); + const slot = view.city.floorInstances(index)[view.files[index].floors.findIndex((floor) => floor.name === 'fanInOutRows')]; + let mesh = null; + view.rootEl.object3D.traverse((object) => { if (object.name === 'agentFlowFloors') { mesh = object; } }); + const matrix = new window.AFRAME.THREE.Matrix4(); + window.__floorGrowth = []; + const sample = () => { + mesh.getMatrixAt(slot, matrix); + window.__floorGrowth.push(matrix.elements[5]); + if (window.__floorGrowth.length < 400) { window.requestAnimationFrame(sample); } + }; + window.requestAnimationFrame(sample); + }, tooltips); state = await stepTo(15, 1600); + const growth = await page.evaluate(() => window.__floorGrowth.slice()); + const grown = growth.at(-1); + const between = new Set(growth.filter((value) => value > 0.0005 && Math.abs(value - grown) > 0.0005).map((value) => value.toFixed(4))); + assert.ok(grown > 0 && between.size >= 2, `the new floor grows over several frames (${growth.length} frames, ${between.size} in between)`); floors = await floorsOf(tooltips); assert.deepEqual(floors.lit, ['fanInOutRows']); assert.ok(floors.rects.includes(floors.names.indexOf('fanInOutRows')), 'the new floor stands once built'); @@ -449,7 +470,8 @@ async function runScenario(browser, port) { assert.equal(state.seeThrough.style, 'transparent'); await shot(page, '17-see-through'); await page.evaluate(() => window.CodeXRAgentFlowRuntime.setToggle('seeThrough', false)); - await sleep(900); + // The fade back runs on frames (at most 64 ms each): software GL needs a few seconds. + await waitFor(page, () => window.CodeXRAgentFlowRuntime.getState().seeThrough.faded.length === 0, undefined, 20000).catch(() => {}); state = await snapshot(page); assert.deepEqual(state.seeThrough.faded, [], 'toggle off: every building solid again'); await page.evaluate(() => window.CodeXRAgentFlowRuntime.setToggle('seeThrough', true));