What version of the Codex App are you using (From "About Codex" dialog)?
26.422.30944 (build 2080)
Codex CLI: codex-cli 0.125.0
What subscription do you have?
ChatGPT Pro / Team / Enterprise
What platform is your computer?
Darwin 25.4.0 x86_64 i386
What issue are you seeing?
I am seeing a possible bug or unclear behavior with Codex Desktop local environment cleanup scripts.
I configured a Codex Desktop local environment with both setup and cleanup scripts. The setup script creates per-worktree resources, and the cleanup script is supposed to remove them.
After archiving the associated Codex-managed worktree thread, the cleanup script did not run. The worktree also remained on disk and was still listed by Git.
In my real case, the setup script created:
- a generated per-worktree test database
- a per-worktree port registry entry
- a generated ignored config file inside the worktree
After archiving the thread, I verified:
worktree path: <HOME>/.codex/worktrees/4a21/2270-YoDa
dir_exists=yes
git_worktree_listed=yes
generated_test_db_exists=yes
port_registry_entry_still_exists=yes
What steps can reproduce the bug?
Uploaded thread: 019dbff7-c97d-7511-9af5-1cee07dd1ab2
Steps:
-
Create a Codex Desktop local environment for a repo.
-
Add a setup script that creates per-worktree resources. In my case, the setup script:
- generated
config/application.yml inside the worktree
- assigned a per-worktree Rails port
- created a per-worktree test database
- wrote the assigned port to a local registry file
-
Add a cleanup script that removes those resources. In my case, the cleanup script:
- removes the worktree entry from the port registry
- drops the generated per-worktree test database
-
Start a new Codex thread using a Codex-managed worktree and this local environment.
-
Confirm the setup script ran successfully.
-
Archive the associated Codex thread from the Codex Desktop UI.
-
Check whether the cleanup script ran.
Actual result after archive:
worktree path: <HOME>/.codex/worktrees/4a21/2270-YoDa
dir_exists=yes
git_worktree_listed=yes
generated_test_db_exists=yes
port_registry_entry_still_exists=yes
The thread was archived, but the worktree remained and the cleanup script did not run.
What is the expected behavior?
When a Codex-managed worktree thread is archived, I expected Codex to either:
- Delete the associated worktree and run the configured local environment cleanup script.
Or:
- Clearly indicate that cleanup is delayed and explain when the cleanup script will actually run.
The current behavior is confusing because the Worktrees docs say Codex-managed worktrees are deleted automatically when the associated thread is archived, but in this case the worktree and generated resources remained.
Expected cleanup result:
- worktree deleted or marked clearly as pending deletion
- cleanup script executed
- generated test database removed
- port registry entry removed
Additional information
I searched existing issues and did not find an exact duplicate for local environment cleanup scripts not running after archiving a Codex-managed worktree.
Potentially related lifecycle/cleanup issues:
This issue seems distinct because it is specifically about the expected behavior of the configured local environment cleanup script when the associated Codex-managed worktree thread is archived.
What version of the Codex App are you using (From "About Codex" dialog)?
26.422.30944 (build 2080)
Codex CLI: codex-cli 0.125.0
What subscription do you have?
ChatGPT Pro / Team / Enterprise
What platform is your computer?
Darwin 25.4.0 x86_64 i386
What issue are you seeing?
I am seeing a possible bug or unclear behavior with Codex Desktop local environment cleanup scripts.
I configured a Codex Desktop local environment with both setup and cleanup scripts. The setup script creates per-worktree resources, and the cleanup script is supposed to remove them.
After archiving the associated Codex-managed worktree thread, the cleanup script did not run. The worktree also remained on disk and was still listed by Git.
In my real case, the setup script created:
After archiving the thread, I verified:
What steps can reproduce the bug?
Uploaded thread:
019dbff7-c97d-7511-9af5-1cee07dd1ab2Steps:
Create a Codex Desktop local environment for a repo.
Add a setup script that creates per-worktree resources. In my case, the setup script:
config/application.ymlinside the worktreeAdd a cleanup script that removes those resources. In my case, the cleanup script:
Start a new Codex thread using a Codex-managed worktree and this local environment.
Confirm the setup script ran successfully.
Archive the associated Codex thread from the Codex Desktop UI.
Check whether the cleanup script ran.
Actual result after archive:
The thread was archived, but the worktree remained and the cleanup script did not run.
What is the expected behavior?
When a Codex-managed worktree thread is archived, I expected Codex to either:
Or:
The current behavior is confusing because the Worktrees docs say Codex-managed worktrees are deleted automatically when the associated thread is archived, but in this case the worktree and generated resources remained.
Expected cleanup result:
Additional information
I searched existing issues and did not find an exact duplicate for local environment cleanup scripts not running after archiving a Codex-managed worktree.
Potentially related lifecycle/cleanup issues:
This issue seems distinct because it is specifically about the expected behavior of the configured local environment cleanup script when the associated Codex-managed worktree thread is archived.