Repository navigation
feat(web): one save model for settings (#4074, #3991) - #4248
Merged
Merged
Conversation
… fields (#4074) Text fields save on blur or Enter when the value changed and validates, with the useAutoSave toast and a revert on failure. Escape undoes. Dirty, saving, saved and error are shown under the field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
#4074) Drop folders, import source folders, the three naming templates and reject words lose their Save buttons and use CommitInput, CommitTextarea or the naming template field. The preferred language select saves on change. Token chips keep focus in the template so picking one is not a commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
…or Enter (#4074) The Google Books key and Hardcover token never send an empty value and empty their box after a save, since the saved secret is write only. Log retention is validated to 1 to 365 before it is sent. The status line only joins the accessible description while it has something to say. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
…blur or Enter (#4074) Six per field Save buttons go. The server's reason for a rejected value stays under the field and the saved value comes back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
…ums on change (#4074) Text, number and secret rows commit on blur or Enter against the stored value. Toggles and enums save at once with the toast. The shared SaveButton has no caller left and is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
…ield (#4074) User guide section rewritten for commit on blur or Enter, changelog fragment, and a Settings deep link or search result now focuses the field control before any button in the anchor, with a test through the real naming tab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…e old input class (#4074) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
… secret, flush on unmount and announce state (#4074) Blur or Enter during a save runs after it. A failed secret keeps its text and stays unsaved. A valid plain edit is flushed when the field unmounts, never a secret. Unsaved and invalid are announced in a polite status region. A late loaded value is the saved one from its first render. nb and sv get distinct real translations, and the orphaned saveKey and hardcoverSaveToken keys go. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
…er Test and Clear wait for the token save (#4074) Tests fail without the Hardcover and retention validation. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
…r Clear waiting and the RanobeDB failure path (#4074) The kept state now covers any failed save where the revert was skipped, not only secrets. Clear is proven to wait for a pending token save. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
| const dropEdit = useCallback((key: string) => { | ||
| setEdits(e => { | ||
| const next = { ...e } | ||
| delete next[key] |
| const saveSetting = async (key: string, onSaved?: (res: SettingSaveResult | undefined) => void, value?: string): Promise<string | null> => { | ||
| try { | ||
| const res = await api.setSetting(key, settings[key] ?? '') | ||
| const res = await api.setSetting(key, value ?? settings[key] ?? '') |
| useTranslation: () => ({ | ||
| t: (key: string, fallback?: unknown, opts?: Record<string, string>) => { | ||
| if (typeof fallback !== 'string') return key | ||
| return fallback.replace(/\{\{(\w+)\}\}/g, (_, k) => opts?.[k] ?? '') |
vavallee
marked this pull request as ready for review
December 2, 2026 03:18
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.
Closes #4074
Closes #3991
Part of #3995.
Maintainer decision to confirm
This PR picks the save model. It is a deliberate choice for the maintainer to confirm or overrule:
Why not debounced autosave for text: a half typed root folder, naming template, API key or URL must not be persisted mid typing. A debounce would still save "/data/li" on a pause.
What changed
One shared hook and component, then the tabs migrated onto it:
useCommitField(new) holds the model: commit on blur or Enter (Ctrl or Cmd + Enter in a textarea), skip when unchanged or invalid, claim the value up front so Enter then blur saves once, Esc undo, revert on failure, status for a dirty, saving, saved or error line. It calls the existinguseAutoSave, so the toast text, live region and revert bookkeeping from feat(web): toast on every Settings save that happens on change (#3991) #4070 are reused. The toast names the setting and never the value.CommitInputandCommitTextarea(new,CommitField.tsx) wrap it with the status line under the field. The status joinsaria-describedbyonly while it has something to say, so the existing "Current:" descriptions are unchanged when idle.NamingTemplateFielduses the hook directly. Token chips now keep focus in the input on mouse down, so picking a token is not a blur and does not commit a half built template.SaveButtonis removed, it has no caller left.useSaveResultstays, the hook uses it.SettingsPage.tsx).Secrets (Google Books key, Hardcover token, Calibre plugin key, Advanced secret rows): commit on blur or Enter, an empty or whitespace value is never sent, the box empties after a save (the value is write only), masking and autofill opt outs unchanged, value never in a toast or log.
Inventory of per field Save buttons
Deliberately left as explicit Save forms, because their fields are only valid together or live in a modal:
Review round 2 (added after the independent review)
validate (frontend)fixed:mobilePolish.test.tsnow checks the Commit field wrapper classes. The wholeweb/srcvitest set (3121 tests) andtscand eslint pass locally.CommitInput. RanobeDB toggle now toasts and reverts.saveKeyandhardcoverSaveTokenkeys removed from all locales.The model itself (commit on blur or Enter for text, instant for discrete controls) is still a maintainer decision to confirm.
Review order
useCommitField.ts,CommitField.tsxanduseCommitField.test.tsx. This is the whole model, review it first.GeneralTab.tsx,NamingTemplateField.tsx) and their tests.SaveButtonremoval.SettingsPage.tsxfocus tweak, the deep link test, docs and the changelog fragment.Each step is its own commit and builds on its own.
Tests
useCommitField.test.tsx: no save while typing, commit on blur, commit on Enter, Enter then blur saves once, Esc reverts without a request, unchanged value not saved, invalid value not saved and flagged, failure toasts an alert and restores the value, dirty state shown, textarea Enter vs Ctrl+Enter, the toast never contains the value./settings?tab=naming#naming.bookTemplatelands the cursor in the template input, Esc undoes, Enter saves once (SettingsPage.test.tsx).GeneralTab,NamingTemplateFieldandSettingsPagechecked out from main, the new tests fail. The deep link test also failed on its own against the unchanged focus logic (focus landed on a token chip).src/pages/settings,src/pages/SettingsPage*andsrc/i18n(854 tests),tsc --noEmit,eslinton the touched folders. CI runs the rest.i18n
Three new strings under
settings.commitin en, nb and sv (real translations, no filler). fr has nosettings.toast, so it is left to fall back.Docs
docs/User-Guide-Wiki.md"How Settings save" is rewritten, and the "Current:" paragraph no longer says fields with a Save button are left out. README does not mention Save buttons. Fragment:changelog.d/4074-unified-settings-save.md.🤖 Generated with Claude Code