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: share image-to-3D unavailable-reason labels between server and client (#3579)

[._.]/ Adam Eivy004546a4be4f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 3c7dad2b4c..432a7ee3d0 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -191,3 +191,4 @@
- **[issue-3578] Image-to-3D renders no longer stall the progress bar on a stage banner that lands across two chunks.** The shared generate driver split each `data` chunk from the generator on its own, with nothing carried between them — but a child process hands out its output on arbitrary byte boundaries, so a banner like "Baking textures at 2048px" could arrive as two halves, neither of which matched any stage signature. The percent then sat where the previous banner left it until the next one happened to land whole, which on the long sampling phase reads as a hung render. Both lanes now feed their output through the same buffered line reader the rest of the app's subprocess streams use, which stitches the partial line back together and flushes whatever is left when the child exits — so a generator that writes its final "Saved:" line without a trailing newline still has its asset path read. stdout and stderr keep separate buffers, since a shared one would splice a partial line from one stream onto a chunk from the other. Tqdm's carriage-return redraws still surface as individual frames, and the raw output kept for classifying a non-zero exit is unchanged, so an out-of-memory or gated-model failure is still named the same way.
- **[issue-3565] Three Writers Room controls are now big enough to hit on a phone.** The Edit pencil on every Cast/Places/Objects bible row was an 11px icon with no padding around it — an ~11x11px tap target sitting next to the row text, so a thumb aiming for it selected the entry description instead. The snapshot Revert button in the Polish panel was 11px text and a matching icon on a row with no vertical padding of its own (~16px tall), and the World style Clear button in the Storyboard config tab was bare 9px text (~10x22px). All three now clear the 44px floor the rest of the app uses. Each one bleeds into the padding its own row already had rather than adding height on top of it, so the bible list and the snapshot list keep their density and the Clear button stays inside its stack gap instead of overlapping the style dropdown beneath it.
+- **[issue-3579] Refusing a 3D model install on unsupported hardware now says why in English, and a new reason code can no longer go label-less.** The image-to-3D registry answers "can this host run that target?" with stable codes like `requires-linux-host` and `cuda-probe-failed`; the 3D page turned those into sentences from a hand-written table of its own, and the install endpoint had no table at all — so asking to install a target this machine can't run streamed back "This host cannot run TRELLIS.2 (CUDA) (requires-linux-host)", handing the user the internal code instead of the one thing they could act on. Both sides now render the same shared map, which lives next to the function that returns the codes and is mirrored to the client the way the catalog type registry already is. A parity test asserts the two copies never drift, and — the reason the drift was worth fixing rather than just re-syncing — it also reads the resolver's source and asserts the labelled set still *equals* the codes it can actually return. The previous arrangement failed silently: the CUDA lane added three codes by hand on each side, and a fourth that someone forgot to mirror would have rendered as the generic "Unsupported on this host" with every test still green.
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index b6ed5e9529..fb66a183f1 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -59,6 +59,7 @@ 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`), `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`. |
| `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`. |
| `videoGenParams.js` | Pure VideoGen param helpers: `FRAME_OPTIONS`/`FPS_OPTIONS`/`VIDEO_EDGE_BOUNDS` constants, `videoModelMemoryGb()` (model memory footprint), `computeFflfSafeFrames()` (FFLF/ltx2 pixel-budget back-solve, mirrors `server/services/videoGen/local.js`), and `isModelAllowedForMode()` (a2v + IC-remix → ltx2 gate). Also mirrors the IC-LoRA remix registry (`IC_LORA_MODES`/`IC_LORA_MODE_VALUES`/`isIcLoraMode()`/`icLoraSpecForMode()`/`icResolutionIssue()`) from `server/lib/icLoraWeights.js` so the form validates a reference render pre-submit — pinned by `server/lib/icLoraWeights.parity.test.js`. |
diff --git a/client/src/lib/imageTo3dReasons.js b/client/src/lib/imageTo3dReasons.js
new file mode 100644
index 0000000000..c3d6636a39
--- /dev/null
+++ b/client/src/lib/imageTo3dReasons.js
@@ -0,0 +1,41 @@
+/**
+ * Client mirror of the image-to-3D unavailable-reason labels in
+ * `server/services/imageTo3d/targets.js`. The server registry returns stable
+ * kebab-case reason codes (`requires-cuda`, `cuda-probe-failed`, …) on every
+ * target it reports as unavailable; this is the label side the UI renders.
+ *
+ * The client can't import the server registry (it pulls in `os` /
+ * `child_process` through the capability probes), so this is a hand-maintained
+ * mirror — drift is asserted by
+ * `server/services/imageTo3d/unavailableReasons.parity.test.js`, which also
+ * checks the key set still equals the codes `unavailableReason()` returns. If
+ * you change one side, change the other.
+ */
+
+export const UNAVAILABLE_REASONS = Object.freeze({
+ 'unknown-target': 'Unavailable',
+ 'requires-apple-silicon': 'Requires an Apple Silicon Mac',
+ 'insufficient-memory': 'Needs 24 GB+ of unified memory',
+ 'requires-cuda': 'Requires an NVIDIA CUDA GPU',
+ // Shown on a Windows host that HAS a qualifying card: upstream TRELLIS.2 builds
+ // its CUDA extensions against a POSIX toolchain and is Linux-only, so WSL2 is the
+ // supported route — name it, since this blocker is the one the user can act on.
+ 'requires-linux-host': 'Requires a Linux host (use WSL2 on Windows)',
+ 'insufficient-vram': 'Needs a 24 GB+ NVIDIA GPU',
+ // The probe itself failed — say so rather than claiming the GPU isn't there.
+ 'cuda-probe-failed': 'Could not detect this host’s GPU',
+});
+
+/** Label for a reason code the map doesn't know (or a null/absent code). */
+export const UNAVAILABLE_REASON_FALLBACK = 'Unsupported on this host';
+
+/**
+ * User-facing label for a reason code. Own-property lookup only, so a code that
+ * happens to name an Object.prototype key can't render as a function/object.
+ * @param {string|null} [reason]
+ * @param {string} [fallback] label for an unknown/absent code.
+ * @returns {string}
+ */
+export function unavailableReasonLabel(reason, fallback = UNAVAILABLE_REASON_FALLBACK) {
+ return Object.hasOwn(UNAVAILABLE_REASONS, reason ?? '') ? UNAVAILABLE_REASONS[reason] : fallback;
+}
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index 5b59cf7354..28d2b92783 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -33,6 +33,7 @@ export * from './imageGenBackends.js';
export * as imageGenModes from './imageGenModes.js';
export * from './imageGenDefaults.js';
export * from './imageGenResolutions.js';
+export * from './imageTo3dReasons.js';
export * from './importerDeepLink.js';
export * from './letteringDensity.js';
export * from './issueLength.js';
diff --git a/client/src/pages/Media3D.jsx b/client/src/pages/Media3D.jsx
index 40cf0fdc3b..bb158e7151 100644
--- a/client/src/pages/Media3D.jsx
+++ b/client/src/pages/Media3D.jsx
@@ -13,6 +13,7 @@ import { useHfTokenStatus } from '../hooks/useHfTokenStatus';
import useUrlParams from '../hooks/useUrlParams';
import MediaImage from '../components/MediaImage';
import { imageTo3dStatusMeta } from '../components/media/imageTo3dStatus';
+import { 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;
@@ -65,22 +66,6 @@ function HfAccessNotice({ models, tokenPresent, tokenSource, onSaved }) {
);
}
-// Human-readable reasons a target can't run on this host, keyed by the stable
-// reason code the registry returns (server/services/imageTo3d/targets.js).
-const REASON_LABEL = {
- 'requires-apple-silicon': 'Requires an Apple Silicon Mac',
- 'insufficient-memory': 'Needs 24 GB+ of unified memory',
- 'requires-cuda': 'Requires an NVIDIA CUDA GPU',
- 'insufficient-vram': 'Needs a 24 GB+ NVIDIA GPU',
- // Shown on a Windows host that HAS a qualifying card: upstream TRELLIS.2 builds
- // its CUDA extensions against a POSIX toolchain and is Linux-only, so WSL2 is the
- // supported route — name it, since this blocker is the one the user can act on.
- 'requires-linux-host': 'Requires a Linux host (use WSL2 on Windows)',
- // The probe itself failed — say so rather than claiming the GPU isn't there.
- 'cuda-probe-failed': 'Could not detect this host’s GPU',
- 'unknown-target': 'Unavailable',
-};
-
const LANE_LABEL = {
'local-mps': 'Runs on-device (Apple Silicon)',
'local-cuda': 'Runs on-device (CUDA)',
@@ -97,7 +82,7 @@ function StatusBadge({ target }) {
return (
<span className="inline-flex items-center gap-1.5 text-xs font-medium text-port-warning">
<AlertTriangle className="w-3.5 h-3.5" />
- {REASON_LABEL[target.unavailableReason] || 'Unsupported on this host'}
+ {unavailableReasonLabel(target.unavailableReason)}
</span>
);
}
@@ -314,7 +299,7 @@ export default function Media3D() {
const generateGatedReason = (() => {
if (!selectedImage) return 'Pick a source image to continue.';
if (!selectedTarget) return 'No image-to-3D model is registered.';
- if (!selectedTarget.available) return REASON_LABEL[selectedTarget.unavailableReason] || 'This model can’t run on this host.';
+ if (!selectedTarget.available) return unavailableReasonLabel(selectedTarget.unavailableReason, 'This model can’t run on this host.');
if (selectedTarget.installed === false) return `Install ${selectedTarget.label} below before generating.`;
return null;
})();
diff --git a/server/routes/imageTo3d.genericDispatch.test.js b/server/routes/imageTo3d.genericDispatch.test.js
index 5eaadf6da6..73e4146411 100644
--- a/server/routes/imageTo3d.genericDispatch.test.js
+++ b/server/routes/imageTo3d.genericDispatch.test.js
@@ -17,7 +17,10 @@ const FAKE_TARGET = Object.freeze({
unavailableReason: null,
});
-vi.mock('../services/imageTo3d/targets.js', () => ({
+// Partial mock — the registry resolvers are stubbed to the synthetic target, but
+// the reason→label helpers stay real (the install-refusal message renders them).
+vi.mock('../services/imageTo3d/targets.js', async (importOriginal) => ({
+ ...(await importOriginal()),
detectHostCapabilities: vi.fn(() => ({ appleSilicon: true, unifiedMemoryGb: 128, cuda: false })),
getTarget: vi.fn((id) => (id === 'fakegen' ? FAKE_TARGET : null)),
listTargets: vi.fn(() => [FAKE_TARGET]),
diff --git a/server/routes/imageTo3d.js b/server/routes/imageTo3d.js
index a7b43fae80..3338969968 100644
--- a/server/routes/imageTo3d.js
+++ b/server/routes/imageTo3d.js
@@ -9,6 +9,7 @@ import {
detectHostCapabilities,
isTargetAvailable,
unavailableReason,
+ unavailableReasonLabel,
IMAGE_TO_3D_TARGET_IDS,
} from '../services/imageTo3d/targets.js';
import { getTargetAdapter } from '../services/imageTo3d/adapters.js';
@@ -106,7 +107,9 @@ async function handleTargetInstall(targetId, req, res) {
if (!isTargetAvailable(targetId, capabilities)) {
send({
type: 'error',
- message: `This host cannot run ${target.label} (${unavailableReason(targetId, capabilities)}). Install skipped.`,
+ // The label, not the raw kebab-case code — this string is read by a human
+ // in the install log, and `requires-linux-host` doesn't tell them to use WSL2.
+ message: `This host cannot run ${target.label} (${unavailableReasonLabel(unavailableReason(targetId, capabilities))}). Install skipped.`,
});
return safeEnd();
}
diff --git a/server/routes/imageTo3d.test.js b/server/routes/imageTo3d.test.js
index 1c097c7eff..0f4688f9e4 100644
--- a/server/routes/imageTo3d.test.js
+++ b/server/routes/imageTo3d.test.js
@@ -23,7 +23,12 @@ const TRELLIS2_TARGET = {
],
};
-vi.mock('../services/imageTo3d/targets.js', () => ({
+// Partial mock: the resolver/probe functions are stubbed so the route tests stay
+// hardware-independent, but the reason→label map + `unavailableReasonLabel` come
+// from the real module, so the refusal message asserted below is the exact string
+// a user would see.
+vi.mock('../services/imageTo3d/targets.js', async (importOriginal) => ({
+ ...(await importOriginal()),
detectHostCapabilities: vi.fn(() => ({ appleSilicon: true, unifiedMemoryGb: 128, cuda: false })),
getTarget: vi.fn((id) => (id === 'trellis2' ? TRELLIS2_TARGET : null)),
listTargets: vi.fn((caps) => [
@@ -324,7 +329,9 @@ describe('GET /trellis2/install (SSE)', () => {
targets.unavailableReason.mockReturnValueOnce('requires-apple-silicon');
const res = await request(makeApp()).get('/api/image-to-3d/trellis2/install');
const frames = sseFrames(res.text);
- expect(frames.at(-1)).toMatchObject({ type: 'error', message: expect.stringMatching(/requires-apple-silicon/) });
+ // The human label, not the raw kebab-case reason code (#3579).
+ expect(frames.at(-1)).toMatchObject({ type: 'error', message: expect.stringMatching(/Requires an Apple Silicon Mac/) });
+ expect(frames.at(-1).message).not.toMatch(/requires-apple-silicon/);
expect(trellis2.installTrellis2).not.toHaveBeenCalled();
});
});
diff --git a/server/services/imageTo3d/targets.js b/server/services/imageTo3d/targets.js
index ed41d1da31..ddc98675db 100644
--- a/server/services/imageTo3d/targets.js
+++ b/server/services/imageTo3d/targets.js
@@ -186,6 +186,51 @@ export function isTargetAvailable(target, caps = {}) {
return unavailableReason(target, caps) === null;
}
+/**
+ * Every reason code `unavailableReason` can return, mapped to the user-facing
+ * label. This is the LABEL side the codes never had: the API/SSE surfaces and
+ * the client both render from here rather than each re-declaring the set, so a
+ * new code is a one-line addition next to the branch that returns it.
+ *
+ * MIRRORED verbatim to `client/src/lib/imageTo3dReasons.js`; the parity test
+ * (`unavailableReasons.parity.test.js`) asserts the two never drift AND that
+ * the key set still equals the codes `unavailableReason` actually returns — so
+ * adding a code without a label fails CI instead of rendering as the generic
+ * "Unsupported on this host" fallback.
+ *
+ * The GB figures restate the registry floors (`minUnifiedMemoryGb` /
+ * `minVramGb`, both 24) as prose rather than interpolating them: the labels are
+ * mirrored to the client, which has no registry to read, and both lanes would
+ * have to move for the numbers to diverge.
+ */
+export const UNAVAILABLE_REASONS = Object.freeze({
+ 'unknown-target': 'Unavailable',
+ 'requires-apple-silicon': 'Requires an Apple Silicon Mac',
+ 'insufficient-memory': 'Needs 24 GB+ of unified memory',
+ 'requires-cuda': 'Requires an NVIDIA CUDA GPU',
+ // Shown on a Windows host that HAS a qualifying card: upstream TRELLIS.2 builds
+ // its CUDA extensions against a POSIX toolchain and is Linux-only, so WSL2 is the
+ // supported route — name it, since this blocker is the one the user can act on.
+ 'requires-linux-host': 'Requires a Linux host (use WSL2 on Windows)',
+ 'insufficient-vram': 'Needs a 24 GB+ NVIDIA GPU',
+ // The probe itself failed — say so rather than claiming the GPU isn't there.
+ 'cuda-probe-failed': 'Could not detect this host’s GPU',
+});
+
+/** Label for a reason code the map doesn't know (or a null/absent code). */
+export const UNAVAILABLE_REASON_FALLBACK = 'Unsupported on this host';
+
+/**
+ * User-facing label for a reason code. Own-property lookup only, so a code that
+ * happens to name an Object.prototype key can't render as a function/object.
+ * @param {string|null} [reason]
+ * @param {string} [fallback] label for an unknown/absent code.
+ * @returns {string}
+ */
+export function unavailableReasonLabel(reason, fallback = UNAVAILABLE_REASON_FALLBACK) {
+ return Object.hasOwn(UNAVAILABLE_REASONS, reason ?? '') ? UNAVAILABLE_REASONS[reason] : fallback;
+}
+
/**
* Reason codes meaning "this machine's hardware will never run that target" — as
* opposed to a blocker the user can act on (install an OS in WSL2, fix a driver,
diff --git a/server/services/imageTo3d/unavailableReasons.parity.test.js b/server/services/imageTo3d/unavailableReasons.parity.test.js
new file mode 100644
index 0000000000..48649e3d2b
--- /dev/null
+++ b/server/services/imageTo3d/unavailableReasons.parity.test.js
@@ -0,0 +1,85 @@
+/**
+ * Cross-package parity for the image-to-3D unavailable-reason labels.
+ *
+ * `server/services/imageTo3d/targets.js` owns the reason CODES (what
+ * `unavailableReason()` returns) and their labels; `client/src/lib/
+ * imageTo3dReasons.js` is a hand-maintained mirror (the client can't import the
+ * registry — it reaches `os`/`child_process` through the capability probes).
+ * This suite imports BOTH and asserts they stay identical, mirroring
+ * `server/lib/catalogTypes.parity.test.js`.
+ *
+ * It also closes the gap that motivated the shared map (#3579): the source
+ * guard below asserts the label key set still EQUALS the codes the function
+ * actually returns, so adding a code without a label — which used to render as
+ * the generic "Unsupported on this host" fallback with a fully green suite —
+ * fails here instead.
+ *
+ * It lives server-side because the server registry can't load under the client
+ * (jsdom) runner, but the pure client mirror loads fine here.
+ */
+
+import { readFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { describe, it, expect } from 'vitest';
+import {
+ UNAVAILABLE_REASONS as SERVER_REASONS,
+ UNAVAILABLE_REASON_FALLBACK as SERVER_FALLBACK,
+ unavailableReasonLabel as serverLabel,
+ UNFIXABLE_HARDWARE_REASONS,
+} from './targets.js';
+import {
+ UNAVAILABLE_REASONS as CLIENT_REASONS,
+ UNAVAILABLE_REASON_FALLBACK as CLIENT_FALLBACK,
+ unavailableReasonLabel as clientLabel,
+} from '../../../client/src/lib/imageTo3dReasons.js';
+
+// Every kebab-case string literal inside `unavailableReason()` is a reason code:
+// the only other literal in the body is `'unknown'` (the cudaProbe status), which
+// has no dash and so falls outside this pattern.
+function reasonCodesInSource() {
+ const src = readFileSync(fileURLToPath(new URL('./targets.js', import.meta.url)), 'utf8');
+ const start = src.indexOf('export function unavailableReason(');
+ const end = src.indexOf('\nexport function isTargetAvailable');
+ expect(start, 'unavailableReason() not found in targets.js').toBeGreaterThan(-1);
+ expect(end, 'isTargetAvailable() not found in targets.js').toBeGreaterThan(start);
+ const body = src.slice(start, end);
+ return [...body.matchAll(/'([a-z][a-z0-9]*(?:-[a-z0-9]+)+)'/g)].map((m) => m[1]);
+}
+
+describe('image-to-3D unavailable reasons — server↔client parity', () => {
+ it('exposes the same codes in the same order with the same labels', () => {
+ expect(Object.entries(CLIENT_REASONS)).toEqual(Object.entries(SERVER_REASONS));
+ });
+
+ it('shares the unknown-code fallback label', () => {
+ expect(CLIENT_FALLBACK).toBe(SERVER_FALLBACK);
+ });
+
+ it('labels every code identically across server and client', () => {
+ const probes = [...Object.keys(SERVER_REASONS), 'not-a-real-code', '', null, undefined, '__proto__', 'constructor'];
+ for (const code of probes) {
+ expect(clientLabel(code), `label for ${String(code)} drifted`).toBe(serverLabel(code));
+ }
+ });
+});
+
+describe('image-to-3D unavailable reasons — code coverage', () => {
+ it('labels exactly the codes unavailableReason() can return', () => {
+ const codes = reasonCodesInSource();
+ expect(codes.length).toBeGreaterThan(0);
+ expect([...new Set(codes)].sort()).toEqual(Object.keys(SERVER_REASONS).sort());
+ });
+
+ it('labels every unfixable-hardware reason', () => {
+ for (const code of UNFIXABLE_HARDWARE_REASONS) {
+ expect(SERVER_REASONS[code], `${code} has no label`).toBeTruthy();
+ }
+ });
+
+ it('falls back for an unknown or absent code rather than rendering the raw code', () => {
+ expect(serverLabel(null)).toBe(SERVER_FALLBACK);
+ expect(serverLabel('brand-new-code')).toBe(SERVER_FALLBACK);
+ expect(serverLabel('brand-new-code', 'custom')).toBe('custom');
+ expect(serverLabel('requires-cuda', 'custom')).toBe(SERVER_REASONS['requires-cuda']);
+ });
+});