Skip to content

fix(settings): keep general preferences unchanged when saving fails - #1068

Merged
dovvnloading merged 1 commit into
mainfrom
fix/general-settings-persistence-1053
Nov 25, 2026
Merged

dovvnloading merged 1 commit into
mainfrom
fix/general-settings-persistence-1053

Conversation

@dovvnloading

@dovvnloading dovvnloading commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #1053. General preference setters now save a candidate state through the existing atomic file replacement before exposing it in memory. If a write, flush/fsync or rename fails, the previous settings stay active and the intent returns a safe, actionable error instead of publishing a misleading success.

What Changed

  • Use one candidate-state save helper for general preferences: token counter, system prompt, onboarding, routing policy, log level, theme, notification preferences, and the update preference/status fields.
  • Use the existing strict persistence path, including staging cleanup, fsync, atomic replacement and existing permission handling. No global persistence default changes.
  • Translate filesystem failures to the existing UserFacingError transport path; never expose raw filesystem exception text or paths.
  • Apply log level only after successful persistence, inside the existing serialized manager mutation so overlapping requests cannot reorder the live effect.
  • Add 27 parameterized regression cases using the real SettingsManager and fault injection at JSON write, fsync and replacement: unchanged state and file, no failed app-settings publication or live logging update, safe error, clean staging, retry and restart. Multi-field update status also commits together.

Why

A setting shown as active should correspond to the last successful save, not an uncommitted candidate. The knowledge embedding preferences already use the same strict candidate-before-publish pattern. The fix preserves the settings schema, accepted enum values, and existing client error reporting.

Validation

  • Isolated Python 3.13 harness: 27/27 real-file failure/retry checks passed across the seven general intent handlers and two update setters, using the committed general setter, intent-handler, and atomic-save bodies (source fingerprints verified after removing comment/blank lines). Used a minimal manager/dispatcher and model-catalog fixture; not the full application.
  • Inspected the current persistence implementation, general intents, WebSocket error handling and controlled settings UI.
  • Reviewed committed change scope: one commit with only three intended files. Main advanced by one unrelated commit during work; the compared changes did not overlap these files.
  • App launches
  • Relevant workflow was exercised manually
  • python -m compileall -q . passes (run from the repo root - matches CI)
  • python -m pytest -q passes (run from the repo root - matches CI)
  • cd web_ui && npm run check passes (matches CI)

Local checkout is blocked: git ls-remote https://github.com/dovvnloading/Graphlink.git HEAD fails DNS resolution. The committed pytest regression suite and full CI gates have not been executed locally; the isolated harness above does not replace them. Focused command in a configured checkout:

python -m pytest -q -n0 backend/tests/test_general_settings_persistence.py backend/tests/test_settings.py backend/tests/test_notifications.py

Manual verification: in a disposable profile, simulate a failed settings-file replacement, change theme or log level, check that the old preference remains active and an error is shown, restore writable storage, retry and restart. Verify both themes and keyboard operation.

UI Notes

  • No screenshots needed for the backend-only change; existing notification/error UI is reused.

Additional Context

Scoped to the general preference setters (including update status); provider configuration, credentials, plugin grants and other persistence mixins are not changed. No dependencies, schema changes, or CI gate changes. Draft pending required CI and manual review; do not merge until they pass.

@dovvnloading dovvnloading left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all three changed files against #1053 and the existing atomic-save, manager-lock, WebSocket error handling and controlled settings UI contracts. No blocking code findings: candidate state is committed only after strict atomic replacement, failed writes do not publish app-settings or apply the live log level, and the error message does not disclose raw filesystem details. The regression suite covers write/fsync/replace faults, unchanged state and file, cleanup, retry and restart, including multi-field update status.

Verified GitHub Actions on this head: all four required checks passed (Windows Python, frontend, wheel build, POSIX permissions), as did MCP Connect Chromium. Windows pytest reports 8,450 passed, 56 skipped, 22 subtests passed and 88.24% coverage. Optional nightly boot-smoke was skipped as designed. Compared the four newer main commits; no changed-file overlap. No review threads outstanding.

Limitation: the native desktop/manual theme and keyboard walkthrough was not performed (local GitHub DNS resolution fails); the full CI and automated real-file/intent regressions provide the functional evidence for this backend-only change. Under the maintainer's current request to process and merge a PR, treating that evidence as sufficient for this change, without claiming the manual checklist passed. No CI gates or branch protections changed. Formal self-approval is not appropriate; this is a review comment.

@dovvnloading
dovvnloading marked this pull request as ready for review November 25, 2026 11:13
@dovvnloading
dovvnloading merged commit f151de4 into main Nov 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(settings): failed disk writes publish changed settings as though they were persisted

1 participant