Skip to content

Commit d951e94

Browse files
fix(tui): honor configured agent colors in Mini (#62067)
Co-authored-by: Daniel Smolsky <dannysmo@gmail.com>
1 parent a62a74a commit d951e94

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

‎packages/tui/src/mini/catalog.shared.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function runAgent(input: CurrentAgent): RunAgent {
3232
id: input.id,
3333
name: input.name,
3434
description: input.description,
35+
color: input.color,
3536
mode: input.mode,
3637
hidden: input.hidden,
3738
}

‎packages/tui/src/mini/footer.view.tsx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// The view itself is stateless except for derived memos.
1010
/** @jsxImportSource @opentui/solid */
1111
import { useRenderer, useTerminalDimensions } from "@opentui/solid"
12-
import { TextBuffer, TextBufferView } from "@opentui/core"
12+
import { RGBA, TextBuffer, TextBufferView } from "@opentui/core"
1313
import { For, Match, Show, Switch, createEffect, createMemo, createSignal, onCleanup } from "solid-js"
1414
import { OneCellSpinner } from "../component/one-cell-spinner"
1515
import { WORK_SPINNERS, SEED_LAUNCH, SEED_MONO } from "../ui/one-cell-motion"
@@ -228,10 +228,10 @@ export function RunFooterView(props: RunFooterViewProps) {
228228
const theme = createMemo(() => runTheme().footer)
229229
const agentColor = createMemo(() => {
230230
const colors = theme().categorical
231-
const index = props
232-
.agents()
233-
.filter((agent) => !agent.hidden)
234-
.findIndex((agent) => agent.id === props.currentAgentID())
231+
const agents = props.agents().filter((agent) => !agent.hidden)
232+
const index = agents.findIndex((agent) => agent.id === props.currentAgentID())
233+
const color = agents[index]?.color
234+
if (!props.mono && color) return RGBA.fromHex(color)
235235
return colors[Math.max(0, index) % colors.length]!
236236
})
237237
const block = createMemo(() => runTheme().block)

‎packages/tui/src/mini/types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export type RunAgent = {
103103
id: string
104104
name: string
105105
description?: string
106+
color?: string
106107
mode: "subagent" | "primary" | "all"
107108
hidden: boolean
108109
}

‎packages/tui/test/mini/footer.view.test.tsx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,22 @@ test.each(["Build", "Plan"])("working marker matches the %s label and prompt rai
21252125
}
21262126
})
21272127

2128+
test("configured agent color paints the label, prompt rail, and working marker", async () => {
2129+
const app = await renderFooter({
2130+
agents: [{ id: "build", name: "Build", mode: "primary", hidden: false, color: "#ff79c6" }],
2131+
state: { phase: "running" },
2132+
})
2133+
try {
2134+
await app.renderOnce()
2135+
const spans = app.captureSpans().lines.flatMap((line) => line.spans)
2136+
for (const text of ["Build", "\u2503", "\u25aa"]) {
2137+
expect(spans.find((span) => span.text.includes(text))?.fg.toInts()).toEqual([255, 121, 198, 255])
2138+
}
2139+
} finally {
2140+
app.cleanup()
2141+
}
2142+
})
2143+
21282144
test("spinner repaints keep the prompt instance, cursor state, and footer height stable", async () => {
21292145
const app = await renderFooter({
21302146
tuiConfig: createTuiResolvedConfig({ animations: true }),

0 commit comments

Comments
 (0)