Skip to content

fix(settings): keep a coverage edit typed during its pending service PUT - #638

Merged
cristim merged 2 commits into
mainfrom
fix/settings-coverage-edit-during-put-576
Oct 6, 2026
Merged

cristim merged 2 commits into
mainfrom
fix/settings-coverage-edit-during-put-576

Conversation

@cristim

@cristim cristim commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Closes #576. Stacked on PR #635 (same function and test block); base is its branch and retargets to main when #635 merges.

Present on main (3413591): saveGlobalSettings service .then ran el.value = String(coverage) unconditionally, so a value typed while that PUT was pending was replaced by the sent value (frontend/src/settings.ts, the coverageId block after updateServiceConfig). The final TRACKED_FIELDS advance loop had no test.

Fix: write the persisted value to the card only when the card still equals what this Save read (sentFields[coverageId]); the snapshot always records the persisted value. An edit typed during the PUT therefore stays dirty and is sent by the next Save. Untouched cards still show the propagated default (the existing propagation tests cover it). Edits to payment, term and enabled were already preserved.

Tests (settings.test.ts, coverage block): (1) 77 typed during the pending PUT survives, isUnsavedChanges stays true, the next Save sends 77, then clean. On main step 1 fails: card.value is reset to 60. (2) edit aws-ec2-payment, Save, isUnsavedChanges() is false; pins the advance loop (passes on main by design; it kills the removal mutant from the review). Jest cannot run offline here; verified by tracing the code, CI is the authority.

Not changed: the theoretical revert-during-PUT case from the issue, #539, #617.

Summary by CodeRabbit

  • Bug Fixes
    • Settings changes now remain marked as unsaved when a save fails, so they can be retried.
    • Changes made while a save is in progress stay visible and unsaved until they are saved.
    • If saving global settings fails, service settings are not submitted. Successful service payment saves clear the unsaved status.

@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/few Limited audience effort/s Hours type/bug Defect labels Oct 6, 2026
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 59f403a3-394c-47b4-a6ca-861cf5b6484f
📥 Commits

Reviewing files that changed from the base of the PR and between 3413591 and feac707.

📒 Files selected for processing (2)
  • frontend/src/__tests__/settings.test.ts
  • frontend/src/settings.ts

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

Service coverage saving now initializes from the loaded service value or global default. Successful saves preserve edits made while a request is pending and update the saved snapshot. Tests cover failed global and service requests, retries, in-flight edits, and payment save-state clearing.

Changes

Settings save-state tracking

Layer / File(s) Summary
Coverage save and dirty-state tracking
frontend/src/settings.ts, frontend/src/__tests__/settings.test.ts
Coverage initialization uses the loaded service value or global default. A successful save updates the saved snapshot without replacing a newer in-flight edit. Tests cover failed requests, retries, and dirty-state clearing after successful saves.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to feac7

No actionable merge-blocking issue is established for the settings save-state change; it is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preserving a coverage edit made while its service PUT is pending.
Linked Issues check ✅ Passed Issue #576 requires coverage edits made during a pending service PUT to remain dirty and be sent by the next Save, plus a test that pins the post-save snapshot advance loop. The coverage update now wr…
Out of Scope Changes check ✅ Passed The implementation changes and added tests concern service coverage persistence, save-state tracking, and the snapshot advance behavior required by issue #576. The additional failed-PUT tests exercise…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@cristim
cristim changed the base branch from test/settings-coverage-snapshot-mutants-551 to main October 6, 2026 20:05
@cristim cristim closed this Oct 6, 2026
@cristim cristim reopened this Oct 6, 2026
@cristim
cristim merged commit feec673 into main Oct 6, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/bug Defect urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(settings): a coverage edit typed during a pending service PUT is overwritten, and the post-save snapshot advance is untested

1 participant