Skip to content

fix(agent-manager): keep latest project selection - #14675

Merged
marius-kilocode merged 2 commits into
mainfrom
repro-13963-worktree-switch
Sep 30, 2026
Merged

marius-kilocode merged 2 commits into
mainfrom
repro-13963-worktree-switch

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

When a project is loading, clicking it and then selecting a ready worktree in another project could end with the loading project selected anyway. The first click awaited project readiness, and when that work finished it activated its older target, overriding the newer selection.

This is a reproduced defect from the #13963 investigation. It is not the full original report.

Why This Change Was Made

activateSelection awaits deps.ready(ctx) before it commits the active project. A second, later click can complete during that await. The handler then committed the earlier target with no check for a newer request.

The fix records the newest selection token per deps object and drops a completion when a newer selection has started. It is five lines and does not change validation, routing, or persistence.

User Impact

The last sidebar selection wins. A slow project can no longer pull the UI back to an older click after the user has already moved on.

Evidence

  • Delayed readiness in isolated VS Code: before the fix the older project activated about 3 seconds after the newer click; after the fix the selected worktree and transcript stayed on the newer target.
  • Rapid switching across two projects still selects the final target.
  • bun test on the focused suites: 124 passed.
  • From packages/kilo-vscode/: bun run compile (typecheck, webview typecheck, lint, bundle) passed.

Scope

Races that need wider changes are not included: stale per-project session listings after movement or deletion, and session creation completing after a project switch. Both need ownership and route changes beyond a few lines.

A delayed project readiness completion could activate an older sidebar selection and override a newer click. Ignore a selection when a newer one has started.
@kilo-code-bot

kilo-code-bot Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/kilo-vscode/src/agent-manager/project/messages.ts
  • packages/kilo-vscode/tests/unit/agent-project-selection.test.ts
Previous Review Summary (commit 5b336a9)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 5b336a9)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-vscode/src/agent-manager/project/messages.ts 138 Selection token is set before the availability check, so a newer click on an unavailable project cancels an in-flight valid selection.
Files Reviewed (3 files)
  • .changeset/agent-manager-latest-selection.md - no issues
  • packages/kilo-vscode/src/agent-manager/project/messages.ts - 1 suggestion
  • packages/kilo-vscode/tests/unit/agent-project-selection.test.ts - no issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

Record the latest-selection token only for an actionable target so a click on an unavailable project cannot discard a pending valid selection.
@marius-kilocode
marius-kilocode merged commit 0fd0604 into main Sep 30, 2026
26 checks passed
@marius-kilocode
marius-kilocode deleted the repro-13963-worktree-switch branch September 30, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants