mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-19 01:51:21 +08:00
fix(vscode): keep active terminal for agent manager context
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"kilo-code": patch
|
||||
---
|
||||
|
||||
Capture the active VS Code terminal when using `@terminal` in Agent Manager.
|
||||
@@ -392,7 +392,7 @@ export class AgentManagerProvider implements Disposable {
|
||||
}
|
||||
|
||||
if (m.type === "requestTerminalContext") {
|
||||
if (m.sessionID) this.terminalManager.showExisting(m.sessionID)
|
||||
if (m.sessionID && !this.terminalManager.hasActiveTerminal()) this.terminalManager.showExisting(m.sessionID)
|
||||
return msg
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,10 @@ export class SessionTerminalManager {
|
||||
return entry !== undefined && entry.terminal.exitStatus === undefined
|
||||
}
|
||||
|
||||
hasActiveTerminal(): boolean {
|
||||
return this.host.activeTerminal() !== undefined
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
void this.host.setContext("kilo-code.agentTerminalFocus", false)
|
||||
for (const entry of this.terminals.values()) entry.terminal.dispose()
|
||||
|
||||
@@ -229,6 +229,15 @@ describe("Agent Manager Provider — onMessage routing", () => {
|
||||
expect(text).toContain("syncOnSessionSwitch")
|
||||
})
|
||||
|
||||
it("terminal context keeps the current active terminal when present", () => {
|
||||
const text = body("onSessionMessage")
|
||||
const check = text.indexOf("!this.terminalManager.hasActiveTerminal()")
|
||||
const show = text.indexOf("this.terminalManager.showExisting(m.sessionID)")
|
||||
expect(check).toBeGreaterThan(-1)
|
||||
expect(show).toBeGreaterThan(-1)
|
||||
expect(check, "active terminal check must guard session terminal reveal").toBeLessThan(show)
|
||||
})
|
||||
|
||||
it("session routing handles clearSession for SSE re-registration", () => {
|
||||
const text = body("onSessionMessage")
|
||||
expect(text).toContain("clearSession")
|
||||
|
||||
@@ -87,4 +87,9 @@ describe("SessionTerminalManager structure", () => {
|
||||
expect(text).toContain("if (!this.panelOpen)")
|
||||
expect(text).toContain("this.showExistingLocal()")
|
||||
})
|
||||
|
||||
it("exposes active terminal state for terminal context routing", () => {
|
||||
const text = body("hasActiveTerminal")
|
||||
expect(text).toContain("this.host.activeTerminal()")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user