Skip to content

feat(web): toast on every Settings save that happens on change (#3991) - #4070

Merged
vavallee merged 7 commits into
mainfrom
feat/settings-save-toasts-3991
Nov 20, 2026
Merged

vavallee merged 7 commits into
mainfrom
feat/settings-save-toasts-3991

Conversation

@vavallee

@vavallee vavallee commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Settings that save on click or change were silent and logged failures to the console. Each now shows a toast, for example "Import Mode set to External" or "Telemetry saved", and a red "Couldn't save ..." toast when the request fails.
  • A failed save puts the control back on its previous value (revert), so it never shows a choice the server did not store.
  • One shared path: useAutoSave() wraps the request and publishes to SettingsToastHost, mounted once in SettingsPage. The field name comes from the same i18n label the Settings search indexes. A tab rendered without the host still saves, only the toast is absent.
  • The host is a stack, so a failure is never overwritten by a later success. Errors stay at least 8 seconds, successes 4. The timer pauses on hover and focus, each toast has a keyboard reachable Dismiss button, and the polite live region is always in the page so successes are announced.
  • Calibre mode and transport toasts use the localized option label. The Logs runtime level select gets the same toast and only moves after the save lands.
  • Tabs covered: General, Metadata, Calibre, Logs, API keys, Quality, Root folders.
  • Skipped on purpose: AdvancedTab. It edits a draft per field and saves with its own Save button (with inline Saved and error state), so it is not an on-change save.
  • Fields with their own Save button elsewhere keep their Saving, Saved, Error button. Unifying those into one save model is not done here and is tracked in Settings: unify the per field Save buttons into one save model #4074.
  • English strings only (settings.toast.*); other locales fall back.

Refs #3991
Refs #3995
Follow-up: #4074

Test plan

  • autoSave.test.tsx: live region present and announces, chosen value, revert on failure and not on success, no host, stacking, dismiss, 8 second error with hover pause
  • GeneralTab.autoSaveToast.test.tsx: Import Mode success and failure, a failed select save restores the old value, a failed Import Mode save restores the previous button
  • Settings, SettingsPage and i18n suites pass (736 tests), tsc clean, eslint has no errors
  • Browser check not done by the builder

🤖 Generated with Claude Code

useTranslation: () => ({
t: (key: string, fallback?: unknown, opts?: Record<string, string>) => {
if (typeof fallback !== 'string') return key
return fallback.replace(/\{\{(\w+)\}\}/g, (_, k) => opts?.[k] ?? '')
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Comment on lines +333 to +337
const label = {
off: t('settings.calibre.mode.off', 'Off'),
calibredb: t('settings.calibre.mode.calibredb', 'calibredb CLI'),
plugin: t('settings.calibre.mode.plugin', 'Calibre Bridge plugin'),
}[next]
useTranslation: () => ({
t: (key: string, fallback?: unknown, opts?: Record<string, string>) => {
if (typeof fallback !== 'string') return key
return fallback.replace(/\{\{(\w+)\}\}/g, (_, k) => opts?.[k] ?? '')
) {
set(s => {
const next = { ...s }
if (previous === undefined) delete next[key]
set(s => {
const next = { ...s }
if (previous === undefined) delete next[key]
else next[key] = previous
Import Mode, the interval selects, the toggles and the other settings that
save the moment they change did it silently and logged failures to the
console. Each now shows a toast naming the field ("Import Mode set to
External", "Telemetry saved") and a red "Couldn't save" toast on failure.
Fields with their own Save button keep their Saving, Saved, Error button.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Signed-off-by: vavallee <vavallee@protonmail.com>
A save that fails now puts the control back on its previous value instead of
leaving a choice the server never stored. The toast host is a stack with a
Dismiss button, keeps errors at least 8 seconds, pauses while hovered or
focused, and keeps its polite live region in the page so successes are
announced. Calibre toasts use the localized option label, and the Logs
runtime level select gets the same toast.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Signed-off-by: vavallee <vavallee@protonmail.com>
…lur (#3991)

Revert on a failed save now restores the last value known saved for that key,
and only when no newer change to the key was made, so a late failure cannot
write an older value over a newer one. The Latest book count saves on blur or
Enter instead of on every keystroke and reverts on failure. State writes after
an await are guarded against unmount. The toast drops the undefined
animate-fade-in class, and its text and fill classes are contrast tested.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Signed-off-by: vavallee <vavallee@protonmail.com>
@vavallee
vavallee force-pushed the feat/settings-save-toasts-3991 branch from 9c22882 to 73ca256 Compare November 20, 2026 04:42
useTranslation: () => ({
t: (key: string, fallback?: unknown, opts?: Record<string, string>) => {
if (typeof fallback !== 'string') return key
return fallback.replace(/\{\{(\w+)\}\}/g, (_, k) => opts?.[k] ?? '')
useTranslation: () => ({
t: (key: string, fallback?: unknown, opts?: Record<string, string>) => {
if (typeof fallback !== 'string') return key
return fallback.replace(/\{\{(\w+)\}\}/g, (_, k) => opts?.[k] ?? '')
const map: Record<string, string> = {}
list.forEach(s => { map[s.key] = s.value })
setSettings(map)
savedLatestCount.current = map[LATEST_COUNT_KEY]
await api.setSetting('author.default_monitor_latest_count', next).catch(console.error)
}
}}
value={settings[LATEST_COUNT_KEY] ?? '1'}
describe('Settings save toast', () => {
for (const kind of ['success', 'error'] as const) {
it(`${kind}: white on its fill is at least ${AA_NORMAL}:1`, () => {
const classes = TOAST_FILL[kind].split(/\s+/)
const classes = TOAST_FILL[kind].split(/\s+/)
const fill = classes.find(c => HUE_BG.test(c))
const text = classes.find(c => HUE_TEXT.test(c))
expect(fill, TOAST_FILL[kind]).toBeTruthy()

it('is reachable by the white-on-fill scanner (one string holds both classes)', () => {
for (const kind of ['success', 'error'] as const) {
expect(TOAST_FILL[kind]).toMatch(/\btext-white\b/)
it('is reachable by the white-on-fill scanner (one string holds both classes)', () => {
for (const kind of ['success', 'error'] as const) {
expect(TOAST_FILL[kind]).toMatch(/\btext-white\b/)
expect(TOAST_FILL[kind]).toMatch(/\bbg-(?:emerald|red)-\d+\b/)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Signed-off-by: vavallee <vavallee@protonmail.com>
…3991)

Enter then blur while a save is pending no longer sends a second request,
a failure only restores the field when it still holds the value that failed,
and Escape restores the last saved value.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Signed-off-by: vavallee <vavallee@protonmail.com>
// the request is pending does not send it twice.
const savedLatestCount = useRef<string | undefined>(undefined)
const inFlightLatestCount = useRef<string | null>(null)
const latestCountText = settings[LATEST_COUNT_KEY] ?? '1'
vavallee and others added 2 commits November 20, 2026 01:30
…3991)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Signed-off-by: vavallee <vavallee@protonmail.com>
@vavallee
vavallee merged commit 71cd109 into main Nov 20, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants