Repository navigation
desktop: persist the desktop configuration as name-keyed KDL - #160
Merged
Merged
Conversation
- Merge ConfigKeys into ConfigurationDocument; the id-to-name map and the document change together. - Persist the default configuration at load time so the file exists before the first change; drop the Option path. - Leave the change pending when a write fails, so the next flush retries. - Extract the KDL<->data conversation into kdl_codec, rename the node lookup helpers *_mut, order helpers by stepdown. - Drop pub(crate) items inside the persistence module; mod.rs only declares child modules and re-exports the facade type. - Remove the too-specific shared-instructions paragraph.
Owner
Author
|
Addressed all review threads:
All threads resolved; no replies posted. |
pragmatrix
commented
Sep 29, 2026
The no-file policy (writing the built-in default) moves up the call chain to the Desktop startup sequence: load now fails on any file error, and initialize_file is the explicit, separately invokable fallback. Also import the kdl_codec helpers instead of spelling super::kdl_codec at each call site.
Load derives the live ProjectSet from the parsed file and registers the resulting names in one step, returning both the document and the set; the separate register_loaded step is gone.
The spawn-parameter (JSON) <-> KDL node conversation moves to its own parameter module; the KDL document's structure (change application, configuration read-back) stays in the document module, now named for what it holds instead of the codec framing.
Owner
Author
|
Parameter (JSON) conversions separated and module renamed:
|
Also replaces the inline std::fs::read_to_string with a fs import.
pragmatrix
commented
Sep 29, 2026
pragmatrix
commented
Sep 29, 2026
…e, get_launch_profile)
…us_target, matrix_placement_of
…un-rename DesktopSystem::placement
pragmatrix
force-pushed
the
persisting-desktop-configuration
branch
from
September 30, 2026 07:16
a736182 to
84bea09
Compare
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.
Why
The desktop configuration (projects, launchers, their matrix placements, and the
startup profile) is the only desktop state that persists across sessions, but it
was stored as
desktop.json, regenerated wholesale, and shaped for the machine:no comments, camelCase keys, and a
tagsfield no consumer read. The file ishuman-maintained — the intended workflow is that a user edits it by hand — so it
should speak in the same vocabulary the desktop presents, and survive automated
writes without shredding a user's comments and blank lines.
Summary
desktop.kdl, keyed by name. Replacesdesktop.json(and itsConfigFile/ProjectConfiguration::from_dir/from_jsonpath) withdesktop/src/projects/persistence.rs: a parsedKdlDocumentkept in memory forthe session, loaded from / written to
<projects dir>/desktop.kdl.so user comments and formatting survive byte-identical. A spike confirmed kdl
nodes carry their comments across remove/insert moves.
session, so the file references names; per ADR 0010 names may repeat (the
planner keeps the "at least one launcher" invariant), and a name lookup
resolves to the nearest node. Node identity lives in a re-parseable tag held
in
KdlNode::span(NodeTags), so live entries map to file nodes withoutrenaming the user's text.
ConfigKeysis gone.node only copies whitespace-only spacing from its sibling (a comment rides on
the preceding node's leading and belongs to it), and replacing the startup
launcher keeps the comments above it. Both pinned by tests.
immediately and the file is written once, synchronously and atomically
(temp-file + rename), at the end of
transact— so actions likeremove-launcher, whose shift moves several launchers, persist as a single
write. Setup transactions (which replay the file's own configuration)
neither mirror nor write.
transactstates that a failingchange leaves earlier effects applied (state may be inconsistent, including
the document mirror, which lands before the apply), with the call site
cross-referenced.
ProjectChange::RemoveSlotis gone; the matrixcomputes the slot-removal shift and the plan emits explicit
MoveLauncherchanges, so the file mirrors the same moves the model made.
tagsis removedfrom the configuration types.
TransactionEffectsModethreaded intoapply_change/apply_project_change/ the mirroring call, so a change states in which termsit is applied (setup replays the file without writing it back).
CONTEXT.mddefines the domain terms;
shared-instructions.mdrecords the resultingconvention (surgical edits for human-maintained config files) and combines the
function-ordering rule into one bullet.
Validation
cargo check -p massive-desktopclean;cargo clippy -p massive-desktopclean;
cargo fmt --checkclean.cargo test -p massive-desktop: 52 passed, 0 failed.Note
This was created entirely with AI assistance.