fix(daemon): persist CODEX_SWITCH_HOME into installed services (#60) - #64
Merged
Merged
Conversation
xjoker
marked this pull request as ready for review
August 25, 2026 23:43
daemon install wrote a LaunchAgent/systemd/Task Scheduler definition that forwarded only HOME and CODEX_HOME. With a relocated store the installed service fell back to the default ~/.codex-switch, so it could poll a stale profile set and rewrite the wrong account's live ~/.codex/auth.json. Capture CODEX_SWITCH_HOME from the installing process (when set and non-empty) and bake it into the generated service definition on all three platforms. Unset leaves the definitions unchanged. Update the wiki caveat and troubleshooting entry to match. Co-authored-by: xJoker <xjoker@users.noreply.github.com>
cursor
Bot
force-pushed
the
cursor/daemon-persist-codex-switch-home-5a91
branch
from
August 26, 2026 06:52
520c9d5 to
dbf19e5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #60.
Problem
daemon installwrites a LaunchAgent (macOS), systemd user unit (Linux), or Task Scheduler command (Windows) that forwards onlyHOMEandCODEX_HOMEinto the daemon's environment. If the user relocated state withCODEX_SWITCH_HOME, the installed service still read the default~/.codex-switch— so it could poll a stale/empty profile set and rewrite the wrong account's live~/.codex/auth.json.Fix
At install time, capture
CODEX_SWITCH_HOMEfrom the installing process (when set and non-empty) and bake it into the generated service definition on all three platforms:CODEX_SWITCH_HOMEkey in the plistEnvironmentVariablesdict (XML-escaped).Environment="CODEX_SWITCH_HOME=…"line (systemd-quoted).set "CODEX_SWITCH_HOME=…" &&in the Task Scheduler command.When the variable is unset/empty, the definitions are byte-for-byte unchanged, so default installs are unaffected. The value is read at install time; changing it later requires re-running
daemon install(documented).Tests
src/daemon/service.rs:launchd_plist_forwards_codex_switch_home_when_set,systemd_unit_forwards_codex_switch_home_when_set,windows_task_scheduler_command_forwards_codex_switch_home_when_set(including escaping/quoting of special characters).Docs
Updated the wiki
Configuration.mdcaveat andTroubleshooting.mdrow to describe the new capture-at-install behavior instead of the manual workaround.Verification (Linux)
cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings,cargo test --all— all pass, 0 failed.Note: the CI Format and audit job will be red until #63 (webbrowser RUSTSEC-2026-0257 lockfile bump) merges to
dev; that failure is pre-existing and unrelated to this change.