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

The 3D view's grid keeps the old theme's colour after a theme switch #17000

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The 3D view's grid now follows a theme switch: it re-reads the page's ink, sets the grid's line colour and draws one frame. I checked the event wiring in the built bundle and in the shell script, and tsc and the model3d and render-client tests pass. I haven't looked at the grid colour in a browser, because it's pixels.

Notes

opened this

The 3D view's grid now follows a theme switch: it re-reads the page's ink, sets the grid's line colour and draws one frame. I checked the event wiring in the built bundle and in the shell script, and tsc and the model3d and render-client tests pass. I haven't looked at the grid colour in a browser, because it's pixels.

  • Theme menu: src/web/client.ts fires a forge-theme event on the document once the theme fade ends (260 ms). Reading the colour then avoids catching a half-faded value.
  • "System" theme: the viewer also listens for a prefers-color-scheme change.
  • Viewer: src/web/render/model3d-client.ts listens for both events and does nothing once the figure has left the page.
  • Type stubs: I added Color.set and typed GridHelper.material.color in vendor/three.d.ts so the change type-checks.
  • Test: one test in test/render-css-client.test.ts fails without the wiring. It checks the bundle for forge-theme and prefers-color-scheme, and the shell for the dispatch.

I left the measure tool's accent colour alone, since it's read once from the --accent token. I also left out a terminal side, with the commit line No door: saying why.

To try it, open an STL or OBJ blob, then switch theme from the menu or the settings gallery. The grid's ink should change straight away, with no reload.

I pushed with an empty commit starting Try:, because the pre-push hook demanded one.

🤖 Generated with Claude Code

Closes #7404

3 earlier comments
commented

The 3D view's grid now follows a theme switch: it re-reads the page's ink, sets the grid's line colour and draws one frame. I checked the event wiring in the built bundle and in the shell script, and tsc and the model3d and render-client tests pass. I haven't looked at the grid colour in a browser, because it's pixels.

  • Theme menu: src/web/client.ts fires a forge-theme event on the document once the theme fade ends (260 ms). Reading the colour then avoids catching a half-faded value.
  • "System" theme: the viewer also listens for a prefers-color-scheme change.
  • Viewer: src/web/render/model3d-client.ts listens for both events and does nothing once the figure has left the page.
  • Type stubs: I added Color.set and typed GridHelper.material.color in vendor/three.d.ts so the change type-checks.
  • Test: one test in test/render-css-client.test.ts fails without the wiring. It checks the bundle for forge-theme and prefers-color-scheme, and the shell for the dispatch.

I left the measure tool's accent colour alone, since it's read once from the --accent token. I also left out a terminal side, with the commit line No door: saying why.

To try it, open an STL or OBJ blob, then switch theme from the menu or the settings gallery. The grid's ink should change straight away, with no reload.

I pushed with an empty commit starting Try:, because the pre-push hook demanded one.

🤖 Generated with Claude Code

commented

<!-- look-pages 637e165ac67c --> Look pages for 637e165, from the gate:

  • look pages (inferred): this pull changes src/web/client.ts, src/web/render/model3d-client.ts, src/web/render/vendor/three.d.ts; the forge pictures / (src/web/client.ts), /docs (src/web/client.ts), /explore (src/web/client.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The look-pages note was an inference, and I've overridden it with a No look: line in a new empty commit on the branch.

The gate picked 31 pages because src/web/client.ts is imported by nearly every route. The only visible change is the grid's line colour inside the WebGL canvas on a 3D blob page. That page isn't one of the listed look pages, and a still image can't show a theme switch anyway. The code itself is unchanged since my first push.

I didn't re-run the checks this time, since nothing but the commit message changed. The forge's check will run on this push.

The pull description stands as written before. The only addition is that the override sits in commit fef0955f3.

To try it, open an STL or OBJ blob, then switch theme from the menu or the settings gallery. The grid's ink should change at once, with no reload.

🤖 Generated with Claude Code

commented

The 3D grid now takes the new theme's ink, and the viewer removes its theme listeners when the figure goes. Pushed. tsc is clean, and the new test and the dead-code test pass, as do the other tests in render-css-client.test.ts, model3d.test.ts and assets.test.ts. The gate's rules listed by --explain are ok. I did not open the viewer in a browser.

What changed

  • Colour fix (1): a new module, src/web/render/grid-ink.ts, has recolourGrid. It writes the new ink into every vertex of the grid's colour attribute and flags it for upload. It replaces the material.color.set call. I dropped the material.color typing from vendor/three.d.ts and added the typings the new code needs. recolourGrid is called from model3d-client.ts, so the dead-code test is satisfied.
  • Test (2): the string-grep test is replaced by one that builds a real GridHelper from the vendored three, recolours it, and checks every vertex equals the new ink. It also checks that the attribute's version goes up (what the renderer compares). It would fail with the old multiplier approach. A second test still checks that the shell announces forge-theme and that the bundle removes its listeners.
  • Listeners (3): the forge-theme and prefers-color-scheme listeners are now removed in the viewer's dispose(). That runs when mountAll finds a figure the page has dropped.
  • Review block (4): below.

Not done

  • No new markup, and no terminal side. The commit carries No door:, since the grid is canvas pixels and the terminal has no theme or 3D view.

To try

[
  {"go": "/ — open a .stl file, or any page with a 3D figure, in the light theme", "look": "the grid lines under the part", "expect": "dark lines at low opacity"},
  {"go": "menu → Theme → Dark", "look": "the grid lines, about a quarter second after the page fades", "expect": "the lines change to the light ink at once, not dark-on-dark and not muddy"},
  {"go": "menu → Theme → Light", "look": "the grid lines", "expect": "back to the dark ink"},
  {"go": "menu → Theme → System, then flip the OS colour scheme", "look": "the grid lines", "expect": "they follow the OS scheme without a reload", "ask": "Does the grid ever stay on the old colour after a switch?"}
]
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs