You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Codex worktree context leaks across all worktrees (shared chats) #19647
bugSomething isn't workingextensionIssues related to the VS Code extensionsessionIssues involving session (thread) management, resuming, forking, naming, archiving
I’m seeing cross-thread context leakage in Codex across git worktrees. A single chat thread context appears shared across multiple worktrees instead of being isolated.
Steps to reproduce
On Linux/WSL, create multiple git worktrees for the same repo.
Open each worktree in VS Code and run/open Codex in each.
Start or open a Codex chat/thread in one worktree, then switch to another worktree.
In the second worktree, observe the visible Codex chat history/context.
Expected behavior
Each worktree should isolate Codex conversations, matching expected local-context behavior (or at minimum, clearly indicate thread/worktree ownership).
Actual behavior
Chats/threads from one worktree are visible in all worktrees; context bleeds across them.
Impact
This causes accidental context confusion and cross-task contamination during multi-worktree parallel work.
Environment
Date/time: 2026-04-26 (UTC+8)
Date for issue reproduction: 2026-04-26
OS: WSL2 Ubuntu on Windows
Client: VS Code Codex extension + local wtnew-managed git worktrees
Repo path: /home/jacob/outlandish/outlandish_web
Current worktrees: /home/jacob/outlandish/outlandish_web, plus multiple .worktrees/*
Repo setup has .vscode/settings.json, .worktree-ports, and symlinked shared node_modules/vendor in worktrees
Codex CLI version: 0.125.0-alpha.3
Codex path in shell: /home/jacob/.local/bin/codex
Additional details
This was reproducible while using stable Codex CLI shim + wtnew/wtopen flows.
/home/jacob/.zshenv contains a shim so codex resolves to /home/jacob/.local/bin/codex
Multiple worktrees are created and opened together through helper functions, then Codex UI shows cross-worktree thread visibility
I’m following the same machine/setup used to report issue #19647.
Observed command sequence:
# main repocd /home/jacob/outlandish/outlandish_web
# list worktrees
git worktree list
# open all worktrees in VS Codewtopen() { # existing helper in ~/.zshrc# ...
}
I open all worktrees from the helper, then Codex thread list/context in one worktree appears in others.
grep -n "wtnew\|wtopen"~/.zshrc
# confirm helper functions are available in this environment
Why this matters
Cross-worktree contamination happens during active parallel coding and can cause wrong-file or wrong-task assumptions in long sessions.
If helpful I can paste a short screen capture / HAR style log next, but at this stage behavior is deterministic and currently fully reproducible on this setup.
Codex Mac App Shows Sibling Git Worktrees as Separate Projects but Assigns Chats to the Wrong Worktree
Product
Codex Mac app / desktop app (Version 26.623.141536 • Released Jul 7, 2026)
Environment
Machine: remote machine (Linux)
OS: macOS client using Codex app connected to remote machine
Repo location: /path/to/repo/main
Git setup: main checkout plus sibling Git worktrees
Summary
The Codex app correctly discovers and displays my sibling Git worktrees as separate projects in the sidebar, but chat/session history is not isolated per worktree.
Chats from multiple worktree projects appear to be grouped under one worktree project, while the other worktree projects show "No chats".
This makes it difficult to use Codex with multiple parallel worktrees because sessions are shown under the wrong project.
These are sibling directories, not nested worktrees.
Observed Behavior
In the Codex app sidebar, the projects are listed separately:
main.worktree-a
main.worktree-b
main.worktree-c
main
However:
main appears to maintain its own sessions correctly.
main.worktree-a shows multiple chats.
main.worktree-b shows "No chats".
main.worktree-c shows "No chats".
Sessions created or expected under the other worktrees appear to be associated incorrectly, seemingly under main.worktree-a.
Expected Behavior
Each worktree project should have independent chat/session history keyed by its worktree root path.
For example:
/path/to/repo/main.worktree-a -> chats for main.worktree-a only
/path/to/repo/main.worktree-b -> chats for main.worktree-b only
/path/to/repo/main.worktree-c -> chats for main.worktree-c only
/path/to/repo/main -> chats for main only
This is normal Git worktree behavior: sibling worktrees have distinct working tree roots but share the main repo's Git common directory.
Suspected Cause
The Codex app appears to use different identity logic for project discovery versus session/history association.
Project discovery seems path-aware, since the app displays each sibling worktree separately. But chat/session history appears to be keyed by shared Git metadata, such as:
git rev-parse --git-common-dir
or another canonical repository identity, instead of the worktree root from:
git rev-parse --show-toplevel
Because all sibling worktrees share /path/to/repo/main/.git, their chats may be getting grouped under one worktree project.
Impact
This breaks a common Git workflow where multiple worktrees are used for parallel feature work, investigations, or offloaded Codex tasks.
The app sidebar becomes unreliable because chats are shown under the wrong worktree or missing from the project where they were created.
Requested Fix
Please key Codex app project chat/session history by the worktree root path, for example:
It locally patches the installed openai.chatgpt extension so Webview-originated thread/list requests include the active vscode.workspace.workspaceFolders paths. Because matching is based on exact saved cwd, separate Git worktree roots can be shown as separate task histories when each worktree is opened as its own VS Code workspace.
Apply it without a global install:
npx -y codex-vscode-project-patch
Restore the official file:
npx -y codex-vscode-project-patch restore
This is only a temporary UI/history mitigation, not a fix for the context-leakage bug reported here. It does not change session ownership, rebind an active thread, enforce filesystem/tool boundaries, or prevent manually resuming a thread from another worktree. Its value is limited to reducing cross-worktree history noise and the chance of selecting the wrong thread.
The CLI uses a strict extension-version and bundle-hash allowlist, creates a verified backup, validates the patched JavaScript, and refuses unknown builds. It modifies the existing local installation and does not redistribute the official VSIX. An upstream fix still needs explicit thread/worktree ownership and safe resume behavior.
bugSomething isn't workingextensionIssues related to the VS Code extensionsessionIssues involving session (thread) management, resuming, forking, naming, archiving
Activity
jacobcoro commentedon Apr 26, 2026
Repro details (extra)
I’m following the same machine/setup used to report issue #19647.
Observed command sequence:
I open all worktrees from the helper, then Codex thread list/context in one worktree appears in others.
Shell state used for Codex
Why this matters
Cross-worktree contamination happens during active parallel coding and can cause wrong-file or wrong-task assumptions in long sessions.
If helpful I can paste a short screen capture / HAR style log next, but at this stage behavior is deterministic and currently fully reproducible on this setup.
Mine77 commentedon May 23, 2026
same
Abhishek1103 commentedon Jul 14, 2026
Codex Mac App Shows Sibling Git Worktrees as Separate Projects but Assigns Chats to the Wrong Worktree
Product
Codex Mac app / desktop app (Version 26.623.141536 • Released Jul 7, 2026)
Environment
/path/to/repo/mainSummary
The Codex app correctly discovers and displays my sibling Git worktrees as separate projects in the sidebar, but chat/session history is not isolated per worktree.
Chats from multiple worktree projects appear to be grouped under one worktree project, while the other worktree projects show "No chats".
This makes it difficult to use Codex with multiple parallel worktrees because sessions are shown under the wrong project.
Repository Layout
These are sibling directories, not nested worktrees.
Observed Behavior
In the Codex app sidebar, the projects are listed separately:
However:
mainappears to maintain its own sessions correctly.main.worktree-ashows multiple chats.main.worktree-bshows "No chats".main.worktree-cshows "No chats".main.worktree-a.Expected Behavior
Each worktree project should have independent chat/session history keyed by its worktree root path.
For example:
Git Diagnostics
For one affected worktree:
Output:
Command:
Output:
This is normal Git worktree behavior: sibling worktrees have distinct working tree roots but share the main repo's Git common directory.
Suspected Cause
The Codex app appears to use different identity logic for project discovery versus session/history association.
Project discovery seems path-aware, since the app displays each sibling worktree separately. But chat/session history appears to be keyed by shared Git metadata, such as:
or another canonical repository identity, instead of the worktree root from:
Because all sibling worktrees share
/path/to/repo/main/.git, their chats may be getting grouped under one worktree project.Impact
This breaks a common Git workflow where multiple worktrees are used for parallel feature work, investigations, or offloaded Codex tasks.
The app sidebar becomes unreliable because chats are shown under the wrong worktree or missing from the project where they were created.
Requested Fix
Please key Codex app project chat/session history by the worktree root path, for example:
rather than by shared Git common directory:
or any other shared repository identity.
cixiangtao commentedon Aug 17, 2026
For the shared-history / accidental-selection part of this worktree issue, I maintain a small unofficial workaround:
https://github.com/cixiangtao/codex-vscode-project-patch
It locally patches the installed
openai.chatgptextension so Webview-originatedthread/listrequests include the activevscode.workspace.workspaceFolderspaths. Because matching is based on exact savedcwd, separate Git worktree roots can be shown as separate task histories when each worktree is opened as its own VS Code workspace.Apply it without a global install:
Restore the official file:
This is only a temporary UI/history mitigation, not a fix for the context-leakage bug reported here. It does not change session ownership, rebind an active thread, enforce filesystem/tool boundaries, or prevent manually resuming a thread from another worktree. Its value is limited to reducing cross-worktree history noise and the chance of selecting the wrong thread.
The CLI uses a strict extension-version and bundle-hash allowlist, creates a verified backup, validates the patched JavaScript, and refuses unknown builds. It modifies the existing local installation and does not redistribute the official VSIX. An upstream fix still needs explicit thread/worktree ownership and safe resume behavior.