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

address review (codex): refuse non-text video pipelines, write routing against fresh settings

[._.]/ Adam Eivyf18790da8e14
diff --git a/client/src/components/instances/UnattendedRenderRouting.jsx b/client/src/components/instances/UnattendedRenderRouting.jsx
index 4f0eebed93..d1797819c3 100644
--- a/client/src/components/instances/UnattendedRenderRouting.jsx
+++ b/client/src/components/instances/UnattendedRenderRouting.jsx
@@ -87,12 +87,21 @@ export default function UnattendedRenderRouting({ peers }) {
// replace the whole thing.
if (!isRecord(federation) || !isRecord(routing)) return;
setSaving(true);
- const nextRouting = { ...routing, [kind]: route };
// The settings PATCH shallow-merges TOP-LEVEL keys, so `federation` is
- // replaced wholesale — carry the rest of the slice forward or a save here
- // would drop the provider config the Sharing tab owns.
+ // replaced wholesale — this write has to carry the rest of the slice. Re-read
+ // it immediately before writing rather than trusting the snapshot taken at
+ // mount: the Sharing tab owns mediaProvider and strict-pull, and a page left
+ // open across an edit there would otherwise write back the stale values it
+ // captured. Fall back to the mount snapshot only if the re-read fails, which
+ // is still strictly better than sending {}.
+ const fresh = await getSettings({ silent: true }).catch(() => null);
+ const base = isRecord(fresh?.federation) ? fresh.federation : federation;
+ // Merge onto the freshest routing too, so a kind another surface set in the
+ // meantime isn't reverted by this one's stale copy.
+ const baseRouting = isRecord(base.mediaRouting) ? base.mediaRouting : routing;
+ const nextRouting = { ...baseRouting, [kind]: route };
const merged = await updateSettings(
- { federation: { ...federation, mediaRouting: nextRouting } },
+ { federation: { ...base, mediaRouting: nextRouting } },
{ silent: true },
).catch(() => null);
setSaving(false);
@@ -103,7 +112,7 @@ export default function UnattendedRenderRouting({ peers }) {
return;
}
setRouting(nextRouting);
- setFederation(isRecord(merged.federation) ? merged.federation : { ...federation, mediaRouting: nextRouting });
+ setFederation(isRecord(merged.federation) ? merged.federation : { ...base, mediaRouting: nextRouting });
};
const savedRoute = (kind) => (isRecord(routing?.[kind]) ? routing[kind] : null);
diff --git a/client/src/components/instances/UnattendedRenderRouting.test.jsx b/client/src/components/instances/UnattendedRenderRouting.test.jsx
index 0aea9e6035..2370928560 100644
--- a/client/src/components/instances/UnattendedRenderRouting.test.jsx
+++ b/client/src/components/instances/UnattendedRenderRouting.test.jsx
@@ -157,3 +157,43 @@ describe('UnattendedRenderRouting — failure and staleness handling', () => {
expect(select.value).toBe('');
});
});
+
+describe('UnattendedRenderRouting — writes against the freshest settings', () => {
+ it('re-reads the federation slice at save time instead of writing a mount-time snapshot', async () => {
+ // Mounted before the Sharing tab enabled the provider elsewhere.
+ getSettings.mockResolvedValueOnce({ federation: { mediaProvider: { enabled: false } } });
+ render(<UnattendedRenderRouting peers={[peerWith()]} />);
+ const select = await screen.findByLabelText('Image');
+
+ getSettings.mockResolvedValueOnce({
+ federation: { mediaProvider: { enabled: true }, strictPullAuthorization: true },
+ });
+ fireEvent.change(select, { target: { value: JSON.stringify(['peer-1', 'comfy', 'sdxl-base']) } });
+
+ await waitFor(() => expect(updateSettings).toHaveBeenCalledWith({
+ federation: {
+ // The newer values survive — writing the stale snapshot would have
+ // reverted mediaProvider.enabled and erased strictPullAuthorization.
+ mediaProvider: { enabled: true },
+ strictPullAuthorization: true,
+ mediaRouting: { image: { peerId: 'peer-1', engine: 'comfy', modelId: 'sdxl-base' } },
+ },
+ }, { silent: true }));
+ });
+
+ it('falls back to the mount snapshot when the re-read fails, never to an empty slice', async () => {
+ getSettings.mockResolvedValueOnce({ federation: { mediaProvider: { enabled: true } } });
+ render(<UnattendedRenderRouting peers={[peerWith()]} />);
+ const select = await screen.findByLabelText('Image');
+
+ getSettings.mockRejectedValueOnce(new Error('offline'));
+ fireEvent.change(select, { target: { value: JSON.stringify(['peer-1', 'comfy', 'sdxl-base']) } });
+
+ await waitFor(() => expect(updateSettings).toHaveBeenCalledWith({
+ federation: {
+ mediaProvider: { enabled: true },
+ mediaRouting: { image: { peerId: 'peer-1', engine: 'comfy', modelId: 'sdxl-base' } },
+ },
+ }, { silent: true }));
+ });
+});
diff --git a/client/src/components/settings/SharingTab.jsx b/client/src/components/settings/SharingTab.jsx
index 59cd9b9d08..14e296d2af 100644
--- a/client/src/components/settings/SharingTab.jsx
+++ b/client/src/components/settings/SharingTab.jsx
@@ -10,6 +10,27 @@ const modelKey = ({ engine, modelId }) => `${engine}\u0000${modelId}`;
// entry already carrying the readiness projection the wire status reports. Audio
// is not in this table — its picker is driven by the music-engine catalog, which
// nests models under engines.
+// A model the operator already shares must stay visible even after it leaves
+// the local catalog (uninstalled, or newly reported broken), or there is no
+// checkbox left to un-share it and the provider keeps advertising a stale
+// `unknown-model` entry forever. Mirrors the peer panel's `not-advertised` rows.
+function candidateRows(candidates, selected) {
+ const rows = [...candidates];
+ const known = new Set(candidates.map(modelKey));
+ for (const model of selected) {
+ if (!model?.engine || !model.modelId || known.has(modelKey(model))) continue;
+ rows.push({
+ kind: null,
+ engine: model.engine,
+ modelId: model.modelId,
+ modelName: model.modelId,
+ ready: false,
+ unavailableReason: 'no longer installed',
+ });
+ }
+ return rows;
+}
+
const VISUAL_KINDS = Object.freeze([
{ kind: 'image', label: 'image', field: 'imageModels' },
{ kind: 'video', label: 'video', field: 'videoModels' },
@@ -363,14 +384,16 @@ export function SharingTab() {
)}
</fieldset>
- {VISUAL_KINDS.map(({ kind, label, field }) => (
+ {VISUAL_KINDS.map(({ kind, label, field }) => {
+ const rows = candidateRows(visualCandidates[kind], providerVisualModels[kind]);
+ return (
<fieldset key={field}>
<legend className="block text-xs uppercase tracking-wider text-gray-500 mb-2">Allowed {label} models</legend>
- {visualCandidates[kind].length === 0 ? (
+ {rows.length === 0 ? (
<p className="text-sm text-gray-500">No local {label} models are installed to share.</p>
) : (
<div className="grid grid-cols-1 lg:grid-cols-2 gap-2">
- {visualCandidates[kind].map((candidate, index) => {
+ {rows.map((candidate, index) => {
const checked = providerVisualModels[kind].some((model) => modelKey(model) === modelKey(candidate));
const inputId = `federated-media-${kind}-model-${index}`;
return (
@@ -396,7 +419,8 @@ export function SharingTab() {
</div>
)}
</fieldset>
- ))}
+ );
+ })}
<button
type="button"
diff --git a/client/src/components/settings/SharingTab.test.jsx b/client/src/components/settings/SharingTab.test.jsx
index 719eb68c45..bd33ac178f 100644
--- a/client/src/components/settings/SharingTab.test.jsx
+++ b/client/src/components/settings/SharingTab.test.jsx
@@ -150,3 +150,62 @@ describe('SharingTab — federation pull authorization (#3659)', () => {
await waitFor(() => expect(strictToggle().checked).toBe(false));
});
});
+
+// #4348 — the provider side could not share visual models at all before this,
+// so no peer ever advertised an image/video capability to route at.
+describe('SharingTab — visual provider models', () => {
+ const candidate = (overrides) => ({
+ engine: 'local', ready: true, unavailableReason: null, ...overrides,
+ });
+
+ it('shares a local image model into its own allowlist', async () => {
+ getMediaShareCandidates.mockResolvedValue({
+ image: [candidate({ modelId: 'flux-dev', modelName: 'FLUX dev' })],
+ video: [],
+ });
+ getSettings.mockResolvedValue({
+ sharingDisplayName: '', sharingBio: '',
+ federation: { mediaProvider: { enabled: true, audioModels: [] } },
+ });
+ getAuthStatus.mockResolvedValue({ enabled: true });
+
+ render(<SharingTab />);
+ fireEvent.click(await screen.findByLabelText('FLUX dev'));
+ fireEvent.click(screen.getByRole('button', { name: 'Save provider' }));
+
+ await waitFor(() => expect(updateSettings).toHaveBeenCalledWith({
+ federation: {
+ mediaProvider: {
+ enabled: true,
+ maxQueuedJobs: 2,
+ audioModels: [],
+ imageModels: [{ engine: 'local', modelId: 'flux-dev' }],
+ videoModels: [],
+ },
+ },
+ }, { silent: true }));
+ });
+
+ // Otherwise the provider keeps advertising a stale unknown-model entry with
+ // no checkbox left to clear it.
+ it('keeps an already-shared model listed after it leaves the local catalog', async () => {
+ getMediaShareCandidates.mockResolvedValue({ image: [], video: [] });
+ getSettings.mockResolvedValue({
+ sharingDisplayName: '', sharingBio: '',
+ federation: {
+ mediaProvider: {
+ enabled: true, audioModels: [],
+ imageModels: [{ engine: 'local', modelId: 'uninstalled-model' }],
+ },
+ },
+ });
+ getAuthStatus.mockResolvedValue({ enabled: true });
+
+ render(<SharingTab />);
+ const checkbox = await screen.findByLabelText(/uninstalled-model/);
+ expect(checkbox).toBeChecked();
+ // Togglable despite being unavailable — that is the whole point.
+ expect(checkbox).toBeEnabled();
+ expect(screen.getByText(/no longer installed/)).toBeInTheDocument();
+ });
+});
diff --git a/server/services/federatedMedia/defaultRouting.js b/server/services/federatedMedia/defaultRouting.js
index b743b0fee1..392c397ca9 100644
--- a/server/services/federatedMedia/defaultRouting.js
+++ b/server/services/federatedMedia/defaultRouting.js
@@ -110,6 +110,15 @@ function assertRoutableConditioning(kind, params) {
// silently gets the opposite of what it asked for. Only a truthy value is a
// conflict — the common `false` is the provider's own default anyway.
if (kind === 'video' && params?.disableAudio === true) unsupported.push('a silent (audio-disabled) render');
+ // For LOCAL video, `mode` is the pipeline semantic for the lane (t2v / i2v /
+ // first-last-frame / audio-to-video), not a backend selector — and only
+ // text-to-video crosses the wire. Because `routedJobParams` drops `mode`
+ // outright, an unguarded 'fflf' or 'a2v' job would come back as a plain
+ // text-to-video clip: a valid-looking render of the wrong pipeline. Mirrors
+ // the interactive route's non-text-mode rejection.
+ if (kind === 'video' && params?.mode !== undefined && params.mode !== 'text') {
+ unsupported.push(`a non-text render mode ('${params.mode}')`);
+ }
if (!unsupported.length) return;
throw new ServerError(
`A federated media provider renders text-to-${kind} only — this ${kind} job uses ${unsupported.join(' and ')}. `
diff --git a/server/services/federatedMedia/defaultRouting.test.js b/server/services/federatedMedia/defaultRouting.test.js
index a9631cf823..b0ee230b1f 100644
--- a/server/services/federatedMedia/defaultRouting.test.js
+++ b/server/services/federatedMedia/defaultRouting.test.js
@@ -249,3 +249,34 @@ describe('hasConfiguredMediaRoute', () => {
await expect(hasConfiguredMediaRoute('image')).resolves.toBe(false);
});
});
+
+describe('non-text video pipelines', () => {
+ const route = { peerId: 'peer-1', engine: 'comfy', modelId: 'wan-remote' };
+
+ beforeEach(() => {
+ getSettings.mockResolvedValue({ federation: { mediaRouting: { video: route } } });
+ });
+
+ // routedJobParams DROPS `mode`, so an unguarded first-last-frame or
+ // audio-to-video job would come back as a plain text-to-video clip — a
+ // valid-looking render of an entirely different pipeline.
+ it.each(['fflf', 'a2v', 'image'])('refuses a routed video in %s mode', async (mode) => {
+ await expect(resolveDefaultMediaRoute({ kind: 'video', params: { prompt: 'p', mode } }))
+ .rejects.toMatchObject({ code: 'MEDIA_PROVIDER_INPUT_UNSUPPORTED' });
+ });
+
+ it('allows an explicit text mode and an absent one', async () => {
+ await expect(resolveDefaultMediaRoute({ kind: 'video', params: { prompt: 'p', mode: 'text' } }))
+ .resolves.toMatchObject({ peer: { id: 'peer-1' } });
+ await expect(resolveDefaultMediaRoute({ kind: 'video', params: { prompt: 'p' } }))
+ .resolves.toMatchObject({ peer: { id: 'peer-1' } });
+ });
+
+ // For images `mode` names the BACKEND (local/codex/grok), not a pipeline, so
+ // it is dropped rather than refused — same as the interactive image route.
+ it('does not apply the video mode guard to images', async () => {
+ getSettings.mockResolvedValue({ federation: { mediaRouting: { image: route } } });
+ await expect(resolveDefaultMediaRoute({ kind: 'image', params: { prompt: 'p', mode: 'codex' } }))
+ .resolves.toMatchObject({ peer: { id: 'peer-1' } });
+ });
+});