fix(profiles): a profile's load-time migration saves to its own file (#316) - #317
Merged
simion merged 1 commit intoSep 21, 2026
Conversation
…imion#316) `load_settings_in(id)` reads any profile's settings, applies its load-time migrations and, when one changed something, persisted with `save_settings_inner`, which is the ROOT writer. Loading a non-root profile that needed a migration therefore wrote that profile's settings over the root profile's settings.json, taking the root's accounts, default tasks path and every root-only setting with it. The profile's own file never received the migration, so it needed it again on the next load and the root file was overwritten again, every time that window loaded its settings. Seen as accounts that could not be kept: added in the root profile, gone after the next action in the other profile's window. The account carries in agents_save and settings_save never saw it, since this path goes around both. Save to the profile the settings came from. Control: the new test fails with `save_settings_inner` (the root file changes) and passes with the fix. Closes simion#316 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
simion
approved these changes
Sep 21, 2026
simion
left a comment
Owner
There was a problem hiding this comment.
Merged, thanks @GabrielDumbrava. Clean one-line fix, verified it writes to the profile's own file and leaves the root migration writers untouched.
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.
Closes #316
Problem
load_settings_in(id)reads any profile's settings, applies its load-time migrations, and when one changed something persisted withsave_settings_inner, which is the ROOT writer.Loading a non-root profile that needed a migration therefore wrote that profile's settings over the root profile's
settings.json: the root's accounts, default, adopted account, default tasks path and every other root-only setting went with it.The non-root file never received the migration, so it needed it again on the next load, and the root file was overwritten again every time that window loaded its settings.
Seen as accounts that could not be kept: added in the root profile, gone after the next action in the other profile's window.
The account carries in
agents_save(0cdfb58) andsettings_save(#309) never saw it, because this path goes around both.Fix
One line: the migration saves to the profile it was read from,
save_settings_in(id, &s).The two other
save_settings_innercalls (stamp_schema_version,migrate_cli_enabled_default) are startup migrations of the root profile and are unchanged.docs/profiles.mdrecords the trap: inside a per-profile path,*_innermeans the root profile, not "this profile".Tests
a_profile_that_needs_a_migration_writes_its_own_file_not_the_roots: a root profile with accounts and its own tasks path, and a second profile whose file carries the legacyworktree_symlink_pathsdefault. Loading the second profile leaves the root file byte-for-byte unchanged and writes the migration into the second profile's own file. Control: withsave_settings_innerthe test fails; with the fix it passes.cargo test: 1073 passed.Manual verification
Not manually verified in the app: I opened this without a hand test.
The failure itself was observed on the real install before the fix: watching the root
settings.jsonshowed it rewritten on actions in the second profile's window, and itsdefault_tasks_pathhad become the second profile's.Settings already overwritten are not restored by this and have to be set again.
🤖 Generated with Claude Code