Skip to content

fix(agent-manager): preserve worktree list scroll on deletion - #13429

Merged
marius-kilocode merged 3 commits into
mainfrom
investigate-worktree-scroll-reset
Aug 25, 2026
Merged

fix(agent-manager): preserve worktree list scroll on deletion#13429
marius-kilocode merged 3 commits into
mainfrom
investigate-worktree-scroll-reset

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Deleting a worktree from a long Agent Manager sidebar rebuilt the worktree rows from a complete state snapshot and reset the list to the top. This made repeated cleanup difficult because the selected position was lost after every deletion.

Why This Change Was Made

Agent Manager has different scroll owners in single-project and multi-project layouts. Preserve both containers before applying a state snapshot, restore their offsets after two animation frames, and cancel stale pending restores when another snapshot arrives. This keeps the fix scoped to the sidebar instead of changing project-state reconciliation.

User Impact

Worktree deletion keeps the current sidebar position in both supported layouts. Removed containers are ignored, and a shorter list naturally clamps to its new maximum scroll position.

Evidence

  • Reproduced the unfixed behavior in an isolated VS Code self-test: deleting a real worktree reset scrollTop from 174 to 0.
  • Verified the final fix with 26 real disposable worktrees: deleting one reduced the row count to 25 while scrollTop remained 320 before and after the deletion.
  • Added focused coverage for worktree and project scroll owners, rapid successive snapshots, and disconnected containers.
  • Passed extension compilation, typechecking, lint, Knip, the Kilo marker guard, and all 4,149 extension unit tests.

Comment thread packages/kilo-vscode/webview-ui/agent-manager/sidebar-scroll.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/kilo-vscode/tests/unit/agent-manager-sidebar-scroll.test.ts
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx
  • packages/kilo-vscode/webview-ui/agent-manager/sidebar-scroll.ts
Previous Review Summaries (2 snapshots, latest commit 71869fd)

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

Previous review (commit 71869fd)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/sidebar-scroll.ts 30 scrollTop === 0 still loses to delayed scrollIntoView
Files Reviewed (3 files)
  • packages/kilo-vscode/tests/unit/agent-manager-sidebar-scroll.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/sidebar-scroll.ts - 1 issue

Fix these issues in Kilo Cloud

Previous review (commit 5da8d6b)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/sidebar-scroll.ts 30 Two-frame restore can undo the sidebar's selection scrollIntoView
Files Reviewed (4 files)
  • .changeset/sidebar-scroll-preservation.md - 0 issues
  • packages/kilo-vscode/tests/unit/agent-manager-sidebar-scroll.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/sidebar-scroll.ts - 1 issue

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 59.2K · Output: 11.6K · Cached: 409.1K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 1aa18c1 into main Aug 25, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the investigate-worktree-scroll-reset branch August 25, 2026 16:05
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