From f1409354cfcd51a4cbe24bd195e1b46697cfa429 Mon Sep 17 00:00:00 2001 From: kirillk Date: Fri, 24 Apr 2026 16:27:21 -0400 Subject: [PATCH] fix(vscode): resolve lint caps in sidebar worktree flow --- packages/kilo-vscode/src/KiloProvider.ts | 45 +++++-------- .../src/kilo-provider/sidebar-worktree.ts | 67 +++++++++++++++++++ .../agent-manager/AgentManagerApp.tsx | 2 - 3 files changed, 82 insertions(+), 32 deletions(-) create mode 100644 packages/kilo-vscode/src/kilo-provider/sidebar-worktree.ts diff --git a/packages/kilo-vscode/src/KiloProvider.ts b/packages/kilo-vscode/src/KiloProvider.ts index a11b9d29fb8..bca4adce541 100644 --- a/packages/kilo-vscode/src/KiloProvider.ts +++ b/packages/kilo-vscode/src/KiloProvider.ts @@ -45,7 +45,7 @@ import { resolveProjectDirectory } from "./project-directory" import { getBusySessionCount, seedSessionStatuses } from "./session-status" import { retry } from "./services/cli-backend/retry" import { slimPart, slimParts } from "./kilo-provider/slim-metadata" -import { handleContinueInWorktree } from "./kilo-provider/continue-worktree" +import { handleSidebarWorktreeMessage } from "./kilo-provider/sidebar-worktree" import { parseMessageFiles, type MessageFile } from "./kilo-provider/message-files" import { handleFileSearch } from "./kilo-provider/file-search" import { getTerminalContents } from "./services/terminal/context" @@ -586,6 +586,20 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper await routeSuggestionWebviewMessage(this.questionCtx, message) if (await ModelState.handleMessage(message.type, message, this.client, (msg) => this.postMessage(msg))) return if (await routeAutocompleteMessage(message, (msg) => this.postMessage(msg))) return + if ( + await handleSidebarWorktreeMessage(message, { + post: (msg) => this.postMessage(msg), + openAgentManager: () => vscode.commands.executeCommand("kilo-code.new.agentManagerOpen"), + openAdvancedWorktree: () => vscode.commands.executeCommand("kilo-code.new.agentManager.advancedWorktree"), + openChanges: () => vscode.commands.executeCommand("kilo-code.new.showChanges"), + createWorktree: async (baseBranch, branchName) => { + await this.createWorktreeHandler?.(baseBranch, branchName) + }, + continueInWorktree: this.continueInWorktreeHandler ?? undefined, + }) + ) { + return + } switch (message.type) { case "webviewReady": console.log("[Kilo New] KiloProvider: ✅ webviewReady received") @@ -707,38 +721,9 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper case "openMarketplacePanel": vscode.commands.executeCommand("kilo-code.new.marketplaceButtonClicked", this.projectDirectory) break - case "openAgentManager": - vscode.commands.executeCommand("kilo-code.new.agentManagerOpen") - break - case "openAdvancedWorktree": - vscode.commands.executeCommand("kilo-code.new.agentManager.advancedWorktree") - break - case "agentManager.requestRepoInfo": { - const root = getWorkspaceRoot() - if (!root) break - const git = new GitOps({ log: () => {} }) - const branch = await git.currentBranch(root).catch(() => "") - git.dispose() - if (!branch || branch === "HEAD") break - this.postMessage({ type: "agentManager.repoInfo", branch }) - break - } - case "agentManager.createWorktree": - await this.createWorktreeHandler?.(message.baseBranch, message.branchName) - break - case "openChanges": - vscode.commands.executeCommand("kilo-code.new.showChanges") - break case "openDiffVirtual": this.openDiffVirtual(message.diff) break - case "continueInWorktree": - handleContinueInWorktree({ - sessionId: message.sessionId, - handler: this.continueInWorktreeHandler ?? undefined, - post: (msg) => this.postMessage(msg), - }) - break case "forkSession": handleForkSession(this.forkCtx, message.sessionId, message.messageId).catch((e) => console.error("[Kilo New] handleForkSession failed:", e), diff --git a/packages/kilo-vscode/src/kilo-provider/sidebar-worktree.ts b/packages/kilo-vscode/src/kilo-provider/sidebar-worktree.ts new file mode 100644 index 00000000000..a478d9b13c4 --- /dev/null +++ b/packages/kilo-vscode/src/kilo-provider/sidebar-worktree.ts @@ -0,0 +1,67 @@ +import { GitOps } from "../agent-manager/GitOps" +import { getWorkspaceRoot } from "../review-utils" +import { handleContinueInWorktree } from "./continue-worktree" + +interface Msg { + type: string + baseBranch?: string + branchName?: string + sessionId?: string +} + +interface Ctx { + post: (msg: unknown) => void + openAgentManager: () => Thenable + openAdvancedWorktree: () => Thenable + openChanges: () => Thenable + createWorktree?: (baseBranch?: string, branchName?: string) => Promise + continueInWorktree?: ( + sessionId: string, + progress: (status: string, detail?: string, error?: string) => void, + ) => Promise +} + +async function repo(post: Ctx["post"]) { + const root = getWorkspaceRoot() + if (!root) return + const git = new GitOps({ log: () => {} }) + const branch = await git.currentBranch(root).catch(() => "") + git.dispose() + if (!branch || branch === "HEAD") return + post({ type: "agentManager.repoInfo", branch }) +} + +export async function handleSidebarWorktreeMessage(message: Msg, ctx: Ctx) { + if (message.type === "openAgentManager") { + await ctx.openAgentManager() + return true + } + + if (message.type === "openAdvancedWorktree") { + await ctx.openAdvancedWorktree() + return true + } + + if (message.type === "agentManager.requestRepoInfo") { + await repo(ctx.post) + return true + } + + if (message.type === "agentManager.createWorktree") { + await ctx.createWorktree?.(message.baseBranch, message.branchName) + return true + } + + if (message.type === "openChanges") { + await ctx.openChanges() + return true + } + + if (message.type !== "continueInWorktree") return false + handleContinueInWorktree({ + sessionId: message.sessionId, + handler: ctx.continueInWorktree, + post: ctx.post, + }) + return true +} diff --git a/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx b/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx index 4239f4e7355..a978a86b988 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx @@ -1,5 +1,3 @@ -// Agent Manager root component - /** @jsxImportSource solid-js */ import {