feat(spotify): report resolved backend + binaryAvailable on /status; share backend resolver [S4.2]

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
saopig1andClaude Opus 4.8 committed 2026-07-03 00:45:55 +08:00
1 parent b672d76634
commit 6a72833c2a
6 files changed
+79 -21

No files matched your search

+10 -14
View File
@@ -29,9 +29,11 @@ import {
type OAuthTokenStore,
} from "./spotify-oauth.js";
import { SpotifyConnectApi } from "./connect-api.js";
/** Which concrete backend the controller will run for this host + config. */
export type SpotifyBackendKind = "go-librespot" | "librespot";
import {
resolveSpotifyBackendKind,
type SpotifyBackendKind,
} from "./backend-select.js";
export type { SpotifyBackendKind }; // keep the name exported for existing importers
/**
* Minimal file-backed OAuth token store used when the caller does not inject a
@@ -156,17 +158,11 @@ export class SpotifyController extends EventEmitter {
* librespot present, else null.
*/
chooseBackend(): SpotifyBackendKind | null {
switch (this.config.backend) {
case "go-librespot":
return this.goPresent() ? "go-librespot" : null;
case "librespot":
return this.rustPresent() ? "librespot" : null;
case "auto":
default:
if (this.goPresent()) return "go-librespot";
if (this.rustPresent()) return "librespot";
return null;
}
return resolveSpotifyBackendKind(
this.config.backend,
this.goPresent(),
this.rustPresent(),
);
}
/** enabled in config AND a backend is selectable (platform + binary present). */