Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

The page's metrics panel script lives in src/ui/metrics-panel.js - no behaviour change #118

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

The Metrics panel's script now lives in Software/so101/src/ui/metrics-panel.js, and viewer.html imports it the first time Metrics is clicked, the same way as machine-panel.js. Type check is clean.

Notes

shipped merged

opened this

The Metrics panel's script now lives in Software/so101/src/ui/metrics-panel.js, and viewer.html imports it the first time Metrics is clicked, the same way as machine-panel.js. Type check is clean. The ui and server tests give 105 pass and 1 fail: "serves the model, its meshes and the vendored libraries", which hit "bun is unable to write files to tempdir: ReadOnlyFileSystem" here. I didn't check whether it also fails without my change.

  • Escaping: the old code put counter values, joint names and peak figures into innerHTML unescaped. The module now escapes every value it prints. The events list is still built from text nodes.
  • Rendering helpers: the module exports esc, summaryRows, summaryHtml, peaksHtml and eventParts. showMetrics fetches /metrics and fills the panel.
  • Page wiring: viewer.html keeps the button and the 5-second refresh, and showMetrics there now loads the module. If the module fails to load, the page shows a "the Metrics panel did not load" message.
  • Tests: ui/metrics-panel.test.ts is new and covers the helpers, including escaping. In server.test.ts I added metrics-panel.js to the list of modules the page must not load up front and a check that the page imports it lazily.
  • Test I changed: "never builds HTML from people's text" in server.test.ts looked for the $("events").replaceChildren( line in the page. That code moved, so the test was wrong. It now applies the same check to the served metrics-panel.js.

The forge's full check hasn't run yet.

🤖 Generated with Claude Code

Closes #96

commented

The Metrics panel's script now lives in Software/so101/src/ui/metrics-panel.js, and viewer.html imports it the first time Metrics is clicked, the same way as machine-panel.js. Type check is clean. The ui and server tests give 105 pass and 1 fail: "serves the model, its meshes and the vendored libraries", which hit "bun is unable to write files to tempdir: ReadOnlyFileSystem" here. I didn't check whether it also fails without my change.

  • Escaping: the old code put counter values, joint names and peak figures into innerHTML unescaped. The module now escapes every value it prints. The events list is still built from text nodes.
  • Rendering helpers: the module exports esc, summaryRows, summaryHtml, peaksHtml and eventParts. showMetrics fetches /metrics and fills the panel.
  • Page wiring: viewer.html keeps the button and the 5-second refresh, and showMetrics there now loads the module. If the module fails to load, the page shows a "the Metrics panel did not load" message.
  • Tests: ui/metrics-panel.test.ts is new and covers the helpers, including escaping. In server.test.ts I added metrics-panel.js to the list of modules the page must not load up front and a check that the page imports it lazily.
  • Test I changed: "never builds HTML from people's text" in server.test.ts looked for the $("events").replaceChildren( line in the page. That code moved, so the test was wrong. It now applies the same check to the served metrics-panel.js.

The forge's full check hasn't run yet.

🤖 Generated with Claude Code

commented

This pull moves the Metrics panel's script into src/ui/metrics-panel.js, which the page imports when the panel opens (#96). I didn't run the tests or the type check before pushing, since the only change since the failed check is in forge.json. The forge's check on this push is the first run of them.

The earlier check failed because forge.json had a check block holding only limits and no run command. The forge reads that as "this commit declares no check". Commit 1142ee6 had already hit and removed the same block.

I removed the check block. The app.limits of 6 cores and 6 GiB stay, so the browser tests keep the resources they need. If the check itself should get those limits, it needs a check.run command added alongside them.

🤖 Generated with Claude Code

Approved

The preview serves the page importing /ui/<hash>/metrics-panel.js, and the module comes back 200 with immutable caching. It is lazy, so the first-visit budget is untouched. The renderers are pure, escape every value, and are tested; the events list still uses text nodes. The changed server.test.ts check is justified and still asserts the no-innerHTML rule on the moved code.

Two things I would do next:

  1. The module's showMetrics is not awaited in viewer.html, so a failed /metrics fetch becomes an unhandled rejection every 5s while the panel is open. Await it inside the try, and word the failure for a person ("could not read metrics") instead of only logging it.
  2. The forge.json check-block removal is unrelated to this refactor. Say so in the pull, or land it separately.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs