diff --git a/.changeset/clarify-settings-preparation-messages.md b/.changeset/clarify-settings-preparation-messages.md new file mode 100644 index 0000000..c4a6e27 --- /dev/null +++ b/.changeset/clarify-settings-preparation-messages.md @@ -0,0 +1,5 @@ +--- +'@hledger-reports/web': patch +--- + +Keep the saved-report warning distinct from queue status and retry availability in Settings. Messages and preparation behavior are unchanged. diff --git a/apps/web/src/routes/(protected)/settings/+page.svelte b/apps/web/src/routes/(protected)/settings/+page.svelte index 764f938..a47362c 100644 --- a/apps/web/src/routes/(protected)/settings/+page.svelte +++ b/apps/web/src/routes/(protected)/settings/+page.svelte @@ -4,11 +4,10 @@ import type { PageProps } from './$types'; let { data, form }: Pick = $props(); - const canPrepare = $derived( - data.preparation !== 'unavailable' && - data.preparation !== 'pending' && - data.preparation !== 'running' - ); + const queueStatus = $derived(data.preparation); + const savedUpdateFailed = $derived(data.failedUpdate !== null); + const preparationInProgress = $derived(queueStatus === 'pending' || queueStatus === 'running'); + const canPrepare = $derived(queueStatus !== 'unavailable' && !preparationInProgress); @@ -31,30 +30,32 @@ {/if}

Report preparation

- {#if data.preparation === 'pending'} + {#if queueStatus === 'pending'}

Report preparation is queued. Waiting for the worker.

- {:else if data.preparation === 'running'} + {:else if queueStatus === 'running'}

Preparing reports.

- {:else if data.preparation === 'canceled'} + {:else if queueStatus === 'canceled'}

The queue marked this request canceled.

- {:else if data.preparation === 'failed' && !data.failedUpdate} -

- The preparation job did not complete. Check the journal and worker, then try again. -

- {:else if data.preparation === 'status-unreadable'} + {:else if queueStatus === 'status-unreadable'}

Preparation status couldn't be read. Reload status or try Prepare reports again.

- {:else if data.preparation === 'unavailable'} + {:else if queueStatus === 'unavailable'}

The job queue is unavailable, so reports cannot be prepared. Reload status to check again. If the problem persists, ask the server operator to check the queue and restart the web service.

- {:else if !data.failedUpdate} -

No preparation is currently running.

+ {:else if !savedUpdateFailed} + {#if queueStatus === 'failed'} +

+ The preparation job did not complete. Check the journal and worker, then try again. +

+ {:else if queueStatus === 'idle'} +

No preparation is currently running.

+ {/if} {/if} - {#if data.failedUpdate} + {#if savedUpdateFailed}

The last failed update didn’t replace the saved report. {#if canPrepare}Choose Prepare reports to try again.{/if} diff --git a/apps/web/src/routes/(protected)/settings/page.test.ts b/apps/web/src/routes/(protected)/settings/page.test.ts index 239b99b..1d4c072 100644 --- a/apps/web/src/routes/(protected)/settings/page.test.ts +++ b/apps/web/src/routes/(protected)/settings/page.test.ts @@ -1,6 +1,7 @@ import { render } from 'svelte/server'; import { expect, it, vi } from 'vitest'; import Settings from './+page.svelte'; +import type { PageProps } from './$types'; vi.mock('$app/paths', () => ({ resolve: (route: string) => route.replace('/(protected)', '') @@ -87,21 +88,64 @@ it.each([ expect(text).toContain('Last recorded strict check Could not validate'); }); -it('explains the queue outage and disables Prepare reports', () => { - const { body } = render(Settings, { +function renderPreparation( + preparation: PageProps['data']['preparation'], + failedUpdate: PageProps['data']['failedUpdate'] = null +) { + return render(Settings, { props: { data: { ...layoutData, - accountSidebar: null, - reportStatus: 'missing', - preparation: 'unavailable', + reportStatus: 'ready', + preparation, + failedUpdate, journalSummary: null, validation: null, validationReadFailed: false }, form: null } - }); - expect(body).toContain('The job queue is unavailable, so reports cannot be prepared.'); + }).body; +} + +const failedUpdate = { asOf: '2026-04-16' }; +const savedReportWarning = 'didn’t replace the saved report'; + +it('keeps browsing and the saved-report warning available while a retry is queued', () => { + const body = renderPreparation('pending', failedUpdate); + expect(body).toContain('Report preparation is queued.'); + expect(body).toContain('Browse reports'); + expect(body).toContain(savedReportWarning); + expect(body).not.toContain('Choose Prepare reports to try again.'); expect(body).toMatch(/