feat: data lifecycle rewrite, download clients, wanted list, and central catalog index
Build & publish Arch package / arch-package (push) Successful in 2m12s
Search index maintenance / maintain-index (push) Successful in 2h22m28s

Ships the fresh-start schema cleanup: rebuilt explore catalog index
pipeline (dump import, artifact fetch/build, incremental listen-count
refresh), a new download subsystem (Lidarr/Prowlarr/qBittorrent/SABnzbd/
slskd/yt-dlp providers, staging, reconciliation, wanted list), and the
supporting schema/query/store changes across backend and frontend.

Also includes two smaller follow-ups: bump the central index's
rebuild-after cadence from 90 to 180 days, and remove the Explore
"library only" online/offline toggle entirely (frontend-only, no
backend counterpart) rather than carry unused UI/state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y2Agd9af5hE7qzti2ackiS
This commit is contained in:
2026-08-06 17:12:01 -04:00
co-authored by Claude Sonnet 5
parent d0d86f85d5
commit e190fd75b9
165 changed files with 31088 additions and 5192 deletions
@@ -0,0 +1,278 @@
import { LitElement, html, css, nothing } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
import '@awesome.me/webawesome/dist/components/dialog/dialog.js';
import '@awesome.me/webawesome/dist/components/button/button.js';
import '@awesome.me/webawesome/dist/components/spinner/spinner.js';
import '@awesome.me/webawesome/dist/components/callout/callout.js';
import { designTokens } from '../../styles/tokens.css';
import type { DownloadCandidate } from '@store/download-store';
import { downloadStore } from '@store/download-store';
import type { download } from '@go/models';
import './candidate-row';
/**
* The "find this album" dialog: searches every enabled download client,
* ranks what comes back, and asks the user to choose.
*
* When the pipeline finds a clear winner it starts on its own and this
* dialog reports that rather than asking a question with one obvious
* answer. When it does not — two equally good candidates, or a free-text
* request with nothing to verify against — the choice is the user's,
* because guessing wrong puts the wrong files in their library.
*/
@customElement('download-picker')
export class DownloadPicker extends LitElement {
@property({ type: Boolean, reflect: true })
open = false;
/** Library the imported files belong to. */
@property({ type: Number, attribute: 'library-id' })
libraryId = 0;
@property({ type: String })
artist = '';
@property({ type: String })
album = '';
/** MusicBrainz release-group ID, when the caller has one. */
@property({ type: String, attribute: 'release-group-mbid' })
releaseGroupMbid = '';
@property({ type: String, attribute: 'release-mbid' })
releaseMbid = '';
/**
* Expected tracklist. Supplying it is what makes the result
* trustworthy: without it there is nothing to check a candidate
* against, and the pipeline will never auto-pick.
*/
@property({ type: Array })
expected: download.ExpectedTrack[] = [];
@state()
private searching = false;
@state()
private candidates: DownloadCandidate[] = [];
@state()
private requestId = '';
@state()
private autoPicked = false;
@state()
private picking = false;
@state()
private errorMessage = '';
static override styles = [
designTokens,
css`
:host {
display: contents;
}
.heading {
display: flex;
flex-direction: column;
gap: 0.15em;
margin-bottom: 1em;
}
.album {
font-size: 1.05em;
font-weight: 600;
}
.artist {
opacity: 0.75;
font-size: 0.9em;
}
.status {
display: flex;
align-items: center;
gap: 0.6em;
padding: 1.5em 0;
justify-content: center;
opacity: 0.85;
}
.list {
display: flex;
flex-direction: column;
gap: 0.6em;
max-height: 55vh;
overflow-y: auto;
}
.footnote {
margin-top: 1em;
font-size: 0.8em;
opacity: 0.65;
}
`,
];
override updated(changed: Map<string, unknown>) {
if (changed.has('open') && this.open) {
void this.search();
}
}
/** Runs the search that populates the dialog. */
private async search(): Promise<void> {
this.searching = true;
this.errorMessage = '';
this.candidates = [];
this.autoPicked = false;
try {
const result = await downloadStore.start({
libraryId: this.libraryId,
releaseMbid: this.releaseMbid,
releaseGroupMbid: this.releaseGroupMbid,
artist: this.artist,
album: this.album,
query: '',
expected: this.expected ?? [],
} as download.SearchRequest);
this.requestId = result.requestId;
this.candidates = result.candidates ?? [];
this.autoPicked = result.autoPicked;
} catch (err) {
this.errorMessage = String(err);
} finally {
this.searching = false;
}
}
private async onPick(event: CustomEvent<{ candidateId: string }>) {
if (this.picking) return;
this.picking = true;
this.errorMessage = '';
try {
await downloadStore.pick(this.requestId, event.detail.candidateId);
this.close();
} catch (err) {
this.errorMessage = String(err);
} finally {
this.picking = false;
}
}
private close() {
this.open = false;
this.dispatchEvent(
new CustomEvent('picker-close', { bubbles: true, composed: true }),
);
}
override render() {
return html`
<wa-dialog
label="Find this album"
?open=${this.open}
@wa-hide=${() => this.close()}
>
<div class="heading">
<span class="album">${this.album || 'Unknown album'}</span>
<span class="artist">${this.artist}</span>
</div>
${this.renderBody()}
<wa-button slot="footer" variant="neutral" @click=${() => this.close()}>
Close
</wa-button>
</wa-dialog>
`;
}
private renderBody() {
if (this.errorMessage) {
return html`
<wa-callout variant="danger">${this.errorMessage}</wa-callout>
`;
}
if (this.searching) {
return html`
<div class="status">
<wa-spinner></wa-spinner>
<span>Searching your download clients…</span>
</div>
`;
}
if (this.autoPicked) {
return html`
<wa-callout variant="success">
Found a clear match and started downloading it. Progress is
in the background jobs panel.
</wa-callout>
`;
}
if (this.candidates.length === 0) {
return html`
<wa-callout variant="neutral">
Nothing found. Try a different spelling, or connect more
download clients in Settings.
</wa-callout>
`;
}
return html`
<div class="list">
${this.candidates.map(
(candidate, index) => html`
<candidate-row
.candidate=${candidate}
?is-best=${index === 0}
?busy=${this.picking}
@candidate-pick=${this.onPick}
></candidate-row>
`,
)}
</div>
${this.renderFootnote()}
`;
}
private renderFootnote() {
const best = this.candidates[0];
if (!best?.match) return nothing;
// Say plainly why nothing was auto-picked, so the dialog does
// not look like it is asking a question it could have answered.
if (!best.match.anchored) {
return html`
<div class="footnote">
This search had no MusicBrainz match to verify against, so
these results could not be checked automatically.
</div>
`;
}
return html`
<div class="footnote">
Downloads are checked and tagged before they are added to your
library.
</div>
`;
}
}
declare global {
interface HTMLElementTagNameMap {
'download-picker': DownloadPicker;
}
}