mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 11:05:31 +08:00
Merge pull request #12593 from Kilo-Org/profile-active-kilo-sessions-cpu-usage
fix(vscode): avoid eager worktree watchers
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@kilocode/cli": patch
|
||||
"kilo-code": patch
|
||||
---
|
||||
|
||||
Prevent the VS Code backend from eagerly starting native file watchers for every Agent Manager worktree.
|
||||
@@ -15,6 +15,10 @@ export namespace KilocodeWatcher {
|
||||
|
||||
export class Service extends Context.Service<Service, Interface>()("@kilocode/Watcher") {}
|
||||
|
||||
export function eager(client = Flag.KILO_CLIENT) {
|
||||
return client !== "vscode"
|
||||
}
|
||||
|
||||
export const layer = Layer.effect(
|
||||
Service,
|
||||
Effect.gen(function* () {
|
||||
@@ -51,10 +55,10 @@ export namespace KilocodeWatcher {
|
||||
}),
|
||||
)
|
||||
|
||||
// Gate the whole layer so LocationServiceMap's dependency graph is never built when the watcher is disabled.
|
||||
// Gate the whole layer so LocationServiceMap is only warmed for clients that consume branch-update events.
|
||||
export const defaultLayer = Layer.unwrap(
|
||||
Effect.gen(function* () {
|
||||
if (yield* Flag.KILO_EXPERIMENTAL_DISABLE_FILEWATCHER.pipe(Effect.orElseSucceed(() => false)))
|
||||
if (!eager() || (yield* Flag.KILO_EXPERIMENTAL_DISABLE_FILEWATCHER.pipe(Effect.orElseSucceed(() => false))))
|
||||
return Layer.succeed(Service, Service.of({ init: () => Effect.void }))
|
||||
return layer.pipe(Layer.provide(LocationServiceMap.layer))
|
||||
}),
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { afterAll, beforeAll, expect } from "bun:test"
|
||||
import { afterAll, beforeAll, describe, expect, test } from "bun:test"
|
||||
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
||||
import { Deferred, Effect, Fiber, Layer } from "effect"
|
||||
import { GlobalBus, type GlobalEvent } from "../../src/bus/global"
|
||||
import { Git } from "../../src/git"
|
||||
import { InstanceLayer } from "../../src/project/instance-layer"
|
||||
import { InstanceStore } from "../../src/project/instance-store"
|
||||
import { KilocodeWatcher } from "../../src/kilocode/watcher"
|
||||
import { tmpdirScoped } from "../fixture/fixture"
|
||||
import { awaitWithTimeout, testEffect } from "../lib/effect"
|
||||
|
||||
@@ -23,6 +24,17 @@ afterAll(() => {
|
||||
// The watcher is unreliable on Windows CI, so this test only runs on unix.
|
||||
const live = process.platform === "win32" ? it.live.skip : it.live
|
||||
|
||||
describe("KilocodeWatcher.eager", () => {
|
||||
test("skips eager location watchers for VS Code", () => {
|
||||
expect(KilocodeWatcher.eager("vscode")).toBe(false)
|
||||
})
|
||||
|
||||
test("keeps eager location watchers for the standalone CLI", () => {
|
||||
expect(KilocodeWatcher.eager("cli")).toBe(true)
|
||||
expect(KilocodeWatcher.eager(undefined)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
live("instances publish branch updates after git switch", () =>
|
||||
Effect.gen(function* () {
|
||||
const dir = yield* tmpdirScoped({ git: true })
|
||||
|
||||
Reference in New Issue
Block a user