Skip to content

Persist preset names in Krokiet on Save Current Preset click - #1940

Open
johntrandall wants to merge 1 commit into
qarmin:masterfrom
johntrandall:fix/save-preset-names-on-button-press
Open

johntrandall wants to merge 1 commit into
qarmin:masterfrom
johntrandall:fix/save-preset-names-on-button-press

Conversation

@johntrandall

@johntrandall johntrandall commented May 12, 2026 •

Copy link
Copy Markdown

Problem

Krokiet's Save Current Preset button writes the per-preset config file (config_preset_N.json) but does not write the base settings file (config_general.json). Preset names live in BasicSettings and are only flushed on clean app exit via save_all_settings_to_file(). On a non-clean exit (window close that returns non-Ok, logger that did not flush, force quit), preset renames silently vanish on next launch.

Repro (Krokiet 11.0.1, macOS 15.7)

  1. Open Krokiet
  2. Settings tab → click Edit name next to a preset, type a new name, click Save
  3. Click Save Current Preset
  4. Quit the app
  5. Relaunch
  6. Preset name has reverted to the default ("Preset 1", etc.)

Fix

on_save_current_preset now calls save_base_settings_to_file in addition to the existing per-preset write, so the Save button matches user expectations — Save means save everything visible, including any preset rename just made through the Edit name dialog.

Adds a round-trip unit test for BasicSettings in krokiet/src/settings/mod.rs to lock in the data path the new call exercises.

Verification

  • cargo test -p krokiet — passes (new test basic_settings_round_trips_renamed_preset_names)
  • cargo +nightly fmt + cargo clippy --all-targets -- -D warnings — clean
  • Manual end-to-end on macOS 15.7 in a clean Tart VM:
    • Rename Preset 1 → TEST-FIX-VERIFY 1 in the Edit name dialog
    • Click Save Current Preset → config_general.json mtime updates, preset_names[0] = "TEST-FIX-VERIFY 1"
    • pkill -9 (worst-case force-quit) → file content survives
    • Relaunch → Settings combo box shows TEST-FIX-VERIFY 1
    • Without the fix, the same sequence leaves config_general.json unchanged (still defaults).

Related

  • "Presets" does not work correctly #1225 (closed 2024-02-24) — "'Presets' does not work correctly" was a previous preset-persistence bug, fixed for the per-preset config path. The base settings file (where preset names live) was not covered by that fix.

Scope

Intentionally minimal: one new call inside the existing callback, plus one unit test. The narrower follow-up — saving base settings directly from the Edit name dialog's own Save button, so rename-then-force-quit-without-clicking-Save-Current-Preset doesn't lose the rename — is out of scope here. That would require a new Callabler callback and wiring it from krokiet/ui/settings_list.slint.

The Save Current Preset button writes the per-preset config file
(config_preset_N.json) but never the base settings file
(config_general.json). Preset names live in BasicSettings and are
only flushed on clean app exit via save_all_settings_to_file. On a
non-clean exit (window close that returns non-Ok, logger that did not
flush, force quit) preset renames silently vanish on next launch.

on_save_current_preset now writes both files, matching the expectation
that Save means save everything visible — including any preset rename
just made through the Edit name dialog.

Adds a round-trip unit test for BasicSettings to lock in the data path
the new call exercises. The GUI wiring itself was verified manually on
macOS 15.7 (rename → Save → force-kill → relaunch; with the fix the
rename persists, without it config_general.json is unchanged).

Related: qarmin#1225 (closed 2024-02) was a previous preset-persistence bug,
fixed for the per-preset config path. The base settings file (preset
names) was not covered by that fix.

Claude-Session-Id: a4668bec-f120-447b-8c91-4ce97a6ca187
Resume: claude --resume a4668bec-f120-447b-8c91-4ce97a6ca187
@johntrandall johntrandall changed the title krokiet: persist preset names on Save button click Persist preset names in Krokiet on Save Current Preset click May 12, 2026
@johntrandall
johntrandall force-pushed the fix/save-preset-names-on-button-press branch from 03d4d02 to a7ce6bf Compare May 12, 2026 20:21
// on this round-trip: edit preset_names in memory → save_data_to_file → load_data_from_file
// must return the edited names. Without it, renaming a preset cannot survive a restart.
#[test]
fn basic_settings_round_trips_renamed_preset_names() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This test don't do anything except saving data to file and reading it via fs and serde options, so it doesn't check almost any logic that could regress in future(this items are quite hide to broke) and this test isn't related in any way with this PR - please remove it.

}
}
// Also persist base settings (preset names, default preset, window prefs).
// Without this, renaming a preset only takes effect after a clean app exit,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This code doesn't need a comment(it is easy to deduce, what this do) so comment needs to be removed

This branch has not been deployed

No deployments
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.

2 participants