Repository navigation
Preserve Pi and Claude settings metadata and symlinks on theme activation - #13983
itsandrewtjames wants to merge 2 commits into
Conversation
|
|
Reviewed at a72ed41 and verified on a disposable worker built from the Omarchy ISO. Nothing needs changing. Reproduction. A Tests on the worker. Second opinion. Codex at medium effort reviewed the diff and found the subshell, EXIT trap and failure propagation sound, and the test not vacuous. Independence is not guaranteed. It raised two minor points, which I did not act on:
Related. #12250 adds This is now waiting on the maintainer. |
…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.
Activating an Omarchy theme for Pi or Claude replaces an existing
settings.jsonwith a0600temporary file. A settings file managed through a dotfiles symlink becomes a regular file, leaving its target unchanged.Resolve the existing settings path, stage the replacement beside its referent, preserve its mode, ownership, ACLs and extended attributes, then publish with an atomic rename. The settings update runs in a subshell with an exit trap, so failed parsing, attribute copying or publication removes the stage file and leaves the original settings intact. If the caller cannot preserve the original access metadata, activation fails before replacing the referent.
Addresses the Pi/Claude settings cases called out in #9326. The open shell-config/migration fix (#12250) does not include these helpers; this PR leaves the wider issue open.
Validation:
0640Pi settings file becomes0600.bash test/shell.d/agent-theme-settings-test.shpasses for both helpers: modes0600/0640/0644/0664, unrelated settings, relative symlinks with spaces in the target path, POSIX ACLs, user extended attributes, and supplemental-group ownership.git diff --checkpass../test/clipasses the existing Pi/Claude theme checks, then reaches the pre-existing VS Code real-file/symlink assertion failure tracked in test/cli vscode assert expects a symlink that 977e0fcd replaced with a real file #13131. The same failure was verified on an untouched base checkout earlier in this session.All settings tests use a temporary HOME and synthetic theme/settings files. ACL/xattr tests require
getfacl,setfacl, and Python; the supplemental-group test skips only when the test user has no second group.