Allow stored Codex threads to be associated with a project cwd after planning
Proposal
Please consider adding a supported way to update a stored Codex thread's project or workspace association after the thread has already been created. One small backend primitive for this would be allowing stored thread metadata updates to patch the thread cwd.
Motivation
A common workflow is to start with early planning in a standalone Codex conversation before the repository or project directory exists. After the project folder is created, the useful planning context can remain outside the project/workspace it now belongs to.
Today, the practical workaround is to ask Codex to generate context files and write them into the new repository. That helps, but it still leaves the original conversation detached from the workspace. A supported metadata update would make it possible for clients to build a more natural "attach", "move", or "promote this thread to a project" flow without touching local sqlite state directly.
Possible implementation direction
The thread model already persists cwd, and thread/list already supports cwd-based filtering. The existing thread/metadata/update method also patches sqlite-backed thread metadata for gitInfo.
One narrow approach would be to extend thread/metadata/update with an optional cwd field, resolve it consistently with existing cwd handling, and persist it through the existing thread metadata patch path.
Benefits
- Preserves planning context when a project is created after the initial conversation.
- Avoids direct client-side edits to local sqlite state.
- Gives Codex clients a small backend primitive for future UI workflows that attach or move a thread into a workspace.
- Keeps the behavior scoped to metadata rather than changing thread contents or replaying conversation history.
I understand that external code contributions are by invitation only. I am happy to keep this as a design discussion unless the Codex team thinks a small PR would be useful.
4 Comments
I prepared a small implementation branch to make the proposal concrete:
I attempted to open it as a draft PR against
openai/codex, but GitHub returned a permission error forCreatePullRequest. That is completely understandable given the contribution policy. I am leaving the branch here only as a reference implementation in case it is useful for the team while evaluating the proposal.Implementation summary:
cwdsupport tothread/metadata/update.StoreThreadMetadataPatchpath, which already supports cwd updates in the thread store.gitInfopatch semantics unchanged.cwdnorgitInfois provided.Validation on a clean worktree based on latest
origin/main(4ca60ef):cargo fmt --all -- --checkpassed. Rustfmt emitted the existingimports_granularity = Itemnightly-channel warning.cargo test -p codex-app-server --test all thread_metadata_updatepassed: 9 tests.cargo test -p codex-app-server-protocolpassed: 209 unit tests and 2 schema fixture tests.Thank you again for considering the workflow. I would be happy to adjust the proposal or follow whichever process is most helpful for the Codex team.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Thank you for the duplicate check.
I reviewed the suggested issues:
I also found #13836 and #20115, which seem to cover the broader product workflow around Projects, movable chats, shared project context, and archiving/attaching conversations to project folders.
This issue is meant to be narrower than the full product request: it documents one possible backend/protocol primitive,
thread/metadata/updatesupport forcwd, that could help implement future attach/move/promote flows without direct sqlite edits. I added a reference implementation branch in the earlier comment only to make that technical option concrete.If the maintainers prefer to keep all discussion consolidated under #13836 or #20115, I am happy to close this issue and continue there. Thank you again for taking a look.
Hi @Lee-take, I'm testing a local-first, read-only diagnostic tool (Codex Rescue Alpha5) against local session persistence and rollout anomalies. It evaluates schema compatibility, tool correlation, and state consistency without modifying the original rollout or SQLite databases.
If the affected session is still present locally, you can run:
No raw data is needed; please redact any private repository paths before sharing results.