mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(agent-manager): exclude local state on startup (#10196)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"kilo-code": patch
|
||||
---
|
||||
|
||||
Keep Agent Manager state hidden from Git before creating local sessions.
|
||||
@@ -251,6 +251,7 @@ export class AgentManagerProvider implements Disposable {
|
||||
return
|
||||
}
|
||||
|
||||
await this.ensureGitExclude(manager)
|
||||
const loaded = await state.load()
|
||||
manager.cleanupOrphanedTempDirs()
|
||||
|
||||
@@ -291,6 +292,12 @@ export class AgentManagerProvider implements Disposable {
|
||||
this.panel?.sessions.recoverPendingPrompts()
|
||||
}
|
||||
|
||||
private async ensureGitExclude(manager: WorktreeManager): Promise<void> {
|
||||
await manager.ensureGitExclude().catch((err) => {
|
||||
this.log("Failed to update git exclude:", err)
|
||||
})
|
||||
}
|
||||
|
||||
private async recoverWorktrees(manager: WorktreeManager, state: WorktreeStateManager): Promise<void> {
|
||||
const infos = await manager.discoverWorktrees().catch((err) => {
|
||||
this.log("Failed to discover worktrees during state recovery:", err)
|
||||
|
||||
@@ -183,6 +183,16 @@ describe("Agent Manager Provider Messages", () => {
|
||||
expect(getMethodBody("onMessage")).toContain("if (this.shouldWaitForState(m)) await this.waitForStateReady(m.type)")
|
||||
})
|
||||
|
||||
it("initializeState updates local git exclude before loading persisted state", () => {
|
||||
const body = getMethodBody("initializeState")
|
||||
const exclude = body.indexOf("await this.ensureGitExclude(manager)")
|
||||
const load = body.indexOf("const loaded = await state.load()")
|
||||
|
||||
expect(exclude).toBeGreaterThanOrEqual(0)
|
||||
expect(load).toBeGreaterThanOrEqual(0)
|
||||
expect(exclude).toBeLessThan(load)
|
||||
})
|
||||
|
||||
it("async shutdown waits for terminal router cleanup", () => {
|
||||
const body = getMethodBody("disposeAsync")
|
||||
expect(body).toContain("await this.terminalRouter.dispose()")
|
||||
|
||||
@@ -680,7 +680,7 @@ describe("WorktreeManager.discoverWorktrees", () => {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe("WorktreeManager.ensureGitExclude", () => {
|
||||
it("adds .kilo/worktrees/ to .git/info/exclude", async () => {
|
||||
it("adds Agent Manager state and worktrees to .git/info/exclude", async () => {
|
||||
const root = await createTempRepo()
|
||||
const mgr = createManager(root)
|
||||
|
||||
@@ -688,6 +688,7 @@ describe("WorktreeManager.ensureGitExclude", () => {
|
||||
|
||||
const content = await fs.readFile(path.join(root, ".git", "info", "exclude"), "utf-8")
|
||||
expect(content).toContain(".kilo/worktrees/")
|
||||
expect(content).toContain(".kilo/agent-manager.json")
|
||||
})
|
||||
|
||||
it("adds only specific legacy Agent Manager paths", async () => {
|
||||
|
||||
Reference in New Issue
Block a user