Repository navigation
feat(web): toast on every Settings save that happens on change (#3991) - #4070
Merged
Merged
Conversation
| 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 Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
force-pushed
the
feat/settings-save-toasts-3991
branch
from
November 20, 2026 04:42
9c22882 to
73ca256
Compare
| 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' |
…3991) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
revert), so it never shows a choice the server did not store.useAutoSave()wraps the request and publishes toSettingsToastHost, mounted once inSettingsPage. 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.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.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 pauseGeneralTab.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🤖 Generated with Claude Code