Skip to content

A second profile's window overwrites the root profile's settings.json on every load (accounts and paths lost) #316

Closed

Description

@GabrielDumbrava

Environment
macOS 26.6.2, arm64.
Termic 1.6.0, two profiles (the root one and a second one).

The problem

An agent's account list keeps disappearing from the root profile, and accounts added again do not stay.
The root profile's other settings are replaced too: its default_tasks_path became the second profile's (~/termic/profiles/<slug>/tasks).

Watching the root settings.json while working showed it being rewritten every time the SECOND profile's window did something (a prompt was enough), always with the same content.

Cause

load_settings_in(id) reads ANY profile's settings, applies its load-time migrations (default sandbox paths for built-in agents, the legacy worktree_symlink_paths defaults, capability backfills, the codex/grok args cleanup), and when one of them changed something it saves with:

if migrated {
    let _ = save_settings_inner(&s);
}

save_settings_inner writes the ROOT profile's file.
So loading a non-root profile that needs a migration writes that profile's settings over the root profile: accounts, default, adopted account and every root-only setting go with it.
And the non-root file itself never receives the migration, so it needs it again on the next load, and the root file is overwritten again on every load from that window.

That is also why the account fixes (0cdfb58, #308) did not help here: this path never goes through agents_save or settings_save.

Fix

Save the migration to the profile it was loaded from: save_settings_in(id, &s).
I have a PR with a Rust test that loads a non-root profile needing a migration and asserts the root file is untouched and the profile's own file received it.

Settings already overwritten are not restored by the fix: the root profile's accounts and paths have to be set again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions