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): route every unattended enqueue, guard conditioning, make visual models configurable

[._.]/ Adam Eivy9b3b9653c068
diff --git a/client/src/components/instances/UnattendedRenderRouting.jsx b/client/src/components/instances/UnattendedRenderRouting.jsx
index e3f1bd02e5..4f0eebed93 100644
--- a/client/src/components/instances/UnattendedRenderRouting.jsx
+++ b/client/src/components/instances/UnattendedRenderRouting.jsx
@@ -1,5 +1,6 @@
import { useEffect, useMemo, useState } from 'react';
import { Bot } from 'lucide-react';
+import toast from '../ui/Toast';
import { getSettings, updateSettings } from '../../services/api';
// Only the visual kinds route. A federated audio submission may carry nothing
@@ -14,6 +15,7 @@ const KINDS = Object.freeze([
const isRecord = (value) => value && typeof value === 'object' && !Array.isArray(value);
const optionValue = ({ peerId, engine, modelId }) => JSON.stringify([peerId, engine, modelId]);
+const modelKey = ({ engine, modelId }) => `${engine}\u0000${modelId}`;
// One option per (peer, allowlisted model) pair that the peer currently
// advertises as a capability. A model the user allowlisted but the peer no
@@ -22,13 +24,18 @@ const optionValue = ({ peerId, engine, modelId }) => JSON.stringify([peerId, eng
function routeOptions(peers, kind, field) {
const options = [];
for (const peer of peers) {
+ // Both switches matter. `peer.enabled === false` disables the peer wholesale
+ // while leaving its last media capabilities cached on the record — offering
+ // it here would save a route whose every job dies on
+ // MEDIA_PROVIDER_PEER_DISABLED.
+ if (peer?.enabled === false) continue;
if (peer?.mediaProvider?.enabled !== true) continue;
const allowed = new Set((peer.mediaProvider[field] || [])
.filter((model) => model?.engine && model?.modelId)
- .map((model) => `${model.engine}\u0000${model.modelId}`));
+ .map(modelKey));
for (const capability of peer.mediaProviderStatus?.snapshot?.capabilities || []) {
if (capability?.kind !== kind) continue;
- if (!allowed.has(`${capability.engine}\u0000${capability.modelId}`)) continue;
+ if (!allowed.has(modelKey(capability))) continue;
options.push({
peerId: peer.id,
engine: capability.engine,
@@ -49,8 +56,14 @@ function routeOptions(peers, kind, field) {
* instance's own settings and the server reads it at enqueue time.
*/
export default function UnattendedRenderRouting({ peers }) {
+ // `null` = not loaded yet, and NOT the same as `{}` (loaded, nothing routed).
+ // Conflating them is what would let a failed settings read save a `federation`
+ // slice rebuilt from an empty object, wiping mediaProvider and
+ // strictPullAuthorization. `loadFailed` keeps the card visible but read-only
+ // so the failure is legible instead of silently destructive.
const [routing, setRouting] = useState(null);
- const [federation, setFederation] = useState({});
+ const [federation, setFederation] = useState(null);
+ const [loadFailed, setLoadFailed] = useState(false);
const [saving, setSaving] = useState(false);
useEffect(() => {
@@ -60,7 +73,7 @@ export default function UnattendedRenderRouting({ peers }) {
setFederation(slice);
setRouting(isRecord(slice.mediaRouting) ? slice.mediaRouting : {});
})
- .catch(() => setRouting({}));
+ .catch(() => setLoadFailed(true));
}, []);
const optionsByKind = useMemo(
@@ -69,6 +82,10 @@ export default function UnattendedRenderRouting({ peers }) {
);
const save = async (kind, route) => {
+ // Belt and braces with the `disabled` below: without a validated snapshot
+ // there is no federation slice to carry forward, so a save here would
+ // 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
@@ -78,17 +95,33 @@ export default function UnattendedRenderRouting({ peers }) {
{ federation: { ...federation, mediaRouting: nextRouting } },
{ silent: true },
).catch(() => null);
- if (merged) {
- setRouting(nextRouting);
- setFederation(isRecord(merged.federation) ? merged.federation : { ...federation, mediaRouting: nextRouting });
- }
setSaving(false);
+ if (!merged) {
+ // The select is controlled off `routing`, so a failed save silently snaps
+ // it back to the old value. Say why, or it reads as the click not landing.
+ toast.error('Failed to save unattended render routing');
+ return;
+ }
+ setRouting(nextRouting);
+ setFederation(isRecord(merged.federation) ? merged.federation : { ...federation, mediaRouting: nextRouting });
};
- // Nothing is routable until at least one peer advertises an allowlisted
- // visual model, and an empty control would read as a broken feature.
+ const savedRoute = (kind) => (isRecord(routing?.[kind]) ? routing[kind] : null);
+ // A persisted route must stay editable even when nothing is advertised for it
+ // any more — otherwise the card hides, the route keeps failing every enqueue,
+ // and there is no way left to clear it.
+ const hasSavedRoute = KINDS.some(({ kind }) => savedRoute(kind));
const anyOptions = KINDS.some(({ kind }) => optionsByKind[kind].length > 0);
- if (routing === null || !anyOptions) return null;
+ if (loadFailed) {
+ return anyOptions ? (
+ <div className="mb-3 rounded-lg border border-port-border bg-port-bg/40 p-3">
+ <p className="text-[11px] text-port-warning">
+ Unattended render routing could not load this instance&rsquo;s settings, so it is read-only. Reload to try again.
+ </p>
+ </div>
+ ) : null;
+ }
+ if (routing === null || (!anyOptions && !hasSavedRoute)) return null;
return (
<div className="mb-3 rounded-lg border border-port-border bg-port-bg/40 p-3">
@@ -104,7 +137,7 @@ export default function UnattendedRenderRouting({ peers }) {
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2">
{KINDS.map(({ kind, label }) => {
const options = optionsByKind[kind];
- const current = isRecord(routing[kind]) ? routing[kind] : null;
+ const current = savedRoute(kind);
const selectId = `unattended-routing-${kind}`;
return (
<label key={kind} className="block" htmlFor={selectId}>
@@ -112,7 +145,9 @@ export default function UnattendedRenderRouting({ peers }) {
<select
id={selectId}
value={current ? optionValue(current) : ''}
- disabled={saving || options.length === 0}
+ // Enabled whenever there is something to choose OR something to
+ // clear; only a kind with neither is inert.
+ disabled={saving || (options.length === 0 && !current)}
onChange={(event) => save(kind, event.target.value
? (([peerId, engine, modelId]) => ({ peerId, engine, modelId }))(JSON.parse(event.target.value))
: null)}
diff --git a/client/src/components/instances/UnattendedRenderRouting.test.jsx b/client/src/components/instances/UnattendedRenderRouting.test.jsx
index 232a919453..0aea9e6035 100644
--- a/client/src/components/instances/UnattendedRenderRouting.test.jsx
+++ b/client/src/components/instances/UnattendedRenderRouting.test.jsx
@@ -5,8 +5,14 @@ vi.mock('../../services/api', () => ({
getSettings: vi.fn(),
updateSettings: vi.fn(),
}));
+vi.mock('../ui/Toast', () => ({
+ default: Object.assign(vi.fn(), {
+ success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn(),
+ }),
+}));
import { getSettings, updateSettings } from '../../services/api';
+import toast from '../ui/Toast';
import UnattendedRenderRouting from './UnattendedRenderRouting';
const capability = (overrides) => ({ ready: true, unavailableReason: null, ...overrides });
@@ -103,3 +109,51 @@ describe('UnattendedRenderRouting', () => {
expect(container).toBeEmptyDOMElement();
});
});
+
+// #4348 review follow-ups.
+describe('UnattendedRenderRouting — failure and staleness handling', () => {
+ it('never rebuilds the federation slice from a failed settings read', async () => {
+ getSettings.mockRejectedValue(new Error('settings unavailable'));
+ render(<UnattendedRenderRouting peers={[peerWith()]} />);
+
+ // Read-only notice instead of a live control: a save from here would send a
+ // federation slice reconstructed from {}, wiping mediaProvider.
+ expect(await screen.findByText(/could not load this instance/i)).toBeInTheDocument();
+ expect(screen.queryByLabelText('Image')).not.toBeInTheDocument();
+ expect(updateSettings).not.toHaveBeenCalled();
+ });
+
+ it('excludes a peer that is disabled wholesale, even with capabilities still cached', async () => {
+ const { container } = render(<UnattendedRenderRouting peers={[peerWith({ enabled: false })]} />);
+ await waitFor(() => expect(getSettings).toHaveBeenCalled());
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it('keeps a stale saved route clearable after its peer stops offering anything', async () => {
+ getSettings.mockResolvedValue({
+ federation: { mediaRouting: { image: { peerId: 'peer-1', engine: 'comfy', modelId: 'sdxl-base' } } },
+ });
+ // No peers at all — without the saved-route carve-out the card would hide
+ // and the failing route could never be cleared.
+ render(<UnattendedRenderRouting peers={[]} />);
+
+ const select = await screen.findByLabelText('Image');
+ expect(select).toBeEnabled();
+ fireEvent.change(select, { target: { value: '' } });
+
+ await waitFor(() => expect(updateSettings).toHaveBeenCalledWith({
+ federation: { mediaRouting: { image: null } },
+ }, { silent: true }));
+ });
+
+ it('tells the user when a route save fails instead of silently reverting', async () => {
+ updateSettings.mockRejectedValue(new Error('nope'));
+ render(<UnattendedRenderRouting peers={[peerWith()]} />);
+
+ const select = await screen.findByLabelText('Image');
+ fireEvent.change(select, { target: { value: JSON.stringify(['peer-1', 'comfy', 'sdxl-base']) } });
+
+ await waitFor(() => expect(toast.error).toHaveBeenCalledWith('Failed to save unattended render routing'));
+ expect(select.value).toBe('');
+ });
+});
diff --git a/client/src/components/settings/SharingTab.jsx b/client/src/components/settings/SharingTab.jsx
index b5aecdf78f..59cd9b9d08 100644
--- a/client/src/components/settings/SharingTab.jsx
+++ b/client/src/components/settings/SharingTab.jsx
@@ -2,9 +2,18 @@ import { useEffect, useState } from 'react';
import { Save, Loader2, Users, ShieldCheck, Network } from 'lucide-react';
import toast from '../ui/Toast';
import BrailleSpinner from '../BrailleSpinner';
-import { getAuthStatus, getSettings, listMusicEngines, updateSettings } from '../../services/api';
+import { getAuthStatus, getMediaShareCandidates, getSettings, listMusicEngines, updateSettings } from '../../services/api';
const modelKey = ({ engine, modelId }) => `${engine}\u0000${modelId}`;
+
+// Image and video share one shape: a flat candidate list from the server, each
+// 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.
+const VISUAL_KINDS = Object.freeze([
+ { kind: 'image', label: 'image', field: 'imageModels' },
+ { kind: 'video', label: 'video', field: 'videoModels' },
+]);
const normalizeSelectedModels = (models) => Array.isArray(models)
? models.filter((model) => model && typeof model.engine === 'string' && typeof model.modelId === 'string')
.map((model) => ({ ...model, engine: model.engine, modelId: model.modelId }))
@@ -36,6 +45,9 @@ export function SharingTab() {
const [providerEnabled, setProviderEnabled] = useState(false);
const [providerMaxQueuedJobs, setProviderMaxQueuedJobs] = useState(2);
const [providerModels, setProviderModels] = useState([]);
+ const [visualCandidates, setVisualCandidates] = useState({ image: [], video: [] });
+ const [providerVisualModels, setProviderVisualModels] = useState({ image: [], video: [] });
+ const [savedProviderVisualModels, setSavedProviderVisualModels] = useState({ image: [], video: [] });
const [savedProviderEnabled, setSavedProviderEnabled] = useState(false);
const [savedProviderMaxQueuedJobs, setSavedProviderMaxQueuedJobs] = useState(2);
const [savedProviderModels, setSavedProviderModels] = useState([]);
@@ -48,6 +60,14 @@ export function SharingTab() {
listMusicEngines({ silent: true })
.then((music) => setMusicEngines(Array.isArray(music?.engines) ? music.engines : []))
.catch(() => setMusicEngines([]));
+ // Same rationale as the engine probe above: readiness inspection can touch
+ // the model cache, so keep it off the critical path for the other controls.
+ getMediaShareCandidates({ silent: true })
+ .then((candidates) => setVisualCandidates({
+ image: Array.isArray(candidates?.image) ? candidates.image : [],
+ video: Array.isArray(candidates?.video) ? candidates.video : [],
+ }))
+ .catch(() => setVisualCandidates({ image: [], video: [] }));
Promise.all([
getSettings({ silent: true }),
getAuthStatus({ silent: true }).catch(() => ({ enabled: false })),
@@ -69,6 +89,8 @@ export function SharingTab() {
const enabled = provider.enabled === true;
const maxQueuedJobs = Number.isInteger(provider.maxQueuedJobs) ? provider.maxQueuedJobs : 2;
const models = normalizeSelectedModels(provider.audioModels);
+ const visual = Object.fromEntries(VISUAL_KINDS.map(({ kind, field }) =>
+ [kind, normalizeSelectedModels(provider[field])]));
setProviderSettings(provider);
setProviderEnabled(enabled);
setProviderMaxQueuedJobs(maxQueuedJobs);
@@ -76,6 +98,8 @@ export function SharingTab() {
setSavedProviderEnabled(enabled);
setSavedProviderMaxQueuedJobs(maxQueuedJobs);
setSavedProviderModels(models);
+ setProviderVisualModels(visual);
+ setSavedProviderVisualModels(visual);
})
.catch(() => toast.error('Failed to load settings'))
.finally(() => setLoading(false));
@@ -84,7 +108,9 @@ export function SharingTab() {
const dirty = displayName !== savedDisplayName || bio !== savedBio;
const providerDirty = providerEnabled !== savedProviderEnabled
|| providerMaxQueuedJobs !== savedProviderMaxQueuedJobs
- || stableModels(providerModels) !== stableModels(savedProviderModels);
+ || stableModels(providerModels) !== stableModels(savedProviderModels)
+ || VISUAL_KINDS.some(({ kind }) =>
+ stableModels(providerVisualModels[kind]) !== stableModels(savedProviderVisualModels[kind]));
const handleSave = async () => {
setSaving(true);
@@ -121,13 +147,29 @@ export function SharingTab() {
: current.filter((model) => modelKey(model) !== key));
};
+ const toggleVisualModel = (kind, candidate, checked) => {
+ const key = modelKey(candidate);
+ setProviderVisualModels((current) => ({
+ ...current,
+ [kind]: checked
+ ? (current[kind].some((model) => modelKey(model) === key)
+ ? current[kind]
+ : [...current[kind], { engine: candidate.engine, modelId: candidate.modelId }])
+ : current[kind].filter((model) => modelKey(model) !== key),
+ }));
+ };
+
const handleProviderSave = async () => {
if (providerEnabled && !authEnabled) {
toast.error('Enable an instance password before sharing media capacity');
return;
}
- if (providerEnabled && providerModels.length === 0) {
- toast.error('Select at least one audio model');
+ const visualSelections = Object.fromEntries(VISUAL_KINDS.map(({ kind }) =>
+ [kind, normalizeSelectedModels(providerVisualModels[kind])]));
+ const totalSelected = providerModels.length
+ + VISUAL_KINDS.reduce((sum, { kind }) => sum + visualSelections[kind].length, 0);
+ if (providerEnabled && totalSelected === 0) {
+ toast.error('Select at least one model to share');
return;
}
const maxQueuedJobs = Math.max(1, Math.min(20, Number(providerMaxQueuedJobs) || 1));
@@ -136,6 +178,7 @@ export function SharingTab() {
enabled: providerEnabled,
maxQueuedJobs,
audioModels: normalizeSelectedModels(providerModels),
+ ...Object.fromEntries(VISUAL_KINDS.map(({ kind, field }) => [field, visualSelections[kind]])),
};
const federation = { ...federationSettings, mediaProvider };
setProviderSaving(true);
@@ -151,6 +194,7 @@ export function SharingTab() {
setSavedProviderEnabled(providerEnabled);
setSavedProviderMaxQueuedJobs(maxQueuedJobs);
setSavedProviderModels(normalizeSelectedModels(providerModels));
+ setSavedProviderVisualModels(visualSelections);
toast.success(providerEnabled ? 'Media provider enabled' : 'Media provider disabled');
};
@@ -319,11 +363,47 @@ export function SharingTab() {
)}
</fieldset>
+ {VISUAL_KINDS.map(({ kind, label, field }) => (
+ <fieldset key={field}>
+ <legend className="block text-xs uppercase tracking-wider text-gray-500 mb-2">Allowed {label} models</legend>
+ {visualCandidates[kind].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) => {
+ const checked = providerVisualModels[kind].some((model) => modelKey(model) === modelKey(candidate));
+ const inputId = `federated-media-${kind}-model-${index}`;
+ return (
+ <label key={modelKey(candidate)} htmlFor={inputId} className="flex items-start gap-2 text-sm cursor-pointer">
+ <input
+ id={inputId}
+ type="checkbox"
+ checked={checked}
+ // An already-shared model stays togglable even when it
+ // reports not-ready, or a model that broke after being
+ // shared could never be un-shared.
+ disabled={providerSaving || strictPullSaving || (!candidate.ready && !checked)}
+ onChange={(event) => toggleVisualModel(kind, candidate, event.target.checked)}
+ className="mt-0.5 h-4 w-4 accent-port-accent disabled:opacity-40"
+ />
+ <span className={candidate.ready ? 'text-gray-200' : 'text-gray-500'}>
+ {candidate.modelName}
+ {!candidate.ready && ` (${candidate.unavailableReason || 'not ready'})`}
+ </span>
+ </label>
+ );
+ })}
+ </div>
+ )}
+ </fieldset>
+ ))}
+
<button
type="button"
onClick={handleProviderSave}
disabled={!providerDirty || providerSaving || strictPullSaving
- || (providerEnabled && (!authEnabled || providerModels.length === 0))}
+ || (providerEnabled && (!authEnabled || (providerModels.length === 0
+ && VISUAL_KINDS.every(({ kind }) => providerVisualModels[kind].length === 0))))}
className="inline-flex items-center justify-center gap-2 min-h-[40px] px-4 py-2 bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded-lg text-sm transition-colors disabled:opacity-40 disabled:cursor-not-allowed"
>
{providerSaving ? <Loader2 size={14} className="animate-spin" /> : <Save size={14} />}
diff --git a/client/src/components/settings/SharingTab.test.jsx b/client/src/components/settings/SharingTab.test.jsx
index 127cc609c8..719eb68c45 100644
--- a/client/src/components/settings/SharingTab.test.jsx
+++ b/client/src/components/settings/SharingTab.test.jsx
@@ -6,6 +6,7 @@ vi.mock('../../services/api', () => ({
getSettings: vi.fn(),
listMusicEngines: vi.fn(),
updateSettings: vi.fn(),
+ getMediaShareCandidates: vi.fn(),
}));
vi.mock('../ui/Toast', () => ({
default: Object.assign(vi.fn(), {
@@ -16,7 +17,7 @@ vi.mock('../ui/Toast', () => ({
}),
}));
-import { getAuthStatus, getSettings, listMusicEngines, updateSettings } from '../../services/api';
+import { getAuthStatus, getMediaShareCandidates, getSettings, listMusicEngines, updateSettings } from '../../services/api';
import { SharingTab } from './SharingTab';
const strictToggle = () => screen.getByLabelText(/Enforce per-peer sharing settings/i);
@@ -26,6 +27,7 @@ beforeEach(() => {
getAuthStatus.mockResolvedValue({ enabled: false });
getSettings.mockResolvedValue({ sharingDisplayName: '', sharingBio: '' });
listMusicEngines.mockResolvedValue({ engines: [] });
+ getMediaShareCandidates.mockResolvedValue({ image: [], video: [] });
updateSettings.mockResolvedValue({});
});
@@ -85,6 +87,10 @@ describe('SharingTab — federated media provider (#4348)', () => {
modelId: 'minimax-music3',
futureModelField: 'keep-model-too',
}],
+ // Every kind's list is written on each save, so a peer that shares
+ // only audio still records an explicit empty visual allowlist.
+ imageModels: [],
+ videoModels: [],
futureField: 'keep-too',
},
},
diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.js
index a82268a36e..1587ace6d1 100644
--- a/client/src/services/apiSystem.js
+++ b/client/src/services/apiSystem.js
@@ -68,6 +68,10 @@ export const updateSettings = (data, options) => request('/settings', {
...options
});
export const getAiAssignments = (options) => request('/settings/ai-assignments', options);
+// Local image/video models this instance could offer as a federated media
+// provider — what the Sharing tab lets you pick from. Local-only inventory;
+// the peer-facing status endpoint only ever reports already-shared models.
+export const getMediaShareCandidates = (options) => request('/settings/media-share-candidates', options);
// API Access — the OpenAPI 3.1 spec for the public API surface (built from the
// exposed entries in apiAccess settings). Rendered by the API Access settings tab.
diff --git a/docs/FEDERATED_MEDIA_PROVIDERS.md b/docs/FEDERATED_MEDIA_PROVIDERS.md
index 187f60fef3..1dfedcb3df 100644
--- a/docs/FEDERATED_MEDIA_PROVIDERS.md
+++ b/docs/FEDERATED_MEDIA_PROVIDERS.md
@@ -31,6 +31,14 @@ The default is disabled:
An older install without this settings slice behaves exactly like the default above. Known fields are validated while unknown future fields are preserved, so rolling an install back does not erase newer provider settings.
+Image and video models are selected the same way as audio, from
+**Settings → Sharing**. Their candidate list comes from
+`GET /api/settings/media-share-candidates`, which enumerates this instance's local
+image/video model catalogs with the same readiness projection the wire status
+reports. That endpoint is **local-only and never exposed to peers** — it lists
+unshared local model inventory, which is exactly what a peer has no business
+reading.
+
## Configure a consumer
1. Register the provider under **Instances** and make the relationship mutual so the provider recognizes this consumer's instance id.
@@ -51,6 +59,14 @@ The consumer default is also disabled:
}
```
+A probe asks each peer for **every** kind this build knows
+(`?kinds=audio,image,video`), not just the kinds already allowlisted here. Scoping
+the question to the allowlist was a chicken-and-egg bug: a fresh consumer
+allowlists nothing, so it asked for audio only, so the peer advertised no visual
+capabilities, so there was never an image or video row to check. A provider too
+old to know the query parameter ignores it and returns the audio-only projection
+it always did.
+
This configuration and the last sanitized capacity snapshot live only on the local peer record. They are stripped from announce responses and do not become federation records. Older peers without the wire-v1 endpoint show as **older peer** rather than making the normal instance probe fail.
The Instances card reports the provider's ready/busy/unavailable state, shared active-job count, queue depth, and advertised model readiness. A consumer preflight accepts a model only when the peer is explicitly enabled, the exact model is locally allowlisted, the wire response validates, the capacity timestamp is fresh, the queue is accepting, and runtime/model/CUDA readiness is positive. Unknown, malformed, clock-skewed, or stale status blocks assignment. The provider remains authoritative and repeats admission checks when a later executor submits the job.
@@ -138,8 +154,22 @@ Set it under **Instances → Unattended render routing**, which offers only
(peer, model) pairs that are both locally allowlisted and currently advertised
by that peer. A kind set to `null` (the default) renders locally.
+An unattended route inherits the same text-to-image/text-to-video boundary the
+interactive routes enforce. A job carrying an init image, reference images,
+keyframes, a clip to extend, IC-LoRA references, LoRA weights, or chained chunks
+is rejected with `400 MEDIA_PROVIDER_INPUT_UNSUPPORTED` naming what has to go,
+rather than being silently rendered without its conditioning — a shot that
+quietly ignores its reference frame is worse unattended than interactively,
+because nobody is watching to notice.
+
Three properties are worth stating explicitly:
+- **Every unattended path routes, or none does.** The Creative Director planner
+ tool, the scene runner, and first-pass portraits/scene frames all enqueue
+ through one helper (`enqueueUnattendedMediaJob`). A route that applied to a
+ project's planner renders but not its scene renders would be worse than no
+ routing: half the shots would come off the peer's model and half off the local
+ one, with nothing to explain why they don't match.
- **The agent names nothing.** The planner's own `modelId` is discarded in favour
of the route's — a peer advertises its own model ids, and a local model name
would fail the peer's allowlist check with a confusing "not allowlisted".
diff --git a/server/routes/settings.js b/server/routes/settings.js
index 917627d633..3ea6e904c3 100644
--- a/server/routes/settings.js
+++ b/server/routes/settings.js
@@ -113,6 +113,19 @@ router.get('/', asyncHandler(async (req, res) => {
res.json(sanitizeSettingsForResponse(settings));
}));
+// GET /api/settings/media-share-candidates
+// The local image/video models this instance COULD share as a federated media
+// provider, so the Sharing tab can offer them. The peer-facing status endpoint
+// can't answer this: it only ever describes already-allowlisted models, which
+// is the chicken-and-egg that left imageModels/videoModels unconfigurable.
+// Deliberately local-only (this is unshared local model inventory, which no
+// peer should read) — it lives here, behind the normal /api/* auth gate,
+// rather than on /api/federation/media/v1.
+router.get('/media-share-candidates', asyncHandler(async (_req, res) => {
+ const { listLocalMediaShareCandidates } = await import('../services/federatedMediaProvider.js');
+ res.json(await listLocalMediaShareCandidates());
+}));
+
// GET /api/settings/ai-assignments
router.get('/ai-assignments', asyncHandler(async (_req, res) => {
res.json(await getAiAssignments());
diff --git a/server/services/creative/tools/media.js b/server/services/creative/tools/media.js
index e2d17d045e..f7a5aaff55 100644
--- a/server/services/creative/tools/media.js
+++ b/server/services/creative/tools/media.js
@@ -5,8 +5,7 @@
*/
import { z } from 'zod';
-import { enqueueJob } from '../../mediaJobQueue/index.js';
-import { resolveDefaultMediaRoute, routedJobParams } from '../../federatedMedia/defaultRouting.js';
+import { enqueueUnattendedMediaJob } from '../../federatedMedia/defaultRouting.js';
import { ASPECT_PRESETS, QUALITY_PRESETS, presetToRenderParams } from '../../../lib/creativeDirectorPresets.js';
import { getSettings } from '../../settings.js';
import { IMAGE_GEN_MODE, resolveQueueImageMode } from '../../imageGen/modes.js';
@@ -363,19 +362,13 @@ const mediaTool = (kind, label) => ({
}
// Unattended jobs never name a peer — the planner is an LLM, and letting
// it pick one is exactly the arbitrary-peer routing the provider contract
- // forbids. Routing comes from this instance's own settings instead, and is
- // resolved LAST so the project/install pin ladder above has already run:
- // a configured remote provider overrides those local backend choices, and
- // a job that would have rendered locally is unaffected.
- const routed = await resolveDefaultMediaRoute({ kind, params });
- if (routed) {
- return enqueueJob({
- kind,
- params: routedJobParams(params, routed),
- owner: resolveOwner(args, ctx),
- });
- }
- return enqueueJob({ kind, params, owner: resolveOwner(args, ctx) });
+ // forbids. Routing comes from this instance's own settings instead, applied
+ // by the shared unattended enqueue helper (which every autonomous render
+ // path goes through, so a configured route can't apply to a project's
+ // planner renders but not its scene renders). It resolves LAST, after the
+ // project/install pin ladder above: a configured remote provider overrides
+ // those local backend choices, and an unrouted job is unaffected.
+ return enqueueUnattendedMediaJob({ kind, params, owner: resolveOwner(args, ctx) });
},
});
diff --git a/server/services/creativeDirector/firstPassGen.js b/server/services/creativeDirector/firstPassGen.js
index 8656476301..18ae27a0ac 100644
--- a/server/services/creativeDirector/firstPassGen.js
+++ b/server/services/creativeDirector/firstPassGen.js
@@ -28,7 +28,7 @@
* auto-cast request. Autonomy seeds what it can; the director takes over.
*/
-import { enqueueJob } from '../mediaJobQueue/index.js';
+import { enqueueUnattendedMediaJob } from '../federatedMedia/defaultRouting.js';
import { getSettings } from '../settings.js';
import { resolveImageCleaners } from '../imageGen/index.js';
import { IMAGE_GEN_MODE } from '../imageGen/modes.js';
@@ -161,7 +161,7 @@ export async function enqueueFirstPassPortraits(members = [], project = null) {
skipped.push({ ingredientId, reason: skip });
continue;
}
- const queued = enqueueJob({
+ const queued = await enqueueUnattendedMediaJob({
kind: 'image',
params: {
...resolved.jobParams,
@@ -265,7 +265,7 @@ export async function enqueueFirstPassSceneFrames(project) {
skipped.push({ sceneId: scene.sceneId, reason: 'no-prompt' });
continue;
}
- const queued = enqueueJob({
+ const queued = await enqueueUnattendedMediaJob({
kind: 'image',
params: {
...resolved.jobParams,
diff --git a/server/services/creativeDirector/sceneRunner.js b/server/services/creativeDirector/sceneRunner.js
index 39083bf0e3..b53773e1ff 100644
--- a/server/services/creativeDirector/sceneRunner.js
+++ b/server/services/creativeDirector/sceneRunner.js
@@ -36,7 +36,8 @@ import { CD_MAX_SCENE_RETRIES } from '../../lib/creativeDirectorPrompts.js';
import { extractLastFrame, sampleEvaluationFrames } from '../videoGen/local.js';
import { VIDEO_GEN_MODE } from '../videoGen/modes.js';
import { grokVideoJobParams, resolveVideoBackendPin } from '../videoGen/backendPin.js';
-import { enqueueJob, mediaJobEvents } from '../mediaJobQueue/index.js';
+import { mediaJobEvents } from '../mediaJobQueue/index.js';
+import { enqueueUnattendedMediaJob } from '../federatedMedia/defaultRouting.js';
import { getSettings } from '../settings.js';
import { updateScene, updateProject, getProject } from './local.js';
import { dispatchSceneEvaluation } from './sceneEvaluator.js';
@@ -242,7 +243,7 @@ export async function runSceneRender(project, scene) {
}
const owner = `cd:${project.id}:${scene.sceneId}`;
- const { jobId } = enqueueJob({ kind: 'video', params, owner });
+ const { jobId } = await enqueueUnattendedMediaJob({ kind: 'video', params, owner });
// Wire one-shot listeners scoped to this jobId so we can hand off to the
// evaluator on success or schedule a retry on failure. mediaJobEvents
diff --git a/server/services/federatedMedia/defaultRouting.js b/server/services/federatedMedia/defaultRouting.js
index 8678bb2bd9..057085c929 100644
--- a/server/services/federatedMedia/defaultRouting.js
+++ b/server/services/federatedMedia/defaultRouting.js
@@ -65,6 +65,54 @@ export function normalizeMediaRoutingConfig(settings) {
return config;
}
+// Params that ask for conditioning wire v1 cannot carry. The interactive routes
+// reject these outright rather than dropping them, because "silently dropping
+// the source image a user pinned returns a plausible render of the wrong
+// thing" — and that reasoning is STRONGER here, not weaker: an unattended run
+// has nobody watching to notice the shot came back unconditioned. Keyed by the
+// param a planner actually writes, valued by the noun the error names.
+const UNSUPPORTED_CONDITIONING = Object.freeze({
+ initImagePath: 'an init image',
+ sourceImagePath: 'a source image',
+ sourceImageFile: 'a source image',
+ lastImageFile: 'an end frame',
+ referenceImagePaths: 'reference images',
+ icReferenceVideoIds: 'IC-LoRA references',
+ icReferenceImageFiles: 'IC-LoRA references',
+ keyframes: 'keyframes',
+ extendFromVideoId: 'a source video to extend',
+ loraFilenames: 'LoRA weights',
+ loraPaths: 'LoRA weights',
+});
+
+const isPresent = (value) => (Array.isArray(value) ? value.length > 0 : value !== undefined && value !== null && value !== '');
+
+/**
+ * Refuse a routed job whose conditioning the wire would silently drop.
+ *
+ * `buildFederatedMediaRequest` projects only the text-to-image/text-to-video
+ * fields onto the wire, so an unrecognized param does not fail validation — it
+ * just disappears. Without this guard a scene render conditioned on a reference
+ * frame would come back as an unrelated text-only image and be filed by its
+ * completion hook as though it were correct.
+ */
+function assertRoutableConditioning(kind, params) {
+ const unsupported = [...new Set(
+ Object.entries(UNSUPPORTED_CONDITIONING)
+ .filter(([key]) => isPresent(params?.[key]))
+ .map(([, label]) => label),
+ )];
+ // A multi-chunk video is chained locally from its own prior output; the
+ // provider renders one clip and knows nothing about the chain.
+ if (kind === 'video' && Number(params?.chunks) > 1) unsupported.push('chained chunks');
+ if (!unsupported.length) return;
+ throw new ServerError(
+ `A federated media provider renders text-to-${kind} only — this ${kind} job uses ${unsupported.join(' and ')}. `
+ + `Clear the ${kind} route under Instances to render it locally.`,
+ { status: 400, code: 'MEDIA_PROVIDER_INPUT_UNSUPPORTED' },
+ );
+}
+
/**
* Resolve the configured default provider for one unattended job, if any.
*
@@ -99,6 +147,7 @@ export async function resolveDefaultMediaRoute({ kind, params }) {
{ status: 400, code: 'MEDIA_PROVIDER_PROMPT_REQUIRED' },
);
}
+ assertRoutableConditioning(kind, params);
const request = buildFederatedMediaRequest({
kind,
engine: route.engine,
@@ -116,6 +165,14 @@ export async function resolveDefaultMediaRoute({ kind, params }) {
kind,
request,
});
+ // NOTE: the geometry forwarded here was snapped to the LOCAL model catalog by
+ // the enqueue path ahead of this resolver, and wire v1's capability payload
+ // publishes no frame-stride/canvas constraints to re-snap it against. A
+ // provider whose model has its own frame rule (Wan 2.2 needs
+ // `(numFrames - 1) % frameStride === 0`) therefore rejects such a job with a
+ // typed `WAN22_INVALID_FRAME_COUNT` — loud and fail-closed, but it makes that
+ // pairing unusable until the capability contract carries the constraint. That
+ // negotiation is its own slice; see the follow-up issue.
return { peer, request, remoteMedia };
}
@@ -144,3 +201,32 @@ export function routedJobParams(params, { request, remoteMedia }) {
for (const key of LOCAL_ONLY_ROUTED_PARAMS) delete jobParams[key];
return { ...jobParams, prompt: '', modelId: request.modelId, remoteMedia };
}
+
+/**
+ * THE enqueue entry point for unattended media work.
+ *
+ * Every autonomous render — the Creative Director planner tool, the scene
+ * runner, first-pass portraits and scene frames — must go through here rather
+ * than calling `enqueueJob` directly, or a configured route silently applies to
+ * some of a project's renders and not others. That inconsistency is worse than
+ * no routing at all: half a project renders on the peer's model and half on the
+ * local one, with no indication why the shots don't match.
+ *
+ * Signature-compatible with `enqueueJob` so a call site converts by changing
+ * the function name.
+ *
+ * @param {object} args
+ * @param {'image'|'video'|'audio'} args.kind
+ * @param {object} args.params
+ * @param {string} [args.owner]
+ * @returns {Promise<object>} The queued-job descriptor `enqueueJob` returns.
+ */
+export async function enqueueUnattendedMediaJob({ kind, params, owner }) {
+ const routed = await resolveDefaultMediaRoute({ kind, params });
+ const { enqueueJob } = await import('../mediaJobQueue/index.js');
+ return enqueueJob({
+ kind,
+ params: routed ? routedJobParams(params, routed) : params,
+ ...(owner === undefined ? {} : { owner }),
+ });
+}
diff --git a/server/services/federatedMedia/defaultRouting.test.js b/server/services/federatedMedia/defaultRouting.test.js
index 29dc1efc6a..35bdeb083a 100644
--- a/server/services/federatedMedia/defaultRouting.test.js
+++ b/server/services/federatedMedia/defaultRouting.test.js
@@ -8,14 +8,19 @@ vi.mock('./remoteSubmission.js', () => ({
prepareRemoteMediaJob: (...args) => prepareRemoteMediaJob(...args),
}));
-const { normalizeMediaRoutingConfig, resolveDefaultMediaRoute, routedJobParams } =
- await import('./defaultRouting.js');
+const enqueueJob = vi.fn(() => ({ jobId: 'mj-test' }));
+vi.mock('../mediaJobQueue/index.js', () => ({ enqueueJob: (...args) => enqueueJob(...args) }));
+
+const {
+ normalizeMediaRoutingConfig, resolveDefaultMediaRoute, routedJobParams, enqueueUnattendedMediaJob,
+} = await import('./defaultRouting.js');
const route = { peerId: 'peer-1', engine: 'comfy', modelId: 'sdxl-remote' };
const withRoute = (mediaRouting) => ({ federation: { mediaRouting } });
beforeEach(() => {
getSettings.mockReset();
+ enqueueJob.mockClear();
prepareRemoteMediaJob.mockReset();
prepareRemoteMediaJob.mockImplementation(async ({ peerId, kind, request }) => ({
peer: { id: peerId },
@@ -118,3 +123,76 @@ describe('routedJobParams', () => {
expect(params.modelId).toBe('sdxl-remote');
});
});
+
+// #4348 review follow-ups.
+describe('routed conditioning guard', () => {
+ const route = { peerId: 'peer-1', engine: 'comfy', modelId: 'sdxl-remote' };
+
+ beforeEach(() => {
+ getSettings.mockResolvedValue({ federation: { mediaRouting: { image: route, video: route } } });
+ });
+
+ // The interactive routes reject these rather than dropping them, because a
+ // render that silently ignores its source image comes back plausible and
+ // wrong. Unattended work has nobody watching, so the guard matters more here.
+ it.each([
+ ['initImagePath', { initImagePath: '/x/a.png' }, 'an init image'],
+ ['sourceImagePath', { sourceImagePath: '/x/a.png' }, 'a source image'],
+ ['referenceImagePaths', { referenceImagePaths: ['/x/a.png'] }, 'reference images'],
+ ['loraFilenames', { loraFilenames: ['style.safetensors'] }, 'LoRA weights'],
+ ['keyframes', { keyframes: [{ at: 0 }] }, 'keyframes'],
+ ])('refuses a routed image job carrying %s', async (_name, extra, label) => {
+ await expect(resolveDefaultMediaRoute({ kind: 'image', params: { prompt: 'p', ...extra } }))
+ .rejects.toMatchObject({ code: 'MEDIA_PROVIDER_INPUT_UNSUPPORTED' });
+ await expect(resolveDefaultMediaRoute({ kind: 'image', params: { prompt: 'p', ...extra } }))
+ .rejects.toThrow(new RegExp(label));
+ expect(prepareRemoteMediaJob).not.toHaveBeenCalled();
+ });
+
+ it('refuses a chained multi-chunk video, which the provider cannot continue', async () => {
+ await expect(resolveDefaultMediaRoute({ kind: 'video', params: { prompt: 'p', chunks: 3 } }))
+ .rejects.toThrow(/chained chunks/);
+ });
+
+ it('allows an empty or single-chunk value through', async () => {
+ await expect(resolveDefaultMediaRoute({
+ kind: 'video',
+ params: { prompt: 'p', chunks: 1, referenceImagePaths: [], loraFilenames: [] },
+ })).resolves.toMatchObject({ peer: { id: 'peer-1' } });
+ });
+});
+
+describe('enqueueUnattendedMediaJob', () => {
+ const route = { peerId: 'peer-1', engine: 'comfy', modelId: 'sdxl-remote' };
+
+ // Every autonomous render path funnels through this helper. If one call site
+ // kept calling enqueueJob directly, a configured route would apply to some of
+ // a project's shots and not others, with no indication why they don't match.
+ it('enqueues locally, untouched, when the kind has no route', async () => {
+ getSettings.mockResolvedValue({});
+ await enqueueUnattendedMediaJob({ kind: 'image', params: { prompt: 'p' }, owner: 'cd:1' });
+ expect(enqueueJob).toHaveBeenCalledWith({ kind: 'image', params: { prompt: 'p' }, owner: 'cd:1' });
+ });
+
+ it('enqueues the routed marker when the kind has a route', async () => {
+ getSettings.mockResolvedValue({ federation: { mediaRouting: { image: route } } });
+ await enqueueUnattendedMediaJob({ kind: 'image', params: { prompt: 'p' }, owner: 'cd:1' });
+ const { params } = enqueueJob.mock.calls.at(-1)[0];
+ expect(params.prompt).toBe('');
+ expect(params.remoteMedia.request.prompt).toBe('p');
+ });
+
+ it('omits owner entirely when the caller passed none', async () => {
+ getSettings.mockResolvedValue({});
+ await enqueueUnattendedMediaJob({ kind: 'audio', params: { prompt: 'p' } });
+ expect(enqueueJob.mock.calls.at(-1)[0]).not.toHaveProperty('owner');
+ });
+
+ it('propagates a provider rejection instead of falling back to a local enqueue', async () => {
+ getSettings.mockResolvedValue({ federation: { mediaRouting: { video: route } } });
+ prepareRemoteMediaJob.mockRejectedValue(new Error('Media provider is at capacity'));
+ await expect(enqueueUnattendedMediaJob({ kind: 'video', params: { prompt: 'p' } }))
+ .rejects.toThrow('Media provider is at capacity');
+ expect(enqueueJob).not.toHaveBeenCalled();
+ });
+});
diff --git a/server/services/federatedMediaConsumer.js b/server/services/federatedMediaConsumer.js
index 0e99733bfb..dd6073a82e 100644
--- a/server/services/federatedMediaConsumer.js
+++ b/server/services/federatedMediaConsumer.js
@@ -90,22 +90,27 @@ function responseState(response, body) {
return ['unavailable', body?.code || `http-${response.status || 'error'}`];
}
-// Only ask the peer for kinds this install actually has models allowlisted
-// for. Keep the request byte-identical to the original audio-only endpoint
-// (no query string) when nothing beyond audio is configured — this is the
-// consumer half of the same opt-in negotiation described in
-// normalizeRequestedMediaKinds (federatedMediaWire.js): a peer that has only
-// ever spoken wire-v1 audio never has to learn about the query param at all.
-function requestedKinds(config) {
- const kinds = KNOWN_MEDIA_KINDS.filter((kind) => config[`${kind}Models`]?.length > 0);
- return kinds.length ? kinds : ['audio'];
-}
-
-function statusUrl(peer, config) {
- const base = `${peerBaseUrl(peer)}/api/federation/media/v1/status`;
- const kinds = requestedKinds(config);
- if (kinds.length === 1 && kinds[0] === 'audio') return base;
- return `${base}?kinds=${kinds.join(',')}`;
+// Ask for EVERY kind this build understands, not just the kinds already
+// allowlisted here.
+//
+// Scoping the request to already-allowlisted kinds was a chicken-and-egg bug:
+// a fresh consumer has no visual models allowlisted, so it asked for audio
+// only, so the peer advertised no image/video capabilities, so the Instances
+// panel had no visual rows to check — and re-probing repeated the same
+// audio-only question forever. Nothing could ever seed the first image or
+// video allowlist.
+//
+// Asking for all kinds is safe in both directions of the version skew the
+// opt-in negotiation exists to protect (see normalizeRequestedMediaKinds in
+// federatedMediaWire.js). That negotiation protects an older CONSUMER, whose
+// own copy of the schema validates `kinds` against a literal('audio') and can
+// never be patched retroactively — it does not protect the provider. A
+// provider too old to know the query parameter simply ignores it and returns
+// the audio-only projection it always did.
+const requestedKinds = () => KNOWN_MEDIA_KINDS;
+
+function statusUrl(peer) {
+ return `${peerBaseUrl(peer)}/api/federation/media/v1/status?kinds=${requestedKinds().join(',')}`;
}
/**
@@ -117,7 +122,7 @@ export async function probeFederatedMediaProvider(peer, { signal, now = Date.now
if (!config.enabled) return probeResult(now, 'disabled', 'not-configured');
const outcome = await peerFetch(
- statusUrl(peer, config),
+ statusUrl(peer),
{ signal },
peer,
).then((response) => ({ response }), (error) => ({ error }));
diff --git a/server/services/federatedMediaConsumer.test.js b/server/services/federatedMediaConsumer.test.js
index a8c707428d..a9a91724a2 100644
--- a/server/services/federatedMediaConsumer.test.js
+++ b/server/services/federatedMediaConsumer.test.js
@@ -130,7 +130,7 @@ describe('federated media provider discovery', () => {
const result = await probeFederatedMediaProvider(target, { now: NOW });
expect(peerFetch).toHaveBeenCalledWith(
- 'http://192.0.2.10:5555/api/federation/media/v1/status',
+ 'http://192.0.2.10:5555/api/federation/media/v1/status?kinds=audio,image,video',
{ signal: undefined },
target,
);
@@ -172,16 +172,23 @@ describe('federated media provider discovery', () => {
});
});
- it('only asks a peer for image/video status once this install allowlists a model for that kind', async () => {
+ // #4348 — this used to scope the query to already-allowlisted kinds, which was
+ // a chicken-and-egg bug: a fresh consumer allowlists nothing, so it asked for
+ // audio only, so the peer advertised no visual capabilities, so the Instances
+ // panel had no image/video rows to check, so nothing could ever be allowlisted.
+ it('asks every peer for every known kind, so a fresh install can discover visual models at all', async () => {
peerFetch.mockResolvedValue(response(readyStatus()));
await probeFederatedMediaProvider(peer(), { now: NOW });
expect(peerFetch).toHaveBeenLastCalledWith(
- 'http://192.0.2.10:5555/api/federation/media/v1/status',
+ 'http://192.0.2.10:5555/api/federation/media/v1/status?kinds=audio,image,video',
{ signal: undefined },
expect.anything(),
);
+ });
+ it('asks for every kind even when only one kind is allowlisted', async () => {
+ peerFetch.mockResolvedValue(response(readyStatus()));
const withImage = peer({
mediaProvider: {
enabled: true,
@@ -189,9 +196,10 @@ describe('federated media provider discovery', () => {
imageModels: [{ engine: 'local', modelId: 'flux-dev' }],
},
});
+
await probeFederatedMediaProvider(withImage, { now: NOW });
expect(peerFetch).toHaveBeenLastCalledWith(
- 'http://192.0.2.10:5555/api/federation/media/v1/status?kinds=image',
+ 'http://192.0.2.10:5555/api/federation/media/v1/status?kinds=audio,image,video',
{ signal: undefined },
expect.anything(),
);
diff --git a/server/services/federatedMediaProvider.js b/server/services/federatedMediaProvider.js
index 51ff3b6815..81a7e760a4 100644
--- a/server/services/federatedMediaProvider.js
+++ b/server/services/federatedMediaProvider.js
@@ -360,6 +360,40 @@ export async function getFederatedMediaProviderStatus(config, { kinds = ['audio'
};
}
+/**
+ * Every LOCAL model this instance could offer to share, per visual kind, with
+ * the same readiness projection the wire status uses.
+ *
+ * This is the provider-side answer to a chicken-and-egg problem: the status
+ * endpoint only ever describes models the operator has ALREADY allowlisted, so
+ * it can never tell the Sharing UI what there is to allowlist in the first
+ * place. Audio doesn't need this — its Sharing UI is driven by the music-engine
+ * catalog, which already enumerates candidates.
+ *
+ * LOCAL ONLY. This is exposed under `/api/` for this instance's own settings
+ * screen, never on the peer surface: it enumerates unshared local models, which
+ * is exactly the inventory a peer has no business reading.
+ *
+ * @returns {Promise<{image: object[], video: object[]}>}
+ */
+export async function listLocalMediaShareCandidates() {
+ const pythonPath = await resolveLocalRuntimePythonPath(['image', 'video']);
+ const catalogs = { image: getImageModels(), video: getVideoModels() };
+ const entries = await Promise.all(
+ Object.entries(catalogs).map(async ([kind, models]) => [
+ kind,
+ (await localGeneratorCapabilities(kind, pythonPath, {
+ models,
+ // Offer the whole local catalog as candidates rather than the
+ // configured subset — that subset is what this call exists to help the
+ // operator choose.
+ configuredList: models.map((model) => ({ engine: 'local', modelId: model.id })),
+ })).map(publicCapability),
+ ]),
+ );
+ return Object.fromEntries(entries);
+}
+
const jobOwner = (callerId) => `${OWNER_PREFIX}${callerId}`;
const jobBelongsToCaller = (job, callerId) =>
job?.owner === jobOwner(callerId)
diff --git a/server/services/instances.test.js b/server/services/instances.test.js
index c13d88660b..09df5236b4 100644
--- a/server/services/instances.test.js
+++ b/server/services/instances.test.js
@@ -1163,7 +1163,7 @@ describe('instances.js', () => {
}
if (String(url).endsWith('/api/apps')) return { ok: true, json: async () => [] };
if (String(url).includes('/api/instances/sync-status')) return { ok: true, json: async () => ({}) };
- if (String(url).endsWith('/api/federation/media/v1/status')) {
+ if (String(url).includes('/api/federation/media/v1/status')) {
return { ok: true, status: 200, text: async () => JSON.stringify(providerStatus) };
}
return { ok: false, status: 404, text: async () => '' };
@@ -1172,8 +1172,11 @@ describe('instances.js', () => {
const result = await probePeer(target);
expect(result.mediaProviderStatus).toMatchObject({ state: 'ready', reason: null });
+ // Every known kind is requested, not just already-allowlisted ones — a
+ // fresh consumer has no visual allowlist, and scoping the question to it
+ // is what previously made image/video capabilities undiscoverable (#4348).
expect(fetch).toHaveBeenCalledWith(
- 'http://10.0.0.1:5555/api/federation/media/v1/status',
+ 'http://10.0.0.1:5555/api/federation/media/v1/status?kinds=audio,image,video',
expect.objectContaining({ signal: expect.any(AbortSignal) }),
);
});