feat(server): capability framework, AudioMuse sonic routing & PsyLab Connections (#1033)

* feat(server): probe AudioMuse via OpenSubsonic and add PsyLab Connections tab

Navidrome ≥0.62: detect sonicSimilarity extension for reliable plugin signal;
older servers keep the legacy getSimilarSongs probe. PsyLab gets a Connections
tab with session, endpoint, and active-server capability details.

* feat(psylab): polish Connections tab, admin role probe, and tab bar layout

Status badges and Navidrome admin/user validation in Connections; prevent
PsyLab tab row from vertically collapsing under the Logs flex layout.

* docs: add CHANGELOG and credits for PR #1032

* feat(settings): auto-enable AudioMuse on Navidrome 0.62+ with status indicator

Replace the per-server manual toggle with a probe-driven badge when
sonicSimilarity is available; pre-0.62 Navidrome keeps the legacy toggle.

* feat(server): capability framework with AudioMuse sonic routing

Add a declarative server-capability catalog (src/serverCapabilities/) that
picks a feature strategy per server generation, runs only the needed probes,
and routes API calls. AudioMuse Instant Mix now prefers the OpenSubsonic
sonicSimilarity endpoint (getSonicSimilarTracks) on Navidrome 0.62+ and
falls back to legacy getSimilarSongs.

- catalog/context/resolve: eligibility, detection, activation, call routing
- storeView: read facade over the existing per-server probe maps
- getSonicSimilarTracks API client + fetchSimilarTracksRouted router
- route Instant Mix and Lucky Mix through the resolver
- ServersTab + PsyLab Connections read the resolver (auto status vs toggle)
- tests: resolve, storeView, router

* docs: update CHANGELOG and credits for PR #1033

Renamed branch supersedes PR #1032: point changelog/credits at #1033 and
document the server-capability framework, auto-managed AudioMuse indicator,
and sonic Instant Mix routing.

* refactor(server): address PR #1033 review — idempotent probe, drop dead code

- Make scheduleInstantMixProbeForServer idempotent: skip when a definitive
  result is cached; re-probe only on force (add/edit/test server), a prior
  error, or a server version/type change (invalidated in setSubsonicServerIdentity).
  Removes the steady-state 120 s re-probe, the present→probing→present flicker,
  and the momentary legacy-fallback routing window.
- Remove now-dead identity helpers (showAudiomuseNavidromeServerSetting,
  isAudiomusePluginAutoManaged, isNavidromeSonicSimilarityEligible,
  resolveAudiomusePluginProbeUiStatus + type) and the superseded
  probeAudiomusePluginWithCredentials; the catalog is the single source of truth.
- Drop the never-emitted 'unsupported' AudiomusePluginProbeResult variant.
- Fill audiomuseStatus* keys in all 8 non-en locales.
- Tests: probe idempotency + version-change invalidation; retarget
  OpenSubsonic test to fetchOpenSubsonicExtensionsWithCredentials.
This commit is contained in:
cucadmuh
2026-06-09 00:16:29 +03:00
committed by GitHub
parent 0878cbf308
commit 6118b3940f
43 changed files with 1867 additions and 74 deletions
+89
View File
@@ -0,0 +1,89 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
vi.mock('./subsonicOpenSubsonic', () => ({
fetchOpenSubsonicExtensionsWithCredentials: vi.fn(),
}));
import { fetchOpenSubsonicExtensionsWithCredentials } from './subsonicOpenSubsonic';
import { scheduleInstantMixProbeForServer } from './subsonic';
import { useAuthStore } from '../store/authStore';
import type { SubsonicServerIdentity } from '../utils/server/subsonicServerIdentity';
const fetchMock = vi.mocked(fetchOpenSubsonicExtensionsWithCredentials);
const SID = 'srv-probe';
const id062: SubsonicServerIdentity = { type: 'navidrome', serverVersion: '0.62.0', openSubsonic: true };
const flush = () => new Promise(resolve => setTimeout(resolve, 0));
function reset() {
useAuthStore.setState({
subsonicServerIdentityByServer: {},
audiomusePluginProbeByServer: {},
instantMixProbeByServer: {},
audiomuseNavidromeByServer: {},
audiomuseNavidromeIssueByServer: {},
} as never);
}
describe('scheduleInstantMixProbeForServer (idempotency)', () => {
beforeEach(() => {
fetchMock.mockReset();
fetchMock.mockResolvedValue(['sonicSimilarity']);
reset();
});
it('probes once, caches the result, then skips on the next poll', async () => {
scheduleInstantMixProbeForServer(SID, 'url', 'u', 'p', id062);
expect(fetchMock).toHaveBeenCalledTimes(1);
await flush();
expect(useAuthStore.getState().audiomusePluginProbeByServer[SID]).toBe('present');
scheduleInstantMixProbeForServer(SID, 'url', 'u', 'p', id062);
expect(fetchMock).toHaveBeenCalledTimes(1);
});
it('re-probes when forced (user-initiated refresh)', async () => {
scheduleInstantMixProbeForServer(SID, 'url', 'u', 'p', id062);
await flush();
scheduleInstantMixProbeForServer(SID, 'url', 'u', 'p', id062, true);
expect(fetchMock).toHaveBeenCalledTimes(2);
});
it('re-probes after a prior error', async () => {
fetchMock.mockResolvedValueOnce(null);
scheduleInstantMixProbeForServer(SID, 'url', 'u', 'p', id062);
await flush();
expect(useAuthStore.getState().audiomusePluginProbeByServer[SID]).toBe('error');
scheduleInstantMixProbeForServer(SID, 'url', 'u', 'p', id062);
expect(fetchMock).toHaveBeenCalledTimes(2);
});
});
describe('setSubsonicServerIdentity (version-change cache invalidation)', () => {
beforeEach(reset);
it('clears cached probes on a version change but keeps the opt-in', () => {
useAuthStore.setState({
subsonicServerIdentityByServer: { [SID]: id062 },
audiomusePluginProbeByServer: { [SID]: 'present' },
audiomuseNavidromeByServer: { [SID]: true },
} as never);
useAuthStore.getState().setSubsonicServerIdentity(SID, { type: 'navidrome', serverVersion: '0.63.0', openSubsonic: true });
const s = useAuthStore.getState();
expect(s.audiomusePluginProbeByServer[SID]).toBeUndefined();
expect(s.audiomuseNavidromeByServer[SID]).toBe(true);
});
it('keeps cached probes when the identity is unchanged', () => {
useAuthStore.setState({
subsonicServerIdentityByServer: { [SID]: id062 },
audiomusePluginProbeByServer: { [SID]: 'present' },
} as never);
useAuthStore.getState().setSubsonicServerIdentity(SID, { ...id062 });
expect(useAuthStore.getState().audiomusePluginProbeByServer[SID]).toBe('present');
});
});