fix(tui): use running agent color for spinner animation

When a user submits a prompt with one agent (e.g., plan) and then
switches to another agent (e.g., build) while the request is running,
the spinner animation would incorrectly show the newly selected agent's
color instead of the actual running agent's color.

- Add runningAgent prop to Prompt component
- Derive running agent from last incomplete assistant message
- Use running agent color for spinner when session is busy
- Fall back to selected agent color when idle or no running agent
This commit is contained in:
David Hill
2026-01-16 00:09:20 +00:00
parent d47510785a
commit 8e49a6e7eb
2 changed files with 9 additions and 3 deletions

View File

@@ -40,6 +40,7 @@ export type PromptProps = {
ref?: (ref: PromptRef) => void
hint?: JSX.Element
showPlaceholder?: boolean
runningAgent?: string
}
export type PromptRef = {
@@ -701,20 +702,19 @@ export function Prompt(props: PromptProps) {
})
const spinnerDef = createMemo(() => {
const color = local.agent.color(local.agent.current().name)
const agent = status().type !== "idle" && props.runningAgent ? props.runningAgent : local.agent.current().name
const color = local.agent.color(agent)
return {
frames: createFrames({
color,
style: "blocks",
inactiveFactor: 0.6,
// enableFading: false,
minAlpha: 0.3,
}),
color: createColors({
color,
style: "blocks",
inactiveFactor: 0.6,
// enableFading: false,
minAlpha: 0.3,
}),
}

View File

@@ -136,6 +136,11 @@ export function Session() {
return messages().findLast((x) => x.role === "assistant")
})
const runningAgent = createMemo(() => {
const msg = messages().findLast((x) => x.role === "assistant" && !x.time.completed)
return msg?.agent
})
const dimensions = useTerminalDimensions()
const [sidebar, setSidebar] = kv.signal<"auto" | "hide">("sidebar", "hide")
const [sidebarOpen, setSidebarOpen] = createSignal(false)
@@ -1044,6 +1049,7 @@ export function Session() {
toBottom()
}}
sessionID={route.sessionID}
runningAgent={runningAgent()}
/>
</box>
</Show>