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): own scene.environmentIntensity instead of riding drei's undeclared effect dep
[._.]/ Adam Eivy01f6ade2f1a3
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 3b1b306669..0b2f44abe0 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -3,7 +3,7 @@## 3D- **Mesh preview display controls moved out of the render, and the lighting sliders now actually change the lighting** — the settings panel was an always-mounted overlay pinned inside the canvas, covering the upper-right quadrant of every model; it now lives behind a small toggle in the corner and expands as a strip *below* the render, so it can never occlude the mesh. Two of the controls it exposed were also effectively inert. The procedural studio environment lit the model at full strength and drowned out Ambient/Key/Fill — a new **Environment** slider dials the image-based lighting down (to 0 for lights-only), and the three light defaults were rebalanced against it. **Show HDRI background** revealed a cube map whose unlit areas were pure black, so the studio read as hard-edged white panels floating in a void (and only ever lit the model from three directions); an inward-facing backdrop sphere fills the gaps, and the map is rendered at 256 instead of 128. The scene-level background color was dropped in favor of the surface's CSS color it duplicated — a scene background raced the environment's own `scene.background` save/restore every time the HDRI toggle or the color picker changed.-- **Generated meshes are easier to inspect and get a denser texture atlas on high-memory Macs** — the GLB preview now has an always-visible background color picker, and an offline procedural light environment makes TRELLIS's metallic PBR surfaces readable instead of turning details such as dark glass into black patches. Newly generated models use a 4K texture bake when at least 48 GB of unified memory is available (four times the 2K texel budget); supported 24 GB systems keep the proven 2K path.+- **Generated meshes are easier to inspect and get a denser texture atlas on high-memory Macs** — the GLB preview now has a background color picker, and an offline procedural light environment makes TRELLIS's metallic PBR surfaces readable instead of turning details such as dark glass into black patches. Newly generated models use a 4K texture bake when at least 48 GB of unified memory is available (four times the 2K texel budget); supported 24 GB systems keep the proven 2K path.- **TRELLIS.2 models no longer render with transparent holes, and high-memory Macs use the sharper texture pipeline** — existing generated meshes now display as solid in the 3D viewer, while newly generated GLBs are normalized to the opaque material mode TRELLIS intended. Macs with at least 48 GB of unified memory now use 1024-cascade generation for better surface-detail placement; supported 24 GB systems stay on the proven lower-memory lane. Re-rendering the same record also refreshes the viewer immediately instead of showing its URL-cached previous mesh.- **[issue-3041] Installing TRELLIS.2 now fetches the Apple toolchain it needs, instead of telling you to run a command** — #2952 made the "correct shape, confetti surface" problem *visible*, but the fix was still a terminal command you had to copy out of a warning and run yourself — leaving every new install one manual step away from bad-looking renders. Installing (or repairing) TRELLIS.2 now downloads Apple's Xcode Metal Toolchain itself when it's missing, before the setup that needs it, so a fresh install produces properly textured meshes with nothing extra to do. No password is required and the download is skipped entirely when you already have it. **Repair install** on an existing degraded copy now genuinely fixes it rather than re-running the same broken setup. Two honest edge cases: if the download fails the install continues anyway (your geometry is unaffected, and the finished install tells you textures will be reduced), and on a Mac with only the Command Line Tools — where nothing PortOS runs can fetch the toolchain — you get a note naming Xcode as the prerequisite and no Repair button that would only fail.- **[issue-2952] The 3D page now catches the install problem that made meshes come out as colorful static** — a TRELLIS.2 render could produce a perfectly accurate 3D shape wrapped in a scrambled, speckled surface, with nothing anywhere saying why. The cause is an install that only *looked* finished: TRELLIS.2's setup builds its high-quality texture painter from Metal source, and on a Mac without Apple's Xcode Metal Toolchain that build quietly fails, the setup still reports success, and every later render silently falls back to a low-resolution painter that can't cover a detailed mesh — so the shape is right and the paint job is confetti. PortOS now checks for the Metal Toolchain **before** you commit to the multi-hour install and warns you if it's missing, verifies after installing whether the good texture painter actually landed, and shows any already-installed copy as **Ready · degraded textures** with a plain explanation and a one-click **Repair install** that rebuilds just the missing piece (your downloaded models are kept). Renders also now bake textures at the highest resolution TRELLIS.2 offers, so surfaces hold more detail either way.diff --git a/client/src/components/media/GlbViewer.jsx b/client/src/components/media/GlbViewer.jsxindex 1050f92841..a36029e2b8 100644--- a/client/src/components/media/GlbViewer.jsx+++ b/client/src/components/media/GlbViewer.jsx@@ -1,5 +1,5 @@-import { Suspense, useEffect, useId, useMemo, useState } from 'react';-import { Canvas } from '@react-three/fiber';+import { Suspense, useEffect, useId, useLayoutEffect, useMemo, useState } from 'react';+import { Canvas, useThree } from '@react-three/fiber';import {Bounds,Environment,@@ -79,6 +79,37 @@ function GlbModel({ src, forceOpaque }) {return <primitive object={renderedScene} />;}+// The environment's contents never change, so keep this element identity stable:+// drei re-bakes the cube map (six render passes + a PMREM regeneration) every+// time `children` changes identity, which for inline JSX is every render — i.e.+// once per pointer-move while dragging any other control on the panel.+const ENVIRONMENT_CONTENTS = (+ <>+ <mesh scale={100}>+ <sphereGeometry args={[1, 32, 32]} />+ <meshBasicMaterial color={ENVIRONMENT_BACKDROP} side={BackSide} />+ </mesh>+ <Lightformer form="rect" intensity={3} position={[0, 4, 4]} rotation-x={Math.PI / 2} scale={[5, 5, 1]} />+ <Lightformer form="rect" intensity={1.5} position={[-4, 1, 2]} rotation-y={Math.PI / 2} scale={[3, 5, 1]} />+ <Lightformer form="rect" intensity={1} position={[4, -1, -2]} rotation-y={-Math.PI / 2} scale={[3, 5, 1]} />+ </>+);++// Own `scene.environmentIntensity` directly rather than passing drei's+// `environmentIntensity` prop: drei applies it from an effect that doesn't+// 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 }) {+ const scene = useThree((state) => state.scene);+ useLayoutEffect(() => {+ scene.environmentIntensity = value;+ }, [scene, value]);+ return null;+}+function LightingControl({ label, max, value, onChange }) {return (<label className="flex items-center gap-2">@@ -158,42 +189,11 @@ export default function GlbViewer({<directionalLight position={[4, 6, 5]} intensity={keyIntensity} /><directionalLight position={[-4, -2, -5]} intensity={fillIntensity} />{/* A procedural environment keeps metallic PBR textures readable without- downloading an HDR preset — PortOS installs can be fully offline.- Keep these children inline: drei applies `environmentIntensity`- from an effect that doesn't list it as a dependency, so the slider- only reaches the scene because inline children change identity on- every render. Memoizing them would silently freeze it. */}- <Environment- background={showEnvironmentBackground}- resolution={256}- environmentIntensity={environmentIntensity}- >- <mesh scale={100}>- <sphereGeometry args={[1, 32, 32]} />- <meshBasicMaterial color={ENVIRONMENT_BACKDROP} side={BackSide} />- </mesh>- <Lightformer- form="rect"- intensity={3}- position={[0, 4, 4]}- rotation-x={Math.PI / 2}- scale={[5, 5, 1]}- />- <Lightformer- form="rect"- intensity={1.5}- position={[-4, 1, 2]}- rotation-y={Math.PI / 2}- scale={[3, 5, 1]}- />- <Lightformer- form="rect"- intensity={1}- position={[4, -1, -2]}- rotation-y={-Math.PI / 2}- scale={[3, 5, 1]}- />+ downloading an HDR preset — PortOS installs can be fully offline. */}+ <Environment background={showEnvironmentBackground} resolution={256}>+ {ENVIRONMENT_CONTENTS}</Environment>+ <EnvironmentIntensity value={environmentIntensity} /><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 1c74bc5dd3..5e375c8fa8 100644--- a/client/src/components/media/GlbViewer.test.jsx+++ b/client/src/components/media/GlbViewer.test.jsx@@ -8,16 +8,21 @@ import { BoxGeometry, Group, Mesh, MeshStandardMaterial } from 'three';// <primitive>/<mesh> would surface unknown DOM elements and r3f hands back// HTMLElement refs without the three.js API. Canvas retains the lighting and// environment elements so their interactive wiring stays covered.-vi.mock('@react-three/fiber', () => ({ Canvas: ({ children }) => <div data-testid="glb-canvas">{children}</div> }));+// `mockScene` stands in for the three.js scene `useThree` hands the viewer, so+// the environment-intensity assertions below check the value the component+// actually writes onto the scene — not merely a prop handed to a mocked+// <Environment>, which would stay green through the exact regression the+// source guards against (memoizing the environment children).+const { mockScene } = vi.hoisted(() => ({ mockScene: {} }));+vi.mock('@react-three/fiber', () => ({+ Canvas: ({ children }) => <div data-testid="glb-canvas">{children}</div>,+ useThree: (selector) => selector({ scene: mockScene }),+}));vi.mock('@react-three/drei', () => ({Canvas: () => null,OrbitControls: () => null,- Environment: ({ background, environmentIntensity, children }) => (- <div- data-testid="glb-environment"- data-background={background ? 'visible' : 'hidden'}- data-env-intensity={String(environmentIntensity)}- >+ Environment: ({ background, children }) => (+ <div data-testid="glb-environment" data-background={background ? 'visible' : 'hidden'}>{children}</div>),@@ -99,18 +104,20 @@ describe('GlbViewer', () => {// The image-based lighting drowned out the three light sliders at full// strength — dialing the environment down is what makes them visible.- it('drives the environment intensity from its own slider', () => {+ it('writes the environment intensity onto the scene from its own slider', () => {+ delete mockScene.environmentIntensity;render(<GlbViewer src="/data/models3d/robot-a1b2.glb" />);openControls();const environment = screen.getByLabelText('Environment light');expect(environment).toHaveValue('0.6');- expect(screen.getByTestId('glb-environment')).toHaveAttribute('data-env-intensity', '0.6');+ expect(mockScene.environmentIntensity).toBe(0.6);fireEvent.change(environment, { target: { value: '0' } });expect(environment).toHaveValue('0');- expect(screen.getByTestId('glb-environment')).toHaveAttribute('data-env-intensity', '0');+ // 0 is a meaningful value (lights-only), not an absent one.+ expect(mockScene.environmentIntensity).toBe(0);});it('honors an explicit downloadName over the derived one', () => {