Skip to content

theme-set-pi: stop stomping the user's chosen theme on re-provision - #13718

Closed
kvnloo wants to merge 1 commit into
omacom:quattrofrom
kvnloo:muse/theme-set-pi-keep-user-theme
Closed

kvnloo wants to merge 1 commit into
omacom:quattrofrom
kvnloo:muse/theme-set-pi-keep-user-theme

Conversation

@kvnloo

@kvnloo kvnloo commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

What

omarchy-theme-set-pi --activate (run by install/user/theme.sh on every re-provision) overwrote a user-chosen Pi theme back to omarchy-system.

Fix

Skip the settings write when the existing .theme is a non-omarchy string (mirrors theme-set-hermes's leave-a-chosen-skin pattern); fresh installs still seed omarchy-system. Also guards the jq write with tmp cleanup.

Evidence

  • New test/shell.d/theme-set-pi-activate-test.sh 4/4 (fails red on base); theme-background-memory-test.sh 12/12; bin-style-test.sh green.

Posted by Kevin's agent on his behalf — AI-assisted contribution (Muse, Meta's Muse Spark) under the contributor's direction. The contributor reviewed the change and takes responsibility for it.

@sanjyay

sanjyay commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

This is an independent community review and unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Tested commit 130f045f058e25f27567d4330abdd90558e6228f in a clean Omarchy test environment.

Verification Summary

  • Base behavior on quattro: omarchy-theme-set-pi --activate is executed during user re-provisioning (install/user/theme.sh). In base quattro, write_setting_theme() unconditionally overwrote .theme in $HOME/.pi/agent/settings.json with "omarchy-system", overriding any custom theme the user configured.
  • PR behavior: Inspects the current .theme field in settings.json; if already set to a non-omarchy-system theme string, it preserves the user's choice and exits early while still syncing the updated omarchy-system.json theme file to $HOME/.pi/agent/themes/. If unset, settings.json is missing, or the theme is currently "omarchy-system", it updates the configuration cleanly with temporary file cleanup on failure.
  • Automated test suite:
    • test/shell.d/theme-set-pi-activate-test.sh passes on the PR branch (all 4/4 assertions pass).
    • Running the test against base quattro reproduces the failure (not ok - --activate leaves a user-chosen Pi theme alone).
    • Whitespace checks and bash -n syntax validation pass without issues.
Test details
# Base quattro failure reproducing stomping of user-selected theme:
$ bash test/shell.d/theme-set-pi-activate-test.sh
not ok - --activate leaves a user-chosen Pi theme alone

# PR branch execution:
$ bash test/shell.d/theme-set-pi-activate-test.sh
ok - --activate leaves a user-chosen Pi theme alone
ok - --activate keeps the Omarchy theme selected
ok - --activate seeds the Omarchy theme on first install
ok - --activate syncs the generated theme file

$ bash test/shell.d/bin-style-test.sh
ok - bin commands use command helpers
ok - bin commands use the notification helper

$ git diff --check
$ bash -n bin/omarchy-theme-set-pi test/shell.d/theme-set-pi-activate-test.sh

If you'd prefer not to receive these independent reviews on your PRs, reply to this comment and say so, and I won't review your future PRs.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 130f045f against quattro. The bug is real and the fix works.

Reproduced on a disposable Omarchy worker. With a Pi settings.json of {"theme":"light","model":"keep"}, running the real caller, install/user/theme.sh, resets the theme to omarchy-system with this fix reverted, and leaves light (and model) alone at this head. The new test/shell.d/theme-set-pi-activate-test.sh fails with the fix reverted and passes 4/4 at the head; user-theme-test.sh, hermes-theme-test.sh, theme-templates-test.sh and bin-style-test.sh pass. The Pi checks in ./test/cli pass. ./test/cli as a whole fails on vscode generated theme references current theme file, but it fails the same way on current quattro, so that is not from this change.

How often it bites: only when omarchy-provision-user runs again, which is guarded by its done marker and so needs --force (or owner provisioning). Ordinary theme switches call omarchy-theme-set-pi without --activate and never touched the setting. So the fix is small, and so is the problem it solves. It follows the same rule install/user/theme.sh already uses for the desktop theme: re-provisioning does not undo a choice the user made.

Second opinion: Codex at medium effort reviewed the same head. It confirmed the comment's comparison to omarchy-theme-set-hermes is accurate (Hermes keeps a non-default skin even with --activate). It found one more edge: a settings.json holding a custom theme followed by trailing garbage is left alone and the script exits 0, where quattro exited non-zero. I did not treat that as a defect, because leaving that file untouched is what this change sets out to do. Nothing was pushed to the branch.

Overlap with other open pull requests on this file:

Nothing is needed from you. This now waits on the maintainer, mainly to choose the merge order among these four.

@jandrusk

jandrusk commented Oct 7, 2026

Copy link
Copy Markdown

Heads-up: #14194 (merged Oct 4) removed the "rerun user setup with --force" guidance, and #7104 / #7473 were closed as declined, because the maintainer has decided not to harden forced reruns of user setup.

As the review above notes, this only bites when omarchy-provision-user runs again (--force), so it probably falls under the same decision. Also note that #13713 and #13693 both edit bin/omarchy-theme-set-pi, so if this does go ahead it'll need a rebase after whichever lands first.

Arash-Afshar added a commit to Arash-Afshar/omarchy that referenced this pull request Nov 6, 2026
…r's pick

omarchy-theme-set-pi wrote the theme and the theme setting into ~/.pi/agent
even when PI_CODING_AGENT_DIR moves Pi's agent tree, so Pi never saw either.
Its Claude and Hermes siblings already follow their agent's variable.

- The agent directory is ${PI_CODING_AGENT_DIR:-~/.pi/agent}, with a leading
  ~ expanded the way Pi expands it (pi 1.5.0 getAgentDir()).
- --activate, which install/user/theme.sh runs on every re-provision, only
  fills in an unset theme. A theme the user picked in Pi is kept.
- The settings write goes through a symlinked settings.json (dotfiles) to its
  target, keeps the file's mode, and leaves the file untouched with no temp
  litter when it is not valid JSON, reporting the failure.

test/shell.d/theme-set-pi-test.sh covers each case; it fails on the first
assertion against the previous script.

Fixes omacom#13691 (theme half). Supersedes omacom#13693, omacom#13718, omacom#13713 (Pi half) and
the Pi half of omacom#13983.
@kvnloo

kvnloo commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Closing per the heads-up above: this only bites on a forced rerun of user setup, which #14194 and the declined #7104 / #7473 put out of scope. Prepared by Claude Opus 5.5 via Hermes Agent; reviewed under kvnloo's account.

@kvnloo kvnloo closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants