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 (claude): make the peer picker agree with the caption it sits above

[._.]/ Adam Eivyce7988cfba16
diff --git a/client/src/components/music/MusicGenPanel.jsx b/client/src/components/music/MusicGenPanel.jsx
index 23fdf18a3e..739ec816b4 100644
--- a/client/src/components/music/MusicGenPanel.jsx
+++ b/client/src/components/music/MusicGenPanel.jsx
@@ -519,8 +519,12 @@ export default function MusicGenPanel({ track, title = '', artistId = '', artist
>
<option value="">This instance</option>
{peers.filter((peer) => peer.mediaProvider?.enabled === true).map((peer) => {
- const status = peer.mediaProviderStatus;
- const suffix = status?.state === 'ready' ? '' : ` (${status?.state || 'checking'})`;
+ // Same reading as the caption and the button below. The stored
+ // `state` alone would leave a switched-off or lapsed peer listed
+ // with no suffix — reading as ready — beside a caption explaining
+ // why it is not.
+ const readiness = resolvePeerMediaReadiness(peer);
+ const suffix = readiness.usable ? '' : ` (${readiness.label})`;
return <option key={peer.id} value={peer.id}>{peer.name || peer.address || 'Federated peer'}{suffix}</option>;
})}
</select>
@@ -544,8 +548,10 @@ export default function MusicGenPanel({ track, title = '', artistId = '', artist
</select>
</label>
<p className="text-[11px] text-gray-400">
- {remoteReadiness?.usable && remoteQueueSegments.length > 0
- ? remoteQueueSegments.join(' · ')
+ {remoteReadiness?.usable
+ // A usable peer carries no remedy text, so falling through would
+ // print the not-ready sentence beside an enabled button.
+ ? (remoteQueueSegments.join(' · ') || 'Peer is ready.')
: remoteReadiness?.help
|| 'Remote generation requires a ready, authenticated peer with fresh capacity.'}
</p>
diff --git a/client/src/components/music/MusicGenPanel.test.jsx b/client/src/components/music/MusicGenPanel.test.jsx
index 73a8bbdce0..7a353f9f5c 100644
--- a/client/src/components/music/MusicGenPanel.test.jsx
+++ b/client/src/components/music/MusicGenPanel.test.jsx
@@ -341,11 +341,38 @@ describe('MusicGenPanel', () => {
expect(screen.queryByText(/shared slots active/i)).not.toBeInTheDocument();
});
+ // The dropdown, the caption and the button all describe the same peer. A
+ // switched-off peer keeps a stored `state: 'ready'` for as long as its
+ // snapshot stays fresh, so gating the suffix on `state` would list it with no
+ // suffix — reading as ready — beside a caption saying it is switched off.
+ it('marks a switched-off peer in the target dropdown, not just in the caption', async () => {
+ api.listMusicEngines.mockResolvedValue({ defaultEngine: 'musicgen', engines: [engine({ ready: true })] });
+ api.getInstances.mockResolvedValue({
+ peers: [{
+ id: 'peer-example',
+ name: 'Example GPU',
+ status: 'online',
+ enabled: false,
+ mediaProvider: { enabled: true, audioModels: [{ engine: 'minimax-music3', modelId: 'minimax-music3' }] },
+ mediaProviderStatus: {
+ state: 'ready',
+ checkedAt: new Date().toISOString(),
+ freshUntil: new Date(Date.now() + 60_000).toISOString(),
+ snapshot: { queue: { accepting: true, running: 0, queued: 0, totalActive: 0, maxQueuedJobs: 4 }, capabilities: [] },
+ },
+ }],
+ });
+
+ render(<MusicGenPanel track={{ id: 'track-1' }} prompt="private prompt" />);
+ await screen.findByRole('combobox', { name: /generation target/i });
+ expect(screen.getByRole('option', { name: /Example GPU \(peer disabled\)/ })).toBeInTheDocument();
+ });
+
// A capacity window expires on the clock, not on a state change, so between
// polls the button can still be enabled against a peer that has gone stale.
it('refuses at click time when the window expired since the last render', async () => {
api.listMusicEngines.mockResolvedValue({ defaultEngine: 'musicgen', engines: [engine({ ready: true })] });
- const freshUntil = new Date(Date.now() + 300).toISOString();
+ const freshUntil = new Date(Date.now() + 60_000).toISOString();
api.getInstances.mockResolvedValue({
peers: [{
id: 'peer-example',
@@ -373,12 +400,16 @@ describe('MusicGenPanel', () => {
const generate = screen.getByRole('button', { name: /^generate$/i });
expect(generate).toBeEnabled();
- // The window lapses without anything re-rendering the panel.
- await new Promise((resolve) => setTimeout(resolve, 350));
+ // The window lapses without anything re-rendering the panel. Advancing the
+ // clock rather than sleeping keeps this instant and load-independent —
+ // `resolvePeerMediaReadiness` reads Date.now(), no timers are involved.
+ const realNow = Date.now();
+ vi.spyOn(Date, 'now').mockReturnValue(realNow + 120_000);
fireEvent.click(generate);
await waitFor(() => expect(toast.error).toHaveBeenCalledWith(expect.stringMatching(/capacity snapshot expired/i)));
expect(api.generateMusic).not.toHaveBeenCalled();
+ Date.now.mockRestore();
});
// The stored probe keeps saying `ready` long after the server would refuse
diff --git a/server/services/federatedMediaProvider.js b/server/services/federatedMediaProvider.js
index 2af10c2d3a..4d3d1815e1 100644
--- a/server/services/federatedMediaProvider.js
+++ b/server/services/federatedMediaProvider.js
@@ -386,6 +386,12 @@ function activeQueueSnapshot(config, kinds) {
// Local work of a kind this contract does not federate (LoRA training) still
// holds a lane, so it counts toward `totalActive` while having no bucket —
// which is why the two need not sum.
+ //
+ // This filter is a WIRE-COMPATIBILITY requirement, not just scoping: the
+ // consumer validates `byKind` with a partialRecord over its own kind enum,
+ // which rejects an unknown key outright. A kind the caller did not
+ // negotiate would therefore invalidate the whole status payload on an older
+ // consumer, not just drop that one bucket.
if (!kinds.includes(job.kind)) continue;
const bucket = byKind[job.kind] ?? (byKind[job.kind] = { running: 0, queued: 0 });
bucket[job.status === 'running' ? 'running' : 'queued'] += 1;
diff --git a/server/services/federatedMediaProvider.test.js b/server/services/federatedMediaProvider.test.js
index 221ab896d2..eabd41bb9e 100644
--- a/server/services/federatedMediaProvider.test.js
+++ b/server/services/federatedMediaProvider.test.js
@@ -262,10 +262,16 @@ describe('federated media provider capacity and idempotency', () => {
// would leave byKind as the one part of the payload the kind projection does
// not govern.
it('scopes the per-kind breakdown to the negotiated kinds', async () => {
- state.jobs = [{ id: 'a', kind: 'image', status: 'running', owner: null }];
+ state.jobs = [
+ { id: 'a', kind: 'image', status: 'running', owner: null },
+ // Federated work of a kind this caller did not negotiate: invisible in
+ // byKind, but still part of the federated share of the machine — so a
+ // kind filter applied before the owner check would under-report it.
+ { id: 'b', kind: 'image', status: 'running', owner: 'federated-media:peer-example' },
+ ];
const status = await getFederatedMediaProviderStatus(config());
expect(status.queue.byKind).toEqual({});
- expect(status.queue.totalActive).toBe(1);
+ expect(status.queue).toMatchObject({ totalActive: 2, providerActive: 1, running: 1, queued: 0 });
});
it('queues allowlisted audio without exposing the prompt in its response', async () => {