fix(dashboard/hands): refetch hand settings after save so inputs persist (#6145)#6147
Merged
Conversation
…ist (#6145) On the Hands "开发团队" (dev team) settings editor, typing into the input fields and clicking Save left the UI showing the old/empty values instead of what was just saved. The editor (`HandSettingsEditor`) holds edits in a local `draft` and, on save success, clears that draft so the inputs fall back to `settings.current_values` from the `useHandSettings` query (key `handKeys.settings(handId)`). But `useUpdateHandSettings` only invalidated `handKeys.lists()` and `handKeys.detail(handId)` — never the settings query. So the cached `current_values` stayed stale, and once the draft was cleared the fields reverted to the pre-save state even though the backend had persisted the change. Invalidate `handKeys.settings(variables.handId)` in the mutation's `onSuccess` so the editor refetches and shows the saved values. Verification: - Extended the existing useUpdateHandSettings test to assert the settings-key invalidation. Confirmed it fails before the fix and passes after. - pnpm test --run (785 passed), pnpm typecheck (clean), pnpm lint (0 errors), pnpm build (ok).
houko
enabled auto-merge (squash)
June 17, 2026 08:46
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
Fixes #6145. On the Hands "开发团队" (dev team) settings editor, typing values into the input fields and clicking Save left the UI showing the old/empty values instead of what was just saved — the data appeared not to persist.
Root cause
HandSettingsEditor(crates/librefang-api/dashboard/src/pages/HandsPage.tsx) keeps edits in a localdraft. On a successful save it clears the draft (setDraft({})), after which each input falls back tosettings.current_values[key]— sourced from theuseHandSettingsquery (keyhandKeys.settings(handId)).But
useUpdateHandSettingsonly invalidatedhandKeys.lists()andhandKeys.detail(handId):The backend
PUT /api/hands/{id}/settingspersists the config (the editor only allows saving while the hand is active, so there is always a live instance to write to), but the cached settings query was never refetched. So once the local draft was cleared, the inputs reverted to the pre-savecurrent_values.Fix
Invalidate the settings query in
onSuccessso the editor refetches and displays the saved values:onSuccess: (_data, variables) => { qc.invalidateQueries({ queryKey: handKeys.lists() }); qc.invalidateQueries({ queryKey: handKeys.detail(variables.handId) }); + qc.invalidateQueries({ queryKey: handKeys.settings(variables.handId) }); },Verification
useUpdateHandSettingstest to assert thehandKeys.settings(handId)invalidation. Confirmed it fails before the fix and passes after.pnpm test --run— 785 passed (80 files)pnpm typecheck— cleanpnpm lint— 0 errors (pre-existing baseline warnings only)pnpm build— ok