codex icon indicating copy to clipboard operation
codex copied to clipboard

Support for multi-root workspaces

Open bscan opened this issue 1 year ago • 23 comments

What version of the VS Code extension are you using?

0.4.0

Which IDE are you using?

VS Code

What platform is your computer?

Linux 6.15.7-200.fc42.x86_64 x86_64 unknown

What steps can reproduce the bug?

When using a Multi-root Workspace, codex is unable to locate files in any folder other than the first. The image shows the extension is able to resolve the relative file paths (see the highlighted links to my_script), but codex does not see the file. If you grant Full Access to the Agent, it can sometimes navigate the file system and find the script, but that's a slow and unreliable mechanism considering the extension has already identified the correct file.

Image Image

What is the expected behavior?

The extension should submit the full path of the current active file instead of submitting a relative path that codex does not understand.

What do you see instead?

Codex is unable to find the active file.

Additional information

These are related: https://github.com/openai/codex/discussions/471 , https://github.com/openai/codex/issues/2797 and are discussing support for multiple folders. That is also a nice enhancement and would be needed for full multi-root workspace support. However, given that codex is currently limited to a single folder, it is a bug that the vscode extension is sending relative paths that codex does not understand.

bscan avatar Aug 29 '25 17:08 bscan

I think this is already added in the CLI. I'm not sure why it hasn't yet been added to the extension? Pls see this https://github.com/openai/codex/issues/2797

It would be so amazing to have that added to the extension!

Pengi123 avatar Dec 25 '25 16:12 Pengi123

Eagerly hoping the vscode plugin also supports --add-dir

tlerbao avatar Jan 13 '26 07:01 tlerbao

This is killing me trying to move to using Codex as my primary coding assistant agent. It works so great on my first project/root in my multi-root workspace. However, working with other projects/roots is very painful with worse results and constant lack of permission (it needs to keep asking me, despite autoApprove configuration of **/* which works as expected for the 1st root).

NateLangloisProscia avatar Jan 31 '26 00:01 NateLangloisProscia

This problem has troubled me for a long time, and I hope it can be resolved.

ribber avatar Mar 04 '26 13:03 ribber

still waiting ..

Achour avatar Mar 14 '26 22:03 Achour

This is such an important "feature" to be missing. Makes Codex unusable for those with multiple root folders. Other extensions like Copilot and Claude have no issues with this.

praemon avatar Apr 07 '26 07:04 praemon

Cursor support just added: https://cursor.com/changelog/04-24-26#multi-root-workspaces-in-agents-window

brandonbloom avatar Apr 25 '26 02:04 brandonbloom

This is currently the most upvoted open issue affecting the VS Code extension that causes broken behavior (e.g., incorrect paths, broken links, and approval request issues).

Given that this is a confirmed bug impacting core functionality for many users, would it make sense to add the "bug" label for better visibility and triage?

For reference: https://github.com/openai/codex/issues?q=is%3Aissue%20state%3Aopen%20sort%3Areactions-%2B1-desc%20label%3Aextension

bscan avatar Apr 28 '26 15:04 bscan

I had the exact same issue on Windows. Moved to claude code and it works like a charm. It's a very basic functionality and is a must have for many of us.

prateekr-dev avatar Jun 10 '26 00:06 prateekr-dev

Yes, this absolutely needs to be fixed. It makes no sense that Codex can only work in one of the folder in the workspace.

emiltin avatar Jun 11 '26 10:06 emiltin

asked codex about this bug:

Summary The VS Code extension handles multi-root UI links, but Codex receives paths relative to the first workspace root. Users report broken file lookup, broken links, and approval prompts for non-first roots. Comments confirm this affects Linux and Windows, and users specifically ask for --add-dir / multi-root support. Proposed Fix Make the VS Code extension send workspace-root information explicitly. In the extension, enumerate vscode.workspace.workspaceFolders. Use absolute folder.uri.fsPath values only. Pick cwd as:the workspace folder containing the active editor or referenced file; otherwise the first workspace folder.

Send all workspace folders to Codex:CLI / TypeScript SDK path: workingDirectory = cwd, additionalDirectories = allRootsExceptCwd. app-server v2 path: send cwd plus runtimeWorkspaceRoots = allRoots.

The backend already supports the required shape: TS SDK forwards additionalDirectories as repeated --add-dir: exec.ts (line 22), exec.ts (line 114) app-server v2 has thread/start.runtimeWorkspaceRoots: thread.rs (line 112) app-server v2 has turn/start.runtimeWorkspaceRoots: turn.rs (line 96) backend dedupes runtime roots: request_processors.rs (line 534) core already tests rebinding permission profiles to runtime workspace roots: session/tests.rs (line 2495) Extra Detail The extension should also rewrite editor/file mentions to absolute paths before placing them in the prompt context. Relative display labels are fine in the UI, but the payload to Codex needs either absolute paths or a root-qualified form that the backend can resolve. Tests Add VS Code extension tests for: two workspace folders, active file in second root; prompt references a file in second root; generated request includes all roots and cwd points at the containing root; Windows paths round-trip correctly; approval/auto-approve behavior works for files outside the first root. This is mainly an extension-side bug. The repo already has most backend/SDK machinery needed.

This suggest to me that this bug is in the wrong repository, and it should be in the vscode extension repository, that I haven't found yet 😅

flamein avatar Jun 15 '26 10:06 flamein

This suggest to me that this bug is in the wrong repository, and it should be in the vscode extension repository, that I haven't found yet 😅

I did not experience this bug with Claude.

emiltin avatar Jun 16 '26 05:06 emiltin

+1 for first-class Codex App support for multi-root workspaces.

My workflow often spans separate repos like frontend, backend, and shared libraries. CLI --add-dir / workspace_roots can grant access, but the App still feels centered on one project root per thread.

I’d love a reusable Codex App workspace with multiple roots where file search, @ mentions, diffs, Git actions, worktrees, and per-repo AGENTS.md context all work naturally across roots.

Main use case: one product change that updates an API, web client, shared types, and tests across multiple repos without splitting the work into separate Codex threads.

ShunnyBunny avatar Jun 26 '26 03:06 ShunnyBunny

As a workaround I place all repos in a folder which is then the only folder added to the workspace. It works well with Codex, but requires you to move repos around if you want a different workspace with some of the same repos, so it's hardly ideal.

emiltin avatar Jun 26 '26 07:06 emiltin

This suggest to me that this bug is in the wrong repository, and it should be in the vscode extension repository, that I haven't found yet 😅

I did not experience this bug with Claude.

Github copilot vscode extension also does not have this problem My point was that I don't think this codex repo has the source for the vscode-extension

flamein avatar Jun 29 '26 14:06 flamein

As a workaround I place all repos in a folder which is then the only folder added to the workspace. It works well with Codex, but requires you to move repos around if you want a different workspace with some of the same repos, so it's hardly ideal.

won't this absolutely blow up your IDE context, eating away your input tokens?

flamein avatar Jun 29 '26 14:06 flamein

As a workaround I place all repos in a folder which is then the only folder added to the workspace. It works well with Codex, but requires you to move repos around if you want a different workspace with some of the same repos, so it's hardly ideal.

won't this absolutely blow up your IDE context, eating away your input tokens?

It works for me, I have maybe 4-5 repos in the workspace. I don't think it would be different from have multiple repos in the workspace root.

emiltin avatar Jun 30 '26 06:06 emiltin

为什么还不支持

java668-real1 avatar Jul 24 '26 05:07 java668-real1

为什么还不支持

I think support was added today. But I have not tried it

ShunnyBunny avatar Jul 24 '26 05:07 ShunnyBunny

I tested, and I see that the codex team added support for multi-root workspace.

Pengi123 avatar Jul 24 '26 08:07 Pengi123