ADE-91: Lane lifecycle operations crash active CLI sessions and chats#505
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
@copilot review but do not make fixes |
📝 WalkthroughWalkthroughThis PR adds chat session teardown during lane deletion by introducing service-level counting and disposal helpers, integrating them into the lane-deletion workflow with a new progress step, extending UI components to report active chats, and preventing draft-launch duplicates. Changes span shared types, service implementations, dependency wiring, UI components, CLI display, and comprehensive test coverage. ChangesChat session teardown and deletion flow
Draft launch duplicate prevention
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
7a7d68d to
d30291f
Compare
Fixes ADE-91
Summary
Describe the change.
What Changed
Key files and behaviors.
Validation
How you tested.
Risks
Anything to watch.
Linked Linear issues
Summary by CodeRabbit
New Features
Bug Fixes
Greptile Summary
This PR closes ADE-91 by adding chat session lifecycle management to the lane deletion pipeline. When a lane is deleted, active chat sessions belonging to that lane (or routing execution through it) are now identified, warned about in the preflight UI, and closed during teardown.
stop_chatsstep (with{ fatal: false }) is injected betweenstop_processesandstop_ptys;claude_sessionsand their associatedsession_linear_issuesrows are also cleaned up in the DB teardown.LaneDeleteRiskgainsactiveChatCount, surfaced with aChatCircleicon inManageLaneDialogand in the CLIformatLaneDeleteRiskformatter.AgentChatPanegains adraftLaunchInFlightKeysRefset to suppress duplicate auto-create background submits while a lane-naming round-trip is still in flight.Confidence Score: 4/5
Safe to merge with one fix: the error-accounting bug in disposeForLane causes misleading warning messages when a session is successfully force-closed after a failed graceful close.
The teardown pipeline and DB cleanup are well-structured and the non-fatal guard ensures deletion always completes. The one defect is in agentChatService.disposeForLane: when dispose() fails but forceDisposeManagedSession() succeeds, the original error is still pushed to errors and the function throws — reporting a failure for sessions that were actually cleaned up. When both paths fail, two strings are pushed for one session, so the count in the thrown message is off. Everything else in the PR — the stop_chats step ordering, the DB delete ordering, the duplicate-submit guard, and the preflight UI — looks correct.
apps/desktop/src/main/services/chat/agentChatService.ts — specifically the error-accumulation logic in disposeForLane
Important Files Changed
Sequence Diagram
sequenceDiagram participant UI as UI / CLI participant LS as laneService.delete() participant ACS as agentChatService participant DB as SQLite UI->>LS: getDeleteRisk(laneId) LS->>ACS: countActiveForLane(laneId) ACS-->>LS: activeChatCount LS-->>UI: "LaneDeleteRisk { activeChatCount, ... }" UI->>LS: delete(laneId) LS->>LS: runStep(cancel_auto_rebase) LS->>LS: runStep(stop_processes) LS->>ACS: "runStep(stop_chats) [fatal=false]" ACS->>ACS: disposeForLane(laneId) alt dispose succeeds ACS-->>LS: disposed count else dispose fails then forceDispose ACS->>ACS: forceDisposeManagedSession() ACS-->>LS: warning (non-fatal) end LS->>LS: runStep(stop_ptys) LS->>LS: runStep(stop_watchers) LS->>LS: runStep(git_worktree_remove) LS->>DB: DELETE claude_sessions WHERE lane_id LS->>DB: DELETE session_linear_issues (lane + sessions) LS->>DB: DELETE terminal_sessions WHERE lane_id LS->>DB: DELETE lanes WHERE id LS-->>UI: completed / completed_with_warningsPrompt To Fix All With AI
Reviews (2): Last reviewed commit: "Address lane delete chat teardown review" | Re-trigger Greptile