feat: new-music notices come from the scanner; request notices and the original specs go
release / web (push) Failing after 1m29s
release / go (push) Successful in 1m55s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 4m22s
release / android (push) Successful in 4m57s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 4m23s

Request notifications (approved, declined, completed, pending) are removed
along with the request flow that produced them. A new_music kind takes the
"new music arrived" slot: when a scan or a watcher batch finishes, the
scanner claims every album not yet announced (albums.announced_at) and tells
every user about the ones that are new: an album with a track on disk and
no track older than itself. The first import into an empty library, and an
album formed only by retagging tracks already held, announce nothing. One
notice per scan, carrying up to 50 albums and the total; it is never
coalesced, so a notice already emailed can't quietly absorb later arrivals.
It feeds the daily summary email, grouped by artist. Defaults: inbox and
email on, phone off.

Migration 0103 deletes request-kind notification rows and prefs, swaps the
kind CHECKs to new_music, and adds albums.announced_at with every album
held marked announced, so the first scan after it announces nothing old.

Web and Android: labels, the Android "Requests" settings section becomes
"New music", the shade channel your_requests becomes new_music (the old one
is deleted at startup), and "/" opens Home in the app. TrackLabel moves to
the notifications package. docs/smart-music-{server,client}-spec.md are
deleted per the operator; an Android comment loses the word "exchanges".

Grimoire #7666, #7671.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 23:29:13 -05:00
co-authored by Claude Opus 5.5
parent 9d267ba8dd
commit 561c1d5eae
42 changed files with 647 additions and 859 deletions
+1 -4
View File
@@ -125,10 +125,7 @@ export function createNotificationSettingsQuery() {
/** Short row labels, menu-style. Unknown kinds show their key. */
export const NOTIFICATION_KIND_LABELS: Record<string, string> = {
request_approved: 'Request approved',
request_rejected: 'Request declined',
request_completed: 'New music arrived',
request_pending: 'Requests to review',
new_music: 'New music arrived',
quarantine_flagged: 'Tracks flagged',
scan_failed: 'Library scan failed',
tracks_missing: 'Tracks gone missing',
@@ -37,9 +37,9 @@ import {
function item(over: Partial<NotificationItem> = {}): NotificationItem {
return {
id: 'n1',
kind: 'request_completed',
title: 'Arrived: Boards of Canada – Geogaddi',
body: 'Your request is in the library.',
kind: 'new_music',
title: 'New album',
body: 'Boards of Canada – Geogaddi is in the library.',
link: '/albums/al-1',
created_at: new Date().toISOString(),
read_at: null,
@@ -95,7 +95,7 @@ describe('NotificationBell', () => {
test('lists each kind with the server-rendered title and body, unread marked', async () => {
setInbox([
item({ id: 'a', kind: 'request_approved', title: 'Request approved', body: 'Geogaddi is on its way.' }),
item({ id: 'a', kind: 'new_music', title: 'New album', body: 'Geogaddi is in the library.' }),
item({
id: 'b',
kind: 'tracks_missing',
@@ -110,7 +110,7 @@ describe('NotificationBell', () => {
const rows = screen.getAllByTestId('notification-item');
expect(rows).toHaveLength(2);
expect(rows[0]).toHaveTextContent('Request approved');
expect(rows[0]).toHaveTextContent('New album');
expect(rows[0]).toHaveTextContent('Geogaddi is on its way.');
expect(rows[0]).toHaveAttribute('data-unread', 'true');
expect(rows[1]).toHaveTextContent('4 tracks went missing');
@@ -33,16 +33,15 @@ import {
type NotificationSettings as Settings
} from '#lib/api/notifications.js';
const requesterKinds: NotificationKindSetting[] = [
{ kind: 'request_approved', admin_only: false, inbox: true, phone: true, email: true },
{ kind: 'request_completed', admin_only: false, inbox: true, phone: true, email: true }
const listenerKinds: NotificationKindSetting[] = [
{ kind: 'new_music', admin_only: false, inbox: true, phone: false, email: true }
];
const adminKinds: NotificationKindSetting[] = [
{ kind: 'tracks_missing', admin_only: true, inbox: true, phone: true, email: false }
];
function setSettings(s: Partial<Settings>) {
const data: Settings = { kinds: requesterKinds, email_available: true, ...s };
const data: Settings = { kinds: listenerKinds, email_available: true, ...s };
(createNotificationSettingsQuery as ReturnType<typeof vi.fn>).mockReturnValue(mockQuery({ data }));
return data;
}
@@ -56,14 +55,14 @@ describe('NotificationSettings', () => {
test('a listener sees their kinds with a toggle per channel and no admin heading', () => {
setSettings({});
render(NotificationSettings);
expect(screen.getByRole('checkbox', { name: 'Request approved: Inbox' })).toBeChecked();
expect(screen.getByRole('checkbox', { name: 'New music arrived: Inbox' })).toBeChecked();
expect(screen.getByRole('checkbox', { name: 'New music arrived: Email' })).toBeChecked();
expect(screen.queryByText('Library health')).toBeNull();
});
test('an admin also sees library health under its own heading', () => {
userState.current = { id: '1', username: 'root', is_admin: true };
setSettings({ kinds: [...requesterKinds, ...adminKinds] });
setSettings({ kinds: [...listenerKinds, ...adminKinds] });
render(NotificationSettings);
expect(screen.getByText('Library health')).toBeInTheDocument();
expect(screen.getByRole('checkbox', { name: 'Tracks gone missing: Email' })).not.toBeChecked();
@@ -76,9 +75,9 @@ describe('NotificationSettings', () => {
await fireEvent.click(screen.getByRole('checkbox', { name: 'New music arrived: Email' }));
expect(putNotificationSettings).toHaveBeenCalledWith([{ kind: 'request_completed', email: false }]);
expect(putNotificationSettings).toHaveBeenCalledWith([{ kind: 'new_music', email: false }]);
const optimistic = setQueryData.mock.calls[0][1] as Settings;
expect(optimistic.kinds.find((k) => k.kind === 'request_completed')?.email).toBe(false);
expect(optimistic.kinds.find((k) => k.kind === 'new_music')?.email).toBe(false);
});
test('a failed save puts the switch back and says so', async () => {
@@ -86,7 +85,7 @@ describe('NotificationSettings', () => {
(putNotificationSettings as ReturnType<typeof vi.fn>).mockRejectedValue(new Error('offline'));
render(NotificationSettings);
await fireEvent.click(screen.getByRole('checkbox', { name: 'Request approved: Phone' }));
await fireEvent.click(screen.getByRole('checkbox', { name: 'New music arrived: Phone' }));
await waitFor(() => expect(pushToast).toHaveBeenCalled());
expect(setQueryData).toHaveBeenLastCalledWith(['notificationSettings'], data);
@@ -94,18 +93,18 @@ describe('NotificationSettings', () => {
test('inbox off disables phone and email for that kind', () => {
setSettings({
kinds: [{ kind: 'request_approved', admin_only: false, inbox: false, phone: true, email: true }]
kinds: [{ kind: 'new_music', admin_only: false, inbox: false, phone: true, email: true }]
});
render(NotificationSettings);
expect(screen.getByRole('checkbox', { name: 'Request approved: Phone' })).toBeDisabled();
expect(screen.getByRole('checkbox', { name: 'Request approved: Email' })).toBeDisabled();
expect(screen.getByRole('checkbox', { name: 'Request approved: Inbox' })).toBeEnabled();
expect(screen.getByRole('checkbox', { name: 'New music arrived: Phone' })).toBeDisabled();
expect(screen.getByRole('checkbox', { name: 'New music arrived: Email' })).toBeDisabled();
expect(screen.getByRole('checkbox', { name: 'New music arrived: Inbox' })).toBeEnabled();
});
test('no email address: the email column is off and points at the profile', () => {
setSettings({ email_available: false, email_unavailable_reason: 'no_address' });
render(NotificationSettings);
expect(screen.getByRole('checkbox', { name: 'Request approved: Email' })).toBeDisabled();
expect(screen.getByRole('checkbox', { name: 'New music arrived: Email' })).toBeDisabled();
expect(screen.getByRole('link', { name: 'add an email address in your profile' })).toHaveAttribute(
'href',
'/settings/account#profile'