From 21ce8bfefc67cd200a2a3d1b21f0275ce315d7dd Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Dec 2026 21:42:46 +0000 Subject: [PATCH] Agent Flow legends: the floor card stands beside the building card (#419) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adrián's test: with a floor pointed, the function card sat on top of the building card. The two now stand side by side in the wrap (building left, floor right, bottoms level), and layoutLegends uses the legend's real width so a wide legend slides sideways as a whole. --- apps/vscode-extension/CHANGELOG.md | 2 +- .../agentFlowRuntime/sceneOverlays.js | 22 ++++++++++++++----- .../test/runners/run-agent-flow-harness.cjs | 8 ++++++- docs/agent-flow/legends.md | 2 +- docs/agent-flow/test-guide.md | 4 ++-- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/apps/vscode-extension/CHANGELOG.md b/apps/vscode-extension/CHANGELOG.md index a4eb7321..0481da0a 100644 --- a/apps/vscode-extension/CHANGELOG.md +++ b/apps/vscode-extension/CHANGELOG.md @@ -32,7 +32,7 @@ - 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 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. + - Legends above the city: the building card, and the function card beside it 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 numbers on the cards are those of the moment on the timeline (lines of code, change, reads, writes), not the end of the session. - With See-through on, the buildings in front of a pinned or hovered building fade while its card is open, so it is always in sight. diff --git a/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/sceneOverlays.js b/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/sceneOverlays.js index aee8a324..bf640a1e 100644 --- a/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/sceneOverlays.js +++ b/apps/vscode-extension/templates/components/codexr/agent-flow/agentFlowRuntime/sceneOverlays.js @@ -305,7 +305,7 @@ // -- Legends: hover and pinned cards (docs/agent-flow/legends.md) ------------ // A legend is the common Code-XR card (same chrome as every other analysis) - // for the building, with a second card stacked on top for the floor + // for the building, with a second card beside it for the floor // (function) when one is pointed. Hover shows one; a click pins it (it stays // while the pointer moves on); a click on the pinned building unpins it. // Cards float in the legend band above the skyline and hang a leader line @@ -454,24 +454,34 @@ var CARD_OPTIONS = { width: LEGEND.width, columns: 2, rowStep: 0.15, animationDuration: 120, titleLength: 34, subtitleLength: 46, rowValueLength: 16 }; var FLOOR_CARD_OPTIONS = { width: LEGEND.width, columns: 2, rowStep: 0.15, animationDuration: 120, titleLength: 34, subtitleLength: 46, rowValueLength: 16, minHeight: 0.5 }; - /** Fills a legend's cards and stacks them inside the wrap (bottom edge at y = 0). */ + /** + * Fills a legend's cards and lays them out inside the wrap, bottom edges at + * y = 0: the building card alone is centred; with a floor pointed the two + * stand side by side, building on the left and floor on the right (the wrap + * faces the viewer, so its x is the viewer's right). + */ function fillLegend(legend, model) { var common = root.CodeXRCommonRuntime; common.updateTooltip(legend.building, model.building, null, CARD_OPTIONS); var buildingHeight = legend.building.height; - legend.building.root.setAttribute('position', '0 ' + (buildingHeight / 2) + ' 0'); var height = buildingHeight; + var width = LEGEND.width; if (model.floor) { common.updateTooltip(legend.floor, model.floor, null, FLOOR_CARD_OPTIONS); var floorHeight = legend.floor.height; - legend.floor.root.setAttribute('position', '0 ' + (buildingHeight + LEGEND.stackGap / LEGEND.scale + floorHeight / 2) + ' 0'); - height += LEGEND.stackGap / LEGEND.scale + floorHeight; + var offset = (LEGEND.width + LEGEND.stackGap / LEGEND.scale) / 2; + legend.building.root.setAttribute('position', (-offset) + ' ' + (buildingHeight / 2) + ' 0'); + legend.floor.root.setAttribute('position', offset + ' ' + (floorHeight / 2) + ' 0'); + height = Math.max(buildingHeight, floorHeight); + width = 2 * LEGEND.width + LEGEND.stackGap / LEGEND.scale; legend.color = model.floor.accentColor; } else { + legend.building.root.setAttribute('position', '0 ' + (buildingHeight / 2) + ' 0'); common.hideTooltip(legend.floor); legend.color = model.building.accentColor; } legend.height = height * LEGEND.scale; + legend.width = width * LEGEND.scale; } function showLegend(v, role, fileIndex, floorIndex) { @@ -566,7 +576,7 @@ var legend = v.legends?.[role]; if (!legend || legend.file < 0) { return; } var target = legendTarget(v, legend.file, legend.floorIndex); - var at = place(target.x, target.z, LEGEND.width * LEGEND.scale / 2, legend.height); + var at = place(target.x, target.z, (legend.width || LEGEND.width * LEGEND.scale) / 2, legend.height); legend.wrap.setAttribute('position', at.x + ' ' + at.y + ' ' + at.z); setLeader(legend.leader, at, target, legend.color); }); 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 78ebf16e..d5337b22 100644 --- a/apps/vscode-extension/test/runners/run-agent-flow-harness.cjs +++ b/apps/vscode-extension/test/runners/run-agent-flow-harness.cjs @@ -325,7 +325,7 @@ async function runScenario(browser, port) { assert.deepEqual(floors.lit, ['fanInOutRows']); await shot(page, '16-floors-edit-existing'); // Legends (#419): hovering a floor shows the building card with the floor - // card on top, floating above the skyline with a leader down to the floor. + // card beside it, floating above the skyline with a leader down to the floor. const legendState = (role) => page.evaluate((r) => { const runtime = window.CodeXRAgentFlowRuntime.__testing; const view = runtime.getView(); @@ -337,6 +337,8 @@ async function runScenario(browser, port) { x: position.x, y: position.y, z: position.z, visible: legend.wrap.object3D.visible, floorCard: legend.floor.root.object3D.visible, + cards: { building: legend.building.root.getAttribute('position'), floor: legend.floor.root.getAttribute('position'), buildingHeight: legend.building.height, floorHeight: legend.floor.height }, + width: legend.width, leader: legend.leader.line.object3D.visible, skyline: runtime.skylineY(view), band: runtime.legendAltitude(view), ufo: runtime.ufoAltitude(view), }; @@ -392,6 +394,10 @@ async function runScenario(browser, port) { let legend = await legendState('hover'); assert.ok(legend.floor >= 0, 'the pointer is on a floor'); assert.ok(legend.visible && legend.floorCard && legend.leader, 'hover card, floor card and leader shown'); + // Side by side, not stacked: building on the left, floor on the right, bottoms level. + assert.ok(legend.cards.floor.x > legend.cards.building.x + 1, 'the floor card stands to the right of the building card'); + assert.ok(Math.abs((legend.cards.building.y - legend.cards.buildingHeight / 2) - (legend.cards.floor.y - legend.cards.floorHeight / 2)) < 1e-6, 'both cards share the bottom edge'); + assert.ok(legend.width > legend.height, 'a legend with a floor is wider than tall'); assert.ok(legend.skyline > 0.3, 'a skyline is measured'); assert.ok(legend.ufo > legend.skyline && legend.band > legend.ufo, 'bands: skyline < UFO lane < legends'); assert.ok(legend.y >= legend.band - 1e-6, 'the hover card floats above the skyline, not among the roofs'); diff --git a/docs/agent-flow/legends.md b/docs/agent-flow/legends.md index b719f899..452803a2 100644 --- a/docs/agent-flow/legends.md +++ b/docs/agent-flow/legends.md @@ -19,7 +19,7 @@ The skyline counts every building at its tallest, so the bands do not jump while Same chrome as every other Code-XR card (`CodeXRCommonRuntime.createTooltip`): dark panel, accent frame and bar, two-column metric grid. A legend is a wrap (scale 0.36) holding: - **Building card**: file name, folder (prefixed "Pinned" when pinned), LOC, delta, reads, writes, searches, functions standing / total, turns, dependents, scope. -- **Floor card** (only when a floor is pointed), stacked on top: `name()`, "Floor n of N Lstart-end", lines, origin (new in the session or existing), reads, writes, last action. Its accent is the colour of the last action (cyan read, orange write). +- **Floor card** (only when a floor is pointed), beside the building card on the viewer's right (side by side, bottoms level, never stacked): `name()`, "Floor n of N Lstart-end", lines, origin (new in the session or existing), reads, writes, last action. Its accent is the colour of the last action (cyan read, orange write). A leader line with a marker drops from the card's bottom edge to the pointed floor's middle, or to the roof. diff --git a/docs/agent-flow/test-guide.md b/docs/agent-flow/test-guide.md index f05f1793..890da50d 100644 --- a/docs/agent-flow/test-guide.md +++ b/docs/agent-flow/test-guide.md @@ -154,7 +154,7 @@ Design and data flow: [floors.md](floors.md). 4. Step to an **Edit** inside an existing function: exactly that floor lights orange; the rest of the building keeps its soft tint. 5. Step to an **Edit** that adds a new function: its floor is not there before the step; when the step plays it grows in green between its neighbours. 6. Seek backwards past that step: the new floor disappears again. Seek forwards: it is back. -7. Rest the pointer on a floor: two cards float above the city, the building card and, on top of it, the floor card (function name, floor n of N, lines, reads/writes). See "Legends" below. +7. Rest the pointer on a floor: two cards float above the city, the building card and, beside it on the right, the floor card (function name, floor n of N, lines, reads/writes). See "Legends" below. 8. Heat and Blast radius toggles: floors only two-tone the building's colour (no per-floor tint) while a view owns the colour. 9. Live: let the agent add a function while you follow live. After the save is analysed, the new floor is built on the building. 10. Code-XR IDE: the same with a chat agent ("Watch in XR"). Steps whose tool reports a line light the floor at that line. @@ -179,7 +179,7 @@ Design: [ufo.md](ufo.md). Design: [legends.md](legends.md). Story #419. 1. Open a session with function floors. Rest the pointer on a building: its card appears **above the tallest building of the city**, never among the roofs, with a thin line down to the roof. -2. Rest the pointer on a floor: a second card (the function) sits on top of the building card, and the line goes down to that floor. +2. Rest the pointer on a floor: a second card (the function) stands beside the building card, to its right, not on top of it, and the line goes down to that floor. 3. Click the building (or a floor): the card stays ("Pinned" before the folder path). Move the pointer to other buildings: their cards appear as before, beside the pinned one when they are close, and the pinned card does not move. 4. Play or seek: the pinned card stays and its numbers follow the playhead. Seek to before the agent edited the file: Writes 0, Delta none and the LOC of the file before the session; seek forward and they grow. 5. Click the pinned building again: the pin is removed (the hover card takes over while the pointer stays on it). Clicking another building moves the pin there.