Skip to content

Add dedicated draw settings store and draw_images export folder#860

Merged
multiplex55 merged 7 commits intodrawingfrom
codex/refactor-draw-settings-and-file-handling
Feb 15, 2026
Merged

Add dedicated draw settings store and draw_images export folder#860
multiplex55 merged 7 commits intodrawingfrom
codex/refactor-draw-settings-and-file-handling

Conversation

@multiplex55
Copy link
Owner

Motivation

  • Rename the draw export directory to draw_images and introduce a dedicated per-executable draw settings file to centralize persistence and enable clearer migration from legacy plugin payloads.
  • Keep runtime behavior unchanged by continuing to call runtime().apply_settings(...) whenever settings are loaded or persisted.
  • Provide a backward-compatible migration path from the legacy settings.json plugin_settings["draw"] payload when the dedicated file is absent.

Description

  • Renamed the export folder constant to DRAW_EXPORT_SUBDIR = "draw_images" while preserving exe-relative resolution and folder auto-creation in src/draw/save.rs and added a test asserting the new folder name.
  • Added a new module src/draw/settings_store.rs that resolves draw_settings.json next to the executable and implements load/save helpers plus load_from_path/save_to_path with parent-folder creation, contextual errors, and sanitization; the load path will migrate from legacy settings.json plugin payload when the dedicated file is missing.
  • Registered the new module in src/draw/mod.rs and updated src/gui/draw_settings_dialog.rs to use settings_store::load(...) and settings_store::save(...) for dialog load/save flows while still writing through to Settings::plugin_settings for transitional compatibility and calling runtime().apply_settings(...).
  • Updated src/plugins/draw.rs so plugin initialization prefers the dedicated store, apply_settings checks the dedicated store first (then falls back to the provided plugin payload), and persist_settings writes the dedicated store as well as producing the plugin UI payload; also adjusted settings_ui to use the plugin's in-memory settings.
  • Added/updated unit tests: src/draw/save.rs (folder name assertion), src/draw/settings_store.rs (path resolution, round-trip serialization, legacy migration), GUI tests in src/gui/mod.rs (dedicated-file persistence and migration), and plugin tests in src/plugins/draw.rs (dedicated-store preference and legacy migration).

Testing

  • Ran cargo fmt successfully to format changes.
  • Attempted to run unit tests, but full test execution failed in this environment due to a system dependency needed by the build (alsa-sys / missing alsa.pc for pkg-config), which caused cargo test to abort during crate compilation, so added tests were not fully executed here.
  • The new tests added are: draw::save::tests::export_folder_name_matches_draw_images_contract, draw::settings_store::tests::settings_path_is_resolved_next_to_executable, draw::settings_store::tests::dedicated_store_roundtrip_serialization, draw::settings_store::tests::load_migrates_legacy_plugin_settings_when_dedicated_file_is_missing, GUI tests in gui::tests for dedicated-file persistence and migration, and plugin tests plugins::draw::tests::apply_settings_prefers_dedicated_store_when_present and plugins::draw::tests::apply_settings_migrates_from_legacy_plugin_settings_when_dedicated_missing, which should pass when run in an environment with required system libraries installed.

Codex Task

@multiplex55 multiplex55 merged commit c76f95d into drawing Feb 15, 2026
@multiplex55 multiplex55 deleted the codex/refactor-draw-settings-and-file-handling branch February 16, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant