Skip to content

feat(viewer): show the host wall of a selected door or window, and jump across the relationship - #269

Merged
DrunkOnJava merged 2 commits into
mainfrom
feat/32-viewer-host-relationship
Sep 19, 2026
Merged

DrunkOnJava merged 2 commits into
mainfrom
feat/32-viewer-host-relationship

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes the last unmet acceptance criterion of M4-04 (#32): "viewer selection shows host relationship". Selecting a door or window now shows the wall that hosts it; selecting a wall lists the doors and windows it carries. Each row jumps to the other end of the relationship — tree selection, 3-D highlight and info panel — by mouse or keyboard.

Motivation

Door/window recovery and host binding already land in the model (#211 / RE-23, 7f00dce): 2024_Core_Interior decodes 132 IFCDOOR, 6 IFCWINDOW and 138 IFCOPENINGELEMENT / IFCRELVOIDSELEMENT / IFCRELFILLSELEMENT chains, and build_scene_graph already nests doors under their host wall. The element info panel, however, dumped the raw entity — host_element_index: 631 and nothing else — so the relationship was present in the data and invisible in the UI. That criterion is what kept #32 open after the decoder work closed.

Changes

  • src/ifc/scene_graph.rs — new RelatedElement { entity_index, name, ifc_type }. ElementInfoPanel gains host (the wall a door or window sits in) and hosted (the openings a wall carries), both computed in Rust from host_element_index and both #[serde(default)] so older payloads still deserialize. Two new unit tests on a synthetic four-element model cover the host row, the hosted list in entity order, an element with neither side, and the snake_case serde shape.
  • viewer/src/worker.ts — an info request/reply pair on the existing worker protocol. The parsed model stays in worker scope and elementInfoPanel runs there per selection, rather than shipping a panel for every element up front. A panel that cannot be built replies null instead of throwing.
  • viewer/src/main.ts — one selectEntity() entry point shared by raycast picking, tree activation and the new relationship rows: selects the tree row (scrolled into view, focused), tints the matching meshes in the scene, and renders the panel. Relationship rows are real <button> elements, so Enter / Space work with no extra key handling. Tree rows carry data-entity-index so a jump can find its target. Escape clears the highlight along with the selection.
  • viewer/index.html — .info-relations / .info-relation styling in the existing panel palette.
  • viewer/tests/viewer-regression.spec.ts — a Core Interior test, gated exactly like the other large real-project test and marked test.slow(): select a door, assert the Hosted by … IFCWALL row, press Enter on it, assert the wall becomes the selected tree row and that its panel lists the openings it hosts. Einhoven has walls only, so Core Interior is the staged sample with openings.
  • docs/viewer-api.md, viewer/README.md — the new fields and the panel behaviour.

Testing

  • cargo test --all passes locally — via tools/check-local.sh --viewer (999 lib tests + all integration targets, all features).
  • cargo clippy --all-targets --all-features -- -D warnings passes.
  • cargo fmt --check passes.
  • New / changed code has unit tests — info_panel_reports_host_and_hosted_openings, info_panel_host_fields_survive_serde_as_snake_case.
  • IFC exporter: not touched. element_info_panel is viewer-side read-only over the existing model; write_step output is unchanged.
  • Element decoder: N/A — no new decoder.
  • Performance change: N/A.

Browser suite, this worktree: wasm-pack build --target web --out-dir viewer/pkg -- --features wasm --no-default-features, then RVT_VIEWER_PORT=4180 RVT_VIEWER_SAMPLE=<Einhoven> npm run test:browser — 13 passed, including the new selecting a door in Core Interior shows its host wall and jumps to it (29.2 s, dominated by the 33.7 MB decode).

Decode evidence re-measured locally on 2024_Core_Interior with rvt-ifc: 132 IFCDOOR, 6 IFCWINDOW, 138 IFCOPENINGELEMENT, 138 IFCRELVOIDSELEMENT, 138 IFCRELFILLSELEMENT. The exact id-set equality behind the count manifest (tests/fixtures/project-counts/2024-core-interior-slim.json, status known, tolerance 0) needs the paired IFC Exports/ directory, which is not in the local corpus checkout; that half stays as the recorded manifest measurement and the corpus-gated CI job, not something this PR re-ran.

Audit-honesty checklist

  • README / docs reflect the current state after this PR.
  • A resolved limitation is documented where it was described — docs/viewer-api.md and viewer/README.md.
  • No new limitation introduced. Relationship rows appear only when the model actually carries a host bind; a model without one renders no section rather than an empty heading.
  • Commit message describes what changed and why.
  • No emojis.
  • No private paths, personal email addresses, or internal jargon in committed files.
  • Reverse-engineering finding: N/A — no new format claim.

Legal and contribution hygiene

  • Licensable under Apache-2.0.
  • No Autodesk proprietary source, decompiled internals, or NDA'd SDK content.
  • No new fixtures; the test drives the already-staged MIT magnetar sample.

Breaking changes

None. host / hosted default on deserialize, and every element id and class the Playwright suite relies on (#info, .info-row, .k, .v, .tree-node.selected) is unchanged.

Screenshots or output samples

Panel for Door-80750 in 2024_Core_Interior, selected in the scene tree under Wall-80747:

ELEMENT INFO
  kind               "BuildingElement"
  ifc_type           "IFCDOOR"
  name               "Door-80750"
  …
  host_element_index 631

Hosted by
  [ Wall-80747 · IFCWALL ]     ← button; click or Enter selects the wall

Selecting that wall replaces the section with Hosts 1 opening and the Door-80750 · IFCDOOR row pointing back.

Related issues

Closes #32.

All three acceptance criteria now hold:

  1. Known corpus host walls contain openings for doors/windows — 138 opening / voids / fills triples on 2024_Core_Interior (Partition element-record recovery for walls / doors / windows: recall is 100%, precision is not #211, RE-23, 7f00dce); re-measured above.
  2. Door/window counts match manifest — 132/132 and 6/6 at tolerance 0 in tests/fixtures/project-counts/2024-core-interior-slim.json, enforced by the corpus-gated project_count_fixtures test.
  3. Viewer selection shows host relationship — this PR, with a Playwright test on the real sample.

The issue's scope bullets list sill height and hand/facing flips, which are not part of its acceptance criteria and are not claimed here; door dimensions and window carve-out remain tracked by #89 and #91.


Note

Low Risk
Read-only viewer and inspect payload changes over existing host binds; no IFC export or decode path changes, with additive serde fields and regression coverage.

Overview
M4-04 viewer acceptance: selecting a door or window now surfaces its host wall in the element info panel; selecting a wall lists hosted openings. Each relationship is a clickable control that re-selects the other element (scene tree row, 3-D mesh highlight, and panel stay in sync).

Rust (element_info_panel): adds RelatedElement and optional host / hosted on ElementInfoPanel, derived from existing host_element_index and reverse lookup over entities (serde-defaulted for backward compatibility). Unit tests cover host/hosted lists and JSON shape.

Viewer: the worker keeps the parsed model and answers { type: 'info', index } with elementInfoPanel on demand (no upfront panel per entity). Main thread adds selectEntity, mesh highlighting, tree data-entity-index / scroll-to-selection, #info-relations UI, stale-reply guarding via pendingInfoIndex, and Escape clears highlight. Docs/README updated; Playwright asserts door → host wall jump on Core Interior.

Reviewed by Cursor Bugbot for commit 5599611. Configure here.

…mp across the relationship

## Summary

The last unmet acceptance criterion of M4-04 (#32) was "viewer
selection shows host relationship". Door/window recovery and host
binding already land in the model — 132 doors, 6 windows and 138
IfcOpeningElement / IfcRelVoidsElement / IfcRelFillsElement chains on
2024_Core_Interior — and the scene tree already nests doors under
their wall, but the element info panel said nothing about the host.

`element_info_panel` now returns both ends of the relationship, and
the viewer renders them as rows that re-select the other element in
the tree, the 3-D scene and the panel.

## Changes

- `src/ifc/scene_graph.rs` — new `RelatedElement { entity_index,
  name, ifc_type }`; `ElementInfoPanel` gains `host` (the wall a door
  or window sits in) and `hosted` (the openings a wall carries), both
  `#[serde(default)]` so older payloads still deserialize. Computed in
  Rust from `host_element_index`, so the viewer does not re-derive
  the relationship.
- `viewer/src/worker.ts` — an `info` request/reply pair. The parsed
  model stays in worker scope and `elementInfoPanel` runs there per
  selection rather than shipping a panel for every element up front.
  A panel that cannot be built replies `null` instead of throwing.
- `viewer/src/main.ts` — one `selectEntity()` entry point used by
  raycast picking, tree activation and the new relationship rows:
  it selects the tree row (scrolls it into view and focuses it),
  tints the matching meshes in the scene, and renders the panel.
  Relationship rows are `<button>` elements, so Enter / Space work
  without extra key handling. Tree rows carry `data-entity-index` so
  a jump can find its target.
- `viewer/index.html` — styling for `.info-relations` /
  `.info-relation`, following the existing panel palette.
- `viewer/tests/viewer-regression.spec.ts` — a Core Interior test
  (gated like the other large real-project test, `test.slow()`):
  select a door, assert the "Hosted by ... IFCWALL" row, press Enter
  on it, assert the wall becomes the selected tree row and its panel
  lists the openings it hosts. Einhoven has walls only, so Core
  Interior is the staged sample with openings.
- `docs/viewer-api.md`, `viewer/README.md` — describe the new fields
  and the panel behaviour.

## Testing

- `tools/check-local.sh --viewer` passes (fmt, clippy -D warnings,
  rustdoc -D warnings, `cargo test --workspace --all-targets
  --all-features` with 999 lib tests, viewer typecheck + build, wasm
  network-import audit).
- Two new Rust unit tests on a synthetic four-element model cover the
  host row, the hosted list, an element with neither, and the
  snake_case serde shape.
- `RVT_VIEWER_PORT=4180 npm run test:browser` — 13 passed, including
  the new door/host test.

## Breaking changes

None. The two new fields default on deserialize; existing element
ids and classes the Playwright suite relies on are unchanged.
@cursor

cursor Bot commented Sep 19, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_bfece54e-bfe1-4a5e-aef3-c5ac692a6744)

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) September 19, 2026 18:46
@DrunkOnJava
DrunkOnJava merged commit 8425a3f into main Sep 19, 2026
21 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/32-viewer-host-relationship branch September 19, 2026 18:49
DrunkOnJava added a commit that referenced this pull request Sep 19, 2026
… dozen times (#266)

## Summary

The weekly Performance Budgets workflow fails the `medium` category on
`2024_Core_Interior.rvt`. The cost is not the geometry the August
element-record work added — it is that work re-inflating the same
partition bytes more than twenty times per export. This memoises the
inflate on the `RevitFile` handle and fixes the two per-byte scans that
dominated what was left. IFC output is byte-identical.

Measured against `main` at `8425a3f` (i.e. **after** #267, #268 and
#269), `ifc_export` goes **17.88 s to 1.45 s** and peak RSS **2642.0 MiB
to 516.2 MiB**, and every `medium` budget passes.

## Motivation

Every partition consumer opened the CFB stream, inflated all its gzip
members and concatenated them for itself:

- `partition_element_records::scan_category_records_multi` — once per
`BuiltInCategory`: columns (RE-26), walls (#211), doors and windows
(RE-23), and floors / building pads / sketch lines (RE-22, RE-25)
- `partition_arc_walls::scan_partition_arc_walls_with_limits`
- `partition_schema_mvp::floors_from_partition_plan_loops` and
`rect_openings_from_partitions`
- `partition_level_records::scan_partition_levels` (RE-24) and
`scan_partition_level_ids` (RE-27, #267)
- `partition_ifc_export_overrides::scan_ifc_export_overrides`
- `partition_scanner::scan_partitions_with_control`
- `object_graph::string_records_from_partitions`, asked for separately
by unit recovery, storey names and the partition MVP

`RvtDocExporter::export_with_diagnostics` then walks the document a
second time to build diagnostics, doubling all of it. On this file the
eight `Partitions/*` streams inflate to 178.9 MiB, so that is well over
3 GiB of redundant inflate per export — plus a byte-at-a-time
`chunks.into_iter().flatten().collect()` per pass, which profiled higher
than the inflate itself.

Hotspot shares from a `samply` profile of `rvt-ifc --mode geometry` on
the pre-change tree (inclusive, 14,467 samples):

| region | share | what it was |
| --- | --- | --- |
| inflate + per-pass concat | 33 % + 24 % |
`inflate_all_chunks_for_stream` and the `flatten().collect()` join,
repeated per consumer |
| `object_graph::extract_string_records` | 34 % (26 % in encoding_rs) |
UTF-16 decode of the whole `Partitions/NN`, run once per consumer |
| `find_category_records` | 3.6 % before, 21 % once inflate was cached |
hand-rolled substring search, once per category over every partition
byte |

## Changes

- `src/compression.rs` — new `InflatedStream`: all gzip members of one
stream inflated and concatenated once, with each member's end offset.
That is exactly the two shapes the callers were rebuilding (plain
concatenation; concatenation plus `chunk_ends` for the scanner), and it
reserves the exact total instead of growing through `Flatten`.
- `src/reader.rs` — `RevitFile::inflated_partition` memoises it per
stream path, `RevitFile::partition_stream_names` replaces six copies of
the same filter, and `RevitFile::partition_string_records` memoises the
`Partitions/NN` string extraction. `RevitFile` never writes a stream, so
one inflate is valid for the life of the handle.
- `src/partition_element_records.rs`, `src/partition_arc_walls.rs`,
`src/partition_level_records.rs`,
`src/partition_ifc_export_overrides.rs`, `src/partition_scanner.rs`,
`src/partition_schema_mvp.rs` — read through the cache instead of
re-inflating.
- `src/object_graph.rs` — `extract_string_records` screens candidates on
the raw code units before decoding. The strict test it applies (every
char graphic, space, tab or newline) is decidable on the bytes: only
ASCII encodes as `[byte, 0x00]` in UTF-16LE, and every other sequence —
non-ASCII, an astral pair, a lone surrogate that decodes to U+FFFD —
yields a char outside that set. Previously it decoded and heap-allocated
at every offset whose length field happened to land in `1..=400`, which
binary data does at a large fraction of offsets, then threw nearly all
of them away.
- `src/partition_element_records.rs` — `find_subslice` now calls
`memchr::memmem::find`, the vectorised form of the
first-byte-then-compare loop it spelled out by hand. The category sweep
runs it over ~180 MiB per category.
- `src/ifc/mod.rs` — `recover_project_units` and
`collect_partition_building_storey_names` take the shared string
records.
- `Cargo.toml` — adds `memchr = "2"`. **This adds no crate to the build
graph**: `cargo tree -p rvt -e normal -i memchr` shows memchr 2.8.0 is
already a normal (non-dev) transitive dependency through both quick-xml
and serde_json. `cargo deny check` passes (advisories ok, bans ok,
licenses ok, sources ok).

### Second commit: the RE-27 sweep

#267 landed while this was in review and added
`scan_partition_level_ids`, a new sweep over every `Partitions/*` stream
— the ~2 s its author measured on Core Interior. The follow-up commit
here routes it through `RevitFile::inflated_partition` like every other
partition consumer, so it costs a scan rather than a decompress. With
that, no partition sweep in `src/` re-inflates:

```
$ grep -rn "inflate_all_chunks_for_stream\|read_stream(&stream)\|read_stream(&partition)" src/ | grep -v "^src/compression.rs"
(no matches)
```

No behaviour flags, no new public semantics, no geometry changes.

## Testing

All numbers below were re-taken against `main` at `8425a3f`, after
merging it into this branch.

- [x] `cargo test --all` passes locally — `tools/check-local.sh` (fmt,
clippy `-D warnings`, rustdoc `-D warnings`, `cargo test --workspace
--all-targets --all-features`) exits 0. With `RVT_PROJECT_CORPUS_DIR`
set to the magnetar Revit tree: **1252 passed, 0 failed**, including
#267's new `core_interior_2024_storey_containment_is_evidence_backed`
corpus gate.
- [x] `cargo clippy --all-targets --all-features -- -D warnings` passes
- [x] `cargo fmt --check` passes
- [x] New / changed code has unit tests — no new behaviour to test; the
change is covered by the existing suite plus the byte-identity evidence
below. `tests/project_count_fixtures.rs` and `tests/witness_registry.rs`
pass against the real reference exports (`IFC
Exports/2024_Core_Interior_slim.ifc` sha256 `bfdf36ff…` and
`Revit/2024_Core_Interior.ifc` sha256 `d07c7462…`, both matching the
manifests), so every scored count — 15 storeys, 360 walls, 80 slabs, 132
doors, 6 windows, 256 columns, 20 shading devices, 138
`IFCRELFILLSELEMENT` pairs — is reproduced.
- [x] IFC exporter byte-identity — see below.
- [ ] `tools/bench.sh` — **not run**: it needs the phi-ag `rac*.rfa`
sample family, which is not in this checkout. `tools/perf_budget.py` was
used instead, which is the harness the failing workflow actually runs.

### Byte-identical output

`rvt-ifc --mode geometry`, a binary built from `main` at `8425a3f`
versus this branch, same input:

| file | main `8425a3f` | this branch | |
| --- | --- | --- | --- |
| `2024_Core_Interior.rvt` | 1,633,625 bytes | 1,633,625 bytes |
identical |
| `Revit_IFC5_Einhoven.rvt` | 44,701 bytes | 44,701 bytes | identical |

`diff` of the two STEP files with the `FILE_NAME` timestamp line
stripped reports exactly one remaining line, the other wall-clock field
the writer stamps:

```
12c12
< #5=IFCOWNERHISTORY(#3,#4,$,.ADDED.,$,#3,#4,1789844650);
---
> #5=IFCOWNERHISTORY(#3,#4,$,.ADDED.,$,#3,#4,1789844652);
```

Normalising both clock fields (drop `FILE_NAME(`, replace the
`IFCOWNERHISTORY` epoch), the two sides hash the same:

```
2024_Core_Interior   main/branch  sha256 4d1382e93b012761c7b1d7810760b0a0f4b9dabdbed0a9b336e407e0b738d489
Revit_IFC5_Einhoven  main/branch  sha256 f6c32f237338b1236757b2849148d421e7672ee5b569fc4f15545c80af640382
```

Note these hashes differ from the pre-#267 ones — that is #267's
intended storey-binding change, which this branch reproduces exactly.

There is no deterministic-timestamp switch (no `SOURCE_DATE_EPOCH`
support in `ifc::step_writer`), so the two clock fields cannot be pinned
without a behaviour change; adding one is out of scope here.

### Performance

`tools/perf_budget.py --require-category medium`, release profile,
`RVT_PROJECT_CORPUS_DIR` on the magnetar Revit tree. Both columns
measured on the same machine (Apple Silicon, macOS) minutes apart,
baseline from a clean `main` tree at `8425a3f`:

| operation | main `8425a3f` | this branch | budget |
| --- | --- | --- | --- |
| `open` | 14.86 ms / 34.6 MiB | 13.13 ms / 34.6 MiB | 1500 ms / 512 MiB
|
| `summarize` | 18.12 ms / 36.0 MiB | 18.64 ms / 36.0 MiB | 5000 ms /
768 MiB |
| `schema_parse` | 14.61 ms / 35.8 MiB | 13.75 ms / 35.7 MiB | 1500 ms /
768 MiB |
| `element_decode` | **6116 ms / 1858.0 MiB** | 919 ms / 478.5 MiB |
12000 ms / 1024 MiB |
| `ifc_export` | **17880 ms / 2642.0 MiB** | 1454 ms / 516.2 MiB | 15000
ms / 1024 MiB |
| `viewer_parse_render` | **18014 ms / 2642.6 MiB** | 1469 ms / 498.8
MiB | 18000 ms / 1024 MiB |

On this machine `main` fails all three heavy rows — `ifc_export` and
`viewer_parse_render` on time, all three on peak RSS. After, every row
passes with an order of magnitude of headroom.

`rvt-ifc --mode geometry` on `2024_Core_Interior.rvt` under
`/usr/bin/time -l`, best of three:

| | wall | peak RSS |
| --- | --- | --- |
| main `8425a3f` | 26.07 s | 2641.4 MiB |
| this branch | **1.69 s** | **490.1 MiB** |

`Revit_IFC5_Einhoven.rvt` control: 0.44 s / 25.1 MiB on main, 0.12 s /
20.7 MiB on this branch.

For reference, the same comparison taken before #267 landed (main at
`730699c`): `ifc_export` 17352 ms to 1366 ms, `element_decode` 5682 ms
to 866 ms. #267 added roughly 0.5-0.9 s of `ifc_export` on the
unoptimised side and none on this one, because its new sweep now reads
an already-inflated buffer.

**No budget change is proposed and none is needed.** Extrapolating to
the GitHub runner from the ratio the workflow reported on the pre-#267
tree — CI `element_decode` 8.5 s against 5.62 s here, CI `ifc_export`
24.5 s against 17.25 s here, so roughly 1.4–1.5× — these numbers project
to about 1.3 s for `element_decode`, 2.1 s for `ifc_export` and 2.1 s
for `viewer_parse_render`, against budgets of 12 s, 15 s and 18 s. Worth
noting that on this machine #267 pushed `viewer_parse_render` past its
18 s budget too (18014 ms against 18000 ms), so the `medium` category
was getting worse, not stable.

One honest caveat on the memory column: the workflow reported ~480–510
MB peak RSS for the failing baseline, where this macOS machine measures
~2640 MiB for the same baseline binary. That is an allocator difference,
not a measurement error — glibc returns freed pages to the OS where
macOS libmalloc retains them, and the baseline's repeated 180 MiB
transient allocations are exactly the pattern that exposes it. The
direction of the change is the same on both platforms: one retained copy
of the inflated partitions replaces many transient ones, and peak RSS
should fall on Linux too.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR — no doc
claims change; this is a pure performance change with identical output
- [x] If a limitation was resolved, the relevant docs are updated — N/A,
no limitation resolved
- [x] If a new limitation was introduced, it is documented — one
tradeoff, documented in-code on `RevitFile::inflated` and
`InflatedStream`: the inflated `Partitions/*` bytes (178.9 MiB on this
file) now stay resident for the life of the handle rather than being
rebuilt per consumer. Measured peak RSS falls sharply anyway, because
the transient copies it replaces cost more than the one it keeps.
- [x] Commit messages describe WHAT changed and WHY
- [x] No emojis in code, docs, or commit messages
- [x] No private paths, personal email addresses, or internal jargon in
committed files
- [x] If this is a reverse-engineering finding: N/A, no new finding — no
decoder, offset or record shape changes

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0
- [x] No Autodesk proprietary source, decompiled internals, or NDA'd SDK
content
- [x] No new test fixtures

## Breaking changes

None. Three additions to `RevitFile`'s public surface
(`inflated_partition`, `partition_stream_names`,
`partition_string_records`) and one new public type
(`compression::InflatedStream`);
`object_graph::string_records_from_partitions` keeps its signature and
now returns a clone of the shared result.

## Screenshots or output samples

IFC output is byte-identical to `main` at `8425a3f` — see the diff and
hashes above.

## Related issues

Refs the `Performance Budgets` workflow `medium` category failure.
Builds on #267 (RE-27), whose new partition sweep the second commit
routes through the same cache. No issue number was given for the budget
failure.
DrunkOnJava added a commit that referenced this pull request Sep 19, 2026
…272)

## Summary

Selecting an element used to dump the raw element record into the info
panel — `property_set` arrived as one long
`{"name":"RvtElementRecordGeometry","properties":[...]}` string,
`location_feet` and `extrusion` as raw arrays and objects, index fields
as bare numbers, and every absent optional as a dash — while the
schedule said "872 scheduled elements" and nothing else. Both now read
as words, with the structure computed in Rust (`element_info_panel` /
`build_schedule`) and only the rendering in `viewer/src/main.ts`.

## Motivation

The panel and the schedule were the two places where the viewer still
spoke in record fields rather than in the building. A person inspecting
a door could see `storey_index: 2` but not which level that is,
`extrusion: {…}` but not how tall the door is, and a dash where a field
was simply absent — indistinguishable from a field the decoder failed
on. The schedule's single count said nothing about what the 872 elements
actually are.

## Changes

- **`src/ifc/scene_graph.rs`** — `ElementInfoPanel` gains
`property_group`, `placement_rows`, `extent_rows`, `storey`, `material`,
`predefined_type` and `missing`; new `PanelRow`, `PanelProperty`,
`PanelPropertyGroup`, `PanelStorey`, `PanelMaterial` types. `Schedule`
gains `groups` (`ScheduleTypeGroup { ifc_type, count, entity_indices,
storeys }`) built by `Schedule::from_rows`. Property values carry their
unit; booleans format as `Yes` / `No`; a value that rounds to zero
prints `0.000 ft`, never `-0.000 ft`.
- **`src/ifc/gltf.rs`** — `build_gltf` now writes `extras: {
entityIndex, ifcType }` on every element node (new `NodeExtras`).
- **`viewer/src/main.ts`** — the panel renders entirely from the Rust
payload; per-type and per-material scene highlight; schedule breakdown;
storey jump; empty-optional omission and the diagnostics-backed gap
note.
- **`viewer/index.html`** — panel band and schedule styles; the
schedule's live region is now a persistent child so only the total line
announces.
- **`viewer/tests/viewer-regression.spec.ts`** — extended project-sample
and Core Interior coverage, plus a new schedule test.
- **`docs/viewer-api.md`, `docs/viewer-build-pipeline.md`** — document
the new payload fields and where `userData.entityIndex` /
`userData.ifcType` actually come from.

### What the panel shows now

Selecting `Door-80750` in Core Interior:

```
Name        Door-80750
Type        IFCDOOR · DOOR
GUID        80750
Storey      Level 1 · 0.000 ft          <- selects that storey in the tree
Placement   X 100.790 ft  Y 78.500 ft  Z 0.000 ft
Extents     Width 3.585 ft  Depth 3.501 ft  Height 7.251 ft  Profile Rectangle
RvtElementRecordGeometry
            BodySource          partition_element_record_bbox
            ProfileResolved     No
            LevelBindResolved   Yes
            BoundingBoxHeight   7.251 ft
            LevelElementId      20268
            LevelBindSource     partition_element_record_reference_list
            SourceStream        Partitions/59
            StoreyBindSource    record_level_reference
Hosted by   Wall-80747 · IFCWALL
```

Sets longer than eight properties collapse behind a native `<details>`.
Absent optionals are omitted; a one-line `Not recovered: …` note names a
field only where the export diagnostics confirm it as a known decode gap
(`unsupported_geometry_missing_level`, `partial_element_geometry`,
`revit_element_parameters_to_ifc_property_sets`, and so on), so an
omission is never mistaken for a failure and a failure is never silently
omitted.

### What the schedule shows now

```
872 scheduled elements · 7 types
IFCWALL           360   Clear
IFCCOLUMN         256   Highlight
IFCDOOR           132   Highlight
IFCSLAB            80   Highlight
IFCSHADINGDEVICE   20   Highlight
IFCSPACE           18   Highlight
IFCWINDOW           6   Highlight
```

Each row toggles a tint over every mesh of that type. The affordance
only appears when the scene actually has tintable meshes; a scaffold
export with no geometry gets counts only.

### The glTF extras fix

`build_gltf` wrote no `extras` at all, so `userData.entityIndex` and
`userData.ifcType` were never populated — which meant raycast picking,
the selection highlight, and the category visibility toggles were all
inert against the 3-D scene, despite `docs/viewer-build-pipeline.md`
documenting `userData.entityIndex` as "set when building the scene".
Writing the extras is what makes the new per-type and per-material
highlights act on the scene, and it repairs those three pre-existing
behaviours at the same time.

### Presentation

Keeps the dark dense engineering identity and adds one motif: a 2 px
left rule whose colour says what a band is — grey for inert data, accent
for somewhere you can navigate to, amber for a decode gap — matching the
rule the status rows and the scaffold note already use. New numeric rows
use `font-variant-numeric: tabular-nums` in the panel's own face rather
than introducing a second family. Everything is CSS custom properties,
no new dependencies, no external resources, and the existing
reduced-motion and focus-ring rules cover the new controls.

## Testing

- [x] `cargo test --all` passes locally
- [x] `cargo clippy --all-targets --all-features -- -D warnings` passes
- [x] `cargo fmt --check` passes
- [x] New / changed code has unit tests — 17 new Rust unit tests across
`scene_graph` (resolved storey/material, typed property rows,
placement/extents labelling, profile naming, `missing`, negative-zero,
serde round-trip, schedule grouping) and `gltf` (extras present on every
element node, camelCase serialization)
- [x] If this touches the IFC exporter: no `step_writer` change;
`tests/fixtures/synthetic-project.ifc` output is unchanged
- [x] N/A: no new element decoder
- [x] N/A: not a performance change

Browser suite: `RVT_VIEWER_PORT=4181
RVT_VIEWER_SAMPLE=<Revit_IFC5_Einhoven.rvt> npm run test:browser` —
14/14 passed. The project-sample test asserts the titled property group,
the typed value kinds, `Yes` / `No` booleans, unit-carrying lengths, the
labelled placement and extents rows, that no row renders a bare dash,
and that the storey link selects that storey in the tree by keyboard. A
new test asserts the schedule's per-type counts sum to the reported
total and that the per-type highlight toggles. The Core Interior test
asserts the collapsed property group.

Three existing assertions that pinned the panel to raw record keys
(`#info` contains `ifc_type`) were updated to the new copy — that
display was the defect this PR fixes.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR
- [x] If a limitation was resolved, the relevant docs are updated —
`docs/viewer-build-pipeline.md` no longer claims `userData.entityIndex`
is set without saying what sets it
- [x] If a new limitation was introduced, it is documented — see Known
limitations below
- [x] Commit messages describe WHAT changed and WHY
- [x] No emojis in code, docs, or commit messages
- [x] No private paths, personal email addresses, or internal jargon in
committed files
- [x] N/A: not a reverse-engineering finding

### Known limitations

- Neither corpus sample binds a material to an element —
`IfcRelAssociatesMaterial` count is 0 for both Einhoven and Core
Interior, because `revit_compound_assemblies_and_walltype_widths` is
still unsupported. The material band and its highlight are therefore
covered by Rust unit tests only and are not exercised by the browser
suite; the project-sample test instead asserts the band is omitted
outright and that the panel does not falsely claim material was "not
recovered" (the diagnostics report 42 recovered materials, they are just
unbound).
- The gap note is only as good as the diagnostics. A field that is
absent for a reason the diagnostics do not name is omitted silently
rather than guessed at, which is the intended trade.
- `elementInfoPanel` still round-trips the whole model through
`serde-wasm-bindgen` per selection. That is pre-existing and fast enough
on the 33.7 MB sample, but it is the obvious next thing to cache if
selection ever feels slow.

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0
- [x] This PR contains no Autodesk proprietary source, decompiled
internals, or NDA'd SDK content
- [x] N/A: no new test fixtures

## Breaking changes

None for the viewer. `Schedule` gains a public `groups` field, so any
external code constructing it with a struct literal should switch to
`Schedule::from_rows`; nothing in this repository did.

## Screenshots or output samples

Attached in the PR thread: the element info panel with `Door-80750`
selected in Core Interior, and the schedule breakdown with `IFCWALL`
highlighted. Both 1600x1000, headless Chromium.

## Related issues

Refs #264, #269.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches core viewer UX and glTF export identity on every mesh;
behavior is well-tested but schedule/panel payloads grew and highlight
logic now depends on extras being present.
> 
> **Overview**
> The element info panel and schedule are now **display-ready from
Rust** instead of dumping raw entity records in the browser.
**`element_info_panel`** adds resolved storey/material objects, typed
**`property_group`** rows, **`placement_rows`** / **`extent_rows`**,
**`missing`**, and humanized formatting (units, **Yes/No**,
negative-zero feet). **`Schedule`** adds **`groups`**
(`ScheduleTypeGroup`) for per-IFC-type counts, entity indices, and
storeys, built via **`Schedule::from_rows`**.
> 
> **`build_gltf`** now writes **`extras: { entityIndex, ifcType }`** on
every element node so Three.js **`userData`** enables picking, category
toggles, and the new **per-type** and **per-material** scene highlights.
> 
> The viewer renders banded panels (storey jump, collapsible properties,
diagnostics-backed “not recovered” notes), a **schedule breakdown** with
toggle highlights, and updated styles/tests/docs to match.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
bc75856. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

M4-04: Recover doors and windows with host relationships

1 participant