Repository navigation
Keep the user's layout when part of it can't be read - #35
Open
edward-mcnair wants to merge 1 commit into
Open
edward-mcnair wants to merge 1 commit into
edward-mcnair wants to merge 1 commit into
Conversation
layout.json holds the only copy of the dashboard, and one bad part used to cost all of it: an unknown enum value (a theme name from a newer version), one malformed widget, or a wrong-typed setting failed the whole document, and a second failure replaced the newer file with defaults. Loading - Each field falls back to its default and each unreadable page or widget is skipped, instead of failing the document. A widget whose settings can't be read keeps its place with default settings. The decoder counts every fallback, so a repaired read is never mistaken for a clean one. - layout.json.bak keeps the last file that read cleanly. A file that can't be decoded is moved aside under its own name (every one is kept) and the backup is restored; a partly read file is kept as a copy. - A file that can't be opened (a transient I/O error), couldn't be moved aside, or was written by a newer version is never saved over. - Widgets with impossible geometry or repeated ids are dropped before use. Importing - An imported file must decode cleanly, have pages and lay out validly, and be from a supported version; otherwise it's refused with a reason. - The layout on screen, including unsaved changes, is kept as layout-before-import.json, and services refresh after an import. Settings shows the import result and says when a save failed. LayoutStoreTests' two quarantine tests now expect one file per failure (stronger than the single .corrupt copy they checked). New Swift Testing tests cover lenient decoding, restoring the last good copy, protecting a newer file, and refusing or keeping layouts on import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What does this PR do?
layout.jsonholds the only copy of the dashboard, and one bad part used to cost all of it:.corruptcopy.{}included, and wrote it straight over the layout.Loading
LenientDecoding.swift).layout.json.bakkeeps the last file that read cleanly.LayoutValidation.swift).Importing
layout-before-import.json.LayoutEngine.importLayout(_:)bumpslayoutVersion, so services follow the new widgets, and clamps the current page.Settings shows the import result, and says when a save failed.
Tests:
LayoutRecoveryTests(Swift Testing, 5 tests): lenient decoding, restoring the last good copy across repeated failures, protecting a newer file, refusing bad imports ({}, no pages, a page without an id, a damaged widget list, negative sizes, a newer version), and keeping the on-screen layout on import.LayoutStoreTests' two quarantine tests now expect one file per failure, which is stronger than the single.corruptcopy they checked. They're XCTest, so CI runs them.Screenshots
No visual change, apart from a line of text under Import Layout in Settings → General.
Checklist
swift-formatlint clean)Note: overlaps #32 in
GlobalSettings.init(from:); I'll rebase whichever lands second.🤖 Generated with Claude Code