Skip to content

fix(theme): scope the remembered theme choice per profile - #336

Merged
stormer78 merged 1 commit into
mainfrom
worktree-fix-theme-per-profile
Sep 18, 2026
Merged

stormer78 merged 1 commit into
mainfrom
worktree-fix-theme-per-profile

Conversation

@stormer78

Copy link
Copy Markdown
Contributor

The bug

Running two OpenVTC instances under different local profiles and changing the theme in one changed it in all of them — and, via a live file-watcher, repainted the other running instances immediately.

Root cause

The theme choice was kept in a single <config>/tui.toml shared by every profile (this was intentional — "how the TUI looks is the person's, not the account's"), while every other profile-scoped surface encodes the profile into its filename. So two instances differing only by --profile read and wrote the same file.

Blast radius (what else crossed profiles): only the cosmetic theme keys (theme, auto_dark, auto_light) and a transient last-startup-failure.txt crash report. Everything that matters — secrets/keyring, the whole config + account/community data, log settings, the process lock — is already correctly isolated per profile.

The fix (theme now fully per-profile)

  • Roots gains a profile; the choice file is tui.toml for the default profile and tui-{profile}.toml otherwise, mirroring the config-{profile}.json convention. The theme library (themes/) stays shared — it's authored content, not a per-profile setting.
  • main.rs resolves the profile before choosing the theme (profile resolution factored into a resolve_profile helper). Its informational messages now print with the default palette since the theme isn't chosen yet — a rare, acceptable trade.
  • The TUI settings theme actions and the openvtc theme CLI both read/write the running profile's file. The live watcher watches that file, so two instances of the same profile still stay in sync while different profiles no longer cross.
  • Fixed the other cross-profile collision too: the startup crash report is now last-startup-failure-{profile}.txt (unsuffixed for default).

Tests / gates

  • New settings_file_is_scoped_per_profile unit test (default → tui.toml, named → tui-{profile}.toml, two profiles differ).
  • cargo fmt, clippy --all-targets --all-features, RUSTDOCFLAGS="-D warnings" cargo doc, and full cargo test (694 core + 611 openvtc + census) all pass.

Note

This reverses a previously-intentional design (theme as a person-level, cross-profile preference) in favour of strict per-profile isolation, per the reporter's requirement that instances be fully isolated.

Running two OpenVTC instances under different local profiles and changing the
theme in one changed it in all of them. The theme choice was kept in a single
`<config>/tui.toml` shared by every profile, and a live file-watcher even
repainted the other running instances immediately. Everything that matters was
already isolated per profile (secrets/keyring, the whole config + account data,
log settings, the process lock — all carry the profile in their filename); only
the cosmetic theme choice, and a transient crash-report file, crossed over.

Make the theme choice per-profile, matching the `config-{profile}.json`
convention the main config already uses:

- `Roots` gains a `profile`; the choice file is `tui.toml` for the `default`
  profile and `tui-{profile}.toml` for any other. The theme *library*
  (`themes/`) stays shared — it is authored content, not a per-profile setting.
- `main.rs` resolves the profile *before* choosing the theme (profile resolution
  factored into `resolve_profile`), so the theme is scoped to it. The
  informational profile messages now print with the default palette, since the
  theme is not chosen yet — a rare, acceptable trade.
- The TUI settings theme actions and the `openvtc theme` CLI both read/write the
  running profile's file. The live watcher watches that file, so two instances
  of the *same* profile still stay in sync while different profiles do not.
- Also fix the one other cross-profile collision the investigation found: the
  startup crash report is now `last-startup-failure-{profile}.txt`
  (unsuffixed for `default`), so one profile's report no longer overwrites
  another's.

Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
@stormer78
stormer78 requested a review from a team as a code owner September 17, 2026 21:19
@stormer78
stormer78 merged commit bff0920 into main Sep 18, 2026
15 checks passed
@stormer78
stormer78 deleted the worktree-fix-theme-per-profile branch September 18, 2026 05:39
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.

1 participant