Skip to content

fix(codex): preserve local environment hydration#649

Open
huntharo wants to merge 1 commit into
mainfrom
codex/local-codex-shell-hydration
Open

fix(codex): preserve local environment hydration#649
huntharo wants to merge 1 commit into
mainfrom
codex/local-codex-shell-hydration

Conversation

@huntharo
Copy link
Copy Markdown
Contributor

@huntharo huntharo commented Jun 5, 2026

Summary

Preserve the local Codex environment setup result so future local Codex App Server threads can run with the same toolchain context instead of rediscovering nvm, pnpm, Corepack, and related PATH state on every command.

Changes

  • Capture a filtered post-setup shell environment after successful local .codex/environments/*.toml setup.
  • Persist the non-secret toolchain environment in the active PwrAgent profile state so it survives app restarts.
  • Reuse cached hydration when setup is disabled or skipped.
  • Pass the hydrated env to local Codex thread/start through config.shell_environment_policy.set.
  • Apply the hydrated env to local environment actions as well.
  • Add focused coverage for capture/filtering, cache reuse, and Codex thread/start payload generation.

Root Cause

PwrAgent ran environment setup commands in a child shell, but the resulting shell state could not mutate the parent Electron process or the Codex App Server thread config. That left local Codex turns with only the default process/login shell environment, so tools installed through project-specific version managers could be missing.

Validation

  • ./node_modules/.bin/tsc --noEmit -p apps/desktop/tsconfig.json
  • ./node_modules/.bin/vitest run apps/desktop/src/main/__tests__/codex-environment-runtime.test.ts apps/desktop/src/main/__tests__/codex-client.test.ts
  • git diff --check

@huntharo huntharo force-pushed the codex/local-codex-shell-hydration branch 4 times, most recently from 43343cc to a70514d Compare June 5, 2026 20:25
@huntharo huntharo force-pushed the codex/local-codex-shell-hydration branch from a70514d to f30b61e Compare June 5, 2026 21:17
@huntharo huntharo marked this pull request as ready for review June 6, 2026 04:38
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