Skip to content

Ask before replacing a keyloom.yml changed outside Keyloom - #38

Merged
BlakeGardner merged 1 commit into
mainfrom
notice-config-edits
Nov 15, 2026
Merged

BlakeGardner merged 1 commit into
mainfrom
notice-config-edits

Conversation

@BlakeGardner

Copy link
Copy Markdown
Owner

What

Keyloom rewrites ~/.config/xremap/keyloom.yml from its own rule model, so anything edited into the file by hand disappeared the next time a mapping changed. A file Keyloom never wrote was backed up and replaced silently. This implements the "Noticing edits to the config file" entry from docs/Upcoming_Features.md.

Behaviour

  • Detection. Generated files carry a # Checksum: <sha256> comment on the line after the marker. A file whose contents no longer match is treated as edited by hand; a file without the marker is treated as not written by Keyloom. Both are handled the same way.
  • Launch. Such a file is left alone, with no notice.
  • A change that would rewrite the file opens a "Replace keyloom.yml?" dialog:
    • Keep a copy and replace copies the file to keyloom.yml.bak[.N], names the copy in a toast, and writes.
    • Replace writes without a copy.
    • Cancel (also Escape or clicking outside) leaves the file alone and takes the change back, so the interface never shows a remap that was not written.
  • A change is saved to the store only once the file is written. A change that leaves the generated document as it was (a rename, say) saves without asking.

Behaviour changes to note

  • A file Keyloom did not write is no longer backed up and replaced automatically on the first change; the dialog decides, and plain "Replace" keeps no copy.
  • The first launch after upgrading rewrites an existing Keyloom file to add the checksum line, without restarting xremap.

Limitations

  • A file written by a version before checksums carries none and counts as untouched, so edits made to it before upgrading are not noticed. Deleting the checksum line hides later edits the same way.
  • The edits are not brought into the app; that is noted under the import entry in docs/Upcoming_Features.md.
  • There is no file watcher: the file is checked when Keyloom is about to write it.

Implementation

  • src/xremap.rs: seal / edited_since_sealed, a Replace policy in place of the overwrite_foreign flag, and new WriteOutcome variants.
  • src/app.rs: the last saved profile state is kept so a cancelled change can be taken back (discard_change); the dialog's state and messages.
  • src/ui/overlays.rs: the dialog.
  • src/app/screenshots.rs: an ignored screenshot test for the dialog.

Validation

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features --locked -- -D warnings, and cargo test --locked (352 passed) pass.
  • New tests cover sealing, each replace policy against edited, foreign and pre-checksum files, and the ask / cancel / replace flow in the app.
  • verify-layers-with-xremap.sh was not run: what the generator emits is unchanged, since the checksum is added only when the file is written.
  • Not verified on desktops other than the development one; the change uses no desktop-specific services.

Keyloom rewrites keyloom.yml from its own rule model, so anything
edited into the file by hand disappeared at the next change, and a
file Keyloom never wrote was backed up and replaced without a word.

Generated files now carry a checksum of themselves on the line after
the marker, which tells Keyloom's own output from a file edited since.
A file that was edited, or that Keyloom did not write, is left alone
at launch. A change that would rewrite it asks first: keep a copy and
replace, replace, or cancel, which leaves the file as it is and takes
the change back so the interface never shows a remap that was not
written. A change is saved only once the file is written, and one
that leaves the document as it was (a rename) does not ask.

A file from a version before checksums carries none and counts as
untouched.
@BlakeGardner
BlakeGardner merged commit 3838523 into main Nov 15, 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.

1 participant