Repository navigation
feat(vscode): port the agent manager to v2 - #15737
Conversation
Work log across the sessions in this worktreeThis branch was built by several sessions working in the same worktree. This comment records what each one changed and verified, so the work is traceable in one place. Port, seam and integration (main session)
Composer parity (requested during the port)
Buttons and tooltips session
Shortcuts and permissions session
Terminal session
Merge and checks (this session)
The open items from the audit are listed in the PR description and in |
|
📈 v2 migration progress: 9.3% → 14.6% (+515 done, 0 total, 0 dropped; 1432/9810 cells) Placement: 36 new marked lines in shared files (20 seam, 16 patch), 1 new Ratchets: 30 core-internal imports (base 30); shared patches by rung 47 seam, 33 patch (base 42 seam, 32 patch).
515 cells closed
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Reporting audit: complete session inventoryI re-read every session in this worktree and compared their results with the PR description. The description now includes the complete audit. Below is the full session inventory and the corrections I made. Sessions in this worktree
The complete file-level audit is committed at What the description was missing and now includes
Corrected self-test claims
No code changed for this update; it is a reporting correction only. |
Audit deltas not in the descriptionThe description already carries the full audit summary. Four items from the eight read-only audits are missing there.
|
- reuse the shared keybinding helpers instead of two copied modules - replace the Effect catch-and-fail with mapError - declare happy-dom for the review tests - add startup budgets for the two new plugins - derive canonical paths and ids in the project tests for Windows - normalize CRLF in the source-text test - replay an exited script PTY so its tab shows the output - register three reviewed duplication exceptions
Blocker B6: PR polling never learns the active worktreeSymptom. With no active worktree, every 15 s PR poll found no target and returned. PR data refreshed only on the 120 s full sync, and switching worktrees did not trigger a fetch, so badges, checks and review state stayed stale up to 8x longer than in v1. Cause. v1 set the poller target on Fix. Files.
Before. A visible worktree session left After. The test covers: a worktree session sets the target and fetches it immediately, switching to another worktree fetches the new one, and local, unknown and null sessions clear the target. Commands and results.
No live self-test was run for this change; the unit test above covers the behavior. |
B4: review comment sends are duplicated or droppedSymptom
Cause
Fix
Files
Before evidenceReproduction with the pre-fix callback bodies from The remote reply path at The new contract test failed before the fix: After evidenceSame flow with the fixed dispatcher and consumers: Remote reply assertion in the new test: New test, from Related suites, from Checks: The package Live result (isolated VS Code, session am-fix-b4)The shared build was taken, Targeted send ( Untargeted send (one dispatch): Second targeted send: No Agent Manager webview console errors; the only console errors were VS Code The live driver was a dispatched |
B2:
|
Blocker B5: auto-approve covered only the selected directory storeSymptom. With the shield on, a pending permission in a worktree the panel is not showing stays blocked, so a background agent hangs until the user opens that tab. It also stalls with the panel closed entirely, because the sweep lived in a webview. Cause. The toggle is one persisted global state ( Fix: the extension host is now the single owner.
Files.
Before evidence. The earlier webview-only attempt also failed its own case in the same scenario: After evidence.
Remaining risks.
|
B1: project session catalog restoredSymptom. The v2 host never posted Cause. The v2 port dropped the catalog on both sides. Fix and files
Before evidence
After evidence
Review pass
Commands
Risk. The catalog is a fresh listing per push, so a session created by a path that emits neither |
B8: Agent Manager settings were unreachable from the project gearSymptom. Opening the Agent Manager project gear landed on the Settings panel's Models tab. The rail had no Agent Manager entry, so automatic branch naming, branch prefix, worktree pre-warm, the project picker, default base branch, setup script and push fixes could not be edited from the gear. The Display tab also had no shortcut hints row. Cause. Two gaps.
Fix.
Files.
No Before evidence.
After evidence.
Commands and results.
Remaining risks.
|
B7: intro dismissal breaks the Agent Manager empty stateSymptomAfter dismissing the Agent Manager intro, the empty session showed only a "How Agent Manager works" button. The shared welcome, the recent sessions list, Show History and the keyboard shortcut hints were missing. Cause
Fix
The reopen action still works: it reveals the intro and persists the dismissed flag as before. Files
Before evidenceIsolated VS Code, own session No welcome sentence, no After evidenceSame flow on the rebuilt dist from HEAD The screenshot shows the Kilo logo, the welcome text, the RECENT row with Clicking "How Agent Manager works" restored the introduction. Snapshot after the click contains: No Agent Manager webview console errors after the fix. The applied and restricted states were not edited and render through the same unchanged branches. Commands and results
No commit, push, checkout, reset or stash was run for this fix. |
The Agent Manager inspector releases a subagent when its tab closes. session.evict clears the root and every descendant, which would blank the parent transcript, so add a per-session message evict and use it.
# Conflicts: # packages/kilo-cli/startup-budget.json # packages/kilo-plugin/src/index.ts # packages/kilo-plugin/test/index.test.ts
WebReflection
left a comment
There was a problem hiding this comment.
unless you want to wait forever, even my automated bot failed at this (probably context related) but kilobot is OK and I trust you, after so many iterations, things are safe and sound in here for v2.
What Problem This Solves
The Kilo v2 VS Code extension has no Agent Manager. The v1 Agent Manager is a large feature (334 source files on
main: 137 host files and 197 webview files) that runs worktrees, parallel model runs, sections, tabs, terminals, diff and review, GitHub PR actions, multiple projects and orchestration tools.This PR ports it to v2, keeping v1 behavior for every in-scope flow. The one structural change is the boundary: v1 talked to the server through its own session plumbing, and v2 talks through
manager(), one client, one event stream fanned out bylocation.directory, and per-directorycreateDatastores.The panel is a second webview entry in the extension, so the extension, not the CLI, owns the window and the server.
Why This Change Was Made
The port follows the "copy the independent part, rewrite the boundary" strategy.
src/agent-manager/connection.ts): oneOpenCode.makeclient, oneevent.subscribewith reconnect, location filters, presence throughsession.view;v2/panel-data.ts): one stream per panel, lazily createdcreateDatastores, released when a worktree or project closes;.kilo/agent-manager.json;kilo-code.v2.agentManager.*, added toKILO_SETTING_KEYS;deactivateinterrupts busy sessions before the server stops.SessionViewwas extracted from the sidebar chat, so the Agent Manager renders the same transcript, docks andPromptInput. The New Worktree dialog keeps its own textarea because it also handles slash commands, worktree mentions and images.packages/kilo-plugin/src/agent-manager(theagent_managerandagent_manager_modelstools, thekilocode.agent-managerRPC with start, requested and cancelled events,list/reply/reject/removeSnapshot, the state file guard and the permission hook) andpackages/kilo-plugin/src/branch-name. Contracts live inpackages/schema/src/kilocode.worktree.refresh; it never callsworktree.create, so the setup script cannot run twice. Teardown usesclient.debug.location.evict.CaffeinationService; visible presence usessession.viewinstead of the removedregisterVisible.Five shared upstream files gain a small, generic seam:
packages/core/src/permission.tspasses the effective rules and the unattended rules to the evaluate hook, because the Agent Manager needs the rules core actually used to decide.packages/plugin/src/effect/permission.tstypes those fields.packages/core/src/pty.tsaccepts an optionalallowExitedattach input, so a script terminal can replay the output of a process that already exited.packages/server/src/handlers/pty.tspassesreplayExited=1from the connect query to that input.packages/client/src/solid/data.tsadds a per-sessionsession.message.evict(sessionID), so closing a subagent inspector tab does not clear the parent transcript (covered bypackages/client/test/solid-eviction.test.ts).All are marked with
kilocode_changeand registered inscript/upstream/shared-patches.json(limits 80 files, 1093 marked lines, 225 unmarked lines; the unmarked count comes from the base). The permission hook now matches v1: an exact "Always allow" forprompt,stop,moveoranswersticks; a wildcard or broad allow asks again; unattended work denies a side effect without an exact approval.Permissions and hot reload
The v2 rules are live, not snapshotted, and the port relies on that:
User Impact
kilo-code.v2.agentManager.*, including "Open Agent Manager in New Window".keybindings.json, with live updates; the shortcuts popup reflects the same.Evidence
Screenshots from the self-test:
Visual
Automated checks
packages/kilo-vscode:bun typecheckclean,bun run lintclean,bun test3134 pass, 0 fail.packages/kilo-plugin:bun typecheckclean,bun test501 pass.packages/kilo-cli:bun typecheckclean,bun test331 pass.packages/client:bun test test/solid-eviction.test.ts5 pass.bun script/check-shared-patches.ts: ok (80 files, 1093 marked, 225 unmarked).expect(promise).rejects/resolves. That matcher waits in a nested event loop that does not fire pending timers on Windows (oven-sh/bun#39089), which stalled the Windows packages job. Test Git runs withcore.autocrlf=falseandcore.eol=lf, git path comparisons fold separators and case, and temp cleanup retries the WindowsEBUSYdelay. The pool now cancels a scheduled replacement warm-up and waits for a running one on dispose, so no pool Git process runs after the pool is turned off; on Windows that running process also blocked temp cleanup. The Git-heavy project preparation tests use a 30 second per-file timeout, as the one Windows extension test in v1 does.bun run check:architecture: ok (0 ratchet sites, 0 boundary violations).bun run check:duplication: 16 bounded exceptions, 0 new duplication. The two copied keybinding modules were removed in favor of the sharedsrc/keybinding-format.ts.bun run lint:effect-simplifications: ok.bun run startupinpackages/kilo-cli: pass, with measured budgets for the two new plugins.packages/corePTY replay test: pass.origin/v2(08cbbfa2fb4). Three conflicts were resolved:chat.tsx(kept the sharedSessionViewand passed upstream's todo chip through),dispositions.json(kept both sides),shared-patches.json(limits raised for the merge).Self-test (VS Code, isolated profile, disposable repositories)
Environment note: the isolated v2 profile is signed out of paid models, so prompts used free Kilo models (
kilo-auto/freeand similar). No behavior under test depends on the model choice.Not verified in this PR
ghauth inside the isolated profile).gh).bun run check: it fails on unrelated pre-existing errors (zlib.zstdCompressSyncinpackages/aiand twotool-shelltests in core), which fail the same way without this branch.Parity Checklist
session.view)Defects Found During Self-Test and Fixed
parentID, notnull.import.meta: fixed in the build entry.kilo-uistyles.useV2 must be used inside V2Provider: the list is now scoped to the project root store..git: the project root is the checkout root.Cmd+/toggled twice when the panel was busy (late command echo): the panel now stops the handled key.terminal.integrated.commandsToSkipShell.origin/v2merge brought a todo chip into the session dock;SessionViewnow passes it through.format-keybinding.tsanduser-keybindings.tsduplicatedsrc/keybinding-format.ts). The copies are removed and both the sidebar and the Agent Manager use the shared module.Effect.catchthat only failed with a transformed error; it now usesEffect.mapError.happy-domwithout declaring it; it is now a devDependency at the versionkilo-uialready uses.kilocode.agent-managerorkilocode.branch-name; both are added at the measured 0 ms plus the standard margin.Windowobjects without closing them. They now close each window after the test, so timers cannot keep the test process alive.Exact v1 Button Order and Tooltips
Checked group by group against v1. Only the view title had drifted; it now matches v1 (new session, history, Agent Manager, marketplace omitted, profile, settings), with
test/chat-view-title-order.test.tsguarding it. The other groups already matched: sidebar header (search, keep awake, keyboard shortcuts), project row (project, new worktree, advanced, history, settings), worktree and session rows, footer (new project, add project), tab bar, inspector strip, session header and composer. Controls that carry onlyaria-labelin v1 carry onlyaria-labelhere. The four new keys are translated in all 20 non-English locales, guarded bytest/agent-manager-i18n.test.ts.One PR instead of a stack
The plan preferred a stack of six PRs. This change ships as one PR because the seam, the panel, the per-directory stores, the worktree lifecycle, terminals, diff, PR and orchestration share one connection and one state model. Splitting now would produce intermediate PRs that do not build or run alone. The areas stay separated by directory and by the sections below, so a later split is possible once this base lands.
Placement
packages/kilo-plugin/src/agent-managerandpackages/kilo-plugin/src/branch-name, registered throughKiloPlugins; contracts inpackages/schema/src/kilocode.packages/kilo-cliregisters the plugins;packages/kilo-vscodeowns the panel, connection, provider and lifetime.packages/core/src/permission.tsandpackages/plugin/src/effect/permission.ts; the exited-PTY replay inpackages/core/src/pty.tsandpackages/server/src/handlers/pty.ts; the per-session message evict inpackages/client/src/solid/data.ts. All have markers and shared-patch entries.packages/client/test/solid-eviction.test.ts, and--log-order=streamfor the packages test lane in.github/workflows/check-test.yml, so a stalled Windows task shows its last test.Progress Map
Hand-written input only; generated outputs are left to CI.
permissioncells from the v1 hardening (packages/opencode/src/kilocode/permission/agent-manager.tsand its test), ported topackages/kilo-plugin.packages/kilo-vscodecells that now exist at the same relative path in v2.agent-manager11: 4 modules and 4 tests ported intopackages/kilo-pluginandpackages/schemaunder a different feature box, plus 3 API cells that became thekilocode.agent-managerRPC (native).branch-name1: the test cell, ported topackages/kilo-plugin/test/branch-name.test.ts.snapshot3: cleanup module, its test, andPOST /kilocode/snapshot/remove(now theremoveSnapshotRPC).caffeination1: ported topackages/kilo-vscode/src/services/caffeination.worktree12: 4 modules, 6 tests, the teardown API (native,client.debug.location.evict) and 1 patch cell.presence7:dropped, attached-session presence is an excluded epic.vscodeabout 28 Agent Manager cells: 13droppedfor excluded epics, 3native(script-terminal-url,transcript-partsand its test), 12portedtests whose v1 files became differently named v2 tests.worktree:34f2839b6fa6and the twosnapshotids. Thepresenceone goes away with thedroppeddispositions.Excluded Epics
Each is out of scope and leaves no control, import or dead module in the shipped code:
dropped; visible presence usessession.view.Investigations With No Code Change
These came up during the sessions and were checked, with no change needed:
XDG_CONFIG_HOME, soghcannot read the real login. v1 shows the same toast under the same harness, and the poller code matches v1.Cmd+/with the VS Code terminal destination: works when a shell has focus. An earlier failure came from a test window running a build that read the old setting key.Cmd+Fcollision: the settings search and the Agent Manager search share the key but have disjointwhenclauses, so VS Code resolves them correctly. The popup lists both, as v1 did.DEP0169url.parsedeprecation: both appear without this branch, so neither is caused by the port.repoUsesLfsENOENT log lines: the code matches v1 and the files are optional, so a missing file only means the repository does not use Git LFS.zlib.zstdCompressSynctype errors in other packages and two coretool-shelltests fail with or without this branch.Known Gaps (complete audit)
The full audit with file references is in
.kilo/plans/agent-manager-v2-audit.md, committed in this branch. Summary of everything still open, in the suggested fix order.1. Data the host must push again
agentManager.projectSessionshas no host sender. Project cards show no live session counts, search and@mentions miss sessions, and the orchestration overview does not see live sessions.agent_managertool dropsmodelandvariantfor worktree sessions, so tool-created worktrees use the default model.test/agent-manager-tool-start.test.tscurrently pins that loss.pauseandclearare dead, and permission and form badges can stay stale after a backend restart.projectId, so busy and done states can land on the active project.2. Composer and session view
readOnlyis computed and the banner shows, butSessionViewdoes not receive it.focusPromptignoresforce,restoreanddeferFocusToQuestion, so a mounting session view can pull focus out of the New Worktree dialog.@mentions are computed but never passed to the composer, and worktree drag-to-prompt is missing./goalin the New Worktree dialog submits literal text. v2 has no goal UI yet.sessionId, with the same effect.SessionViewreceiveshasActionswithout arowprop.promptAppendclosure survivesSessionViewunmount, so review sends can target the previous session after a project switch.3. Review and diff
onSendClickandonSendAllappend the prompt while the review controller already dispatches the send. Send-all sends twice, andsendAllToGithubdumps comments into chat before publishing.targetTerminalIdis set, and no v2 terminal listens. This affects inline comments, send-all, PR checks, PR summary, PR batches and remote replies.kilo-code.v2.diff.renderMarkdownis not declared incontributes.configuration, so the toggle is memory-only and the update rejection is unhandled.sessionId, so relative paths resolve to the project root and worktree-only files fail to open.openChanges/turnIdmessage.saveImagefrom a worktree transcript defaults to the project root.4. History and navigation
5. Terminals
pty.createhas no size field, so the first prompt bytes are captured at 80 columns and replayed.[connection error]for application close codes other than 1000. A script that exits before its tab connects now replays its output and closes with 1000, which removes the case seen during the self-test. Other application closes (for example the replay overflow code 4009) still show the generic error.KILO_TERMINAL_ACTIVITY.PtyRelay.closeTerminalis unused.requestTerminalContext,terminalContextErrorandsyncOnSessionSwitchhave no callers, so the v1 behavior that revealed the existing per-session integrated terminal on session change is gone.6. Settings, manifest and packaging
SettingsNavigationdropsprojectId.files.watcherExcludefor**/.kilo/worktrees/**and**/.kilocode/worktrees/**is missing, so VS Code watches every worktree.-workbench.actions.view.problemsunbind for Ctrl/Cmd+Shift+M is missing, so the Agent Manager binding collides with the Problems view.kilo-code.v2.showShortcutHintshas no settings row and is absent fromKiloSettingKey.kilo-worktree-setuptask definition is missing while the runner still creates that task type..vscodeignore/fileslist and no packaging step that placesbin/kilo2, so packaged content is undefined.kilo-code.v2.showTaskTimelinedefaults tofalse, while v1 defaulted totrue.7. Branch naming
8. Medium and low items
.kilo2/agent-manager.jsonhas no migration marker andapplyignoresversion, so a corrupt-file backup re-imports the stale v1 file.STATE_DIRECTORIESlost.kilocode, so the legacy state file is no longer protected from edits.@model) was removed from the New Worktree dialog while the file header still claims it.event.location.directory, so symlinked or case-different paths stop live updates silently.agentManagerwrite allowlist carriesshowTaskTimeline, which the panel never posts, and omits settings the ported tab would need.9. Dead code to remove or wire
tool-project.tsis imported only by tests.discardWorktreehas no production caller.AgentManagerProvidermethodsfocusPanel,waitForReady,revealSession,getWorktreeDirectoriesandcreateFromSidebarhave no callers outside tests.requestTerminalContext,clearSession,previewImage, the Agent ManageropenFilevariant,loadMessages,copyFilePath.setSessionsCollapsed,selectProject,configureSetupScript,setDefaultBaseBranch.directories(),isSubmitting,interrupt,intro.fallback,resolveTerminal, thehasQuestionOptionimport.opensignal.10. Test drift
test/agent-manager-tool-start.test.tsasserts the model and variant are absent for worktree sessions; it should assert they are applied once the gap is fixed.Verified as Correctly Migrated
The audit checked these and found no divergence:
.kilo2git exclude; state schema, sections, tab order, pinned tabs, closed sessions, worktree order, active target, corrupt-file backup; reconcile, recovery, health, doctor, diagnostics, file paths, orphans, git import and transfer, stats poller, quarantine, semaphore; delete, env copy, multi-version, creation plan.agent_managertool schema, validation, events, reply and reject, model matching, timeout, permission hardening, registration.terminal.createdandrestarted, relay open/send/close, replay, the 4009 overflow code, script terminals, run scripts, setup scripts, integrated terminals, terminal font and destination settings.Planning Documents
The port plan, ledger, conventions and the full audit are included in the repository:
.kilo/plans/agent-manager-v2-plan.md.kilo/plans/agent-manager-v2-ledger.md.kilo/plans/agent-manager-v2-conventions.md.kilo/plans/agent-manager-v2-audit.mdPart of #15315