diff options
| author | Spoon <[email protected]> | 2026-01-07 07:10:00 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-07 00:10:00 -0600 |
| commit | 85ed32931873c764ea6a6ec59ba2ce2f73667bfc (patch) | |
| tree | 9108e9b308886acaad081ff6699fff1dd5193ed2 | |
| parent | 37decee795bf3c152227ddff988a0ef5dec13e60 (diff) | |
| download | opencode-85ed32931873c764ea6a6ec59ba2ce2f73667bfc.tar.gz opencode-85ed32931873c764ea6a6ec59ba2ce2f73667bfc.zip | |
add agent color to inline task tool ascii char and highlight agent name (#7142)
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/context/local.tsx | 5 | ||||
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/routes/session/index.tsx | 18 |
2 files changed, 18 insertions, 5 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/context/local.tsx b/packages/opencode/src/cli/cmd/tui/context/local.tsx index b60a775b3..63f1d9743 100644 --- a/packages/opencode/src/cli/cmd/tui/context/local.tsx +++ b/packages/opencode/src/cli/cmd/tui/context/local.tsx @@ -75,9 +75,10 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({ }) }, color(name: string) { - const agent = agents().find((x) => x.name === name) + const all = sync.data.agent + const agent = all.find((x) => x.name === name) if (agent?.color) return RGBA.fromHex(agent.color) - const index = agents().findIndex((x) => x.name === name) + const index = all.findIndex((x) => x.name === name) if (index === -1) return colors()[0] return colors()[index % colors().length] }, diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index 1503e37d9..aa331ca0f 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -23,6 +23,7 @@ import { MacOSScrollAccel, type ScrollAcceleration, TextAttributes, + RGBA, } from "@opentui/core" import { Prompt, type PromptRef } from "@tui/component/prompt" import type { AssistantMessage, Part, ToolPart, UserMessage, TextPart, ReasoningPart } from "@opencode-ai/sdk/v2" @@ -1410,7 +1411,14 @@ function ToolTitle(props: { fallback: string; when: any; icon: string; children: ) } -function InlineTool(props: { icon: string; complete: any; pending: string; children: JSX.Element; part: ToolPart }) { +function InlineTool(props: { + icon: string + iconColor?: RGBA + complete: any + pending: string + children: JSX.Element + part: ToolPart +}) { const [margin, setMargin] = createSignal(0) const { theme } = useTheme() const ctx = use() @@ -1461,7 +1469,7 @@ function InlineTool(props: { icon: string; complete: any; pending: string; child > <text paddingLeft={3} fg={fg()} attributes={denied() ? TextAttributes.STRIKETHROUGH : undefined}> <Show fallback={<>~ {props.pending}</>} when={props.complete}> - <span style={{ bold: true }}>{props.icon}</span> {props.children} + <span style={{ fg: props.iconColor }}>{props.icon}</span> {props.children} </Show> </text> <Show when={error() && !denied()}> @@ -1644,8 +1652,10 @@ function Task(props: ToolProps<typeof TaskTool>) { const { theme } = useTheme() const keybind = useKeybind() const { navigate } = useRoute() + const local = useLocal() const current = createMemo(() => props.metadata.summary?.findLast((x) => x.state.status !== "pending")) + const color = createMemo(() => local.agent.color(props.input.subagent_type ?? "unknown")) return ( <Switch> @@ -1679,11 +1689,13 @@ function Task(props: ToolProps<typeof TaskTool>) { <Match when={true}> <InlineTool icon="◉" + iconColor={color()} pending="Delegating..." complete={props.input.subagent_type ?? props.input.description} part={props.part} > - {Locale.titlecase(props.input.subagent_type ?? "unknown")} Task "{props.input.description}" + <span style={{ fg: theme.text }}>{Locale.titlecase(props.input.subagent_type ?? "unknown")}</span> Task " + {props.input.description}" </InlineTool> </Match> </Switch> |
