Skip to content

fix(theme): let mq-theme-manager.sh run outside $HOME/macos-scripts - #173

Merged
MCamner merged 1 commit into
mainfrom
fix/theme-manager-base-dir
Aug 3, 2026
Merged

fix(theme): let mq-theme-manager.sh run outside $HOME/macos-scripts#173
MCamner merged 1 commit into
mainfrom
fix/theme-manager-base-dir

Conversation

@MCamner

@MCamner MCamner commented Aug 3, 2026

Copy link
Copy Markdown
Owner

The sibling #172 named and deliberately left alone. One line of runtime, plus its test.

Defect

terminal/themes/mq-theme-manager.sh read ${HOME}/macos-scripts outright, where tools/scripts/doctor.sh, tools/scripts/scan.sh and — since #172mq-zsh-theme-switcher.sh all read ${MACOS_SCRIPTS_HOME:-$HOME/macos-scripts}.

Measured with HOME pointed away from the checkout:

list      exit 0
current   exit 0
reset     exit 0
apply     exit 0
preview   exit 1   line 140: .../macos-scripts/ui/terminal-ui/mq-ui.sh

Only preview reads BASE_DIR, through UI_LIB. That is why this stayed invisible: four of the five verbs work anywhere, and on a developer machine $HOME/macos-scripts exists so the fifth does too.

Fix

-BASE_DIR="${HOME}/macos-scripts"
+BASE_DIR="${MACOS_SCRIPTS_HOME:-$HOME/macos-scripts}"

THEME_FILE is untouched at ${HOME}/.mq-theme. The selected theme is user state, the same class as ~/.zshrc, and belongs in $HOME wherever the checkout lives.

Test

tests/theme-manager-path-smoke.sh, 5 steps:

step asserts
2 preview runs from a temp tree holding nothing but a symlinked ui/, and rendersTHEME PREVIEW and Theme: green — rather than merely exiting 0
3 list, current, apply, reset work there too; apply writes .mq-theme inside the isolated HOME, current reads it back, reset removes it
4 with MACOS_SCRIPTS_HOME unset and a HOME holding no macos-scripts, preview still fails — the fallback is unchanged, and the step would prove nothing if it passed
5 the real ~/.mq-theme has the same checksum as before the test

Proven able to fail: with the hard-coded path put back, the run stops at step 2 with FAIL: preview exited 1 from a non-default checkout.

Step 5 is not decoration. apply writes and reset deletes ~/.mq-theme, and an earlier probe in this work applied a theme to the machine running it. Every run in this test gets its own HOME.

Full suite green, markdownlint clean.

🤖 Generated with Claude Code

It read `${HOME}/macos-scripts` outright, where doctor.sh, scan.sh and — since
#172 — mq-zsh-theme-switcher.sh all read
`${MACOS_SCRIPTS_HOME:-$HOME/macos-scripts}`. This is the sibling #172 named
and deliberately left for its own change.

Measured with HOME pointed away from the checkout, only `preview` fails: it is
the one verb that reads BASE_DIR, through UI_LIB, and it dies sourcing a UI
library that is not there. list, current, apply and reset work anywhere, which
is why this stayed invisible — and on a developer machine $HOME/macos-scripts
exists, so preview works too.

THEME_FILE stays at ${HOME}/.mq-theme. The selected theme is user state, the
same class as ~/.zshrc, and belongs in $HOME wherever the checkout lives.

tests/theme-manager-path-smoke.sh runs the manager from a temporary tree
holding nothing but a symlinked ui/, requires preview to render its panel
rather than merely exit 0, and drives apply -> current -> reset. Proven able
to fail: with the hard-coded path back it stops at step 2.

Every run gets its own HOME, and the last step compares a checksum of the real
~/.mq-theme taken before the test. apply writes and reset deletes that file,
and an earlier probe in this work applied a theme to the machine running it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@MCamner
MCamner merged commit ac89efd into main Aug 3, 2026
3 checks passed
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