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): stop a stale peer from enabling Generate, and label the federated share

[._.]/ Adam Eivy5474697dadb0
diff --git a/client/src/components/instances/PeerMediaProviderPanel.test.jsx b/client/src/components/instances/PeerMediaProviderPanel.test.jsx
index 263065783b..eebd46fb31 100644
--- a/client/src/components/instances/PeerMediaProviderPanel.test.jsx
+++ b/client/src/components/instances/PeerMediaProviderPanel.test.jsx
@@ -81,7 +81,7 @@ describe('PeerMediaProviderPanel', () => {
render(<PeerMediaProviderPanel peer={peer} onRefresh={vi.fn()} />);
fireEvent.click(screen.getByRole('button', { name: /Remote media provider/i }));
- expect(screen.getByText(/runs 2 at a time · audio 1 running, 2 queued/i)).toBeInTheDocument();
+ expect(screen.getByText(/runs 2 at a time · audio 1 running, 2 queued · federated 1 running, 2 queued/i)).toBeInTheDocument();
// An idle kind is omitted, not rendered as a zero.
expect(screen.queryByText(/(image|video) \d/i)).not.toBeInTheDocument();
});
@@ -96,7 +96,7 @@ describe('PeerMediaProviderPanel', () => {
render(<PeerMediaProviderPanel peer={peer} onRefresh={onRefresh} />);
fireEvent.click(screen.getByRole('button', { name: /Remote media provider/i }));
- expect(screen.getByText(/1 running · 2 queued · 3\/4 slots active/i)).toBeInTheDocument();
+ expect(screen.getByText(/3\/4 shared slots active · federated 1 running, 2 queued/i)).toBeInTheDocument();
fireEvent.click(screen.getByLabelText('Allow audio model MiniMax Music 3'));
await waitFor(() => expect(updatePeer).toHaveBeenCalledWith('peer-example', {
diff --git a/client/src/components/music/MusicGenPanel.jsx b/client/src/components/music/MusicGenPanel.jsx
index b8e43fc77d..a6db85b055 100644
--- a/client/src/components/music/MusicGenPanel.jsx
+++ b/client/src/components/music/MusicGenPanel.jsx
@@ -322,10 +322,17 @@ export default function MusicGenPanel({ track, title = '', artistId = '', artist
setDurationSec((d) => (d == null ? engine.defaultDurationSec : d));
}, [engine?.id, engine?.models]);
+ // The same resolver the Instances card and System Health use, rather than the
+ // `state` recorded on the stored probe: a snapshot written as `ready` keeps
+ // saying so after its freshness window closes, and this is the surface where
+ // the user actually commits a render to that peer. It gates the button as
+ // well as the caption — a caption reading "stale" beside an enabled Generate
+ // just moves the rejection to the server.
+ const remoteReadiness = selectedRemotePeer ? resolvePeerMediaReadiness(selectedRemotePeer) : null;
+ const remoteQueueSegments = remoteReadiness ? summarizePeerMediaQueue(remoteReadiness.queue) : [];
const remoteReady = isRemote
- && selectedRemotePeer?.status === 'online'
- && selectedRemotePeer?.mediaProviderStatus?.state === 'ready'
- && selectedRemotePeer?.mediaProviderStatus?.snapshot?.queue?.accepting === true
+ && remoteReadiness?.state === 'ready'
+ && remoteReadiness.queue?.accepting === true
&& selectedRemoteModel?.ready === true;
const canGenerate = (isRemote ? remoteReady : !!engine?.ready && selectedModelReady)
&& !!prompt?.trim() && !isGenerating;
@@ -483,12 +490,6 @@ export default function MusicGenPanel({ track, title = '', artistId = '', artist
const selectedUserModel = engine?.models?.find((m) => m.id === modelId && m.userAdded);
const showRuntimeInstallHint = !isRemote && !!engine && (!engine.ready || !selectedModelReady) && (!!prompt?.trim() || userSelectedEngine);
- // The same resolver the Instances card and System Health use, rather than
- // reading `state` off the stored probe: a snapshot recorded as `ready` keeps
- // saying so after its freshness window closes, and this is the surface where
- // the user actually commits a render to that peer.
- const remoteReadiness = selectedRemotePeer ? resolvePeerMediaReadiness(selectedRemotePeer) : null;
- const remoteQueueSegments = remoteReadiness ? summarizePeerMediaQueue(remoteReadiness.queue) : [];
return (
<div className="space-y-2 border border-port-border rounded-lg p-3 bg-port-bg/40">
diff --git a/client/src/components/music/MusicGenPanel.test.jsx b/client/src/components/music/MusicGenPanel.test.jsx
index 22c11e00e4..91196e2a28 100644
--- a/client/src/components/music/MusicGenPanel.test.jsx
+++ b/client/src/components/music/MusicGenPanel.test.jsx
@@ -264,6 +264,11 @@ describe('MusicGenPanel', () => {
mediaProvider: { enabled: true, audioModels: [{ engine: 'minimax-music3', modelId: 'minimax-music3' }] },
mediaProviderStatus: {
state: 'ready',
+ // A capacity claim needs a verifiable freshness window: the panel
+ // re-derives `stale` at render time rather than trusting the state
+ // the probe recorded, so a snapshot with no window reads as stale.
+ checkedAt: new Date().toISOString(),
+ freshUntil: new Date(Date.now() + 60_000).toISOString(),
snapshot: {
queue: { accepting: true, running: 0, queued: 0 },
capabilities: [{
@@ -295,6 +300,40 @@ describe('MusicGenPanel', () => {
expect(requestBody).not.toHaveProperty('lyrics');
});
+ // The stored probe keeps saying `ready` long after the server would refuse
+ // the submission. Leaving Generate enabled beside a caption reading "stale"
+ // just moves the rejection to the server, after the user committed to it.
+ it('blocks generation on a peer whose capacity window has expired', async () => {
+ api.listMusicEngines.mockResolvedValue({ defaultEngine: 'musicgen', engines: [engine({ ready: true })] });
+ api.getInstances.mockResolvedValue({
+ peers: [{
+ id: 'peer-example',
+ name: 'Example GPU',
+ status: 'online',
+ mediaProvider: { enabled: true, audioModels: [{ engine: 'minimax-music3', modelId: 'minimax-music3' }] },
+ mediaProviderStatus: {
+ state: 'ready',
+ checkedAt: new Date(Date.now() - 120_000).toISOString(),
+ freshUntil: new Date(Date.now() - 60_000).toISOString(),
+ snapshot: {
+ queue: { accepting: true, running: 0, queued: 0 },
+ capabilities: [{
+ kind: 'audio', engine: 'minimax-music3', engineName: 'MiniMax Music 3', modelId: 'minimax-music3',
+ modelName: 'MiniMax Music 3', ready: true, autoDuration: false, lyrics: true,
+ minDurationSec: 10, maxDurationSec: 300, defaultDurationSec: 60,
+ }],
+ },
+ },
+ }],
+ });
+
+ render(<MusicGenPanel track={{ id: 'track-1' }} prompt="private prompt" />);
+
+ fireEvent.change(await screen.findByRole('combobox', { name: /generation target/i }), { target: { value: 'peer-example' } });
+ expect(screen.getByRole('button', { name: /^generate$/i })).toBeDisabled();
+ expect(screen.getByText(/capacity snapshot expired/i)).toBeInTheDocument();
+ });
+
it('can render instrumentally without conditioning on or clearing the track lyrics', async () => {
api.listMusicEngines.mockResolvedValue({
defaultEngine: 'acestep',
diff --git a/client/src/components/system-resources/MediaCapacityPanel.test.jsx b/client/src/components/system-resources/MediaCapacityPanel.test.jsx
index 30359046a8..4d4aee1171 100644
--- a/client/src/components/system-resources/MediaCapacityPanel.test.jsx
+++ b/client/src/components/system-resources/MediaCapacityPanel.test.jsx
@@ -91,7 +91,7 @@ describe('MediaCapacityPanel', () => {
renderPanel();
expect(await screen.findByText('render-box')).toBeInTheDocument();
expect(screen.getByText('ready')).toBeInTheDocument();
- expect(screen.getByText('1 running · 0 queued · 1/4 slots active')).toBeInTheDocument();
+ expect(screen.getByText('1/4 shared slots active · federated 1 running')).toBeInTheDocument();
});
// The local lanes above already show running/limit; a peer row that could only
@@ -113,7 +113,7 @@ describe('MediaCapacityPanel', () => {
},
})] });
renderPanel();
- expect(await screen.findByText(/runs 4 at a time · audio 1 running/)).toBeInTheDocument();
+ expect(await screen.findByText(/runs 4 at a time · audio 1 running · federated 1 running/)).toBeInTheDocument();
});
// An older provider sends neither field. The row drops the segments rather
diff --git a/client/src/lib/federatedMediaReadiness.js b/client/src/lib/federatedMediaReadiness.js
index 56be71deb7..8e809e169f 100644
--- a/client/src/lib/federatedMediaReadiness.js
+++ b/client/src/lib/federatedMediaReadiness.js
@@ -135,6 +135,15 @@ function verifiedState(status, now) {
const isCount = (value) => Number.isInteger(value) && value >= 0;
+// "<label> 1 running, 2 queued", or null when nothing is there to report.
+const occupancySegment = (label, entry) => {
+ if (!isRecord(entry) || !isCount(entry.running) || !isCount(entry.queued)) return null;
+ const parts = [];
+ if (entry.running > 0) parts.push(`${entry.running} running`);
+ if (entry.queued > 0) parts.push(`${entry.queued} queued`);
+ return parts.length > 0 ? `${label} ${parts.join(', ')}` : null;
+};
+
/**
* The peer's queue block as finished display segments.
*
@@ -153,24 +162,26 @@ const isCount = (value) => Number.isInteger(value) && value >= 0;
export function summarizePeerMediaQueue(queue) {
if (!isRecord(queue)) return NO_QUEUE_SEGMENTS;
const segments = [];
- if (isCount(queue.running) && isCount(queue.queued)
- && isCount(queue.totalActive) && isCount(queue.maxQueuedJobs)) {
- segments.push(`${queue.running} running · ${queue.queued} queued · ${queue.totalActive}/${queue.maxQueuedJobs} slots active`);
+ // Machine-wide: every local render on that peer competes for these slots,
+ // which is why this is the number that predicts a wait.
+ if (isCount(queue.totalActive) && isCount(queue.maxQueuedJobs)) {
+ segments.push(`${queue.totalActive}/${queue.maxQueuedJobs} shared slots active`);
}
if (isCount(queue.concurrency) && queue.concurrency > 0) {
segments.push(`runs ${queue.concurrency} at a time`);
}
- // The provider reports only the kinds holding a lane, so every entry here has
- // work in it; a kind that is idle is simply absent.
+ // Also machine-wide — this is what breaks the slot count down. The provider
+ // reports only the kinds holding a lane, so an idle kind is simply absent.
const byKind = isRecord(queue.byKind) ? queue.byKind : {};
for (const { kind, label } of FEDERATED_MEDIA_KINDS) {
- const entry = byKind[kind];
- if (!isRecord(entry) || !isCount(entry.running) || !isCount(entry.queued)) continue;
- const parts = [];
- if (entry.running > 0) parts.push(`${entry.running} running`);
- if (entry.queued > 0) parts.push(`${entry.queued} queued`);
- if (parts.length > 0) segments.push(`${label} ${parts.join(', ')}`);
+ const segment = occupancySegment(label, byKind[kind]);
+ if (segment) segments.push(segment);
}
+ // The federated share of the same slots, labelled so it cannot be read as the
+ // whole picture: an unlabelled "0 running" beside "audio 1 running" says the
+ // peer is both busy and idle.
+ const federated = occupancySegment('federated', queue);
+ if (federated) segments.push(federated);
return segments;
}
diff --git a/client/src/lib/federatedMediaReadiness.test.js b/client/src/lib/federatedMediaReadiness.test.js
index 4d9be95429..538ce8d133 100644
--- a/client/src/lib/federatedMediaReadiness.test.js
+++ b/client/src/lib/federatedMediaReadiness.test.js
@@ -193,26 +193,41 @@ describe('summarizePeerMediaQueue', () => {
totalActive: 2, providerActive: 1, queued: 1, running: 1, maxQueuedJobs: 4, accepting: true, ...overrides,
});
- it('renders slots, drain rate, and every kind holding a lane', () => {
+ it('renders shared slots, drain rate, per-kind load, and the federated share', () => {
expect(summarizePeerMediaQueue(queue({
concurrency: 2,
byKind: { audio: { running: 1, queued: 1 }, image: { running: 0, queued: 1 } },
}))).toEqual([
- '1 running · 1 queued · 2/4 slots active',
+ '2/4 shared slots active',
'runs 2 at a time',
'audio 1 running, 1 queued',
'image 1 queued',
+ 'federated 1 running, 1 queued',
]);
});
- // An older provider sends neither field. Rendering the absence as a zero
+ // byKind is machine-wide while running/queued are the federated share, so an
+ // unlabelled "0 running" beside "audio 1 running" would claim the peer is
+ // both busy and idle.
+ it('labels the federated share so it cannot be read as the whole machine', () => {
+ expect(summarizePeerMediaQueue({
+ totalActive: 1, providerActive: 0, queued: 0, running: 0, maxQueuedJobs: 2, accepting: true,
+ byKind: { audio: { running: 1, queued: 0 } },
+ })).toEqual(['1/2 shared slots active', 'audio 1 running']);
+ });
+
+ // An older provider sends neither new field. Rendering the absence as a zero
// would claim idle lanes the peer never reported on.
it('drops the segments an older provider never sent instead of showing zeroes', () => {
- expect(summarizePeerMediaQueue(queue())).toEqual(['1 running · 1 queued · 2/4 slots active']);
+ expect(summarizePeerMediaQueue(queue())).toEqual([
+ '2/4 shared slots active',
+ 'federated 1 running, 1 queued',
+ ]);
});
it('drops a concurrency that claims no capacity', () => {
- expect(summarizePeerMediaQueue(queue({ concurrency: 0 }))).toHaveLength(1);
+ expect(summarizePeerMediaQueue(queue({ concurrency: 0 })))
+ .not.toContain('runs 0 at a time');
});
// The provider omits an idle kind, but a build that sent one must not add a
@@ -220,7 +235,10 @@ describe('summarizePeerMediaQueue', () => {
it('omits a kind reporting no work', () => {
expect(summarizePeerMediaQueue(queue({
byKind: { audio: { running: 0, queued: 0 }, image: { running: 2, queued: 0 } },
- }))).toEqual(['1 running · 1 queued · 2/4 slots active', 'image 2 running']);
+ }))).toContain('image 2 running');
+ expect(summarizePeerMediaQueue(queue({
+ byKind: { audio: { running: 0, queued: 0 } },
+ }))).not.toContain('audio');
});
it('reports nothing at all when the queue block is missing', () => {
diff --git a/docs/FEDERATED_MEDIA_PROVIDERS.md b/docs/FEDERATED_MEDIA_PROVIDERS.md
index 47d91956ae..2eee3392c2 100644
--- a/docs/FEDERATED_MEDIA_PROVIDERS.md
+++ b/docs/FEDERATED_MEDIA_PROVIDERS.md
@@ -323,7 +323,7 @@ cannot say:
| Field | Meaning |
|-------|---------|
| `totalActive` | every queued/running local media job, including kinds this contract does not federate |
-| `providerActive` / `queued` / `running` | the subset owned by federated callers |
+| `providerActive` / `queued` / `running` | the subset owned by federated callers — a *share* of the above, never the whole picture |
| `maxQueuedJobs` | the admission bound `accepting` is computed against |
| `concurrency` | how many jobs run at once on the lane a federated submission lands on |
| `byKind` | `{running, queued}` for each negotiated kind currently holding a lane |
@@ -340,6 +340,11 @@ block present, an absent kind is idle. It need not sum to `totalActive`, which
also counts local work of kinds this contract does not federate (LoRA training)
occupying the same lanes.
+`byKind` and `totalActive` describe the whole machine, while `running`/`queued`
+describe only the federated share of it — so the UI labels the federated
+numbers rather than rendering them bare. An unlabelled `0 running` beside
+`audio 1 running` would say the peer is simultaneously busy and idle.
+
Both fields were added after wire v1 shipped, so both are optional: a provider
on an older build omits them and a consumer must read that absence as
**unknown**, never as zero. The UI drops the segment rather than rendering a