Skip to content

When handing off to an existing wortree the task CWD does not change #47394

Open

Description

@gmatev

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

26.917.51856

What subscription do you have?

Pro

What platform is your computer?

Darwin 25.5.0 arm64 arm

What issue are you seeing?

After creating a local task in the MacOS app, I'm trying to hand-off to an existing worktree. That succeeds but the CWD of the task does not change to the worktree root.

This is very frustrating when trying to continue existing worktree work in a new chat for context management purposes. With the CLI this is not an issue since one can start the session from the workree directory but there is no comparable mechanism in the desktop client which is otherwise excellent.

What steps can reproduce the bug?

  1. Create a worktree (either managed from a previous Codex task chat OR separately with git worktree add
  2. Start a local new task chat in the project
  3. Select "Move to a worktree" action
  4. Codex shows your previously created worktree. Select it and click Handoff

Observed behavior:

The chat task moves to the new worktree as expected

BUT the working directory of the chat DOES not move to the worktree.

What is the expected behavior?

The chat task moves to the new worktree
AND the working directory of the chat ALSO MOVES to the worktree.

Additional information

Interestingly enough launch a terminal session from this chat does lauch the terminal session in the correct worktree.

Activity

  1. added
    app
    on Sep 22, 2026
  2. added
    bug
    session
    on Sep 22, 2026
  3. ekusiadadus commented on Sep 24, 2026

    @ekusiadadus

    I found a lower-level behavior that may help narrow this down. This is an app-server test on Linux/WSL2 with the official Codex CLI 0.156.1 binary, not a reproduction of the macOS Handoff UI.

    Using a disposable repo A and an existing linked worktree B:

    1. Start a thread in A and run a read-only thread/shellCommand to record pwd and Git identity.
    2. Keep that thread loaded and subscribed in the same client connection, with no active turn.
    3. Call thread/resume with the same thread ID and cwd: B.
    4. The response cwd and thread.cwd both remain A. Another thread/shellCommand, with no directory override, also runs in A.
    5. Restart only the app-server process and resume the same persisted thread with cwd: B: both the response and actual shell execution now use B.

    This appears consistent with the handling in resume_running_thread:

    https://github.com/openai/codex/blob/rust-v0.156.1/codex-rs/app-server/src/request_processors/thread_processor.rs#L4085-L4132

    When the requested resume overrides differ from the loaded thread config, the implementation can keep the existing loaded thread if a subscriber is still attached, and logs:

    thread/resume overrides ignored for loaded thread

    So at least at the app-server level, a cwd override can be ignored for an already-loaded subscribed thread, while the same persisted thread accepts the new cwd after the app-server is restarted and cold-resumed.

    Does Desktop Handoff update the live thread's execution environment through a separate path, or does it eventually rely on this resume path?

    If it uses thread/resume, checking the returned cwd / thread.cwd before updating the task UI may help detect this mismatch.

    I haven't verified which path the desktop app uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugsession

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions