mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-30 17:14:40 +08:00
fix(vscode): route focusChatInput (Cmd+Shift+A) to active panel (#526)
* fix(vscode): route focusChatInput (Cmd+Shift+A) to active panel The focusChatInput command was hardcoded to always target the sidebar KiloProvider. When the Agent Manager panel was focused, the shortcut had no effect. Now the command checks which panel is active at invocation time and routes the message accordingly. * fix(vscode): route addToContext setChatBoxMessage through target() too Both setChatBoxMessage and focusInput in the addToContext handler now use target() so the context text and focus always go to the same panel.
This commit is contained in:
@@ -577,6 +577,10 @@ export class AgentManagerProvider implements vscode.Disposable {
|
||||
this.panel.reveal(vscode.ViewColumn.One, false)
|
||||
}
|
||||
|
||||
public isActive(): boolean {
|
||||
return this.panel?.active === true
|
||||
}
|
||||
|
||||
public postMessage(message: unknown): void {
|
||||
this.panel?.webview.postMessage(message)
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
registerCommitMessageService(context, connectionService)
|
||||
|
||||
// Register code actions (editor context menus, terminal context menus, keyboard shortcuts)
|
||||
registerCodeActions(context, provider)
|
||||
registerCodeActions(context, provider, agentManagerProvider)
|
||||
registerTerminalActions(context, provider)
|
||||
|
||||
// Register CodeActionProvider (lightbulb quick fixes)
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import * as vscode from "vscode"
|
||||
import type { KiloProvider } from "../../KiloProvider"
|
||||
import type { AgentManagerProvider } from "../../agent-manager/AgentManagerProvider"
|
||||
import { getEditorContext } from "./editor-utils"
|
||||
import { createPrompt } from "./support-prompt"
|
||||
|
||||
export function registerCodeActions(context: vscode.ExtensionContext, provider: KiloProvider): void {
|
||||
export function registerCodeActions(
|
||||
context: vscode.ExtensionContext,
|
||||
provider: KiloProvider,
|
||||
agentManager?: AgentManagerProvider,
|
||||
): void {
|
||||
const target = () => (agentManager?.isActive() ? agentManager : provider)
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("kilo-code.new.explainCode", () => {
|
||||
const ctx = getEditorContext()
|
||||
@@ -54,12 +61,12 @@ export function registerCodeActions(context: vscode.ExtensionContext, provider:
|
||||
endLine: String(ctx.endLine),
|
||||
selectedText: ctx.selectedText,
|
||||
})
|
||||
provider.postMessage({ type: "setChatBoxMessage", text: prompt })
|
||||
provider.postMessage({ type: "action", action: "focusInput" })
|
||||
target().postMessage({ type: "setChatBoxMessage", text: prompt })
|
||||
target().postMessage({ type: "action", action: "focusInput" })
|
||||
}),
|
||||
|
||||
vscode.commands.registerCommand("kilo-code.new.focusChatInput", () => {
|
||||
provider.postMessage({ type: "action", action: "focusInput" })
|
||||
target().postMessage({ type: "action", action: "focusInput" })
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -405,6 +405,7 @@ const AgentManagerContent: Component = () => {
|
||||
else if (msg.action === "closeTab") closeActiveTab()
|
||||
else if (msg.action === "newWorktree") handleNewWorktreeOrPromote()
|
||||
else if (msg.action === "closeWorktree") closeSelectedWorktree()
|
||||
else if (msg.action === "focusInput") window.dispatchEvent(new Event("focusPrompt"))
|
||||
}
|
||||
window.addEventListener("message", handler)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user