refactor(network): decouple network-reachability layer from features → lib/network

The connection-reachability + Subsonic network-guard helpers were pinned low by
four lib/api consumers (subsonicLibrary/Playlists/Ratings/Scrobble) yet ran two
lower-layer→feature inversions. Both removed without a registry:

- devOfflineBrowseStore is a self-contained DEV-only toggle with zero offline-
  feature coupling — it was only colocated there. Relocated features/offline/store
  → store/ (global). The @/features/offline barrel re-exports it so feature/UI
  consumers are unchanged; the three lower-layer readers (subsonicNetworkGuard,
  activeServerReachability, useConnectionStatus) now import it from @/store directly.

- subsonicNetworkGuard's only other feature dep was playback's resolvePlaybackUrl,
  used solely for the psysonic-local:// skip check. Added hasLocalPlaybackUrl to the
  existing M4 substrate store/localPlaybackResolve — it mirrors resolvePlaybackUrl's
  local-source branch exactly (same profile resolution; the empty-serverId playback
  fallback never applies in the guard), so the skip stays bit-identical.

network/ (subsonicNetworkGuard + activeServerReachability + tests) → lib/network,
now @/features-free. useConnectionStatus is now iron-rule-clean and stays in hooks/
(cross-cutting). Test mocks retargeted to the new seam modules.

Behavior-adjacent (covered by suite; default paths identical): the local-bytes skip
helper — flag for offline-playback runtime QA alongside the M4 media-resolver seam.
This commit is contained in:
Psychotoxical
2026-06-30 21:23:44 +02:00
parent d4ab56f5a6
commit c37d5f7389
40 changed files with 81 additions and 68 deletions
@@ -37,7 +37,7 @@ vi.mock('@/lib/api/subsonicPlayQueue', () => ({
savePlayQueue: vi.fn(async () => undefined),
getPlayQueue: vi.fn(async () => ({ songs: [], current: undefined, position: 0 })),
}));
vi.mock('@/utils/network/activeServerReachability', () => ({
vi.mock('@/lib/network/activeServerReachability', () => ({
isActiveServerReachable: () => true,
}));
@@ -30,7 +30,7 @@ vi.mock('@/lib/api/subsonicPlayQueue', () => ({
savePlayQueue: vi.fn(async () => undefined),
getPlayQueue: vi.fn(async () => ({ songs: [], current: undefined, position: 0 })),
}));
vi.mock('@/utils/network/activeServerReachability', () => ({
vi.mock('@/lib/network/activeServerReachability', () => ({
isActiveServerReachable: () => true,
}));
vi.mock('@/lib/api/subsonicStreamUrl', () => ({
@@ -13,7 +13,7 @@ const { savePlayQueueMock, playerState, progressSnapshot, isSubsonicServerReacha
}));
vi.mock('@/lib/api/subsonicPlayQueue', () => ({ savePlayQueue: savePlayQueueMock }));
vi.mock('@/utils/network/subsonicNetworkGuard', () => ({
vi.mock('@/lib/network/subsonicNetworkGuard', () => ({
isSubsonicServerReachable: (serverId: string) => isSubsonicServerReachableMock(serverId),
}));
vi.mock('@/features/playback/utils/playback/playbackServer', () => ({
+1 -1
View File
@@ -1,6 +1,6 @@
import { savePlayQueue } from '@/lib/api/subsonicPlayQueue';
import type { QueueItemRef, Track } from '@/lib/media/trackTypes';
import { isSubsonicServerReachable } from '@/utils/network/subsonicNetworkGuard';
import { isSubsonicServerReachable } from '@/lib/network/subsonicNetworkGuard';
import {
filterQueueRefsForPlaybackServer,
getPlaybackServerId,