diff --git a/apps/vscode-extension/CHANGELOG.md b/apps/vscode-extension/CHANGELOG.md index c279ba16..50a8e7ec 100644 --- a/apps/vscode-extension/CHANGELOG.md +++ b/apps/vscode-extension/CHANGELOG.md @@ -29,7 +29,7 @@ - A function the agent deletes keeps its floor until that step, then the floor comes down. - Growth, fades and floors animate when a step plays; before, they finished on the next frame, so a replayed step showed its result already built. - Deleting or moving a file no longer counts as a blind edit. - - 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 848dae58..2eab7930 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, '15-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 50c6ade6..474d1300 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 0a7f134e..dad6ae84 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. @@ -164,7 +164,7 @@ Design and data flow: [floors.md](floors.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.