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): make the avatar asset panel reachable, and guard route order (#4688)
[._.]/ Adam Eivy41e0e00cd333
diff --git a/client/src/components/cos/CoSCanvasGuard.jsx b/client/src/components/cos/CoSCanvasGuard.jsxindex 7d263da834..f43f098619 100644--- a/client/src/components/cos/CoSCanvasGuard.jsx+++ b/client/src/components/cos/CoSCanvasGuard.jsx@@ -15,6 +15,13 @@ import CoSAvatarFrame from './CoSAvatarFrame';* a model 404 told the user to go change an unrelated setting. `isWebGLAvailable`* is a real pre-gate and keeps the WebGL hint; anything thrown afterwards is an* asset failure and says so.+ *+ * `fallback` overrides the PRE-GATE only. A caught error deliberately outranks+ * it: the GLB-loading callers already probe for a missing model with a HEAD+ * request and render their own "no model, run setup" hint before mounting this+ * guard at all, so a failure that reaches HERE means the file answered and then+ * failed — a different cause, which that hint would misreport (it is what sent+ * a user chasing `npm run setup:data` for a server returning HTML).*/const panelClass = (background) =>@@ -70,7 +77,7 @@ export default function CoSCanvasGuard({const error = failure?.key === resetKey ? failure.error : null;if (!supported) return fallback || <WebGLUnavailableHint background={background} />;- if (error) return fallback || <AvatarAssetFailure background={background} error={error} />;+ if (error) return <AvatarAssetFailure background={background} error={error} />;return (<CoSAvatarFrame label={label} background={background}>diff --git a/client/src/components/cos/CoSCanvasGuard.test.jsx b/client/src/components/cos/CoSCanvasGuard.test.jsxindex 40ebade4ac..c85dd29868 100644--- a/client/src/components/cos/CoSCanvasGuard.test.jsx+++ b/client/src/components/cos/CoSCanvasGuard.test.jsx@@ -1,4 +1,4 @@-import { render, screen } from '@testing-library/react';+import { cleanup, render, screen } from '@testing-library/react';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';// The guard's whole job is deciding WHICH failure the user is looking at, and@@ -17,7 +17,10 @@ describe('CoSCanvasGuard', () => {webgl.available = true;logged = vi.spyOn(console, 'error').mockImplementation(() => {});});- afterEach(() => { vi.restoreAllMocks(); });+ afterEach(() => {+ cleanup();+ vi.restoreAllMocks();+ });it('renders the canvas when WebGL is available and nothing throws', () => {render(<CoSCanvasGuard><div data-testid="avatar-canvas" /></CoSCanvasGuard>);@@ -86,15 +89,30 @@ describe('CoSCanvasGuard', () => {expect(screen.getByTestId('avatar-canvas')).toBeInTheDocument();});- it('lets an explicit caller fallback override both panels', () => {- const fallback = <div data-testid="caller-fallback" />;- const { rerender } = render(- <CoSCanvasGuard fallback={fallback}><Boom error={new Error('boom')} /></CoSCanvasGuard>,- );- expect(screen.getByTestId('caller-fallback')).toBeInTheDocument();-+ it('lets an explicit caller fallback override the WebGL pre-gate', () => {+ // `supported` comes from a `useState` INITIALIZER, which runs once at mount —+ // flipping the mock and rerendering would silently exercise some other+ // branch, so this needs a fresh mount.webgl.available = false;- rerender(<CoSCanvasGuard fallback={fallback}><div /></CoSCanvasGuard>);+ render(<CoSCanvasGuard fallback={<div data-testid="caller-fallback" />}><div /></CoSCanvasGuard>);expect(screen.getByTestId('caller-fallback')).toBeInTheDocument();+ expect(screen.queryByText(/This display has no WebGL/i)).not.toBeInTheDocument();+ });++ // ...but NOT an asset failure. The GLB-loading callers pass a "no model, run+ // setup" hint as their fallback, and they already probe for a missing model+ // with a HEAD request before mounting the guard — so a failure reaching here+ // means the file answered and then failed, which that hint misreports. This+ // is the exact path #4688 describes: the server hands back the SPA index, the+ // parser chokes on `<`, and the user gets sent to run setup for nothing.+ it('shows the asset failure even when the caller supplied a fallback', () => {+ render(+ <CoSCanvasGuard fallback={<div data-testid="caller-fallback" />}>+ <Boom error={new Error("Unexpected token '<', \"<!DOCTYPE \"... is not valid JSON")} />+ </CoSCanvasGuard>,+ );+ expect(screen.getByTestId('cos-avatar-asset-error')).toBeInTheDocument();+ expect(screen.getByText(/web page instead of the mesh file/i)).toBeInTheDocument();+ expect(screen.queryByTestId('caller-fallback')).not.toBeInTheDocument();});});diff --git a/client/src/components/media/GlbViewer.jsx b/client/src/components/media/GlbViewer.jsxindex 071f8d2aaf..89ba94f4d3 100644--- a/client/src/components/media/GlbViewer.jsx+++ b/client/src/components/media/GlbViewer.jsx@@ -180,6 +180,10 @@ export default function GlbViewer({// at a different mesh drops the panel without an effect — and one record's// failure never sticks to the next one.const [failure, setFailure] = useState(null);+ // The HDRI degrades on its own (see the boundary around <Environment>), but the+ // two controls that drive it would keep sitting in the panel doing nothing —+ // exactly the dead-knob shape this change exists to remove.+ const [environmentFailed, setEnvironmentFailed] = useState(false);if (!src) return null;const loadError = failure?.src === src ? failure.error : null;const retryLoad = () => {@@ -252,7 +256,7 @@ export default function GlbViewer({image-based LIGHTING, which the three lights below alreadystand in for. Same shape OpenWorldScene documents for itsgalaxy spheremap: degrade to lights-only, keep the scene. */}- <ErrorBoundary fallback={null}>+ <ErrorBoundary fallback={null} onError={() => setEnvironmentFailed(true)}><Suspense fallback={null}>{/* Keep the HDRI in public/ instead of using drei's remote presets:preview lighting and the default backdrop must work offline. */}@@ -282,12 +286,18 @@ export default function GlbViewer({<LightingControl label="Ambient" max={2} value={ambientIntensity} onChange={setAmbientIntensity} /><LightingControl label="Key" max={3} value={keyIntensity} onChange={setKeyIntensity} /><LightingControl label="Fill" max={2} value={fillIntensity} onChange={setFillIntensity} />- <LightingControl- label="Environment"- max={2}- value={environmentIntensity}- onChange={setEnvironmentIntensity}- />+ {environmentFailed ? (+ <p className="text-xs text-port-text-muted">+ Environment lighting unavailable — the HDRI could not be loaded, so the scene is lit by the sliders alone.+ </p>+ ) : (+ <LightingControl+ label="Environment"+ max={2}+ value={environmentIntensity}+ onChange={setEnvironmentIntensity}+ />+ )}<div className="flex items-center gap-2"><label htmlFor={backgroundInputId} className="w-20">Background</label><input@@ -299,15 +309,17 @@ export default function GlbViewer({className="h-7 w-10 cursor-pointer rounded border border-port-border bg-transparent p-0.5"/></div>- <label className="flex items-center gap-2">- <input- type="checkbox"- checked={showEnvironmentBackground}- onChange={(event) => setShowEnvironmentBackground(event.target.checked)}- className="accent-port-accent"- />- Show HDRI background- </label>+ {!environmentFailed && (+ <label className="flex items-center gap-2">+ <input+ type="checkbox"+ checked={showEnvironmentBackground}+ onChange={(event) => setShowEnvironmentBackground(event.target.checked)}+ className="accent-port-accent"+ />+ Show HDRI background+ </label>+ )}</div>)}<div className="flex items-center justify-between gap-2 border-t border-port-border px-3 py-2">diff --git a/client/src/components/media/GlbViewer.test.jsx b/client/src/components/media/GlbViewer.test.jsxindex 46e455507d..db8680d8a2 100644--- a/client/src/components/media/GlbViewer.test.jsx+++ b/client/src/components/media/GlbViewer.test.jsx@@ -334,6 +334,11 @@ describe('GlbViewer HDRI failures', () => {expect(screen.getByLabelText('Preview display settings')).toBeInTheDocument();openControls();expect(screen.getByLabelText('Ambient light')).toBeInTheDocument();+ // ...but the two knobs that drove the now-unmounted Environment are gone,+ // replaced by a line saying why, instead of sitting there doing nothing.+ expect(screen.queryByLabelText('Environment light')).not.toBeInTheDocument();+ expect(screen.queryByText('Show HDRI background')).not.toBeInTheDocument();+ expect(screen.getByText(/Environment lighting unavailable/i)).toBeInTheDocument();expect(logged).toHaveBeenCalledWith(expect.stringContaining('💥 React Error'), expect.anything());});diff --git a/client/src/components/threejsModels/ThreejsModelPreview.jsx b/client/src/components/threejsModels/ThreejsModelPreview.jsxindex f1c24d102f..80837bc8ae 100644--- a/client/src/components/threejsModels/ThreejsModelPreview.jsx+++ b/client/src/components/threejsModels/ThreejsModelPreview.jsx@@ -490,7 +490,8 @@ function SpecRenderFailure({ error, onRetry }) {// remaps hardcoded light ink to dark and the heading goes near-invisible.<divdata-testid="threejs-spec-error"- className="port-media-overlay absolute inset-0 flex flex-col items-center justify-center gap-2 p-4 text-center"+ role="alert"+ className="port-media-overlay absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 p-4 text-center"><AlertTriangle className="h-6 w-6 text-port-error" aria-hidden="true" /><p className="text-sm font-medium">This model spec could not be rendered</p>@@ -677,112 +678,114 @@ export default function ThreejsModelPreview({ spec, family = null, className = '</Canvas></ErrorBoundary>)}- <div className="port-media-overlay absolute left-2 top-2 flex max-w-[calc(100%-1rem)] flex-wrap items-center gap-1.5 rounded-lg px-2 py-1.5 text-[10px]">- <span className="mr-1 whitespace-nowrap text-port-text-muted">Background</span>- <div className="flex flex-wrap gap-1" role="radiogroup" aria-label="Preview background">- {BACKGROUND_PRESETS.map((preset) => (- <button- key={preset.id}- type="button"- aria-label={preset.label}- aria-pressed={selectedPreset === preset.id}- onClick={() => setBackground(preset.value)}- className="port-media-overlay-item rounded px-1.5 py-1"- >- {preset.label}- </button>- ))}- </div>- <label className="port-media-overlay-item flex items-center gap-1 rounded px-1.5 py-1">- Custom- <input- type="color"- aria-label="Custom preview background color"- value={background || '#000000'}- onChange={(event) => setBackground(event.target.value)}- className="h-4 w-5 rounded border-0 bg-transparent p-0"- />- </label>- <span className="port-media-overlay-divider mx-1 hidden h-3 w-px sm:block" />- <label htmlFor={qualitySelectId} className="whitespace-nowrap text-port-text-muted">- Quality- </label>- <select- id={qualitySelectId}- value={qualityMode === 'auto' ? 'auto' : fixedTier}- onChange={handleQualityChange}- className="port-media-overlay-item rounded px-1.5 py-1 text-[10px]"- >- <option value="auto">Auto</option>- {PREVIEW_QUALITY_TIERS.map((tier) => <option key={tier} value={tier}>{tier}</option>)}- </select>- <span className="whitespace-nowrap text-port-text-muted">- {qualityMode === 'auto' ? `Auto · ${effectiveTier}` : `Fixed · ${effectiveTier}`}- </span>- <span className="port-media-overlay-divider mx-1 hidden h-3 w-px sm:block" />- <label htmlFor={explodeSliderId} className="whitespace-nowrap text-port-text-muted">- Explode- </label>- <input- id={explodeSliderId}- type="range"- min="0"- max="1"- step="0.02"- value={explode}- disabled={layout.unitIds.length < 2}- onChange={(event) => setExplode(Number(event.target.value))}- className="h-1 w-20 cursor-pointer accent-port-accent disabled:cursor-not-allowed disabled:opacity-40 sm:w-28"- />- <span className="w-8 tabular-nums text-port-text-muted">{Math.round(explode * 100)}%</span>- {explode > 0 && (- <button- type="button"- onClick={() => setExplode(0)}- className="port-media-overlay-item rounded px-1.5 py-1"- >- Reassemble- </button>- )}- <span className="port-media-overlay-divider mx-1 hidden h-3 w-px sm:block" />- <span className="whitespace-nowrap text-port-text-muted">Audit camera</span>- <div className="flex flex-wrap gap-1" role="radiogroup" aria-label="Audit camera">- {AUDIT_CAMERAS.map((camera) => {- const unavailable = camera.id === 'family' && !family;- return (+ {!specError && (+ <div className="port-media-overlay absolute left-2 top-2 flex max-w-[calc(100%-1rem)] flex-wrap items-center gap-1.5 rounded-lg px-2 py-1.5 text-[10px]">+ <span className="mr-1 whitespace-nowrap text-port-text-muted">Background</span>+ <div className="flex flex-wrap gap-1" role="radiogroup" aria-label="Preview background">+ {BACKGROUND_PRESETS.map((preset) => (<button- key={camera.id}+ key={preset.id}type="button"- aria-label={camera.label}- aria-pressed={auditCamera === camera.id}- disabled={unavailable}- title={unavailable ? 'Choose a subject family to enable family review' : undefined}- onClick={() => setPreviewParam('auditCamera', camera.id)}- className="port-media-overlay-item rounded px-1.5 py-1 disabled:cursor-not-allowed disabled:opacity-40"+ aria-label={preset.label}+ aria-pressed={selectedPreset === preset.id}+ onClick={() => setBackground(preset.value)}+ className="port-media-overlay-item rounded px-1.5 py-1">- {camera.label}+ {preset.label}</button>- );- })}- </div>- <span className="port-media-overlay-divider mx-1 hidden h-3 w-px sm:block" />- <span className="whitespace-nowrap text-port-text-muted">Inspection</span>- <div className="flex flex-wrap gap-1" role="radiogroup" aria-label="Inspection mode">- {AUDIT_RENDER_MODES.map((mode) => (+ ))}+ </div>+ <label className="port-media-overlay-item flex items-center gap-1 rounded px-1.5 py-1">+ Custom+ <input+ type="color"+ aria-label="Custom preview background color"+ value={background || '#000000'}+ onChange={(event) => setBackground(event.target.value)}+ className="h-4 w-5 rounded border-0 bg-transparent p-0"+ />+ </label>+ <span className="port-media-overlay-divider mx-1 hidden h-3 w-px sm:block" />+ <label htmlFor={qualitySelectId} className="whitespace-nowrap text-port-text-muted">+ Quality+ </label>+ <select+ id={qualitySelectId}+ value={qualityMode === 'auto' ? 'auto' : fixedTier}+ onChange={handleQualityChange}+ className="port-media-overlay-item rounded px-1.5 py-1 text-[10px]"+ >+ <option value="auto">Auto</option>+ {PREVIEW_QUALITY_TIERS.map((tier) => <option key={tier} value={tier}>{tier}</option>)}+ </select>+ <span className="whitespace-nowrap text-port-text-muted">+ {qualityMode === 'auto' ? `Auto · ${effectiveTier}` : `Fixed · ${effectiveTier}`}+ </span>+ <span className="port-media-overlay-divider mx-1 hidden h-3 w-px sm:block" />+ <label htmlFor={explodeSliderId} className="whitespace-nowrap text-port-text-muted">+ Explode+ </label>+ <input+ id={explodeSliderId}+ type="range"+ min="0"+ max="1"+ step="0.02"+ value={explode}+ disabled={layout.unitIds.length < 2}+ onChange={(event) => setExplode(Number(event.target.value))}+ className="h-1 w-20 cursor-pointer accent-port-accent disabled:cursor-not-allowed disabled:opacity-40 sm:w-28"+ />+ <span className="w-8 tabular-nums text-port-text-muted">{Math.round(explode * 100)}%</span>+ {explode > 0 && (<button- key={mode.id}type="button"- aria-label={mode.label}- aria-pressed={auditMode === mode.id}- onClick={() => setPreviewParam('auditMode', mode.id)}+ onClick={() => setExplode(0)}className="port-media-overlay-item rounded px-1.5 py-1">- {mode.label}+ Reassemble</button>- ))}+ )}+ <span className="port-media-overlay-divider mx-1 hidden h-3 w-px sm:block" />+ <span className="whitespace-nowrap text-port-text-muted">Audit camera</span>+ <div className="flex flex-wrap gap-1" role="radiogroup" aria-label="Audit camera">+ {AUDIT_CAMERAS.map((camera) => {+ const unavailable = camera.id === 'family' && !family;+ return (+ <button+ key={camera.id}+ type="button"+ aria-label={camera.label}+ aria-pressed={auditCamera === camera.id}+ disabled={unavailable}+ title={unavailable ? 'Choose a subject family to enable family review' : undefined}+ onClick={() => setPreviewParam('auditCamera', camera.id)}+ className="port-media-overlay-item rounded px-1.5 py-1 disabled:cursor-not-allowed disabled:opacity-40"+ >+ {camera.label}+ </button>+ );+ })}+ </div>+ <span className="port-media-overlay-divider mx-1 hidden h-3 w-px sm:block" />+ <span className="whitespace-nowrap text-port-text-muted">Inspection</span>+ <div className="flex flex-wrap gap-1" role="radiogroup" aria-label="Inspection mode">+ {AUDIT_RENDER_MODES.map((mode) => (+ <button+ key={mode.id}+ type="button"+ aria-label={mode.label}+ aria-pressed={auditMode === mode.id}+ onClick={() => setPreviewParam('auditMode', mode.id)}+ className="port-media-overlay-item rounded px-1.5 py-1"+ >+ {mode.label}+ </button>+ ))}+ </div></div>- </div>- {selectedId && (+ )}+ {selectedId && !specError && (<div className="port-media-overlay absolute right-2 top-2 flex max-w-[calc(100%-1rem)] items-center gap-2 rounded-lg px-2 py-1.5 text-[10px]"><span className="truncate font-medium">{selection.names[selectedId] || selectedId}</span><code className="truncate text-port-text-muted">{selectedId}</code>@@ -806,43 +809,45 @@ export default function ThreejsModelPreview({ spec, family = null, className = '</button></div>)}- <div className="pointer-events-none absolute bottom-2 left-2 flex max-w-[calc(100%-1rem)] flex-wrap items-center gap-1.5 text-[10px]">- <ThreejsClipTransport- clips={clips}- clip={clip}- duration={playback.duration}- time={playback.timeSeconds}- playing={playback.playing}- speed={playback.speed}- activeSequenceNames={activeSequenceNames}- onSelectClip={(clipId) => setPreviewParam('clip', clipId)}- onTogglePlay={playback.togglePlay}- onStop={playback.stop}- onScrub={playback.setPlayhead}- onSpeedChange={playback.setSpeed}- />- <span className="port-media-overlay rounded px-2 py-1">- Drag to orbit · scroll to zoom · click a part to identify it · audit controls never change the saved model- </span>- {family && (- <span className="port-media-overlay rounded px-2 py-1 text-port-text-muted">- Family review: {(family.orbitViews || []).join(', ') || 'review the authored subject'}- {family.reviewAxes?.length > 0 ? ` · ${family.reviewAxes.join('; ')}` : ''}+ {!specError && (+ <div className="pointer-events-none absolute bottom-2 left-2 flex max-w-[calc(100%-1rem)] flex-wrap items-center gap-1.5 text-[10px]">+ <ThreejsClipTransport+ clips={clips}+ clip={clip}+ duration={playback.duration}+ time={playback.timeSeconds}+ playing={playback.playing}+ speed={playback.speed}+ activeSequenceNames={activeSequenceNames}+ onSelectClip={(clipId) => setPreviewParam('clip', clipId)}+ onTogglePlay={playback.togglePlay}+ onStop={playback.stop}+ onScrub={playback.setPlayhead}+ onSpeedChange={playback.setSpeed}+ />+ <span className="port-media-overlay rounded px-2 py-1">+ Drag to orbit · scroll to zoom · click a part to identify it · audit controls never change the saved model</span>- )}- {/* Never "animation-ready": nothing here is skinned. The badge says only- whether the spec declared a usable articulation graph, and a model- that predates the contract has none and reads as a static assembly. */}- <span- className={articulation.articulationReady- ? 'port-media-overlay rounded px-2 py-1 text-port-success'- : 'port-media-overlay rounded px-2 py-1 text-port-text-muted'}- >- {articulation.articulationReady- ? `Articulation-ready · ${articulation.jointCount} joints · ${articulation.socketCount} pivot${articulation.socketCount === 1 ? '' : 's'}`- : `Static assembly${articulation.jointCount > 0 ? ` · ${articulation.jointCount} joints declared` : ''}`}- </span>- </div>+ {family && (+ <span className="port-media-overlay rounded px-2 py-1 text-port-text-muted">+ Family review: {(family.orbitViews || []).join(', ') || 'review the authored subject'}+ {family.reviewAxes?.length > 0 ? ` · ${family.reviewAxes.join('; ')}` : ''}+ </span>+ )}+ {/* Never "animation-ready": nothing here is skinned. The badge says only+ whether the spec declared a usable articulation graph, and a model+ that predates the contract has none and reads as a static assembly. */}+ <span+ className={articulation.articulationReady+ ? 'port-media-overlay rounded px-2 py-1 text-port-success'+ : 'port-media-overlay rounded px-2 py-1 text-port-text-muted'}+ >+ {articulation.articulationReady+ ? `Articulation-ready · ${articulation.jointCount} joints · ${articulation.socketCount} pivot${articulation.socketCount === 1 ? '' : 's'}`+ : `Static assembly${articulation.jointCount > 0 ? ` · ${articulation.jointCount} joints declared` : ''}`}+ </span>+ </div>+ )}</div>);}diff --git a/client/src/components/threejsModels/ThreejsModelPreview.test.jsx b/client/src/components/threejsModels/ThreejsModelPreview.test.jsxindex cdc5de20fd..7f669644af 100644--- a/client/src/components/threejsModels/ThreejsModelPreview.test.jsx+++ b/client/src/components/threejsModels/ThreejsModelPreview.test.jsx@@ -845,6 +845,12 @@ describe('ThreejsModelPreview spec-render failures', () => {expect(screen.getByText(/NaN position values/)).toBeInTheDocument();expect(screen.queryByTestId('threejs-canvas')).not.toBeInTheDocument();expect(logged).toHaveBeenCalledWith(expect.stringContaining('💥 React Error'), expect.anything());+ // The overlay chrome is a DOM peer that comes AFTER the panel, so leaving it+ // mounted paints it over the message — and every control on it drives a+ // canvas that no longer exists.+ expect(screen.queryByRole('radiogroup', { name: 'Preview background' })).not.toBeInTheDocument();+ expect(screen.queryByLabelText('Explode')).not.toBeInTheDocument();+ expect(screen.queryByText(/Drag to orbit/)).not.toBeInTheDocument();});// A lost WebGL context throws the same way a bad spec does, but it can comediff --git a/scripts/dev-proxy-drift.test.js b/scripts/dev-proxy-drift.test.jsindex fe508bbaef..bd7f6778f7 100644--- a/scripts/dev-proxy-drift.test.js+++ b/scripts/dev-proxy-drift.test.js@@ -62,6 +62,20 @@ const proxyMatches = (context, url) =>const navPaths = NAV_COMMANDS.map((command) => command.path);+/**+ * Every path the client router declares.+ *+ * NOT just `NAV_COMMANDS`: `client/src/CLAUDE.md` requires a selectable view to+ * register only its BASE path in the nav manifest while its `:id` detail route+ * lives in `App.jsx` alone. A convention-following `<Route path="data/:category">`+ * would therefore be invisible to a nav-manifest-only check — and the terminator+ * would 404 it in production with nothing failing near the new route.+ */+function clientRoutePaths(source) {+ return [...source.matchAll(/<Route\s+path="([^"]+)"/g)]+ .map(([, path]) => (path.startsWith('/') ? path : `/${path}`));+}+describe('vite dev proxy vs the server and the client router', () => {// The mounts come from the table `server/index.js` mounts from, not from a// regex over its source — that table is why the two cannot disagree.@@ -110,16 +124,46 @@ describe('the asset table vs what the server mounts', () => {});describe('server-owned prefixes vs the client router', () => {+ const routePaths = [...new Set([...navPaths, ...clientRoutePaths(read('client/src/App.jsx'))])];++ it('finds the client routes it is comparing', () => {+ expect(routePaths.length).toBeGreaterThan(50);+ expect(routePaths).toContain('/data');+ });+it('declares every client route that lives under a server-owned prefix', () => {// The failure this catches: someone adds a `/data/backups` page. The// terminator 404s it, the page simply does not exist, and nothing points at// `assetRoutePrefixes.js`. Adding the route to that entry's `spaPaths` is// the fix — this test is what says so.const undeclared = SERVER_OWNED_PREFIXES.flatMap(({ prefix, spaPaths }) => (- navPaths.filter((path) => (+ routePaths.filter((path) => ((path === prefix || path.startsWith(`${prefix}/`)) && !spaPaths.includes(path)))));expect(undeclared).toEqual([]);});});++describe('server/index.js route registration order', () => {+ // `mountAssetRoutes` installs a terminating 404 on /api and /sdapi, so+ // registration order became load-bearing: a router added BELOW the call is+ // shadowed by that 404 and never runs. Nothing else reads this file any+ // more — the drift guard reads the tables — so this is what catches it.+ const source = read('server/index.js');++ it('registers every API router above the terminators', () => {+ const mountIndex = source.indexOf('mountAssetRoutes(app)');+ expect(mountIndex).toBeGreaterThan(0);+ const shadowed = [...source.matchAll(/app\.use\(\s*'(\/(?:api|sdapi)[^']*)'/g)]+ .filter((match) => match.index > mountIndex)+ .map(([, route]) => route);+ expect(shadowed).toEqual([]);+ });++ it('leaves no asset mount behind in the file the table replaced', () => {+ // An inline `app.use('/data/x', express.static(…))` added back here would sit+ // BELOW the terminator and be dead — and would miss the dev proxy too.+ expect(source).not.toMatch(/app\.use\(\s*'\/data[^']*',\s*express\.static/);+ });+});diff --git a/server/index.js b/server/index.jsindex 0f3e79f69e..5ee0e9034a 100644--- a/server/index.js+++ b/server/index.js@@ -389,9 +389,10 @@ app.use('/api/ask', askRoutes);// Asset static mounts, then a terminating 404 for every server-owned prefix so// an extensionless `/data/…` or a mistyped `/api/…` can no longer fall through// to the SPA fallback below and be answered with index.html and a 200 (#4688).-// Both lists live in lib/assetRoutePrefixes.js, which `client/vite.config.js`-// and `scripts/dev-proxy-drift.test.js` read as data — so the dev proxy and the-// guard cannot fall behind this file.+// Both lists live in lib/assetRoutePrefixes.js, which `scripts/dev-proxy-drift.test.js`+// reads as data. NOTE: this call installs a terminating 404 on `/api` and+// `/sdapi` too, so every router above must stay above — one added BELOW it is+// shadowed and never runs. That guard test holds the ordering.mountAssetRoutes(app);// Serve built client UI (production mode — no Vite dev server needed)