mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
fix(vscode): respect terminal display for background processes (#12301)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"kilo-code": patch
|
||||
---
|
||||
|
||||
Respect the Terminal Command Blocks display setting for background process tool cards.
|
||||
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "bun:test"
|
||||
import type { Part, ToolPart } from "@kilocode/sdk/v2"
|
||||
import { toolDefaultOpen } from "../../webview-ui/src/components/chat/tool-default-open"
|
||||
|
||||
function tool(name: string) {
|
||||
return { type: "tool", tool: name } as ToolPart
|
||||
}
|
||||
|
||||
describe("toolDefaultOpen", () => {
|
||||
it.each(["bash", "background_process"])("uses the terminal preference for %s", (name) => {
|
||||
expect(toolDefaultOpen(tool(name), false, true)).toBe(false)
|
||||
expect(toolDefaultOpen(tool(name), true, false)).toBe(true)
|
||||
})
|
||||
|
||||
it.each(["edit", "write", "apply_patch"])("uses the code edit preference for %s", (name) => {
|
||||
expect(toolDefaultOpen(tool(name), true, false)).toBe(false)
|
||||
expect(toolDefaultOpen(tool(name), false, true)).toBe(true)
|
||||
})
|
||||
|
||||
it("leaves unrelated parts unchanged", () => {
|
||||
expect(toolDefaultOpen(tool("read"), true, true)).toBeUndefined()
|
||||
expect(toolDefaultOpen({ type: "text" } as Part, true, true)).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -33,14 +33,7 @@ import type { Part as TimelinePart } from "../../types/messages"
|
||||
import type { TimelineHighlight } from "../../utils/timeline/highlight"
|
||||
import { QuestionDock } from "./QuestionDock"
|
||||
import { SuggestBar } from "./SuggestBar"
|
||||
|
||||
const EDIT_TOOLS = new Set(["edit", "write", "apply_patch"])
|
||||
|
||||
function editOpen(part: SDKPart, open: boolean) {
|
||||
if (part.type !== "tool") return undefined
|
||||
const tool = (part as unknown as ToolPart).tool
|
||||
return EDIT_TOOLS.has(tool) ? open : undefined
|
||||
}
|
||||
import { toolDefaultOpen } from "./tool-default-open"
|
||||
|
||||
/** Extract plan path from a completed plan_exit tool part. */
|
||||
function planExitInfo(part: SDKPart): { plan: string } | undefined {
|
||||
@@ -296,7 +289,7 @@ export const AssistantMessage: Component<AssistantMessageProps> = (props) => {
|
||||
part={part}
|
||||
message={props.message as SDKMessage}
|
||||
showAssistantCopyPartID={props.showAssistantCopyPartID}
|
||||
defaultOpen={editOpen(part, edit())}
|
||||
defaultOpen={toolDefaultOpen(part, open(), edit())}
|
||||
forceOpen={forceOpen()}
|
||||
forceOpenFile={forceOpen() ? props.forceOpenFile : undefined}
|
||||
reasoningAutoCollapse={display.reasoningAutoCollapse()}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { Part as SDKPart, ToolPart } from "@kilocode/sdk/v2"
|
||||
|
||||
const EDIT_TOOLS = new Set(["edit", "write", "apply_patch"])
|
||||
const TERMINAL_TOOLS = new Set(["bash", "background_process"])
|
||||
|
||||
export function toolDefaultOpen(part: SDKPart, terminal: boolean, edit: boolean) {
|
||||
if (part.type !== "tool") return undefined
|
||||
const tool = (part as unknown as ToolPart).tool
|
||||
if (TERMINAL_TOOLS.has(tool)) return terminal
|
||||
if (EDIT_TOOLS.has(tool)) return edit
|
||||
return undefined
|
||||
}
|
||||
Reference in New Issue
Block a user