diff --git a/.changeset/fix-agent-manager-terminal-toggle.md b/.changeset/fix-agent-manager-terminal-toggle.md new file mode 100644 index 00000000000..a93825d5957 --- /dev/null +++ b/.changeset/fix-agent-manager-terminal-toggle.md @@ -0,0 +1,5 @@ +--- +"kilo-code": patch +--- + +Fix the Agent Manager terminal toolbar button to toggle panel visibility directly. diff --git a/packages/kilo-vscode/tests/unit/agent-manager-terminal-side.test.ts b/packages/kilo-vscode/tests/unit/agent-manager-terminal-side.test.ts index 4d6a9848d11..4b1c633f587 100644 --- a/packages/kilo-vscode/tests/unit/agent-manager-terminal-side.test.ts +++ b/packages/kilo-vscode/tests/unit/agent-manager-terminal-side.test.ts @@ -83,6 +83,23 @@ describe("Agent Manager side terminal controller", () => { expect(hidden.calls.hide).toBe(0) }) + it("toggles panel visibility from toolbar button without requiring focus", () => { + const visibleUnfocused = scene({ destination: "agentManager", visible: true }) + visibleUnfocused.ctl.openPreferred("tab_toolbar") + expect(visibleUnfocused.calls.hide).toBe(1) + expect(visibleUnfocused.calls.requestSide).toBe(0) + + const visibleFocused = scene({ destination: "agentManager", visible: true, focusedId: "terminal:side" }) + visibleFocused.ctl.openPreferred("tab_toolbar") + expect(visibleFocused.calls.hide).toBe(1) + expect(visibleFocused.calls.requestSide).toBe(0) + + const hidden = scene({ destination: "agentManager", visible: false }) + hidden.ctl.openPreferred("tab_toolbar") + expect(hidden.calls.requestSide).toBe(1) + expect(hidden.calls.hide).toBe(0) + }) + it("ensures an open terminal panel has a terminal after switching contexts", async () => { const visible = scene({ visible: true }) visible.ctl.syncContext("wt-2", "wt-1") diff --git a/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx b/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx index 50aff3bff75..5487c25b066 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx @@ -2401,9 +2401,6 @@ const AgentManagerContent: Component = () => { onToggleReview={metrics.click("fullscreen_review", "tab_toolbar", toggleReviewTab)} terminalDestination={sideCtl.destination} terminalDestinationActive={() => sidePanel() === "terminal"} - terminalDestinationFocused={() => - sideCtl.destination() === "agentManager" && terms.sideFocusedId() !== undefined - } terminalKeybind={() => kb().showTerminal ?? ""} onTerminalDestinationOpen={() => { cancelAmbientSetup() diff --git a/packages/kilo-vscode/webview-ui/agent-manager/TabBar.tsx b/packages/kilo-vscode/webview-ui/agent-manager/TabBar.tsx index 7dacbda4bcb..359ad99e4cb 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/TabBar.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/TabBar.tsx @@ -57,7 +57,6 @@ export interface TabBarProps { onToggleReview: () => void terminalDestination: () => TerminalDestination terminalDestinationActive: () => boolean - terminalDestinationFocused: () => boolean terminalKeybind: () => string onTerminalDestinationOpen: () => void onTerminalDestinationChoose: (destination: TerminalDestination) => void @@ -260,7 +259,6 @@ export const TabBar: Component = (props) => ( /** True while the embedded terminal panel is showing. */ active: Accessor - /** True while the embedded terminal owns DOM focus. */ - focused: Accessor keybind: Accessor onOpen: () => void onChoose: (destination: TerminalDestination) => void @@ -29,10 +27,6 @@ interface Props { export const TerminalDestinationButton: Component = (props) => { const { t } = useLanguage() - const title = () => - props.destination() === "agentManager" && props.focused() - ? t("agentManager.shortcuts.toggleTerminal") - : t("agentManager.tab.openTerminal") const item = (destination: TerminalDestination, label: string) => ( props.onChoose(destination)}> @@ -45,7 +39,7 @@ export const TerminalDestinationButton: Component = (props) => { ) return (
- + { + const toggle = (trigger: "keyboard_shortcut" | "tab_toolbar" = "keyboard_shortcut") => { if (deps.visible()) { - if (!deps.focusedId()) { + if (trigger === "keyboard_shortcut" && !deps.focusedId()) { deps.handlers.requestSide() return } + const was = deps.focusedId() !== undefined deps.hide() - handoff(true) + handoff(was) return } deps.handlers.requestSide() @@ -149,7 +148,7 @@ export function createSideTerminal(deps: SideTerminalDeps) { const target = destination() deps.track("terminal", trigger, { destination: target }) if (target === "agentManager") { - toggle() + toggle(trigger) return } deps.openVscode()