fix: share Codex task state across worktrees#492
Conversation
Rescue tasks launched from isolated worktrees now remain visible to the parent session, and unspecified rescue runs stay foreground so callers receive the final Codex output instead of an untracked background job.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ac71420c7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| export function resolveStateDir(cwd) { | ||
| const workspaceRoot = resolveWorkspaceRoot(cwd); | ||
| let canonicalWorkspaceRoot = workspaceRoot; | ||
| const repositoryIdentity = resolveRepositoryIdentity(workspaceRoot); |
There was a problem hiding this comment.
Cache repository identity lookups
When a task emits progress, paths like upsertJob/saveState and resolveJobFile reach resolveStateDir repeatedly, so this call now synchronously runs the Git identity lookup (including git worktree list) several times per state update. In foreground or background tasks with many progress events, those subprocesses block the Node process and can make status/log updates noticeably slow; compute the repository identity once per command or cache it per workspace/common-dir.
Useful? React with 👍 / 👎.
Summary
/codex:rescueforeground unless the user explicitly requests--background, preserving its stdout-forwarding contractCLAUDE_PLUGIN_DATATest plan
node --test tests/commands.test.mjs tests/state.test.mjsnpm run check-versiongit diff --check/codex:statusfrom the main worktreeKnown baseline issue
npm testretains three pre-existing failures intests/runtime.test.mjsthat also fail unchanged onorigin/main; they share state through the process environment during parallel execution. The affected new and command-contract tests pass independently.