mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 11:05:31 +08:00
fix(vscode): resolve main merge and keep provider within size cap
Route the settings-panel message through the shared project message handler, build the project settings handler in the project wiring, and drop the duplicate projectId prop that the merge left in SidebarBody.
This commit is contained in:
@@ -72,12 +72,10 @@ import { PLATFORM } from "./constants"
|
||||
import { ProjectRegistry } from "./project/registry"
|
||||
import type { ProjectContext } from "./project/context"
|
||||
import { ProjectContexts } from "./project/contexts"
|
||||
import { createSettingsHandler } from "./project/settings"
|
||||
import type { SettingsHandler } from "./project/settings"
|
||||
import { hydrateExpanded } from "./project/hydrate"
|
||||
import { createMultiVersion, type MultiVersionHost } from "./provider-multi-version"
|
||||
import { handleProjectMessage, type ProjectMessageDeps } from "./project/messages"
|
||||
import { createProjectWiring } from "./project/wiring"
|
||||
import { createProjectWiring, type ProjectWiring } from "./project/wiring"
|
||||
import { ProjectScope } from "./project/scope"
|
||||
import type { AgentManagerOutMessage, AgentManagerInMessage } from "./types"
|
||||
import type { Host, PanelContext, OutputHandle, Disposable } from "./host"
|
||||
@@ -118,11 +116,9 @@ export class AgentManagerProvider implements Disposable {
|
||||
private destination = new DestinationState()
|
||||
private closing: Promise<void> | undefined
|
||||
private onVisibilityChange: ((visible: boolean) => void) | undefined
|
||||
// Tracks sessions owned by this panel until they are explicitly closed.
|
||||
private panelSessions = new Set<string>()
|
||||
private busySessions = new Set<string>()
|
||||
public readonly settings: SettingsHandler
|
||||
|
||||
readonly settings: ProjectWiring["settings"]
|
||||
/** Session ID most recently loaded via `loadMessages`; updated synchronously. */
|
||||
private activeSessionId: string | undefined
|
||||
private visiblePresence = new AgentManagerVisiblePresence(
|
||||
@@ -198,18 +194,13 @@ export class AgentManagerProvider implements Disposable {
|
||||
expand: (ctx) => this.initExpanded(ctx),
|
||||
ready: (ctx) => initContextState(ctx, (...args) => this.log(...args)),
|
||||
push: () => this.pushProjects(),
|
||||
pushState: (ctx) => this.pushState(ctx),
|
||||
changed: () => this.onWorkspaceChanged(),
|
||||
refresh: () => this.pushState(),
|
||||
selected: (target) => this.postToWebview({ type: "agentManager.selectionActivated", target }),
|
||||
})
|
||||
this.registry = wiring.registry
|
||||
this.contexts = wiring.contexts
|
||||
this.settings = createSettingsHandler({
|
||||
contexts: this.contexts,
|
||||
open: (path) => this.host.openDocument(path),
|
||||
push: (ctx) => this.pushState(ctx),
|
||||
log: (...args) => this.log(...args),
|
||||
})
|
||||
this.settings = wiring.settings
|
||||
this.projects = wiring.messages
|
||||
this.unsubProjects = () => wiring.dispose()
|
||||
this.naming = new BranchNamingController({
|
||||
@@ -518,13 +509,6 @@ export class AgentManagerProvider implements Disposable {
|
||||
// Message interceptor
|
||||
|
||||
private async onMessage(msg: Record<string, unknown>): Promise<Record<string, unknown> | null> {
|
||||
if (msg.type === "openSettingsPanel") {
|
||||
this.host.openSettings(
|
||||
typeof msg.tab === "string" ? msg.tab : undefined,
|
||||
typeof msg.projectId === "string" ? msg.projectId : undefined,
|
||||
)
|
||||
return null
|
||||
}
|
||||
if (this.prBridge.handleMessage(msg)) return null
|
||||
if (msg.type === "requestFileSearch" && typeof msg.sessionID !== "string" && this.activeSessionId) {
|
||||
return { ...msg, sessionID: this.activeSessionId }
|
||||
|
||||
@@ -31,6 +31,8 @@ export interface ProjectMessageDeps {
|
||||
selected: (target: SidebarTarget) => void
|
||||
/** Show a user-facing error. */
|
||||
error: (message: string) => void
|
||||
/** Open the Kilo Settings editor, optionally on a tab and project. */
|
||||
openSettings: (tab?: string, projectId?: string) => void
|
||||
/** Ensure a context's repository state is ready (no-op once initialized). */
|
||||
ready: (ctx: ProjectContext) => Promise<ProjectInitResult>
|
||||
log: (...args: unknown[]) => void
|
||||
@@ -38,6 +40,10 @@ export interface ProjectMessageDeps {
|
||||
|
||||
/** Handle a project-management message. Returns true when the message was consumed. */
|
||||
export async function handleProjectMessage(m: AgentManagerInMessage, deps: ProjectMessageDeps): Promise<boolean> {
|
||||
if (m.type === "openSettingsPanel") {
|
||||
deps.openSettings(m.tab, m.projectId)
|
||||
return true
|
||||
}
|
||||
if (m.type === "agentManager.requestProjects") {
|
||||
deps.push()
|
||||
return true
|
||||
|
||||
@@ -12,10 +12,13 @@ import { ProjectRegistry } from "./registry"
|
||||
import type { ProjectContext, ProjectInitResult } from "./context"
|
||||
import { ProjectContexts, type ProjectSnapshot } from "./contexts"
|
||||
import type { ProjectMessageDeps } from "./messages"
|
||||
import { createSettingsHandler, type SettingsHandler } from "./settings"
|
||||
|
||||
export interface ProjectWiring {
|
||||
registry: ProjectRegistry
|
||||
contexts: ProjectContexts
|
||||
/** Project-scoped settings handler shared with the Kilo Settings editor. */
|
||||
settings: SettingsHandler
|
||||
messages: ProjectMessageDeps
|
||||
/** Payload for the agentManager.projects webview message. */
|
||||
snapshots(): { type: "agentManager.projects"; multiProject: boolean; projects: ProjectSnapshot[] }
|
||||
@@ -35,10 +38,10 @@ export function createProjectWiring(opts: {
|
||||
ready: (ctx: ProjectContext) => Promise<ProjectInitResult>
|
||||
/** Push the project catalog to the webview. */
|
||||
push: () => void
|
||||
/** Push one project's state (or every context when omitted) to the webview. */
|
||||
pushState: (ctx?: ProjectContext) => void
|
||||
/** Re-derive the pinned project after workspace folder changes. */
|
||||
changed: () => void
|
||||
/** Re-push worktree state (e.g. after the flag toggles). */
|
||||
refresh: () => void
|
||||
/** Acknowledge an atomically validated sidebar selection. */
|
||||
selected: (target: import("./route").SidebarTarget) => void
|
||||
}): ProjectWiring {
|
||||
@@ -64,8 +67,15 @@ export function createProjectWiring(opts: {
|
||||
push: opts.push,
|
||||
selected: opts.selected,
|
||||
error: (message) => opts.host.showError(message),
|
||||
openSettings: (tab, projectId) => opts.host.openSettings(tab, projectId),
|
||||
log: opts.log,
|
||||
}
|
||||
const settings = createSettingsHandler({
|
||||
contexts,
|
||||
open: (path) => opts.host.openDocument(path),
|
||||
push: opts.pushState,
|
||||
log: opts.log,
|
||||
})
|
||||
const listeners: Disposable[] = [
|
||||
opts.host.onDidChangeWorkspaceFolders(() => opts.changed()),
|
||||
opts.host.onDidChangeMultiProject((enabled) => {
|
||||
@@ -74,12 +84,13 @@ export function createProjectWiring(opts: {
|
||||
if (pinned) opts.activate(pinned)
|
||||
}
|
||||
opts.push()
|
||||
opts.refresh()
|
||||
opts.pushState()
|
||||
}),
|
||||
]
|
||||
return {
|
||||
registry,
|
||||
contexts,
|
||||
settings,
|
||||
messages,
|
||||
snapshots: () => ({
|
||||
type: "agentManager.projects",
|
||||
|
||||
@@ -673,6 +673,12 @@ interface RenameWorktreeIn {
|
||||
label: string
|
||||
}
|
||||
|
||||
interface OpenSettingsPanelIn {
|
||||
type: "openSettingsPanel"
|
||||
tab?: string
|
||||
projectId?: string
|
||||
}
|
||||
|
||||
interface RequestStateIn {
|
||||
type: "agentManager.requestState"
|
||||
}
|
||||
@@ -1093,6 +1099,7 @@ export type AgentManagerInMessage =
|
||||
| RequestRepoInfoIn
|
||||
| CreateMultiVersionIn
|
||||
| RenameWorktreeIn
|
||||
| OpenSettingsPanelIn
|
||||
| RequestStateIn
|
||||
| RequestBranchesIn
|
||||
| SetTabOrderIn
|
||||
|
||||
@@ -63,7 +63,6 @@ export interface SidebarBodyProps {
|
||||
onNewWorktree: () => void
|
||||
onNewSection: () => void
|
||||
onShortcuts: () => void
|
||||
projectId?: string
|
||||
sections: () => SectionState[]
|
||||
sortedWorktrees: () => WorktreeState[]
|
||||
worktrees: () => WorktreeState[]
|
||||
|
||||
Reference in New Issue
Block a user