Skip to content

fix(dashboard/hands): refetch hand settings after save so inputs persist (#6145)#6147

Merged
houko merged 2 commits into
mainfrom
fix-hand-settings-invalidate
Jun 17, 2026
Merged

fix(dashboard/hands): refetch hand settings after save so inputs persist (#6145)#6147
houko merged 2 commits into
mainfrom
fix-hand-settings-invalidate

Conversation

@houko

@houko houko commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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 local draft. On a successful save it clears the draft (setDraft({})), after which each input falls back to settings.current_values[key] — sourced from the useHandSettings query (key handKeys.settings(handId)).

But useUpdateHandSettings only invalidated handKeys.lists() and handKeys.detail(handId):

onSuccess: (_data, variables) => {
  qc.invalidateQueries({ queryKey: handKeys.lists() });
  qc.invalidateQueries({ queryKey: handKeys.detail(variables.handId) });
  // settings query never invalidated → current_values stays stale
},

The backend PUT /api/hands/{id}/settings persists 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-save current_values.

Fix

Invalidate the settings query in onSuccess so 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

  • Extended the existing useUpdateHandSettings test to assert the handKeys.settings(handId) invalidation. Confirmed it fails before the fix and passes after.
  • pnpm test --run — 785 passed (80 files)
  • pnpm typecheck — clean
  • pnpm lint — 0 errors (pre-existing baseline warnings only)
  • pnpm build — ok

Evan and others added 2 commits June 17, 2026 15:17
…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).
@github-actions github-actions Bot added size/S 10-49 lines changed no-rust-required This task does not require Rust knowledge labels Jun 17, 2026
@houko
houko enabled auto-merge (squash) June 17, 2026 08:46
@houko
houko merged commit 4051215 into main Jun 17, 2026
33 checks passed
@houko
houko deleted the fix-hand-settings-invalidate branch June 17, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-rust-required This task does not require Rust knowledge size/S 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hands 开发团队的设置输入项 保存无效果

2 participants