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: 2 additions & 2 deletions .claude/docs/XR_COMPONENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ The analysis table is the central XR surface; the old "pedestal" was split into
## Chart system

- **Registry**: `src/core/charts/chartRegistry.ts` (`BabiaChartRegistry` singleton) — chart types + dimension requirements (`models/chartModels.ts`: `ChartMetadata`, `DimensionMapping`).
- **Presentation contract**: `src/core/charts/chartPresentation.ts` (`CHART_PRESENTATION_PROFILES`) is the single source for how every chart presents on the table — entity rotation (pie/donut stand at `90 0 0`, Babia's own convention), containment fit strategy (`uniform` / `planar-uniform` / per-axis), base component attributes beyond the mapped fields (bubbles' `heightMax`/`radiusMax`, cyls' `radiusMax`, boats' full base), row budget + ranking dimension for the top-N data slice, the Babia element-key dimensions (duplicate keys collapse elements, so slices de-duplicate), and `surfaceLift` (clearance above the anchor plane — it sits at the tabletop slab, ~1.7 cm under the visible glass, which slices round-bottomed geometry; note the anchor's ~1.5 cm anti-jitter deadband swallows smaller lifts). Templates are BUILT from it (`buildChartEntityHtml` in `templateCharts.ts`), the scene injects it as JSON (`#codexr-chart-base-config`, `createStructure.ts`), and the mapping runtime keeps a fallback mirror — same pattern that already protected babia-boats.
- **Presentation contract**: `src/core/charts/chartPresentation.ts` (`CHART_PRESENTATION_PROFILES`) is the single source for how every chart presents on the table — entity rotation (pie/donut stand at `90 0 0`, Babia's own convention), containment fit strategy (`uniform` / `planar-uniform` / per-axis), base component attributes beyond the mapped fields (bubbles' `heightMax`/`radiusMax`, cyls' `radiusMax`, boats' full base, and `animation: false` on bars/barsmap/cyls/cylsmap, whose BabiaXR default grows them from the floor while containment measures them), an optional `maxHeight` in metres that widens a uniform fit's height band (pie/donut stand up to 2 m), row budget + ranking dimension for the top-N data slice, the Babia element-key dimensions (duplicate keys collapse elements, so slices de-duplicate), and `surfaceLift` (clearance above the anchor plane — it sits at the tabletop slab, ~1.7 cm under the visible glass, which slices round-bottomed geometry; note the anchor's ~1.5 cm anti-jitter deadband swallows smaller lifts). Templates are BUILT from it (`buildChartEntityHtml` in `templateCharts.ts`), the scene injects it as JSON (`#codexr-chart-base-config`, `createStructure.ts`), and the mapping runtime keeps a fallback mirror — same pattern that already protected babia-boats.
- **Rotation has exactly one owner: the presentation profile.** Anywhere a babia chart component is attached to an entity, the entity's `rotation` must be (re)derived from `getChartPresentation(chartId).rotation` — never inherited, never left over. Three builders learned this the hard way and now follow it: the live switch (`applyChartTypeToEntity`), the evolution movie (`buildEvolutionChart`) and the comparison clones (`createChartFromTemplate`). The same applies to the `data-codexr-active-chart-id` marker, which the containment reads to pick the fit strategy and the surface lift — a stale marker mis-fits the chart. Note that the containment's own transform snapshots (`cloneTransform`/`restoreTransform`) deliberately carry position, scale and visibility only, so they can never be the source of a rotation problem.
- **Row-budgeted datasource**: every chart except boats reads from a CodeXR-maintained sliced `babia-queryjson` entity (`codexrChartDataSlice__<source>`, `chartDataSlice.js` part of the mapping runtime). The slice ranks rows by the mapped magnitude, honours `numeric-positive` value rules by VALUE (a zero radius makes babia-cylsmap compute `-Infinity` axis lengths), and keeps one row per Babia element key. It subscribes to the real producer's NotiBuffer, so re-analysis pushes and evolution frame swaps flow through.
- **Row-budgeted datasource**: every chart except boats reads from a CodeXR-maintained sliced `babia-queryjson` entity (`codexrChartDataSlice__<source>`, `chartDataSlice.js` part of the mapping runtime). The slice ranks rows by the mapped magnitude, honours `numeric-positive` value rules by VALUE (a zero radius makes babia-cylsmap compute `-Infinity` axis lengths), and keeps one row per Babia element key. It subscribes to the real producer's NotiBuffer, so re-analysis pushes and evolution frame swaps flow through. Since 1.2.1 that is true for every producer, not just the main `data`: project evolution (`codexrChartDataSlice__codexrProjectEvolutionData`) and each comparison side (`codexrChartDataSlice__codexrComparisonData{Left,Right}`) warm their slice with `prepareChartDataSlice()` and wait for its NotiBuffer before building the chart on it (A-Frame lists a component before its `init()` runs, so "the component exists" is not enough). A slice whose producer was removed and rebuilt under the same id re-subscribes to the new one. `getChartFromSource` keeps any flat producer a chart already reads and only swaps a tree for `data` (it used to fall back to `data`, re-slicing the main dataset from the evolution chart).
- **Validation**: `processing/dimensionValidator.ts` validates mappings against the Python-derived field schema (see `PYTHON_ANALYSIS.md` → field-schema contract) before launch. The in-scene Mapping UI performs transactional mapping changes with safe recovery.
- **Default hierarchical chart is Babia Boats.** The custom `code-xr-boats` ("Code City") prototype was **deleted on `fix/gitcontroller` (2026-07-25)** — nothing injected it, generated scenes use `babia-boats`, and old configs migrate (see V1.2.0_STATUS.md).

Expand Down
10 changes: 10 additions & 0 deletions apps/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
- The table fit checked the chart's size but not its position: centring the bars could push the axis off one side. The axes are now kept on the table, and a chart that still sticks out is no longer reported as fitted.
- The fit could measure a cached, outdated size of a line that had just changed. Sizes are now re-read when the geometry changes.
- Generated scenes first built every chart over all files and only then switched to the top 20/30 shown. They now build once, from the files that are shown.
- **Charts no longer flash oversized, grow into towers or leave the table while they are rebuilt.** Every way a chart is (re)built now follows the same rules: it reads the row-limited data, stays hidden until it has been fitted to the table, and only then appears.
- Switching chart type drew the new chart at the previous chart's scale for a moment, up to 75 m wide. It is now hidden until fitted.
- Bar and cylinder charts grew up from the floor on their first build, reaching 26-32 m before the fit caught up. BabiaXR's grow animation is now off for them.
- The project evolution movie built every frame from all of its files (a 160-file frame gave a wall of 138 bars that sat oversized for almost 4 s). Frames now use the same top 20/30 as the classic analysis, a frame that would overflow is hidden until it is fitted, and frames no longer wait for an animation that never ran.
- Each side of a historical comparison now shows the top files of its own revision instead of all of them, and starts from the chart's own scale instead of a fixed one that squashed pie, donut and bubble charts.
- Changing which field labels the bars no longer leaves "ghost" bars from the previous mapping behind.
- A mapping with no files to show says "No files to show for this mapping." instead of blaming the mapping or showing "still rebuilding" forever.
- Bubble charts rested their smallest bubble on the table and sank their axes up to 0.6 m into it. The lowest of the bubbles and the axes now rests on the table.
- Pie and donut charts stand up to 2 m tall (they were about 1.3 m), so their sectors and labels are readable from the controller position.
- A live re-analysis no longer undoes a remap you made while the charts were refreshing, and a second chart change made in project evolution while the first is applied is no longer ignored.
- A source file of the XR chart-mapping runtime contained a raw control character typed into a string. Behaviour was correct, but the file was invisible to code search and review tools. It now uses the equivalent escape sequence; the runtime value is identical.

## [1.2.0] - 2026-07-30
Expand Down
25 changes: 21 additions & 4 deletions apps/vscode-extension/src/core/charts/chartPresentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ export interface ChartPresentationProfile {
* against jitter, so a lift only takes effect above that.
*/
surfaceLift?: number;
/**
* Tallest the chart may stand above the table, in metres, replacing the
* table's height band for this chart. Only the standing pie and donut set
* it: a standing disc's height IS its diameter, so the band sized for bar
* heights held them to ~1.27 m across on a 5.6 m table (CHARTS-15).
*/
maxHeight?: number;
/**
* Component attributes the chart always needs beyond the mapped fields
* (normalization caps, title placement, boats construction). Merged under
Expand All @@ -125,23 +132,31 @@ export interface ChartPresentationProfile {
baseAttributes: Record<string, string | number | boolean>;
}

// Pie and donut stand on the table as discs up to 2 m across: large enough to
// read the slices from the table's edge, low enough that the top stays near
// eye height for a standing user (decision recorded for epic #72, story S8).
const STANDING_DISC_MAX_HEIGHT = 2;

export const CHART_PRESENTATION_PROFILES: Record<string, ChartPresentationProfile> = {
// The row charts are built with Babia's grow animation OFF. Bars and
// cylinders default to growing from 0 over 2 s, and containment fitted
// them mid-growth: towers 25-36 m tall for ~3 s on every build (CHARTS-5).
bars: {
rotation: '0 0 0',
initialScale: '1.5 1.5 1.5',
fit: 'planar-uniform',
rowBudget: 20,
orderBy: 'height',
keyBy: ['x_axis'],
baseAttributes: {},
baseAttributes: { animation: false },
},
barsmap: {
rotation: '0 0 0',
initialScale: '1.5 1.5 1.5',
rowBudget: 30,
orderBy: 'height',
keyBy: ['x_axis', 'z_axis'],
baseAttributes: {},
baseAttributes: { animation: false },
},
cyls: {
rotation: '0 0 0',
Expand All @@ -150,7 +165,7 @@ export const CHART_PRESENTATION_PROFILES: Record<string, ChartPresentationProfil
rowBudget: 20,
orderBy: 'height',
keyBy: ['x_axis'],
baseAttributes: { radiusMax: 1 },
baseAttributes: { radiusMax: 1, animation: false },
},
cylsmap: {
rotation: '0 0 0',
Expand All @@ -159,12 +174,13 @@ export const CHART_PRESENTATION_PROFILES: Record<string, ChartPresentationProfil
rowBudget: 30,
orderBy: 'height',
keyBy: ['x_axis', 'z_axis'],
baseAttributes: { radiusMax: 1 },
baseAttributes: { radiusMax: 1, animation: false },
},
pie: {
rotation: '90 0 0',
initialScale: '1.5 1.5 1.5',
fit: 'uniform',
maxHeight: STANDING_DISC_MAX_HEIGHT,
rowBudget: 12,
orderBy: 'size',
keyBy: ['key'],
Expand All @@ -174,6 +190,7 @@ export const CHART_PRESENTATION_PROFILES: Record<string, ChartPresentationProfil
rotation: '90 0 0',
initialScale: '1.5 1.5 1.5',
fit: 'uniform',
maxHeight: STANDING_DISC_MAX_HEIGHT,
rowBudget: 12,
orderBy: 'size',
keyBy: ['key'],
Expand Down
1 change: 1 addition & 0 deletions apps/vscode-extension/templates/components/COMPONENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ its parts directory. Manual harnesses load assembled copies from
- `codexr/analysis-table/analysisTableRuntime.js`
- Owns the XR table, visual surface, table modes and chart containment.
- The anchor pass centres the chart's PRIMARY bounds (bars, sectors) and then shifts it just enough to keep the CONTAINMENT bounds (axes included) on the usable tabletop; `getChartStatus()` reports `off-table` (with `overhangX/Z`) instead of `ok` while they stick out. Measurements recompute a geometry's bounding box whenever its position attribute changed (`refreshGeometryBoundingBox`): three.js never invalidates the cached box, and Babia axes rewrite their positions in place.
- **Rebuild and reveal (1.2.1).** A chart that is being (re)built is hidden until its first fit: containment's `beginRebuild(reason)` hides `object3D` (on init, on a chart switch from `applyChartTypeToEntity`, and during a data transition whose new rows overflow the table, via `guardDataTransitionOverflow` in `tick`), the first `tryNormalize` fits without animating and calls `finishReveal()`, and a 6 s safety timer (`CHART_REVEAL_SAFETY_MS`) reveals it whatever happens. A chart whose source has zero rows (`resolveChartSourceRowCount`, read from the producer's NotiBuffer) enters an explicit empty state (`reason: 'no-data'`) instead of an axis error or an endless "rebuilding". The tabletop anchor rests the LOWER of the primary and containment floors on the table, so a scatter chart's axes no longer sink below its smallest bubble. `requestRenormalize` has a trailing edge, so the last request of a burst (the one that sees the finished geometry) always runs.
- `babiaCompat.js` part: two BabiaXR 1.3.4 compatibility patches, installed at load (before any entity initialises). (1) Axis lines are written directly instead of through `animation__<axis>axis`, which A-Frame 1.7.1 never applies to `line.end` (an axis otherwise keeps the length of its first build forever); every resize asks the enclosing containment for one re-fit. (2) A `babia-queryjson` with neither `data` nor `url` waits instead of fetching the empty URL (the page itself): generated scenes declare the row slice that way, so a row-budgeted chart's first build is already the slice.
- Containment applies a per-chart fit strategy (`chartFitProfiles.js` part): `uniform` for circular charts (pie/doughnut stand rotated 90° — one factor on all axes so the disk stays circular), `planar-uniform` for row charts with flat axis labels or round geometry (x/z converge to the same scale value), per-axis for everything else.
- `codexr/xr-chart-mapping-ui/xrChartMappingUiRuntime.js`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,46 @@
return true;
}

var CHART_SOURCE_PRODUCER_COMPONENTS = ['babia-queryjson', 'babia-treebuilder', 'babia-filter'];

/**
* Rows the chart's data source currently holds: 0 when the producer has an
* empty array, null when it cannot tell (no producer yet, no data yet, or a
* shape it does not know). Containment uses it to tell an empty dataset
* (nothing to draw: say so) from geometry that is still being built.
*/
function resolveChartSourceRowCount(el) {
var components = el && el.components;
if (!components) {
return null;
}
var names = Object.keys(components);
for (var i = 0; i < names.length; i += 1) {
var name = names[i];
if (name.indexOf('babia-') !== 0 || CHART_SOURCE_PRODUCER_COMPONENTS.indexOf(name) !== -1) {
continue;
}
var from = components[name] && components[name].data && components[name].data.from;
if (!from || typeof from !== 'string') {
continue;
}
var doc = el.ownerDocument || root.document;
var producerEl = doc && typeof doc.getElementById === 'function' ? doc.getElementById(from) : null;
if (!producerEl || !producerEl.components) {
return null;
}
for (var j = 0; j < CHART_SOURCE_PRODUCER_COMPONENTS.length; j += 1) {
var producer = producerEl.components[CHART_SOURCE_PRODUCER_COMPONENTS[j]];
var buffered = producer && producer.notiBuffer ? producer.notiBuffer.data : undefined;
if (Array.isArray(buffered)) {
return buffered.length;
}
}
return null;
}
return null;
}

installBabiaAxisLineCompat(AFRAME);
installBabiaQueryJsonCompat(AFRAME);

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,35 @@
return 0;
}

/**
* The tallest the chart may stand above the table, in metres, when its
* presentation profile overrides the table's height band (the standing pie
* and donut: a disc's height IS its diameter, so the band built for bar
* heights capped them at ~1.27 m on a 5.6 m table). Null when the band
* applies.
*/
function resolveChartMaxHeight(el) {
var chartId = el && typeof el.getAttribute === 'function' ? (el.getAttribute('data-codexr-active-chart-id') || '') : '';
var mappingRuntime = root.CodeXRMappingUiRuntime;
if (chartId && mappingRuntime && typeof mappingRuntime.getChartPresentation === 'function') {
var profile = mappingRuntime.getChartPresentation(chartId);
if (profile && Number.isFinite(profile.maxHeight) && profile.maxHeight > 0) {
return profile.maxHeight;
}
}
return null;
}

/** The containment data with the chart's own height cap folded into the band. */
function resolveChartFitData(el, data) {
var maxHeight = resolveChartMaxHeight(el);
if (!maxHeight || !data || !(data.targetHeight > 0)) {
return data;
}
var ratio = clamp(maxHeight / data.targetHeight, 0.06, 2.5);
return Object.assign({}, data, { heightBandMaxRatio: ratio });
}

function resolveChartFitMode(el) {
if (!el) {
return 'per-axis';
Expand Down
Loading
Loading