Skip to content

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

refactor(models): share the 3D target fetch, keep the moved tabs route-split (#4728)

[._.]/ Adam Eivyc63a08e7a72b
diff --git a/client/src/App.jsx b/client/src/App.jsx
index 1df3ed5e51..b79a68a92b 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -54,7 +54,6 @@ const ThreejsModels = lazyWithReload(() => import('./pages/ThreejsModels'));
const Media3D = lazyWithReload(() => import('./pages/Media3D'));
const Media3DDetail = lazyWithReload(() => import('./pages/Media3DDetail'));
const ThreejsModelDetail = lazyWithReload(() => import('./pages/ThreejsModelDetail'));
-const LoraDatasetDetail = lazyWithReload(() => import('./pages/LoraDatasetDetail'));
const UniverseBuilder = lazyWithReload(() => import('./pages/UniverseBuilder'));
const Universes = lazyWithReload(() => import('./pages/Universes'));
const Authors = lazyWithReload(() => import('./pages/Authors'));
@@ -316,11 +315,11 @@ export default function App() {
<Route path="settings/embeddings" element={<Navigate to="/models/embeddings" replace />} />
<Route path="settings/:tab" element={<Settings />} />
<Route path="models" element={<Navigate to="/models/performance" replace />} />
- {/* The training tab has a routed dataset workbench. React Router ranks
- the static `training` segment above `:tab`, so the drill-down wins
- over the tab route without depending on declaration order. */}
- <Route path="models/training/:datasetId" element={<LoraDatasetDetail />} />
+ {/* A tab's drill-down (today: the LoRA dataset workbench) renders through
+ Models itself, so it keeps the section header and tab bar — see
+ TAB_DETAIL there. */}
<Route path="models/:tab" element={<Models />} />
+ <Route path="models/:tab/:recordId" element={<Models />} />
<Route path="local-llm/playground" element={<LocalLlmPlayground />} />
<Route path="uploads" element={<Uploads />} />
<Route path="shell" element={<Shell />} />
diff --git a/client/src/components/media/Image3dHfAccessNotice.test.jsx b/client/src/components/media/Image3dHfAccessNotice.test.jsx
new file mode 100644
index 0000000000..4ddf02e360
--- /dev/null
+++ b/client/src/components/media/Image3dHfAccessNotice.test.jsx
@@ -0,0 +1,60 @@
+/**
+ * The gated-Hugging-Face prerequisite notice, tested directly.
+ *
+ * It has two hosts (the `/3d` render flow and Models → 3D), so asserting its
+ * contract only through them means a change to the component fails suites named
+ * after other things — and either host could drop its cases without anyone
+ * noticing the component lost coverage.
+ *
+ * The contract that matters is TRI-STATE `tokenPresent`: `null` means "status
+ * still loading", NOT "absent". Collapsing those flashes "go add a token" at a
+ * user who already has one.
+ */
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen, fireEvent } from '@testing-library/react';
+
+vi.mock('../../services/api', () => ({ setHfToken: vi.fn() }));
+
+import Image3dHfAccessNotice from './Image3dHfAccessNotice';
+
+const MODELS = [{ label: 'briaai/RMBG-2.0', url: 'https://huggingface.co/briaai/RMBG-2.0' }];
+
+const renderNotice = (props) => render(
+ <Image3dHfAccessNotice models={MODELS} tokenPresent={false} tokenSource="none" {...props} />,
+);
+
+describe('Image3dHfAccessNotice', () => {
+ it('renders nothing when no gated repos apply', () => {
+ const { container } = renderNotice({ models: [] });
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it('renders nothing while token status is still unknown', () => {
+ // `null` is "not fetched yet", not "no token" — the difference between a
+ // silent panel and a false alarm.
+ const { container } = renderNotice({ tokenPresent: null });
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it('offers the paste-and-save banner when no token is configured', () => {
+ renderNotice({ tokenPresent: false });
+ expect(screen.getByPlaceholderText('hf_…')).toBeInTheDocument();
+ });
+
+ it('confirms a configured token, names its source, and still lists the gated repos', () => {
+ // A token does NOT grant access until the repo terms are accepted, so the
+ // list has to survive the "you're all set" state.
+ renderNotice({ tokenPresent: true, tokenSource: 'stored' });
+ expect(screen.getByText(/Hugging Face token configured/i)).toBeInTheDocument();
+ expect(screen.getByRole('link', { name: /briaai\/RMBG-2\.0/ })).toBeInTheDocument();
+ expect(screen.queryByPlaceholderText('hf_…')).toBeNull();
+ });
+
+ it('reopens the paste form for a token that is present but rejected', () => {
+ // The runner's auth-failure guidance says to add a token on this page, so a
+ // stale/invalid token must not lock the form away behind "already configured".
+ renderNotice({ tokenPresent: true, tokenSource: 'stored' });
+ fireEvent.click(screen.getByRole('button', { name: /use a different token/i }));
+ expect(screen.getByPlaceholderText('hf_…')).toBeInTheDocument();
+ });
+});
diff --git a/client/src/components/models/Image3dRuntimes.jsx b/client/src/components/models/Image3dRuntimes.jsx
index 73f1b05cf4..eeda5eda80 100644
--- a/client/src/components/models/Image3dRuntimes.jsx
+++ b/client/src/components/models/Image3dRuntimes.jsx
@@ -1,8 +1,9 @@
-import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useMemo, useState } from 'react';
import { AlertTriangle, CheckCircle2, Download, ExternalLink, Loader2 } from 'lucide-react';
-import { getImageTo3dTargets } from '../../services/api';
import { useHfTokenStatus } from '../../hooks/useHfTokenStatus';
-import { unavailableReasonLabel } from '../../lib/imageTo3dReasons';
+import { useImageTo3dTargets } from '../../hooks/useImageTo3dTargets';
+import { isTargetReady, unavailableReasonLabel } from '../../lib/imageTo3dReasons';
+import Banner from '../ui/Banner.jsx';
import RuntimeInstallModal from '../install/RuntimeInstallModal';
import Image3dHfAccessNotice from '../media/Image3dHfAccessNotice';
@@ -31,7 +32,7 @@ function StatusBadge({ target }) {
</span>
);
}
- if (target.installed) {
+ if (isTargetReady(target)) {
// An installed-but-degraded target still renders — TRELLIS.2 with no Metal bake
// produces correct geometry with a scrambled surface; Pixal3D with no NATTEN
// falls back to DINO projection features — so "Ready" alone would be a lie. The
@@ -119,23 +120,11 @@ function TargetCard({ target, onInstall }) {
}
export default function Image3dRuntimes() {
- const [targets, setTargets] = useState([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
+ const { targets, loading, error, reload } = useImageTo3dTargets();
// The target whose install modal is open (only local-install targets); null = closed.
const [installTarget, setInstallTarget] = useState(null);
const { present: hfTokenPresent, source: hfTokenSource, refresh: refreshHfToken } = useHfTokenStatus();
- const load = useCallback(() => {
- setLoading(true);
- getImageTo3dTargets()
- .then((data) => { setTargets(data?.targets || []); setError(null); })
- .catch((err) => setError(err?.message || 'Failed to load 3D targets'))
- .finally(() => setLoading(false));
- }, []);
-
- useEffect(() => { load(); }, [load]);
-
// Every gated repo across the runnable targets, deduped by id — the token is
// central, so listing one target's repos twice would just be noise. Unavailable
// targets are excluded: their terms are irrelevant on a host that can't run them.
@@ -175,12 +164,18 @@ export default function Image3dRuntimes() {
)}
{error && !loading && (
- <div className="flex items-center justify-between rounded-lg border border-port-error/40 bg-port-error/10 p-4 text-sm text-port-error">
- <span>{error}</span>
- <button onClick={load} className="rounded-md border border-port-error/50 px-3 py-1 text-xs hover:bg-port-error/20">
- Retry
- </button>
- </div>
+ <Banner tone="error" icon={AlertTriangle}>
+ <div className="flex items-center justify-between gap-3">
+ <span>{error}</span>
+ <button
+ type="button"
+ onClick={reload}
+ className="shrink-0 rounded-md border border-port-error/50 px-3 py-1 text-xs hover:bg-port-error/20"
+ >
+ Retry
+ </button>
+ </div>
+ </Banner>
)}
{!loading && !error && (
@@ -222,7 +217,7 @@ export default function Image3dRuntimes() {
: null,
].filter(Boolean).join(' ') || undefined}
onClose={() => setInstallTarget(null)}
- onComplete={() => { setInstallTarget(null); load(); }}
+ onComplete={() => { setInstallTarget(null); reload(); }}
/>
</div>
);
diff --git a/client/src/components/models/Image3dRuntimes.test.jsx b/client/src/components/models/Image3dRuntimes.test.jsx
index 1aa8afc31a..d0f8f385f9 100644
--- a/client/src/components/models/Image3dRuntimes.test.jsx
+++ b/client/src/components/models/Image3dRuntimes.test.jsx
@@ -8,6 +8,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
+import { imageTo3dTarget } from '../../lib/imageTo3dTargetFixture';
import Image3dRuntimes from './Image3dRuntimes';
const getImageTo3dTargets = vi.fn();
@@ -25,26 +26,7 @@ vi.mock('../install/RuntimeInstallModal', () => ({
</div> : null),
}));
-const target = (over = {}) => ({
- id: 'trellis2',
- label: 'TRELLIS.2',
- description: 'Microsoft TRELLIS.2 — single image to a PBR-textured GLB mesh.',
- executionLane: 'local-mps',
- outputKind: 'glb-mesh',
- available: true,
- installed: false,
- unavailableReason: null,
- upstream: 'https://github.com/microsoft/TRELLIS.2',
- port: 'https://github.com/shivampkumar/trellis-mac',
- gatedRepos: [
- {
- label: 'facebook/dinov3-vitl16-pretrain-lvd1689m',
- url: 'https://huggingface.co/facebook/dinov3-vitl16-pretrain-lvd1689m',
- },
- { label: 'briaai/RMBG-2.0', url: 'https://huggingface.co/briaai/RMBG-2.0' },
- ],
- ...over,
-});
+const target = imageTo3dTarget;
const renderPanel = () => render(<MemoryRouter><Image3dRuntimes /></MemoryRouter>);
diff --git a/client/src/components/models/ModelStatusTab.jsx b/client/src/components/models/ModelStatusTab.jsx
index 687f503030..2d83670789 100644
--- a/client/src/components/models/ModelStatusTab.jsx
+++ b/client/src/components/models/ModelStatusTab.jsx
@@ -1,4 +1,4 @@
-import ModelsPanel from '../system-resources/ModelsPanel.jsx';
+import ModelsPanel from './ModelsPanel.jsx';
import { useSystemResourceReport } from '../../hooks/useSystemResourceReport.js';
/**
diff --git a/client/src/components/system-resources/ModelsPanel.jsx b/client/src/components/models/ModelsPanel.jsx
similarity index 99%
rename from client/src/components/system-resources/ModelsPanel.jsx
rename to client/src/components/models/ModelsPanel.jsx
index 00feb63493..83515a7c48 100644
--- a/client/src/components/system-resources/ModelsPanel.jsx
+++ b/client/src/components/models/ModelsPanel.jsx
@@ -3,7 +3,7 @@ import { AlertTriangle, Box, Download, HardDrive, RefreshCw } from 'lucide-react
import { Link } from 'react-router';
import MemoryManagement from '../settings/MemoryManagement.jsx';
import Banner from '../ui/Banner.jsx';
-import CleanupControl from './CleanupControl.jsx';
+import CleanupControl from '../system-resources/CleanupControl.jsx';
import { formatBytes } from '../../utils/formatters.js';
const BACKEND_LABEL = {
diff --git a/client/src/components/system-resources/ModelsPanel.test.jsx b/client/src/components/models/ModelsPanel.test.jsx
similarity index 100%
rename from client/src/components/system-resources/ModelsPanel.test.jsx
rename to client/src/components/models/ModelsPanel.test.jsx
diff --git a/client/src/components/models/ModelsTabsHeader.jsx b/client/src/components/models/ModelsTabsHeader.jsx
index 24030ea30d..9646a21f5e 100644
--- a/client/src/components/models/ModelsTabsHeader.jsx
+++ b/client/src/components/models/ModelsTabsHeader.jsx
@@ -19,9 +19,9 @@ import RouteTabsHeader from '../ui/RouteTabsHeader';
// section and the path is in ⌘K history — but it renders this header too, so
// selecting it does not strand the user outside the tab bar.
//
-// Keep this list alphabetical by label, matching the sidebar convention. It is
-// past the width a scrolling pill bar reads well at, so the header collapses to
-// a `<select>` under `sm`.
+// Keep this list alphabetical by label, matching the sidebar convention.
+// RouteTabsHeader collapses a list this long to a `<select>` under `sm` on its
+// own — no per-section flag to remember.
export const TABS = [
{ id: '3d', label: '3D', to: '/models/3d' },
{ id: 'embeddings', label: 'Embeddings', to: '/models/embeddings' },
@@ -35,13 +35,5 @@ export const TABS = [
];
export default function ModelsTabsHeader({ activeTab }) {
- return (
- <RouteTabsHeader
- tabs={TABS}
- activeTab={activeTab}
- ariaLabel="Models sections"
- mobileDropdown
- mobileSelectId="models-section-select"
- />
- );
+ return <RouteTabsHeader tabs={TABS} activeTab={activeTab} ariaLabel="Models sections" />;
}
diff --git a/client/src/components/ui/RouteTabsHeader.jsx b/client/src/components/ui/RouteTabsHeader.jsx
index 61c7261cd3..27f6eb5f81 100644
--- a/client/src/components/ui/RouteTabsHeader.jsx
+++ b/client/src/components/ui/RouteTabsHeader.jsx
@@ -1,6 +1,12 @@
import { useNavigate } from 'react-router';
import TabPills from './TabPills';
+// Above this many tabs, a phone-width pill row is a horizontal scroll nobody
+// finds the far end of. Six fits 375px; nine (Models) does not.
+const MOBILE_DROPDOWN_THRESHOLD = 6;
+
+const selectIdFor = (ariaLabel) => `${String(ariaLabel || 'section').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')}-select`;
+
/**
* A `TabPills` bar whose tabs are ROUTES rather than local state.
*
@@ -15,14 +21,19 @@ import TabPills from './TabPills';
* whose `to` lives outside their route prefix (Models → Playground) — the id
* still selects it, so the host page passes its own `activeTab`.
*
- * Sections with more tabs than a pill bar reads well at (Models) pass
- * `mobileDropdown` — plus `mobileSelectId`, so the collapsed `<select>` gets a
- * real `<label htmlFor>` rather than only an aria-label.
+ * Past `MOBILE_DROPDOWN_THRESHOLD` tabs the bar collapses to a `<select>` under
+ * `sm`. That is decided HERE rather than per section: every caller has the same
+ * phone width and the same pill sizes, so leaving it to each one meant Settings
+ * (19 tabs) kept scrolling horizontally while Models (9) collapsed. The select's
+ * id is derived from `ariaLabel` for the same reason — a caller that passed
+ * `mobileDropdown` but forgot the id silently downgraded from a real
+ * `<label htmlFor>` to a bare aria-label, and nothing failed.
*
- * @param {{ tabs: Array<{id:string,label:string,to:string}>, activeTab: string, ariaLabel: string, mobileDropdown?: boolean, mobileSelectId?: string }} props
+ * @param {{ tabs: Array<{id:string,label:string,to:string}>, activeTab: string, ariaLabel: string }} props
*/
-export default function RouteTabsHeader({ tabs, activeTab, ariaLabel, mobileDropdown = false, mobileSelectId }) {
+export default function RouteTabsHeader({ tabs, activeTab, ariaLabel }) {
const navigate = useNavigate();
+ const mobileDropdown = tabs.length > MOBILE_DROPDOWN_THRESHOLD;
const handleChange = (tabId) => {
const target = tabs.find((t) => t.id === tabId);
@@ -36,7 +47,7 @@ export default function RouteTabsHeader({ tabs, activeTab, ariaLabel, mobileDrop
onChange={handleChange}
ariaLabel={ariaLabel}
mobileDropdown={mobileDropdown}
- mobileSelectId={mobileSelectId}
+ mobileSelectId={mobileDropdown ? selectIdFor(ariaLabel) : undefined}
className="w-full min-w-0 shrink-0"
/>
);
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index da08edf15d..310c29adb3 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -184,6 +184,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| `useSongTraining` | Drives a song training run over one scope (whole song or a sliced section) on top of `useColorMatch`: counts in, walks + grades the scope's score, then folds the finished take into the rolling progress history (`songProgress.recordAttempt`) and surfaces the next aggregate via `onProgress`. Supports looping (auto-restart after a run) and keeps a `lastSummary`. Exposes `{ running, countingIn, noteColors, activeIndex, lastSummary, start, stop }`; cancels pending loop relaunches on stop/unmount. | The Song editor's Training panel. |
| `useSyncIntegrity` | Fetches per-kind integrity diff from every eligible online peer; reduces to worst-case `statusById` + `byPeer` breakdown maps. | Federated media sync integrity UI — badges, drawers, peer breakdown. |
| `useSystemResourceReport` | The system-resource disk scan plus its cleanup lifecycle: generation-guarded `runReport` (a late scan can never resurrect rows a newer one removed), one-delete-at-a-time removal keyed on the candidate's server-issued action, and report invalidation after a successful delete. Returns `{ report, setReport, loading, runReport, cleanup }` — `cleanup` is the prop bag `StoragePanel`/`ModelsPanel`/`CleanupControl` expect. | Dev Tools → System Resources → Storage, and Models → Status. Don't re-wire the scan/cleanup pair by hand. |
+| `useImageTo3dTargets` | The image-to-3D target registry (`GET /api/image-to-3d/targets`), fetched once per mount. Returns `{ targets, loading, error, reload }` — `error` is first-class, because a failed registry read is NOT an empty registry and both call sites render that distinction. | The `/3d` render flow (target picker + readiness summary) and Models → 3D (install/repair). Don't re-roll the fetch in a third surface. |
| `useTwinEvaluationSuite` | Shared lifecycle for the three Digital Twin evaluation-suite panels (Values-Alignment, Adversarial-Boundary, Multi-Turn): loads suite + recent history (silenced), runs every selected provider/model in parallel, prepends fresh runs, and handles the stale-persona / partial-failure toast fan-out. `countField` names the suite's pass-count key so history stays generic. Returns `{ items, history, loading, running, results, expanded, setExpanded, run, reload }`. | The Digital Twin `TwinEvaluationSuitePanel` presentation shell — don't re-roll the load/run/history dance per suite. |
| `useRepoIntake` | The Brain capture boxes' GitHub-repo state: `repo` (the parsed `{owner,repo}` when the ENTIRE capture text is a repo URL — i.e. exactly when the server will clone it), the two sticky post-clone agent opt-ins (`options`/`toggle`, persisted to `localStorage`), per-capture repo-study context, and `intakeFor(submittedText)` which re-derives at submit time so a sticky tick can't ride along on a capture retyped into a plain thought. Also exports the pure `capturedGitHubRepo(text)`. | Any capture surface that should offer the malware-scan / repo-study runs. Render with `components/brain/RepoIntakeOptions`; don't re-parse the text in the component. |
| `useRenderJobQueue` | Per-entry render-job queue for the Universe Builder — `pendingByEntryId` (entryId → jobId[]), `pendingHeadByEntryId` (first jobId per entry for single-subscription thumbs), `enqueueEntryJobs` (append variation/canon jobs), `clearPendingForEntry` (shift a jobId out, or drop the entry). | Universe Builder render orchestration. Don't re-roll the per-entry pending-jobs reducer. |
diff --git a/client/src/hooks/index.js b/client/src/hooks/index.js
index 93a3c3f82f..d456fb6086 100644
--- a/client/src/hooks/index.js
+++ b/client/src/hooks/index.js
@@ -123,6 +123,7 @@ export * from './useOpenClawStream.js';
export * from './usePipelineProgress.js';
export * from './useReaderPanel.js';
export * from './useSeriesEditorial.js';
+export * from './useImageTo3dTargets.js';
export * from './useSseProgress.js';
export * from './useStoryStepRuns.jsx';
export * from './useModelDownloadStatus.js';
diff --git a/client/src/hooks/useImageTo3dTargets.js b/client/src/hooks/useImageTo3dTargets.js
new file mode 100644
index 0000000000..3865e32e76
--- /dev/null
+++ b/client/src/hooks/useImageTo3dTargets.js
@@ -0,0 +1,39 @@
+/**
+ * The image-to-3D target registry (`GET /api/image-to-3d/targets`), fetched once
+ * per mount.
+ *
+ * Two surfaces read the same list and neither can be derived from the other:
+ * `/3d` needs it to pick a render target and report how many runtimes are ready,
+ * and Models → 3D needs it to install/repair them (#4728). The descriptor is
+ * still growing (`degraded`, `repairable`, `gatedRepos`, `installNotes` all
+ * landed recently), so the fetch lives here rather than inline in both — a shape
+ * change is one edit, not two that can drift.
+ *
+ * `error` is a first-class return, not a swallowed catch: a failed registry read
+ * is NOT an empty registry, and both call sites render the distinction (a Retry
+ * affordance / "could not check" rather than "no models registered").
+ *
+ * @returns {{ targets: object[], loading: boolean, error: string|null, reload: () => void }}
+ */
+import { useCallback, useEffect, useState } from 'react';
+import { getImageTo3dTargets } from '../services/api';
+
+export function useImageTo3dTargets() {
+ const [targets, setTargets] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ const reload = useCallback(() => {
+ setLoading(true);
+ getImageTo3dTargets()
+ .then((data) => { setTargets(data?.targets || []); setError(null); })
+ .catch((err) => setError(err?.message || 'Failed to load 3D targets'))
+ .finally(() => setLoading(false));
+ }, []);
+
+ useEffect(() => { reload(); }, [reload]);
+
+ return { targets, loading, error, reload };
+}
+
+export default useImageTo3dTargets;
diff --git a/client/src/hooks/useSystemResourceReport.js b/client/src/hooks/useSystemResourceReport.js
index b868ac524c..f966843b40 100644
--- a/client/src/hooks/useSystemResourceReport.js
+++ b/client/src/hooks/useSystemResourceReport.js
@@ -20,7 +20,7 @@
* Returns `{ report, setReport, loading, runReport, cleanup }`, where `cleanup`
* is the prop bag `StoragePanel` / `ModelsPanel` / `CleanupControl` expect.
*/
-import { useCallback, useRef, useState } from 'react';
+import { useCallback, useMemo, useRef, useState } from 'react';
import * as api from '../services/api';
import toast from '../components/ui/Toast';
import { useConfirmDelete } from './useConfirmDelete.js';
@@ -83,14 +83,14 @@ export function useSystemResourceReport() {
setBusyId(null);
}, [runReport]);
- const cleanup = {
+ const cleanup = useMemo(() => ({
busyId,
locked: busyId != null || loading,
isConfirming,
request: requestDelete,
cancel: cancelDelete,
confirm: (candidate) => confirmDelete(() => removeCandidate(candidate)),
- };
+ }), [busyId, loading, isConfirming, requestDelete, cancelDelete, confirmDelete, removeCandidate]);
return { report, setReport, loading, runReport, cleanup };
}
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index 84fc6c11bc..64bec19d68 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -66,7 +66,8 @@ grep -i "what you want to do" client/src/lib/README.md
| `imageGenModes.js` | Node-safe (dependency-free) image/video backend constants + pure helpers: `IMAGE_GEN_MODE`, render-target mirror (`RENDER_TARGET_OPTIONS`, `normalizeRenderPinValue`, `applyRecordRenderPin` — fold a record's `imageMode`/`imageModelId` pin over a settings-derived cfg), `VIDEO_RENDER_MODES`, `modeLabel`, cloud/model-override/i2i capability gating. Imported by the server-side parity suite — must stay importable without client packages. |
| `imageGenDefaults.js` | Shared `DEFAULT_NEGATIVE_PROMPT` used by the Image Gen form and quick-submit entry points. Mirrors server-side default. |
| `imageGenResolutions.js` | Shared resolution presets for image generation. |
-| `imageTo3dReasons.js` | Client mirror of the image-to-3D unavailable-reason labels in `server/services/imageTo3d/targets.js`: `UNAVAILABLE_REASONS` (reason code → user-facing label), `UNAVAILABLE_REASON_FALLBACK`, and `unavailableReasonLabel(code, fallback?)`. Use this anywhere a target's `unavailableReason` is rendered — never re-declare the codes. Parity + code coverage enforced by `server/services/imageTo3d/unavailableReasons.parity.test.js`. |
+| `imageTo3dReasons.js` | Client mirror of the image-to-3D unavailable-reason labels in `server/services/imageTo3d/targets.js`: `UNAVAILABLE_REASONS` (reason code → user-facing label), `UNAVAILABLE_REASON_FALLBACK`, and `unavailableReasonLabel(code, fallback?)`, plus `isTargetReady(target)` — the shared readiness predicate (`installed` is tri-state: `null` = a hosted lane with no install concept, ready as soon as it is available). Use these anywhere a target's `unavailableReason` or readiness is rendered — never re-declare the codes or re-derive readiness from `target.installed` truthiness. Parity + code coverage enforced by `server/services/imageTo3d/unavailableReasons.parity.test.js`. |
+| `imageTo3dTargetFixture.js` | `imageTo3dTarget(overrides)` — one representative image-to-3D target descriptor for tests. Shared by the `/3d` and Models → 3D suites so a server-side descriptor change is one edit, not two fixtures that can half-update. |
| `imageTo3dRenderOptions.js` | Image-to-3D per-run render options — the client mirror of the server bounds (`SEED_MAX`), the `STEPS_PRESETS` / `DETAIL_PRESETS` / `ALPHA_MODE_PRESETS` select options, `renderOptionsBody` (fields → API body), `fieldsFromRun` (carry-over from the last run), and `runWantsTransparency` (mirrors the server's alpha gating — the viewer's force-opaque pass must agree with it). Pinned by `renderOptions.parity.test.js`. |
| `importerDeepLink.js` | The Importer deep-link contract both ways: `buildImporterLink({ universeId, seriesId, seriesName })` builds the `/importer?…` URL a Series Pipeline page navigates to; `resolveImporterDeepLink(...)` reads those params back into the universe + series names the importer matches on. |
| `muscriptorModels.js` | `MUSCRIPTOR_MODELS` (audio → MIDI size tiers `small`/`medium`/`large`) + `DEFAULT_MUSCRIPTOR_MODEL`. Single source consumed by the transcribe `<select>`s in `MusicVideo.jsx` and `ReferenceAnalysis.jsx`. Mirrors the server's `MUSCRIPTOR_MODELS` in `server/services/audioMidiTranscription.js`. |
diff --git a/client/src/lib/imageTo3dReasons.js b/client/src/lib/imageTo3dReasons.js
index e5654bea9e..6fec555e05 100644
--- a/client/src/lib/imageTo3dReasons.js
+++ b/client/src/lib/imageTo3dReasons.js
@@ -31,6 +31,23 @@ export const UNAVAILABLE_REASONS = Object.freeze({
'cuda-probe-failed': 'Could not detect this host’s GPU',
});
+/**
+ * Is this target ready to render on this host?
+ *
+ * `installed` is TRI-STATE and the third state is the one that gets missed:
+ * `true` = local weights present, `false` = installable but not installed, and
+ * `null` = the target has no install concept at all (a hosted API lane), which is
+ * ready the moment it is available. Gating on plain `target.installed` truthiness
+ * silently reports a hosted target as not-ready.
+ *
+ * Shared so the `/3d` readiness summary and the Models → 3D status badge can't
+ * give different answers about the same target.
+ *
+ * @param {{available?: boolean, installed?: boolean|null}|null} [target]
+ * @returns {boolean}
+ */
+export const isTargetReady = (target) => !!target && !!target.available && target.installed !== false;
+
/** Label for a reason code the map doesn't know (or a null/absent code). */
export const UNAVAILABLE_REASON_FALLBACK = 'Unsupported on this host';
diff --git a/client/src/lib/imageTo3dTargetFixture.js b/client/src/lib/imageTo3dTargetFixture.js
new file mode 100644
index 0000000000..b20655ef94
--- /dev/null
+++ b/client/src/lib/imageTo3dTargetFixture.js
@@ -0,0 +1,38 @@
+/**
+ * A representative image-to-3D target descriptor, for tests.
+ *
+ * Two suites render the same server descriptor from different hosts (the `/3d`
+ * render flow and Models → 3D), and the shape is still growing — `degraded`,
+ * `repairable`, `gatedRepos` and `installNotes` all landed recently. One fixture
+ * means a server-side field rename is a single edit; two copies mean a
+ * half-updated pair where one suite stays green while testing a shape the server
+ * no longer sends.
+ *
+ * Values mirror `server/services/imageTo3d/targets.js`; `installed: false` is the
+ * default because "available but not installed" is the state most cases vary
+ * from.
+ *
+ * @param {object} [over] fields to override.
+ */
+export const imageTo3dTarget = (over = {}) => ({
+ id: 'trellis2',
+ label: 'TRELLIS.2',
+ description: 'Microsoft TRELLIS.2 — single image to a PBR-textured GLB mesh.',
+ executionLane: 'local-mps',
+ outputKind: 'glb-mesh',
+ available: true,
+ installed: false,
+ unavailableReason: null,
+ upstream: 'https://github.com/microsoft/TRELLIS.2',
+ port: 'https://github.com/shivampkumar/trellis-mac',
+ gatedRepos: [
+ {
+ label: 'facebook/dinov3-vitl16-pretrain-lvd1689m',
+ url: 'https://huggingface.co/facebook/dinov3-vitl16-pretrain-lvd1689m',
+ },
+ { label: 'briaai/RMBG-2.0', url: 'https://huggingface.co/briaai/RMBG-2.0' },
+ ],
+ ...over,
+});
+
+export default imageTo3dTarget;
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index 375dd56b0b..b5f1f83494 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -37,6 +37,7 @@ export * as imageGenModes from './imageGenModes.js';
export * from './imageGenDefaults.js';
export * from './imageGenResolutions.js';
export * from './imageTo3dReasons.js';
+export * from './imageTo3dTargetFixture.js';
export * from './imageTo3dRenderOptions.js';
export * from './importerDeepLink.js';
export * from './letteringDensity.js';
diff --git a/client/src/pages/LoraDatasetDetail.jsx b/client/src/pages/LoraDatasetDetail.jsx
index 30b99f070b..25a6bb717d 100644
--- a/client/src/pages/LoraDatasetDetail.jsx
+++ b/client/src/pages/LoraDatasetDetail.jsx
@@ -1,5 +1,9 @@
/**
- * LoRA dataset workbench (/models/training/:datasetId).
+ * LoRA dataset workbench (/models/training/:recordId).
+ *
+ * Rendered by `pages/Models.jsx` inside the Models section shell (its TAB_DETAIL
+ * map), not as a bare route — so it keeps the section header and tab bar the way
+ * it used to under the Media Gen shell.
*
* Build reference material for one universe bible subject (generate via the image
* queue, upload, slice the reference-sheet turnaround), caption it with
@@ -268,8 +272,11 @@ function ReassignDialog({ dataset, onClose, onReassigned }) {
);
}
-export default function LoraDatasetDetail() {
- const { datasetId } = useParams();
+export default function LoraDatasetDetail({ recordId }) {
+ // Models renders this inside the section shell and passes the id from
+ // `/models/training/:recordId`; `:datasetId` is the fallback for a direct mount.
+ const params = useParams();
+ const datasetId = recordId ?? params.datasetId;
const [dataset, setDataset] = useState(null);
const [loadError, setLoadError] = useState(null);
const [subject, setSubject] = useState(null);
diff --git a/client/src/pages/Loras.jsx b/client/src/pages/Loras.jsx
index c5e41ee7cc..2c91c486e5 100644
--- a/client/src/pages/Loras.jsx
+++ b/client/src/pages/Loras.jsx
@@ -278,8 +278,10 @@ export default function Loras() {
return (
<div className="space-y-6">
+ {/* An h2, not an h1: this page is the LoRAs tab under the Models section
+ (#4728), whose PageHeader already owns the page's h1. */}
<div>
- <h1 className="text-2xl font-bold text-white mb-1">LoRA Manager</h1>
+ <h2 className="text-2xl font-bold text-white mb-1">LoRA Manager</h2>
<p className="text-sm text-gray-400">
Install LoRA fine-tunes from Civitai or HuggingFace and apply them to your Image Gen and Video Gen renders.
</p>
diff --git a/client/src/pages/Media3D.jsx b/client/src/pages/Media3D.jsx
index 7dd67eee14..cb3b2ee98f 100644
--- a/client/src/pages/Media3D.jsx
+++ b/client/src/pages/Media3D.jsx
@@ -1,8 +1,9 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { Link } from 'react-router';
import { Boxes, CheckCircle2, AlertTriangle, Loader2, ImagePlus, Sparkles, Settings2 } from 'lucide-react';
-import { getImageTo3dTargets, createImageTo3dModel, getImageTo3dModel, listImageTo3dModels } from '../services/api';
+import { createImageTo3dModel, getImageTo3dModel, listImageTo3dModels } from '../services/api';
import { useAutoRefetch } from '../hooks/useAutoRefetch';
+import { useImageTo3dTargets } from '../hooks/useImageTo3dTargets';
import useMounted from '../hooks/useMounted';
import { nameFromImageFilename, timeAgo } from '../utils/formatters';
import GalleryImagePicker from '../components/imageGen/GalleryImagePicker';
@@ -14,16 +15,11 @@ import MediaImage from '../components/MediaImage';
import { imageTo3dStatusMeta } from '../components/media/imageTo3dStatus';
import ImageTo3dRenderOptions from '../components/media/ImageTo3dRenderOptions';
import { renderOptionsBody } from '../lib/imageTo3dRenderOptions';
-import { unavailableReasonLabel } from '../lib/imageTo3dReasons';
+import { isTargetReady, unavailableReasonLabel } from '../lib/imageTo3dReasons';
// Poll cadence while a render is in flight (a real TRELLIS.2 render is multi-minute).
const POLL_INTERVAL_MS = 2500;
-// A target is generation-ready when it can run on this host and its local model
-// is present (installed:null means "no install concept" — a hosted target that's
-// ready as soon as it's available).
-const isTargetReady = (t) => !!t && t.available && t.installed !== false;
-
export default function Media3D() {
const [searchParams, updateParams] = useUrlParams();
// URL is the source of truth for what's open: the source image, the chosen
@@ -32,9 +28,7 @@ export default function Media3D() {
const targetFromRoute = searchParams.get('target') || '';
const glbFromRoute = searchParams.get('glb') || '';
- const [targets, setTargets] = useState([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
+ const { targets, loading, error } = useImageTo3dTargets();
const [pickerOpen, setPickerOpen] = useState(false);
// Render lifecycle: a create kicks off an on-device render, then we poll the
// record (via useAutoRefetch below) until it lands (ready → preview) or fails
@@ -58,14 +52,6 @@ export default function Media3D() {
const { present: hfTokenPresent, source: hfTokenSource, refresh: refreshHfToken } = useHfTokenStatus();
const mountedRef = useMounted(); // gate setState after the create/poll awaits
- const load = useCallback(() => {
- setLoading(true);
- getImageTo3dTargets()
- .then((data) => { setTargets(data?.targets || []); setError(null); })
- .catch((err) => setError(err?.message || 'Failed to load 3D targets'))
- .finally(() => setLoading(false));
- }, []);
-
const loadRecords = useCallback(() => {
listImageTo3dModels({ silent: true })
.then((data) => { if (mountedRef.current) setRecords(Array.isArray(data) ? data : []); })
@@ -81,7 +67,6 @@ export default function Media3D() {
: [record, ...prev]));
}, [mountedRef]);
- useEffect(() => { load(); }, [load]);
useEffect(() => { loadRecords(); }, [loadRecords]);
const selectedImage = useMemo(
@@ -168,6 +153,16 @@ export default function Media3D() {
return null;
})();
+ // One sentence describing runtime availability. A failed registry read reports
+ // the error rather than "0 registered" — a list that could not be READ is not an
+ // empty list, and the remedy differs.
+ const runtimeSummary = (() => {
+ if (loading) return 'Checking which image-to-3D runtimes are installed…';
+ if (error) return error;
+ if (!targets.length) return 'No image-to-3D models are registered.';
+ return `${targets.filter(isTargetReady).length} of ${targets.length} ready on this host.`;
+ })();
+
const gatedHfModels = selectedTarget?.available ? selectedTarget.gatedRepos : null;
return (
@@ -348,15 +343,7 @@ export default function Media3D() {
<div className="flex flex-wrap items-center justify-between gap-3">
<div className="min-w-0">
<h2 className="text-sm font-semibold text-white">Runtimes</h2>
- <p className="mt-1 text-xs text-gray-400">
- {loading
- ? 'Checking which image-to-3D runtimes are installed…'
- : error
- ? error
- : targets.length === 0
- ? 'No image-to-3D models are registered.'
- : `${targets.filter(isTargetReady).length} of ${targets.length} ready on this host.`}
- </p>
+ <p className="mt-1 text-xs text-gray-400">{runtimeSummary}</p>
</div>
<Link
to="/models/3d"
diff --git a/client/src/pages/Media3D.test.jsx b/client/src/pages/Media3D.test.jsx
index 7499831b77..52bf803a99 100644
--- a/client/src/pages/Media3D.test.jsx
+++ b/client/src/pages/Media3D.test.jsx
@@ -1,6 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { MemoryRouter, useLocation } from 'react-router';
+import { imageTo3dTarget } from '../lib/imageTo3dTargetFixture';
import Media3D from './Media3D';
const getImageTo3dTargets = vi.fn();
@@ -31,26 +32,7 @@ vi.mock('../components/imageGen/GalleryImagePicker', () => ({
vi.mock('../components/MediaImage', () => ({ default: ({ alt }) => <img alt={alt} /> }));
-const target = (over = {}) => ({
- id: 'trellis2',
- label: 'TRELLIS.2',
- description: 'Microsoft TRELLIS.2 — single image to a PBR-textured GLB mesh.',
- executionLane: 'local-mps',
- outputKind: 'glb-mesh',
- available: true,
- installed: false,
- unavailableReason: null,
- upstream: 'https://github.com/microsoft/TRELLIS.2',
- port: 'https://github.com/shivampkumar/trellis-mac',
- gatedRepos: [
- {
- label: 'facebook/dinov3-vitl16-pretrain-lvd1689m',
- url: 'https://huggingface.co/facebook/dinov3-vitl16-pretrain-lvd1689m',
- },
- { label: 'briaai/RMBG-2.0', url: 'https://huggingface.co/briaai/RMBG-2.0' },
- ],
- ...over,
-});
+const target = imageTo3dTarget;
function LocationProbe() {
return <output aria-label="Current query">{useLocation().search}</output>;
diff --git a/client/src/pages/Models.jsx b/client/src/pages/Models.jsx
index f344213e67..f9bcab082c 100644
--- a/client/src/pages/Models.jsx
+++ b/client/src/pages/Models.jsx
@@ -1,15 +1,24 @@
+import { Suspense } from 'react';
import { useParams, Navigate } from 'react-router';
import { Cpu } from 'lucide-react';
import PageHeader from '../components/PageHeader';
+import PageSkeleton from '../components/ui/PageSkeleton';
import ModelsTabsHeader from '../components/models/ModelsTabsHeader';
import Image3dRuntimes from '../components/models/Image3dRuntimes';
import ModelStatusTab from '../components/models/ModelStatusTab';
import EmbeddingsTab from '../components/settings/EmbeddingsTab';
import LocalModelAssessments from '../components/settings/LocalModelAssessments.jsx';
import { LocalLlmTab } from '../components/settings/LocalLlmTab';
-import Loras from './Loras';
-import LoraTraining from './LoraTraining';
-import MediaModels from './MediaModels';
+import { lazyWithReload } from '../utils/lazyWithReload';
+
+// The three panels moved in from the Media Gen tabs were each their own route
+// chunk before the move (#4728) — keep them split, or landing on Performance
+// downloads the whole LoRA manager and HF-cache browser to render an
+// assessments table. The small always-on tabs above stay static.
+const Loras = lazyWithReload(() => import('./Loras'));
+const LoraTraining = lazyWithReload(() => import('./LoraTraining'));
+const LoraDatasetDetail = lazyWithReload(() => import('./LoraDatasetDetail'));
+const MediaModels = lazyWithReload(() => import('./MediaModels'));
/**
* Models — the top-level home for everything about the models this machine runs.
@@ -46,14 +55,32 @@ const TAB_CONTENT = {
training: LoraTraining,
};
+/**
+ * Drill-downs rendered INSIDE the section shell, keyed by the tab that owns them.
+ *
+ * A tab's detail view is still that tab — the LoRA dataset workbench is Training
+ * with one dataset open — so it keeps the section header and tab bar rather than
+ * becoming a bare route that drops both. Under `/media` these pages got that for
+ * free, because MediaGen was a layout route; declaring them here gives the same
+ * result without every future detail view needing its own special case in
+ * App.jsx.
+ */
+const TAB_DETAIL = {
+ training: LoraDatasetDetail,
+};
+
export default function Models() {
- const { tab } = useParams();
+ const { tab, recordId } = useParams();
// An unknown slug lands on Performance rather than rendering a blank page —
// it is the tab that answers "which model should I use?", which is what most
// people arrive here for.
const activeTab = tab && TAB_CONTENT[tab] ? tab : null;
if (!activeTab) return <Navigate to="/models/performance" replace />;
+ // A record id in the URL selects the tab's drill-down, when it has one. A tab
+ // with no detail view ignores the extra segment and renders its index — better
+ // than 404ing a link that merely carries one segment too many.
+ const DetailContent = recordId ? TAB_DETAIL[activeTab] : null;
const TabContent = TAB_CONTENT[activeTab];
return (
@@ -63,7 +90,11 @@ export default function Models() {
<ModelsTabsHeader activeTab={activeTab} />
<div className="flex-1 min-w-0 overflow-auto p-4">
- <TabContent />
+ {/* Local boundary rather than the App-level one: a lazy tab must not blank
+ out the section header and tab bar while its chunk loads. */}
+ <Suspense fallback={<PageSkeleton />}>
+ {DetailContent ? <DetailContent recordId={recordId} /> : <TabContent />}
+ </Suspense>
</div>
</div>
);
diff --git a/client/src/pages/Models.test.jsx b/client/src/pages/Models.test.jsx
index 93315f90c1..d1addd20b3 100644
--- a/client/src/pages/Models.test.jsx
+++ b/client/src/pages/Models.test.jsx
@@ -12,7 +12,6 @@ import { render, screen } from '@testing-library/react';
import { MemoryRouter, Route, Routes } from 'react-router';
import { TABS } from '../components/models/ModelsTabsHeader';
-vi.mock('../components/settings/MemoryManagement.jsx', () => ({ default: () => <div>memory panel</div> }));
vi.mock('../components/settings/LocalModelAssessments.jsx', () => ({ default: () => <div>assessments panel</div> }));
vi.mock('../components/settings/LocalLlmTab', () => ({ LocalLlmTab: () => <div>llms panel</div> }));
vi.mock('../components/settings/EmbeddingsTab', () => ({ default: () => <div>embeddings panel</div> }));
@@ -21,38 +20,66 @@ vi.mock('../components/models/ModelStatusTab', () => ({ default: () => <div>stat
vi.mock('./Loras', () => ({ default: () => <div>loras panel</div> }));
vi.mock('./LoraTraining', () => ({ default: () => <div>training panel</div> }));
vi.mock('./MediaModels', () => ({ default: () => <div>media models panel</div> }));
+vi.mock('./LoraDatasetDetail', () => ({ default: ({ recordId }) => <div>dataset workbench {recordId}</div> }));
import Models from './Models';
+// The marker each tab's stubbed panel renders. Keyed by tab id so the cases below
+// are DERIVED from the header's TABS rather than re-listing the paths — a tab
+// added to the header with no entry here fails the completeness check, instead of
+// quietly going unrendered by a hand-maintained second list.
+const PANEL_MARKER = {
+ '3d': '3d runtimes panel',
+ embeddings: 'embeddings panel',
+ llms: 'llms panel',
+ loras: 'loras panel',
+ media: 'media models panel',
+ performance: 'assessments panel',
+ status: 'status panel',
+ training: 'training panel',
+};
+
+// Playground is the one destination the header lists that this page does not
+// serve — it predates the section and keeps its own `/local-llm/playground` path.
+const EXTERNAL_TAB_IDS = ['playground'];
+const ownTabs = TABS.filter((t) => !EXTERNAL_TAB_IDS.includes(t.id));
+
const renderAt = (path) => render(
<MemoryRouter initialEntries={[path]}>
<Routes>
<Route path="/models/:tab" element={<Models />} />
+ <Route path="/models/:tab/:recordId" element={<Models />} />
</Routes>
</MemoryRouter>
);
describe('Models', () => {
- it.each([
- ['/models/3d', '3d runtimes panel'],
- ['/models/embeddings', 'embeddings panel'],
- ['/models/llms', 'llms panel'],
- ['/models/loras', 'loras panel'],
- ['/models/media', 'media models panel'],
- ['/models/performance', 'assessments panel'],
- ['/models/status', 'status panel'],
- ['/models/training', 'training panel'],
- ])('renders %s from the route param, not from local state', (path, expected) => {
- renderAt(path);
- expect(screen.getByText(expected)).toBeInTheDocument();
+ it('names the one destination served outside /models', () => {
+ // Asserted by id, not as a count: the day a second external destination joins
+ // the header, this should say WHICH one appeared, not just that a number moved.
+ expect(TABS.filter((t) => !t.to.startsWith('/models/')).map((t) => t.id)).toEqual(EXTERNAL_TAB_IDS);
});
+ it('has a panel marker for every tab this page serves', () => {
+ expect(ownTabs.map((t) => t.id).filter((id) => !PANEL_MARKER[id])).toEqual([]);
+ });
+
+ it.each(ownTabs.map((t) => [t.to, PANEL_MARKER[t.id]]))(
+ 'renders %s from the route param, not from local state',
+ async (path, expected) => {
+ renderAt(path);
+ // `await`, not a sync get: the three panels moved in from the Media Gen tabs
+ // are lazy chunks, so they resolve a tick after mount.
+ expect(await screen.findByText(expected)).toBeInTheDocument();
+ },
+ );
+
// A stale ⌘K entry or a typo must not produce a blank page — Performance is
// the tab that answers "which model should I use?", which is why people land
// here at all.
- it('redirects an unknown tab slug to Performance', () => {
+ it('redirects an unknown tab slug to Performance', async () => {
renderAt('/models/not-a-tab');
- expect(screen.getByText('assessments panel')).toBeInTheDocument();
+ expect(await screen.findByText('assessments panel')).toBeInTheDocument();
});
it('offers every Models destination in the sub-nav', () => {
@@ -70,20 +97,34 @@ describe('Models', () => {
expect([...select.options].map((o) => o.textContent)).toEqual(TABS.map((t) => t.label));
});
- // The header is the section's own map, so it must stay in sync with what the
- // page can actually render. A tab listed but missing from TAB_CONTENT falls
- // through to the unknown-slug redirect and silently lands on Performance —
- // which the per-path cases above cannot see, because they enumerate the paths
- // by hand. Selection state is what distinguishes "rendered this tab" from
- // "bounced to Performance". Playground is the one deliberate exception: it
- // predates the section and keeps its own `/local-llm/playground` path.
+ // A tab listed in the header but missing from TAB_CONTENT falls through to the
+ // unknown-slug redirect and silently lands on Performance. Selection state is
+ // what distinguishes "rendered this tab" from "bounced to Performance" — the
+ // per-path cases above can't see it, because a bounced tab still renders A panel.
it('serves every /models tab the header advertises, without bouncing to Performance', () => {
- const own = TABS.filter((t) => t.to.startsWith('/models/'));
- expect(own.length).toBe(TABS.length - 1);
- for (const tab of own) {
+ for (const tab of ownTabs) {
const { unmount } = renderAt(tab.to);
expect(screen.getByRole('tab', { name: tab.label })).toHaveAttribute('aria-selected', 'true');
unmount();
}
});
});
+
+describe('Models — tab drill-downs', () => {
+ it('renders a tab detail view INSIDE the section shell, not as a bare page', async () => {
+ // Under /media these pages kept the shell's chrome for free, because MediaGen
+ // was a layout route. Registering the workbench as its own top-level route
+ // would silently drop the section header and tab bar; asserting the tab bar is
+ // still present (and still marks Training active) is what catches that.
+ renderAt('/models/training/dataset-abc');
+ expect(await screen.findByText('dataset workbench dataset-abc')).toBeInTheDocument();
+ expect(screen.getByRole('tab', { name: 'Training' })).toHaveAttribute('aria-selected', 'true');
+ });
+
+ it('falls back to the tab index when the tab has no detail view', async () => {
+ // A link carrying one segment too many should land on something real rather
+ // than 404 — every tab except Training is in this case today.
+ renderAt('/models/loras/some-id');
+ expect(await screen.findByText('loras panel')).toBeInTheDocument();
+ });
+});
diff --git a/server/lib/navManifest.js b/server/lib/navManifest.js
index c32c0cd564..fe77529d5c 100644
--- a/server/lib/navManifest.js
+++ b/server/lib/navManifest.js
@@ -1,7 +1,15 @@
// Single source of truth for PortOS navigation. Consumed by
// server/services/voice/tools.js#ui_navigate and the Cmd+K palette.
-// Entry: { id, path, label, section, aliases?, keywords? }. See CLAUDE.md
-// "Command Palette & Voice Nav" for the contract.
+// Entry: { id, path, label, section, aliases?, keywords?, previousPaths? }.
+// See CLAUDE.md "Command Palette & Voice Nav" for the contract.
+//
+// `previousPaths` lists every path this page has ANSWERED TO BEFORE. Bookmarks,
+// stale palette history, and links held by other installs all still say the old
+// path, so a move that drops the redirect 404s them — and nothing else notices,
+// because every other guard here only looks at where a route points now. Declare
+// the old path when you move a page and `navManifest.test.js` proves App.jsx
+// still redirects it; the data lives next to the thing that moved, so the next
+// move needs no edit to the test.
import { PORTOS_APP_ID } from './appIdentity.js';
@@ -267,16 +275,16 @@ export const NAV_COMMANDS = [
// prefix: they are opaque and stored in palette history, so renaming them
// would orphan those entries — only the path, label and section move.
{ id: 'nav.models.3d', path: '/models/3d', label: '3D Runtimes', section: 'Models', aliases: ['3d-runtimes', 'image-to-3d-runtimes', 'trellis-install', 'pixal3d-install'], keywords: ['trellis', 'pixal3d', 'install', 'repair', 'runtime', 'mesh', 'image to 3d', 'on-device'] },
- { id: 'nav.settings.embeddings', path: '/models/embeddings', label: 'Embeddings', section: 'Models', aliases: ['settings-embeddings', 'embeddings', 'embedding'], keywords: ['vector', 'pgvector', 'semantic search', 'nomic', 'ollama', 'lm studio'] },
- { id: 'nav.settings.local-llm', path: '/models/llms', label: 'LLMs', section: 'Models', aliases: ['local-llm', 'local-llms', 'llms', 'models-llms', 'ollama', 'lm-studio', 'lmstudio'], keywords: ['ollama', 'lm studio', 'local model', 'local llm', 'gguf', 'pull model', 'install model', 'migrate', 'switch backend', 'llama.cpp'] },
- { id: 'nav.media.loras', path: '/models/loras', label: 'LoRAs', section: 'Models', aliases: ['loras', 'lora', 'lora-manager', 'civitai'], keywords: ['lora', 'civitai', 'fine-tune', 'style adapter', 'realstagram', 'photoreal', 'flux lora'] },
- { id: 'nav.media.training', path: '/models/training', label: 'LoRA Training', section: 'Models', aliases: ['training', 'lora-training', 'train-lora', 'datasets', 'character-lora'], keywords: ['fine-tune', 'dataset', 'caption', 'dreambooth', 'character consistency', 'train', 'flux lora'] },
- { id: 'nav.media.models', path: '/models/media', label: 'Media Models', section: 'Models', aliases: ['media-models', 'image-models', 'video-models', 'huggingface'], keywords: ['hf cache', 'model storage', 'disk', 'add model', 'install model', 'custom model'] },
+ { id: 'nav.settings.embeddings', path: '/models/embeddings', label: 'Embeddings', section: 'Models', previousPaths: ['/settings/embeddings'], aliases: ['settings-embeddings', 'embeddings', 'embedding'], keywords: ['vector', 'pgvector', 'semantic search', 'nomic', 'ollama', 'lm studio'] },
+ { id: 'nav.settings.local-llm', path: '/models/llms', label: 'LLMs', section: 'Models', previousPaths: ['/settings/local-llm'], aliases: ['local-llm', 'local-llms', 'llms', 'models-llms', 'ollama', 'lm-studio', 'lmstudio'], keywords: ['ollama', 'lm studio', 'local model', 'local llm', 'gguf', 'pull model', 'install model', 'migrate', 'switch backend', 'llama.cpp'] },
+ { id: 'nav.media.loras', path: '/models/loras', label: 'LoRAs', section: 'Models', previousPaths: ['/media/loras'], aliases: ['loras', 'lora', 'lora-manager', 'civitai'], keywords: ['lora', 'civitai', 'fine-tune', 'style adapter', 'realstagram', 'photoreal', 'flux lora'] },
+ { id: 'nav.media.training', path: '/models/training', label: 'LoRA Training', section: 'Models', previousPaths: ['/media/training'], aliases: ['training', 'lora-training', 'train-lora', 'datasets', 'character-lora'], keywords: ['fine-tune', 'dataset', 'caption', 'dreambooth', 'character consistency', 'train', 'flux lora'] },
+ { id: 'nav.media.models', path: '/models/media', label: 'Media Models', section: 'Models', previousPaths: ['/media/models', '/media-models'], aliases: ['media-models', 'image-models', 'video-models', 'huggingface'], keywords: ['hf cache', 'model storage', 'disk', 'add model', 'install model', 'custom model'] },
{ id: 'nav.models.performance', path: '/models/performance', label: 'Model Performance', section: 'Models', aliases: ['model-performance', 'performance', 'assessments', 'model-assessments', 'benchmark-models', 'tuning'], keywords: ['measure', 'assessment', 'benchmark', 'throughput', 'chars per second', 'ttft', 'context', 'tuning', 'llama.cpp', 'mtplx', 'vllm', 'which model', 'fastest model'] },
// Absorbed the Dev Tools 'Model Resources' page (#4728), so its aliases and
// keywords live here — 'model resources' and 'downloaded models' must keep
// resolving after the fold.
- { id: 'nav.models.status', path: '/models/status', label: 'Model Status', section: 'Models', aliases: ['model-status', 'models-status', 'memory-management', 'resident-models', 'model-resources', 'loaded-models', 'downloaded-models', 'model-memory'], keywords: ['memory', 'resident', 'loaded', 'unload', 'ram', 'vram', 'free memory', 'what is loaded', 'ollama', 'lm studio', 'hugging face', 'lora', 'delete model', 'disk'] },
+ { id: 'nav.models.status', path: '/models/status', label: 'Model Status', section: 'Models', previousPaths: ['/system-resources/models'], aliases: ['model-status', 'models-status', 'memory-management', 'resident-models', 'model-resources', 'loaded-models', 'downloaded-models', 'model-memory'], keywords: ['memory', 'resident', 'loaded', 'unload', 'ram', 'vram', 'free memory', 'what is loaded', 'ollama', 'lm studio', 'hugging face', 'lora', 'delete model', 'disk'] },
{ id: 'nav.settings.local-llm-playground', path: '/local-llm/playground', label: 'Local LLM Playground', section: 'Models', aliases: ['llm-playground', 'playground', 'model-playground', 'compare-models'], keywords: ['ollama', 'lm studio', 'compare', 'benchmark', 'chat', 'test model', 'ttft', 'tokens per second', 'local llm'] },
{ id: 'nav.settings.mortalloom', path: '/settings/mortalloom', label: 'MortalLoom', section: 'Settings', aliases: ['settings-mortalloom', 'mortalloom'] },
{ id: 'nav.settings.openclaw', path: '/openclaw', label: 'OpenClaw', section: 'Settings', aliases: ['openclaw', 'settings-openclaw'], keywords: ['operator', 'chat', 'agent', 'runtime', 'sessions', 'streaming'] },
diff --git a/server/lib/navManifest.test.js b/server/lib/navManifest.test.js
index 18af8f7cdd..0a465b99f2 100644
--- a/server/lib/navManifest.test.js
+++ b/server/lib/navManifest.test.js
@@ -531,23 +531,35 @@ describe('nav coverage — every navigable App.jsx route has a manifest entry',
// stale ⌘K history, and in links other installs' peers may hold. A move that
// forgets the redirect 404s all of them, and nothing else in this file would
// notice — the coverage guard above only looks at where routes point NOW.
- it('keeps a redirect for every relocated model-management path', () => {
- const moved = [
- ['/media/models', '/models/media'],
- ['/media/loras', '/models/loras'],
- ['/media/training', '/models/training'],
- ['/settings/embeddings', '/models/embeddings'],
- ['/settings/local-llm', '/models/llms'],
- ['/system-resources/models', '/models/status'],
- ['/media-models', '/models/media'],
- ];
+ //
+ // Driven by each command's own `previousPaths`, NOT a list maintained here: the
+ // declaration then lives beside the path that moved, and the next move is one
+ // edit in navManifest.js instead of two files that can disagree.
+ it('keeps a redirect from every declared previous path to its current one', () => {
const byFrom = new Map(scan.redirects.map((r) => [r.from, r.to]));
- const broken = moved
- .filter(([from, to]) => byFrom.get(from) !== to)
- .map(([from, to]) => `${from} → ${byFrom.get(from) ?? 'NO REDIRECT'} (want ${to})`);
+ const broken = NAV_COMMANDS
+ .flatMap((c) => (c.previousPaths || []).map((from) => ({ from, to: c.path.split(/[?#]/)[0], id: c.id })))
+ .filter(({ from, to }) => byFrom.get(from) !== to)
+ .map(({ from, to, id }) => `${id}: ${from} → ${byFrom.get(from) ?? 'NO REDIRECT'} (want ${to})`);
expect(broken).toEqual([]);
});
+ // The guard above is only as good as what it is pointed at, and it reads a
+ // field that is easy to simply not add. Pin the moves already made so deleting
+ // a `previousPaths` entry fails here rather than silently shrinking coverage.
+ it('still declares the previous paths of the pages already moved', () => {
+ const declared = new Set(NAV_COMMANDS.flatMap((c) => c.previousPaths || []));
+ const missing = [
+ '/settings/local-llm', // #4736 — Local LLM management left Settings
+ '/media/models', // #4728 — the rest of model management left Create/Settings/Dev Tools
+ '/media/loras',
+ '/media/training',
+ '/settings/embeddings',
+ '/system-resources/models',
+ ].filter((p) => !declared.has(p));
+ expect(missing).toEqual([]);
+ });
+
// A redirect that forwards to a path nothing serves is a 404 with extra steps.
it('every redirect lands on a real route or nav destination', () => {
const known = new Set([...routePaths, ...navPaths]);