diff --git a/.changeset/bash-tool-render-sync.md b/.changeset/bash-tool-render-sync.md new file mode 100644 index 000000000000..ade15d49be30 --- /dev/null +++ b/.changeset/bash-tool-render-sync.md @@ -0,0 +1,5 @@ +--- +"kilo-code": patch +--- + +Speed up rendering of expanded bash tool cards in the VS Code chat webview. diff --git a/packages/kilo-ui/src/components/basic-tool.tsx b/packages/kilo-ui/src/components/basic-tool.tsx index ac225cd73b00..fa4776d51353 100644 --- a/packages/kilo-ui/src/components/basic-tool.tsx +++ b/packages/kilo-ui/src/components/basic-tool.tsx @@ -1,4 +1,4 @@ -import { Show } from "solid-js" +import { createMemo, Show } from "solid-js" import { BasicTool as Base, GenericTool } from "@opencode-ai/ui/basic-tool" import type { BasicToolProps as BaseProps, TriggerTitle } from "@opencode-ai/ui/basic-tool" import { toolOpenKey, readToolOpen, writeToolOpen } from "./tool-open-state" @@ -46,12 +46,18 @@ export function BasicTool(props: BasicToolProps) { } // Renders after the body/tool list, not before — it's context about what // happened, not part of the header. - const details = () => ( + const buildDetails = () => (
{props.children} {(value) => }
) + // Base reads its children getter several times while laying out the tool, and a + // bare accessor rebuilds this subtree on every read (for a bash card, three + // BashHighlightedOutput instances per render). Memoize eager tools so repeated + // reads reuse one subtree. Deferred tools must stay lazy: createMemo runs + // eagerly, which would build a collapsed body before the card opens. + const details = props.defer ? buildDetails : createMemo(buildDetails) // A , not a plain `if`: inBody() tracks the visibility toggle, which can // flip after mount (Settings), so the branch must stay reactive. return (