Skip to content

Add remote --cd forwarding for app-server sessions#16700

Merged
etraut-openai merged 2 commits intomainfrom
etraut/implement-remote-cd
Apr 3, 2026
Merged

Add remote --cd forwarding for app-server sessions#16700
etraut-openai merged 2 commits intomainfrom
etraut/implement-remote-cd

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Apr 3, 2026

Addresses #16124

Problem: codex --remote --cd <path> canonicalized the path locally and then omitted it from remote thread lifecycle requests, so remote-only working directories failed or were ignored.

Solution: Keep remote startup on the local cwd, forward explicit --cd values verbatim to thread/start, thread/resume, and thread/fork, and cover the behavior with codex-tui tests.

Testing: I manually tested --remote --cd with both absolute and relative paths and validated correct behavior.


Update based on code review feedback:

Problem: Remote --cd was forwarded to thread/resume and thread/fork, but not to thread/list lookups, so --resume --last and picker flows could select a session from the wrong cwd; relative cwd filters also failed against stored absolute paths.

Solution: Apply explicit remote --cd to thread/list lookups for --last and picker flows, normalize relative cwd filters on the app-server before exact matching, and document/test the behavior.

@fcoury-oai
Copy link
Copy Markdown
Contributor

From a local Codex review:

  1. You have one remote app-server hosting multiple repos, for example /srv/repo-a and /srv/repo-b.
  2. Yesterday you worked in /srv/repo-a, and that’s currently the most recently updated thread overall.
  3. Today you run:

codex --remote ws://host:3000 --cd /srv/repo-b --resume --last

  1. What you expect: Codex resumes the latest thread whose working directory is /srv/repo-b.
  2. What can happen with this PR as written: the “find latest thread” lookup still ignores --cd in remote mode, so it may pick the latest / srv/repo-a thread instead. Then the new --cd /srv/repo-b override gets sent to thread/resume for that /srv/repo-a thread.

So the user-visible symptom would be: “I asked to resume my latest session in repo B, but Codex opened some other conversation from repo A, possibly now running it in repo B’s directory.”

That’s risky because it’s not just a confusing selection bug: the resumed conversation’s context and the working directory can now be mismatched, which could lead the agent to edit the wrong checkout or interpret prior discussion against the wrong repo.

@etraut-openai
Copy link
Copy Markdown
Collaborator Author

Good catch. That's inconsistent with the local --cd --resume --last behavior. Local resume uses the explicit --cd as the latest-session lookup filter before selecting the thread, but remote lookup still drops cwd and then applies the override only at thread/resume, which can mismatch conversation context and working tree. I'll work on a fix that matches the local behavior.

@etraut-openai
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@etraut-openai etraut-openai merged commit 0ab8eda into main Apr 3, 2026
22 checks passed
@etraut-openai etraut-openai deleted the etraut/implement-remote-cd branch April 3, 2026 18:26
@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants