Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (claude): re-assert environment intensity when the HDRI toggle flips
[._.]/ Adam Eivy14b572e9a134
diff --git a/client/src/components/media/GlbViewer.jsx b/client/src/components/media/GlbViewer.jsxindex a36029e2b8..de53931cf1 100644--- a/client/src/components/media/GlbViewer.jsx+++ b/client/src/components/media/GlbViewer.jsx@@ -100,13 +100,19 @@ const ENVIRONMENT_CONTENTS = (// declare it as a dependency, so the prop only lands while `children` changes// identity every render — coupling a user-facing control to an upstream bug AND// to the re-bake cost above. drei's `applyProps` skips `undefined`, so omitting-// the prop leaves this write untouched, and its save/restore reads back the-// live value. Mounted after `<Environment>` so this layout effect runs last.-function EnvironmentIntensity({ value }) {+// the prop leaves this write untouched when its effect *applies*.+//+// `reassertOn` exists because its *cleanup* does not: drei snapshots+// `scene.environmentIntensity` before we ever write it (so the snapshot is+// three's default 1) and restores that snapshot unconditionally when its effect+// re-runs. Its only remaining live dependency is `background`, so pass the same+// toggle here — otherwise ticking "Show HDRI background" silently returns the+// IBL to full strength while the slider still reads the user's value.+function EnvironmentIntensity({ value, reassertOn }) {const scene = useThree((state) => state.scene);useLayoutEffect(() => {scene.environmentIntensity = value;- }, [scene, value]);+ }, [scene, value, reassertOn]);return null;}@@ -193,7 +199,7 @@ export default function GlbViewer({<Environment background={showEnvironmentBackground} resolution={256}>{ENVIRONMENT_CONTENTS}</Environment>- <EnvironmentIntensity value={environmentIntensity} />+ <EnvironmentIntensity value={environmentIntensity} reassertOn={showEnvironmentBackground} /><Suspense fallback={null}><Bounds fit clip observe margin={1.2}><GlbModel src={src} forceOpaque={forceOpaque} />diff --git a/client/src/components/media/GlbViewer.test.jsx b/client/src/components/media/GlbViewer.test.jsxindex 5e375c8fa8..9a9e7dec95 100644--- a/client/src/components/media/GlbViewer.test.jsx+++ b/client/src/components/media/GlbViewer.test.jsx@@ -120,6 +120,25 @@ describe('GlbViewer', () => {expect(mockScene.environmentIntensity).toBe(0);});+ // drei's Environment snapshots scene.environmentIntensity before we write it+ // and restores that snapshot whenever its own effect re-runs — and toggling+ // the HDRI background is the one thing that still re-runs it. Without a+ // re-assert the IBL silently returns to full strength while the slider still+ // reads the user's value. The mocked Environment can't perform the restore,+ // so stand in for it by writing the pre-write default back onto the scene.+ it('re-asserts the environment intensity when the HDRI background is toggled', () => {+ delete mockScene.environmentIntensity;+ render(<GlbViewer src="/data/models3d/robot-a1b2.glb" />);+ openControls();+ fireEvent.change(screen.getByLabelText('Environment light'), { target: { value: '0' } });+ expect(mockScene.environmentIntensity).toBe(0);++ mockScene.environmentIntensity = 1; // drei restoring its pre-write snapshot+ fireEvent.click(screen.getByLabelText('Show HDRI background'));++ expect(mockScene.environmentIntensity).toBe(0);+ });+it('honors an explicit downloadName over the derived one', () => {render(<GlbViewer src="/data/models3d/x.glb?v=2" downloadName="my-mesh.glb" />);expect(screen.getByRole('link', { name: /Download \.glb/i })).toHaveAttribute('download', 'my-mesh.glb');