Skip to content

fix(ui): unbreak viz.html — OrbitControls importmap, WS URL, toast NPE (#760) - #773

Merged
ruvnet merged 2 commits into
mainfrom
fix/issue-760-sensing-ui-bugs
May 23, 2026
Merged

fix(ui): unbreak viz.html — OrbitControls importmap, WS URL, toast NPE (#760)#773
ruvnet merged 2 commits into
mainfrom
fix/issue-760-sensing-ui-bugs

Conversation

@ruvnet

@ruvnet ruvnet commented May 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Switches Three.js + OrbitControls to importmap-based ES module load (r160 removed examples/js/). THREE + THREE.OrbitControls are re-exposed as globals so the existing component modules don't need a wider refactor.
  • Replaces the hardcoded ws://localhost:8000/ws/pose with the existing buildSensingWsUrl() helper so the page hits the correct /ws/sensing endpoint regardless of port pairing (8080/8765 default, 3000/3001 Docker). ?ws=… query overrides for non-standard deployments.
  • Lazy-inits the toast container in ToastManager.show() so the "backend connected" notification no longer NPEs and kills the rest of page init (patch from Sensing UI fails to load — 3 bugs block all live data visualization #760 reporter).

Test plan

  • Start server: cargo run -p wifi-densepose-sensing-server -- --http-port 3000 --ws-port 3001 --source esp32
  • Open http://localhost:3000/ui/viz.html — 3D scene loads, no OrbitControls error in console
  • WebSocket connects to /ws/sensing, demo mode flips to live data when frames arrive
  • Toast notifications render without console errors
  • Default port pairing also works: --http-port 8080 --ws-port 8765, open http://localhost:8080/ui/viz.html

Closes #760.

🤖 Generated with claude-flow

ruvnet added 2 commits May 23, 2026 10:25
#760)

Three independent bugs were stacking to make ui/viz.html unusable from `main`:

1. Three.js r160 removed `examples/js/OrbitControls.js`, so the script-tag
   load 404'd and `new THREE.OrbitControls(...)` threw. Switch to an
   importmap that pulls the ES module build, then re-expose
   `window.THREE` and `THREE.OrbitControls` so the existing component
   modules (scene.js, body-model.js, …) keep working without a wider
   refactor.

2. The WebSocket client was hardcoded to `ws://localhost:8000/ws/pose`,
   but the sensing-server listens on `--ws-port` (8765 default, 3001 in
   the Docker image) at `/ws/sensing`. Reuse the existing
   `buildSensingWsUrl()` helper from `sensing.service.js` so port
   pairings are handled centrally, and add a `?ws=…` query-string
   override for non-standard setups. The websocket-client.js default is
   also updated to derive from `window.location` instead of the dead
   `:8000/ws/pose` literal.

3. `ToastManager.show()` called `this.container.appendChild(...)` even
   when `init()` had never been called, throwing a TypeError that
   killed the rest of page initialization. Auto-init the container
   lazily on first show (patch from issue reporter).

Closes #760.

Co-Authored-By: claude-flow <ruv@ruv.net>
Browser validation against the previous commit caught two stacked issues:

1. `import * as THREE from 'three'` returns a frozen Module Namespace
   Object — assignment `THREE.OrbitControls = OrbitControls` silently
   no-ops, so the global never gets the OrbitControls reference.

2. Two separate `<script type="module">` blocks (one installing the
   THREE global, one consuming it via Scene) are independently
   async-resolved. The second can finish dependency loading first and
   call `new THREE.OrbitControls(...)` before the first script has run.

Fixed by spreading the namespace into a plain mutable object and merging
all initialization into a single module script with `await import()` for
component modules. Order is now strictly: import THREE → install
window.THREE → import components → run init().

Validated via agent-browser: page logs `[VIZ] Initialization complete`,
WebSocket targets the correct `ws://127.0.0.1:3001/ws/sensing` endpoint
(derived from buildSensingWsUrl), toast lazy-init confirmed via eval.

Co-Authored-By: claude-flow <ruv@ruv.net>
@ruvnet
ruvnet merged commit 5d54412 into main May 23, 2026
13 checks passed
@apubowacodo054-del

Copy link
Copy Markdown

omm887275@gmail.com

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.

Sensing UI fails to load — 3 bugs block all live data visualization

2 participants