Skip to content

feat(agent-manager): pin worktrees in the sidebar - #14891

Merged
marius-kilocode merged 3 commits into
mainfrom
allow-worktree-pinning-agent-manager
Oct 7, 2026
Merged

marius-kilocode merged 3 commits into
mainfrom
allow-worktree-pinning-agent-manager

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The Agent Manager sidebar lists every worktree and section. With many worktrees, the few that matter at a given moment are hard to keep in view. Their jump shortcuts also shift as worktrees are added or reordered.

Why This Change Was Made

Session tabs already support pinning with Shift+click. Worktrees had no equivalent. This adds a pinned flag to the worktree state and treats pinned worktrees as top-level sidebar items, above ungrouped worktrees and sections.

User Impact

  • Pin or unpin a worktree with Shift+click, the hover pin button, or Pin/Unpin in the right-click menu.
  • Pinned worktrees lead the sidebar and take the first jump shortcuts (⌘2, ⌘3, ...). They can be reordered inside the pinned block.
  • Pinned worktrees stay visible when their section is collapsed.
  • Pinning keeps the section. Unpinning returns the worktree to its section, and the hover card shows that section.
  • Moving a pinned worktree into a section (menu or drag) unpins it, so the move is visible.
  • Multi-version siblings pin together.
  • A pinned row replaces the hover delete button with an unpin button, so a stray click cannot delete it. Delete stays in the context menu.
  • The pin is stored in .kilo/agent-manager.json.

Evidence

From an isolated VS Code run against a fixture repo with 4 git worktrees and a "Backend" section.

Before, no pinned block:

Agent Manager sidebar before pinning

After, two pinned worktrees above the section:

Agent Manager sidebar with two pinned worktrees

Pin in the context menu:

Pin in the worktree context menu

Hover card on a pinned worktree showing its section:

Pinned worktree hover card with Section Backend

Manual checks: Shift+click on a section worktree pinned it without selecting it; the pin, order, and collapsed state survived two VS Code restarts; a collapsed section kept its pinned worktree visible; the hover unpin button returned the worktree to its section; the right-click move to a section unpinned it; a normal click still selected the worktree. Typecheck, lint, knip, and the focused unit tests pass.

Limitation: drag-and-drop ordering of pinned rows was not exercised in the UI, because the test harness cannot drag.

Allow pinning worktrees with Shift+click or the context menu. Pinned
worktrees lead the sidebar above ungrouped worktrees and sections, and
keep their section so unpinning returns them to it.
@kilo-code-bot

kilo-code-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The incremental commit 9d0ac627e1 ("fix(agent-manager): keep the pin on no-op section moves") resolves both prior suggestions: unpinForMove now leaves the pin intact on no-op section moves (current section / already-ungrouped), and memberCount keeps pinned members in the section header count.

Files Reviewed (1 file)
  • packages/kilo-vscode/webview-ui/agent-manager/ProjectSidebarBody.tsx - no new issues; 2 prior suggestions resolved
Previous Review Summaries (2 snapshots, latest commit c48bfc1)

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

Previous review (commit c48bfc1)

Status: 2 Issues Found | Recommendation: Address before merge

The incremental commit c48bfc1222 ("chore(agent-manager): format pin worktree changes") only reformats two files; no semantic changes and no new issues introduced. The two prior suggestions in ProjectSidebarBody.tsx remain unresolved.

Overview

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

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/ProjectSidebarBody.tsx 289 unpin runs on no-op section moves (current section / already-ungrouped), unexpectedly unpinning the worktree and its group
packages/kilo-vscode/webview-ui/agent-manager/ProjectSidebarBody.tsx 96 Section header count now excludes pinned members although they still belong to the section
Files Reviewed (3 files)
  • packages/kilo-vscode/tests/unit/section-helpers.test.ts - formatting only, no issues
  • packages/kilo-vscode/webview-ui/agent-manager/WorktreeItem.tsx - formatting only, no issues
  • packages/kilo-vscode/webview-ui/agent-manager/ProjectSidebarBody.tsx - 2 carried-forward suggestions (unchanged)

No memory leaks were introduced in this increment (no new listeners, timers, or subscriptions).

Fix these issues in Kilo Cloud

Previous review (commit ce9a04b)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

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

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/ProjectSidebarBody.tsx 289 unpin runs on no-op section moves (current section / already-ungrouped), unexpectedly unpinning the worktree and its group
packages/kilo-vscode/webview-ui/agent-manager/ProjectSidebarBody.tsx 96 Section header count now excludes pinned members although they still belong to the section
Files Reviewed (37 files)
  • .changeset/agent-manager-pin-worktrees.md - reviewed
  • packages/kilo-vscode/src/agent-manager/WorktreeStateManager.ts - reviewed (pin state, order normalization, persistence)
  • packages/kilo-vscode/src/agent-manager/project/state-gate.ts - reviewed
  • packages/kilo-vscode/src/agent-manager/section-handler.ts - reviewed
  • packages/kilo-vscode/src/agent-manager/types.ts - reviewed
  • packages/kilo-vscode/tests/unit/navigate.test.ts - reviewed
  • packages/kilo-vscode/tests/unit/section-helpers.test.ts - reviewed
  • packages/kilo-vscode/tests/unit/worktree-state-sections.test.ts - reviewed
  • packages/kilo-vscode/webview-ui/agent-manager/ProjectSidebarBody.tsx - 2 suggestions
  • packages/kilo-vscode/webview-ui/agent-manager/WorktreeItem.tsx - reviewed
  • packages/kilo-vscode/webview-ui/agent-manager/agent-manager.css - reviewed
  • 21 i18n dicts (agent-manager/i18n/*.ts) - reviewed (new keys consistent across all locales)
  • packages/kilo-vscode/webview-ui/agent-manager/navigate.ts - reviewed
  • packages/kilo-vscode/webview-ui/agent-manager/project-nav.ts - reviewed
  • packages/kilo-vscode/webview-ui/agent-manager/section-helpers.ts - reviewed
  • packages/kilo-vscode/webview-ui/src/types/messages/agent-manager.ts - reviewed
  • packages/kilo-vscode/webview-ui/src/types/messages/webview-messages.ts - reviewed

The core ordering/persistence logic is sound: top() keeps pinned section members in the top bucket, setNormalizedWorktreeOrder re-buckets correctly, the drag guard prevents cross-block reorders, and nav/shortcut ordering matches the rendered order. No memory leaks were introduced (no new listeners, timers, or subscriptions).

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 52.1K · Output: 7.9K · Cached: 427.6K

Review guidance: REVIEW.md from base branch main

@WebReflection WebReflection left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is sound but prettier is failing and there are 2 kilobot suggestions.

I let you decide what/how to address both, meanwhile you have my approval

Moving a pinned worktree to its current section, or to Ungrouped when it
is already ungrouped, no longer unpins it. The section count keeps
pinned members, because pinning does not remove a worktree from a
section.
@marius-kilocode
marius-kilocode merged commit 405cea9 into main Oct 7, 2026
26 checks passed
@marius-kilocode
marius-kilocode deleted the allow-worktree-pinning-agent-manager branch October 7, 2026 10:15
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