Skip to content

refactor(vscode): remove dead code from Agent Manager - #12594

Merged
marius-kilocode merged 1 commit into
mainfrom
agent-manager-dead-code
Jul 28, 2026
Merged

refactor(vscode): remove dead code from Agent Manager#12594
marius-kilocode merged 1 commit into
mainfrom
agent-manager-dead-code

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

Static analysis (tsc unused-locals sweep + protocol message flow tracing) surfaced several Agent Manager code paths that are unreachable in production. This PR deletes them, net -316 lines.

Dead message flows (never travel the wire):

  • agentManager.externalWorktrees: the extension posted it, but the webview has no handler. The webview also never sends requestExternalWorktrees, importExternalWorktree, or importAllExternalWorktrees, so the whole flow is dead: provider handlers, WorktreeImporter.external()/path()/all(), WorktreeManager.listExternalWorktrees(), ExternalWorktreeItem/ExternalWorktreeInfo, and the matching message type definitions on both sides of the protocol. Branch/PR import (importFromBranch/importFromPR) is untouched.
  • agentManager.sessionMeta: posted after worktree creation but never handled in the webview. The worktreeSetup ready message already carries everything the webview consumes.

Dead interface surface:

  • Host.serverPort(): no callers (the panel gets the port through buildWebviewHtml directly).
  • SessionTerminalManager.hasTerminal()/hasActiveTerminal() and SetupScriptService.getScript(): no callers and no behavior tests.
  • Unused imports (Disposable, ExtensionMessage, Popover) and an unused derivedFallbackBranches parameter.

Arch tests that asserted on the removed structure were updated to match.

Remove code paths that are unreachable in production:

- External-worktrees message flow: the webview never sends
  requestExternalWorktrees, importExternalWorktree, or
  importAllExternalWorktrees, and never handles the externalWorktrees
  response. Drop the provider handlers, WorktreeImporter.external()/
  path()/all(), WorktreeManager.listExternalWorktrees(), and the
  matching message types on both sides of the protocol.
- agentManager.sessionMeta: posted by the extension after worktree
  creation but never handled in the webview.
- Host.serverPort(): interface member with no callers.
- Unused imports (Disposable, ExtensionMessage, Popover), an unused
  derivedFallbackBranches parameter, and two methods with no callers
  or tests (SessionTerminalManager.hasTerminal/hasActiveTerminal,
  SetupScriptService.getScript).

Net -316 lines. Typecheck, lint, knip, and unit tests pass.
@marius-kilocode
marius-kilocode enabled auto-merge (squash) July 28, 2026 11:28
@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Verified via grep that all removed symbols (ExternalWorktreeItem/ExternalWorktreeInfo, agentManager.externalWorktrees/sessionMeta/requestExternalWorktrees/importExternalWorktree/importAllExternalWorktrees, listExternalWorktrees, WorktreeImporter.external()/path()/all(), Host.serverPort(), SessionTerminalManager.hasTerminal()/hasActiveTerminal(), SetupScriptService.getScript()) have no remaining references anywhere in packages/kilo-vscode. Arch/unit tests were updated to match the removed code paths. No changeset needed since this is a pure internal dead-code removal with no user-facing behavior change.

Files Reviewed (15 files)
  • packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts
  • packages/kilo-vscode/src/agent-manager/SessionTerminalManager.ts
  • packages/kilo-vscode/src/agent-manager/SetupScriptService.ts
  • packages/kilo-vscode/src/agent-manager/WorktreeManager.ts
  • packages/kilo-vscode/src/agent-manager/__tests__/AgentManagerProvider.spec.ts
  • packages/kilo-vscode/src/agent-manager/host.ts
  • packages/kilo-vscode/src/agent-manager/types.ts
  • packages/kilo-vscode/src/agent-manager/vscode-host.ts
  • packages/kilo-vscode/src/agent-manager/worktree-importer.ts
  • packages/kilo-vscode/tests/unit/agent-manager-arch.test.ts
  • packages/kilo-vscode/tests/unit/session-terminal-manager.test.ts
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx
  • packages/kilo-vscode/webview-ui/src/types/messages/agent-manager.ts
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts
  • packages/kilo-vscode/webview-ui/src/types/messages/webview-messages.ts

Reviewed by claude-sonnet-5 · Input: 34 · Output: 7.2K · Cached: 848.8K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit d80aeac into main Jul 28, 2026
22 checks passed
@marius-kilocode
marius-kilocode deleted the agent-manager-dead-code branch July 28, 2026 12:15
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
Remove code paths that are unreachable in production:

- External-worktrees message flow: the webview never sends
  requestExternalWorktrees, importExternalWorktree, or
  importAllExternalWorktrees, and never handles the externalWorktrees
  response. Drop the provider handlers, WorktreeImporter.external()/
  path()/all(), WorktreeManager.listExternalWorktrees(), and the
  matching message types on both sides of the protocol.
- agentManager.sessionMeta: posted by the extension after worktree
  creation but never handled in the webview.
- Host.serverPort(): interface member with no callers.
- Unused imports (Disposable, ExtensionMessage, Popover), an unused
  derivedFallbackBranches parameter, and two methods with no callers
  or tests (SessionTerminalManager.hasTerminal/hasActiveTerminal,
  SetupScriptService.getScript).

Net -316 lines. Typecheck, lint, knip, and unit tests pass.
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