Avoid ?q fallback on external hifi-api search

Agent-Logs-Url: https://github.com/monochrome-music/monochrome/sessions/b34dfb4a-cfae-459a-ac01-4c675551575b

Co-authored-by: binimum <61615730+binimum@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-16 19:22:30 +00:00 committed by GitHub
parent 66d132dbbc
commit 9bd76fd2dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,6 +79,9 @@ export class LosslessAPI {
return await HiFiClient.instance.query(relativePath);
} catch (err) {
if (options.directOnly) {
throw err;
}
console.warn(
`Direct fetch failed for ${relativePath}. Falling back to configured API instances...`,
err
@ -446,7 +449,10 @@ export class LosslessAPI {
try {
// Keep direct TIDAL combined search behavior for normal mode.
// If direct query fails, fall back to hifi-api-compatible scoped searches (?s, ?a, ?al, ?v, ?p).
const response = await HiFiClient.instance.query(`/search/?q=${encodeURIComponent(query)}`, options.signal);
const response = await this.fetchWithRetry(`/search/?q=${encodeURIComponent(query)}`, {
...options,
directOnly: true,
});
const data = await response.json();
// Check if backend returned an error or if this looks like individual fallback