diff --git a/src/entrypoints/manager/App.svelte b/src/entrypoints/manager/App.svelte index a03baf3..ed69973 100644 --- a/src/entrypoints/manager/App.svelte +++ b/src/entrypoints/manager/App.svelte @@ -58,11 +58,17 @@ }; }); - /** Shared by the header controls so a silent failure there is impossible. */ + /** + * Shared by the header controls so a silent failure there is impossible. + * + * The toast carries the LOCALIZED sentence, never the raw browser error — + * `detail` is essentially always present for a storage rejection, so putting + * it first made every translation of settings.saveFailed unreachable. The + * header has no room for a detail block; #settings shows one. + */ function save(patch: Parameters[0]): void { void updateSettings(patch).then((outcome) => { - if (outcome.ok) pushToast(t('settings.saved'), 'success'); - else pushToast(outcome.detail ?? t('settings.saveFailed'), 'danger'); + pushToast(t(outcome.ok ? 'settings.saved' : 'settings.saveFailed'), outcome.ok ? 'success' : 'danger'); }); } diff --git a/src/lib/components/LegalGate.svelte b/src/lib/components/LegalGate.svelte index 25eb565..67bacfa 100644 --- a/src/lib/components/LegalGate.svelte +++ b/src/lib/components/LegalGate.svelte @@ -18,7 +18,8 @@ let checked = $state(false); let saving = $state(false); - let saveError = $state(); + let saveFailed = $state(false); + let saveDetail = $state(); let closeFailed = $state(false); let heading: HTMLHeadingElement | undefined = $state(); let closeTimer: ReturnType | undefined; @@ -35,13 +36,22 @@ function accept(): void { if (!checked || saving) return; saving = true; - saveError = undefined; + saveFailed = false; + saveDetail = undefined; // Timestamp taken at click time and passed down, so the store stays free of // ambient time. Nothing is dismissed until the write resolves. void acceptLegal(new Date().toISOString()).then((outcome) => { saving = false; - if (outcome.ok) onaccepted(); - else saveError = outcome.detail ?? t('legal.saveFailed'); + if (outcome.ok) { + onaccepted(); + return; + } + // The localized recovery sentence is the message; the raw browser error + // is the separate technical detail (docs/02 §7). Showing `detail` in its + // place made legal.saveFailed dead in all three locales — at the one + // moment a first-run user most needs an actionable instruction. + saveFailed = true; + saveDetail = outcome.detail; }); } @@ -95,8 +105,11 @@ {t('legal.accept')} - {#if saveError !== undefined} - {saveError} + {#if saveFailed} + {t('legal.saveFailed')} + {#if saveDetail !== undefined} +
{saveDetail}
+ {/if} {/if}
@@ -169,6 +182,18 @@ font-size: var(--fs-1); } + .detail { + margin: 0; + padding: var(--sp-2); + border: 1px solid var(--border); + border-radius: var(--radius-sm); + background: var(--bg); + color: var(--fg-muted); + font-size: var(--fs-0); + white-space: pre-wrap; + overflow-x: auto; + } + .actions { display: flex; gap: var(--sp-2); diff --git a/src/lib/components/SettingsTab.svelte b/src/lib/components/SettingsTab.svelte index 45c5f55..5eaec9e 100644 --- a/src/lib/components/SettingsTab.svelte +++ b/src/lib/components/SettingsTab.svelte @@ -19,6 +19,8 @@ const settings = $derived(getSettings()); let confirmingReset = $state(false); + /** Raw browser error behind the last failed save, if any. */ + let saveDetail = $state(); /** * Every write reports what actually happened. The toast used to be the only @@ -27,8 +29,17 @@ */ function save(patch: Partial, successKey = 'settings.saved'): void { void updateSettings(patch).then((outcome) => { - if (outcome.ok) pushToast(t(successKey), 'success'); - else pushToast(outcome.detail ?? t('settings.saveFailed'), 'danger'); + if (outcome.ok) { + pushToast(t(successKey), 'success'); + saveDetail = undefined; + return; + } + // The LOCALIZED sentence is the message; the raw browser error is the + // separate technical detail docs/02 §7 asks for. Putting `detail` first + // made every translation of settings.saveFailed dead code and showed a + // VI/JA user an untranslated Chrome string. + pushToast(t('settings.saveFailed'), 'danger'); + saveDetail = outcome.detail; }); } @@ -48,8 +59,13 @@ function confirmReset(): void { confirmingReset = false; void resetSettings().then((outcome) => { - if (outcome.ok) pushToast(t('settings.resetDone'), 'success'); - else pushToast(outcome.detail ?? t('settings.saveFailed'), 'danger'); + if (outcome.ok) { + pushToast(t('settings.resetDone'), 'success'); + saveDetail = undefined; + return; + } + pushToast(t('settings.saveFailed'), 'danger'); + saveDetail = outcome.detail; }); } @@ -139,6 +155,10 @@ {/snippet} + {#if saveDetail !== undefined} +
{saveDetail}
+ {/if} + @@ -178,6 +198,18 @@ border-color: var(--accent); } + .detail { + margin: var(--sp-3) 0 0; + padding: var(--sp-2); + border: 1px solid var(--border); + border-radius: var(--radius-sm); + background: var(--bg-raised); + color: var(--fg-muted); + font-size: var(--fs-0); + white-space: pre-wrap; + overflow-x: auto; + } + footer { padding-top: var(--sp-4); }