Skip to content

Source control: settle threads and clean up worktrees when linked PRs merge #534

Description

@Tryanks

Summary

Use linked PR state for settling and worktree cleanup, once Settled and forge support exist.

Spec

  • Settle on merge / close (setting auto_settle_on_merge, default on): a thread whose latest-terminal linked PR was closed, or merged with the setting on, is auto-settled — only when the close/merge happened at or after the last user activity (so reopened work is not re-settled). Any visible linked PR that is open or not yet synced blocks auto-settle entirely, inactivity included. A merely open branch PR does not block inactivity settling. Before settling on a terminal PR, re-check the branch for a newly opened PR.
  • Worktree cleanup on merge (opt-in): remove a Tcode-managed worktree only when both the host reports the PR merged and git merge-base --is-ancestor HEAD origin/<default> succeeds after a fetch; refuse if the worktree is dirty, shared, has a live terminal, or is not Tcode-managed. Squash merges fail the ancestry check by design; the snapshot/keep-count lifecycle from Worktrees: host-owned ownership and an archive lifecycle (snapshot, transfer, keep-count) #530 still applies.
  • The settlement sweep reacts immediately to PR merge/close events.

Dependencies

#526, #532, #530.

Reference

T3 Code ThreadSettlementPolicy.ts (PR rules), #9528, #12161; apps/server/src/storageCleanup.ts (#11598).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions