Skip to content

Persist tracking settings as defaults; seed on new pack load#89

Closed
emosaru wants to merge 1 commit into
mainfrom
fix/issue-83-tracking-settings-defaults
Closed

Persist tracking settings as defaults; seed on new pack load#89
emosaru wants to merge 1 commit into
mainfrom
fix/issue-83-tracking-settings-defaults

Conversation

@emosaru
Copy link
Copy Markdown
Contributor

@emosaru emosaru commented May 10, 2026

Fixes #83.

Summary

  • Persist UI changes: When the user toggles a tracking setting (Ignore All Logic, Show All Locations, Always Allow Clearing, Auto-unpin on Clear, Pin on Item Capture) via the menu, the change now propagates back to ApplicationSettings' seed fields and writes to application_settings.json. Previously, UI bindings went directly to SessionSettings bypassing the seed, so preferences were lost on restart.

  • Seed on new pack/variant load: ActivatePackage now calls SeedIntoSession before PackageLoader.LoadInto, so the state's settings are reset to the user's saved defaults before init.lua runs. Pack scripts can still override them during initialization.

  • Guard against init.lua overwriting seeds: SyncSeedsFromSession no-ops when PackageLoader.IsLoading is true, so pack-script-driven setting changes don't clobber the user's saved preferences.

  • Reload is unchanged: Reload() does not seed — reloading the same pack preserves the current session settings.

Changes

File What changed
PackageLoader.cs Added internal static bool IsLoading (exposes the existing [ThreadStatic] mInProgress flag)
ApplicationSettings.cs Added SyncSeedsFromSession: updates seed fields + writes JSON, guarded by IsLoading
SessionSettings.cs Added [OnChanged(SyncSeedsToApplicationSettings)] to the 4 settings without hooks; OnIgnoreAllLogicChanged also calls the sync method
TrackerState.PackageOps.cs ActivatePackage calls SeedIntoSession(Settings) before LoadInto

Test plan

  • Toggle "Ignore All Logic" on → restart app → setting should still be on
  • Toggle "Show All Locations" → restart → persists
  • Load pack A with "Ignore All Logic" on → settings seeded correctly before init.lua
  • Switch variant → settings reset to saved defaults before init.lua runs
  • Reload pack (Refresh) → current settings preserved, not reset to defaults

🤖 Generated with Claude Code

…(issue #83)

When the user toggles a tracking setting via the UI (which binds directly
to SessionSettings), the change now propagates back to ApplicationSettings'
seed fields and writes to application_settings.json — so the preference
survives restart and becomes the default for future sessions.

When a new pack/variant is activated, SessionSettings is seeded from the
saved defaults before init.lua executes, so pack scripts start from the
user's preferences and may optionally override them. Reloading the same
pack leaves the current settings unchanged (no seed reset).

Pack-script-driven changes (i.e. those made while PackageLoader.IsLoading
is true) are suppressed from writing the seeds, so init.lua cannot
accidentally overwrite the user's saved preferences.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@emosaru emosaru requested a review from a team May 10, 2026 19:28
/// suppress seed-writes driven by pack-script (init.lua) changes,
/// so only explicit user UI changes update the saved defaults.
/// </summary>
internal static bool IsLoading => mInProgress;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This appears unused. If it is, it should be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is used — ApplicationSettings.SyncSeedsFromSession checks it at line 119 (if (Sessions.PackageLoader.IsLoading) return;). Easy to miss since it's a cross-file internal reference. Happy to leave as-is.

@emosaru
Copy link
Copy Markdown
Contributor Author

emosaru commented May 10, 2026

Closing for further design work before merging.

@emosaru emosaru closed this May 10, 2026
@emosaru emosaru deleted the fix/issue-83-tracking-settings-defaults branch May 10, 2026 20:18
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.

"Tracking" options not conserved on relaunch / change of pack

1 participant