New handoff to worktree doesn't use environments

Open 💬 3 comments Opened Apr 22, 2026 by ViaxCo
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

Version 26.417.41555 (1858)

What subscription do you have?

Pro Lite

What platform is your computer?

Darwin 25.4.0 arm64 arm

What issue are you seeing?

When creating a new conversation using a new worktree, you get to choose environment which sets up stuff for you for the worktree. Now, if I'm working in a local thread and I want to hand it off to a new worktree, it creates the worktree but without the environment. I think there should maybe be an option to select the environment when handing off a local thread to worktree (for the first time). The environment is already setup in the case of creating new worktree with environment, handoff to local and handoff back to worktree.

What steps can reproduce the bug?

  • Start a thread in a project locally.
  • At the work locally drop down, click handoff to worktree.

It'll create a new worktree and branch but without the environment.

What is the expected behavior?

We should be allowed to choose environment when handing off to worktree for the first time.

Additional information

_No response_

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #18828

Powered by Codex Action

dataders · 4 months ago

Can confirm a very concrete worktree-env bug here: in Codex Desktop, the worktree shell/handoff path appears to drop SSH_AUTH_SOCK even when the original shell has it.

That breaks signed git flows in the worktree:

  • original/main-repo Codex shell: SSH_AUTH_SOCK is present, ssh-add -l shows my key, signed commits work
  • worktree Codex shell: SSH_AUTH_SOCK is empty, so git commit -S / signed git rebase fail because git cannot talk to the existing ssh-agent

I also verified this is not a limitation of git worktrees themselves. From the main-repo Codex shell I successfully created a signed commit in a plain non-worktree clone. From the worktree Codex shell, I used that same plain clone and the signed commit failed. Same repo, same clone, same key config; only the worktree-shell environment changed.

This feels like a specific worktree/handoff variant of #14064: the worktree session is not inheriting the existing auth/session environment, and SSH_AUTH_SOCK is one of the missing variables.

JoshTheMenace · 4 months ago

Similar issue for me, when working on a codex web session locally and handing off to a local worktree, the environment also would not pass along.
This is my workaround until this can be fixed.

Add this function to your ~/.zshrc (or ~/.bashrc), then run source ~/.zshrc or open a new terminal to load it. After that, cd into any orphan worktree and run codex-sync-env to pull your .codex/ config over from the main checkout.

```# in your ~/.zshrc or ~/.bashrc
codex-sync-env() {
local main_root
main_root="$(git worktree list --porcelain | awk '/^worktree/{print $2; exit}')"
if [ -z "$main_root" ] || [ "$main_root" = "$PWD" ]; then
echo "Not in a linked worktree" >&2
return 1
fi
mkdir -p .codex
rsync -av --ignore-existing "$main_root/.codex/" ".codex/"
echo "Synced .codex/ from $main_root"
}