fix(vscode): stop moved active sessions - #11404
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Incremental review (commit The change extracts the abort-tracking state and logic out of Behavioral equivalence verified across all paths:
Lifecycle/leak surface is unchanged or smaller: per-session pruning in Previous Review Summaries (2 snapshots, latest commit d43df06)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit d43df06)Status: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Incremental review (commit
Previous review (commit f35d9c5)Status: No Issues Found | Recommendation: Merge Files Reviewed (6 files)
Notes:
Reviewed by glm-5.2 · 574,796 tokens Review guidance: REVIEW.md from base branch |
fix(vscode): stop moved active sessions
Agent Manager can change the directory associated with a session while that session is already running. The backend does not move the active runner when this happens: runners are isolated by directory, so a turn started under
/reporemains owned by the/repoinstance even after Agent Manager maps the same session ID to/repo/.kilo/worktrees/foo.Stop was sending
session.abortonly to the session's current mapped directory. In the example above, it asked the worktree instance to abort a runner that still belonged to the repository instance. The abort endpoint treats an absent runner as a successful no-op, so the request appeared successful while the original response continued and the UI remained in its Stop state. Remote mode can make the timing more visible, but it is not the cause.Regression history
PR #11152 contains two overlapping cancellation fixes:
a09dafe61bfirst added directory-aware ownership tracking, aborted both the active owner and current mapped directory, and added moved-session regression coverage.b23d3dfd75then added the separate ability to abort prompts during session startup. While replacing the samehandleAbortand status-management path, it unintentionally restored single-directory cancellation and removed the moved-session coverage.The final version of #11152 therefore retained its intended startup-cancellation behavior but lost the protection for already-running sessions that are reassigned between the local workspace and a worktree.
Durable behavior
This change combines both requirements rather than reverting #11152. An instance-scoped abort helper records directories that report a non-idle session and preserves the current owner before Agent Manager changes the session mapping. Stop asks every known owner plus the current mapped directory to abort, attempts all requests even if one fails, and returns the webview to Send only after all known-owner aborts succeed. Session deletion, provider disposal, idle events, and backend-instance disposal clear the corresponding ownership state.
The ownership and multi-directory orchestration live outside
KiloProvider; the provider only forwards lifecycle signals and reconciles the successful Stop state.