feat: delete worktrees when Linear issue moves to Done or Cancelled#980
Open
cyrusagent wants to merge 3 commits intocypack-910from
Open
feat: delete worktrees when Linear issue moves to Done or Cancelled#980cyrusagent wants to merge 3 commits intocypack-910from
cyrusagent wants to merge 3 commits intocypack-910from
Conversation
Add IssueStateChangeMessage type and isIssueStateChangeWebhook type guard to detect when Linear issues transition to completed/canceled states. Implement GitService.deleteWorktree() for single-repo and multi-repo layouts. Wire EdgeWorker to stop active sessions and clean up worktrees on state change. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The current branch still uses the Map<string, AgentSessionManager> pattern. The consolidation to a single instance happens on cypack-910 and will apply at merge time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assignee: @PaytonWebber (payton)
Summary
When a Linear issue transitions to "Done" or "Cancelled" state, automatically clean up associated worktrees. This replaces the previous external CYHOST-triggered cleanup flow, which no longer works with multi-repo sessions (CYPACK-910).
IssueStateChangeMessagetype andisIssueStateChangeWebhooktype guardGitService.deleteWorktree()supporting both single-repo and multi-repo layoutsEdgeWorkerto stop active sessions and delete worktrees when issues are completed/canceledImplementation
New message type (
packages/core)"issue_state_change"to theMessageActionunionIssueStateChangeMessageinterface withnewStateTypefieldLinearIssueStateChangePlatformDataplatform data typeisIssueStateChangeMessage()type guardWebhook detection (
packages/core)IssueStateChangeWebhooktype forIssue/updatewebhooks wherestateIdchanged inupdatedFromisIssueStateChangeWebhook()type guard — checked beforeisIssueTitleOrDescriptionUpdateWebhookto avoid conflictsMessage translation (
packages/linear-event-transport)translateIssueStateChange()toLinearMessageTranslatordata.state.type(e.g., "completed", "canceled")Worktree deletion (
packages/edge-worker)GitService.deleteWorktree(workspaceBaseDir, issueIdentifier):git worktree remove --forcefor each beforerm -rfEdgeWorker.handleIssueStateChangeMessage():completedandcanceledstatesEdge cases handled
Testing
isIssueStateChangeWebhook)Links