Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import type { KiloConnectionService } from "../cli-backend"
import { playwrightCommand } from "./settings"
import { canonicalizePath, samePath } from "../../agent-manager/project/paths"

type BrowserAutomationState = "disabled" | "registering" | "connected" | "failed" | "disconnected"

/**
* Manages the built-in Playwright MCP browser server for ordinary Kilo sessions.
*
Expand All @@ -19,7 +17,6 @@ export class BrowserAutomationService implements vscode.Disposable {
private readonly registered = new Set<string>()
private queue: Promise<void> = Promise.resolve()
private disposed = false
private state: BrowserAutomationState = "disabled"

constructor(
private readonly connectionService: KiloConnectionService,
Expand Down Expand Up @@ -140,7 +137,6 @@ export class BrowserAutomationService implements vscode.Disposable {
}
if (!vscode.workspace.isTrusted) {
console.warn("[Kilo New] BrowserAutomationService: Workspace is not trusted, skipping Playwright MCP")
this.setState("disabled")
return
}
const dirs = this.directories()
Expand Down Expand Up @@ -169,12 +165,8 @@ export class BrowserAutomationService implements vscode.Disposable {

private async register(dirs: string[]): Promise<void> {
const client = this.getClient()
if (!client) {
this.setState("failed")
return
}
if (!client) return
const command = this.command()
this.setState("registering")
let failure: unknown
for (const directory of dirs) {
try {
Expand Down Expand Up @@ -206,16 +198,8 @@ export class BrowserAutomationService implements vscode.Disposable {
failure = error
}
}
if (this.registered.size > 0) {
this.setState("connected")
return
}
if (failure) {
console.error("[Kilo New] BrowserAutomationService: Failed to register MCP server:", failure)
this.setState("failed")
return
}
this.setState("disconnected")
if (this.registered.size > 0) return
if (failure) console.error("[Kilo New] BrowserAutomationService: Failed to register MCP server:", failure)
}

private async unregister(dirs = [...this.registered]): Promise<void> {
Expand All @@ -233,7 +217,6 @@ export class BrowserAutomationService implements vscode.Disposable {
}
}
}
this.setState("disabled")
}

private getClient(): KiloClient | null {
Expand All @@ -244,12 +227,6 @@ export class BrowserAutomationService implements vscode.Disposable {
}
}

private setState(state: BrowserAutomationState): void {
if (this.state === state) return
console.log(`[Kilo New] BrowserAutomationService: State ${this.state} -> ${state}`)
this.state = state
}

dispose(): void {
this.disposed = true
for (const disposable of this.disposables) disposable.dispose()
Expand Down
Loading