[Bug]: Completed subagents block their own parent's file revert#31865
Summary
A parent conversation in its own worktree cannot use Revert files too after its subagents finish. Completed child threads retain that same worktree path, and the restore-isolation check treats them as independent workspace owners. The error suggests another thread or side chat is sharing the workspace, even when the only other owners are the parent's completed delegated tasks.
Reproduction
- Start a parent conversation in a dedicated worktree.
- Delegate work or a review to a subagent using that worktree.
- Let the child and parent finish; leave the completed child in history.
- On an earlier parent message, choose Edit from here → Revert files too.
Actual: file restore is rejected with “File restore requires an isolated worktree.”
Expected proposal: completed subagent descendants that belong to the restoring parent and use its exact worktree should not independently block that parent. Unrelated chats, forks, active or queued children, pending requests, and background work must continue to block unsafe restoration.
Source-level evidence
On main at 291bcc39, CheckpointRestoreSafety.isCheckpointRestoreIsolated scans every nondeleted thread, including archived threads, and considers its worktree and checkpoint paths. It has an exception for idle side chats without tool activity, but no ownership exception for completed subagents.
A new synthetic regression calling the real helper reproduces this without provider credentials or user data:
- completed direct child: expected isolated=true, actual=false;
- completed grandchild: expected true, actual=false;
- archived completed child: expected true, actual=false.
The existing 10 restore-safety cases pass. With the regression matrix added and production code unchanged, 3 cases fail and 23 pass.
Proposed scope
Use strict subagent ancestry to the restoring thread, exact worktree equality, explicit completed status, and existing liveness checks. Do not infer ownership from a shared root id alone. Reject queued or unfinished runs even if the shell looks completed. Reuse the admission and execution safety checks and existing workspace lease.
This is separate from allowing arbitrary no-change restores in shared workspaces and separate from generic asynchronous rollback error wording.
Workaround
Revert and keep changes rewinds only the conversation.
Prepared with Codex in the Codex desktop app.