mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
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:
@@ -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,
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user