Skip to content

[Bug]: Deleting a thread's worktree while its session is "running" permanently wedges the thread (archive blocked, reaper never clears it) #4723

Description

@alexito4

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Start a thread and let its provider session reach status: "running" with an active turn, bound to a git worktree.
  2. Outside the app, delete that worktree's directory (e.g. it was removed by other tooling, or manually).
  3. The provider process/cwd for that thread is gone, but nothing updates the thread's session state.
  4. Try to archive the thread from the sidebar.

Expected behavior

The thread's session should eventually reflect that the underlying process/worktree is gone (e.g. via the idle/session reaper), or archiving should be possible once that's detected.

Actual behavior

The thread is permanently stuck. The client's archive guard (apps/web/src/hooks/useThreadActions.ts:158-172) refuses to archive any thread with session.status === "running" and a non-null activeTurnId. ProviderSessionReaper (apps/server/src/provider/Layers/ProviderSessionReaper.ts:59-67) unconditionally skips any thread with activeTurnId set, no matter how stale, so nothing ever clears it automatically.

Impact

Minor bug or occasional failure

Version or commit

main @ 4f584da

Workaround

Switch the thread to a different branch/worktree via the branch toolbar selector — this triggers thread.session.stop, which unconditionally sets status: "stopped", activeTurnId: null through the normal event path. Avoid using the regular Stop button first, since turn-interrupt uses allowRecovery: true and may try to restart the session in the missing worktree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions