mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-29 09:16:36 +00:00
Add spinner animation for Task tool (#11725)
This commit is contained in:
@@ -16,6 +16,7 @@ import path from "path"
|
||||
import { useRoute, useRouteData } from "@tui/context/route"
|
||||
import { useSync } from "@tui/context/sync"
|
||||
import { SplitBorder } from "@tui/component/border"
|
||||
import { Spinner } from "@tui/component/spinner"
|
||||
import { useTheme } from "@tui/context/theme"
|
||||
import {
|
||||
BoxRenderable,
|
||||
@@ -1559,7 +1560,13 @@ function InlineTool(props: {
|
||||
)
|
||||
}
|
||||
|
||||
function BlockTool(props: { title: string; children: JSX.Element; onClick?: () => void; part?: ToolPart }) {
|
||||
function BlockTool(props: {
|
||||
title: string
|
||||
children: JSX.Element
|
||||
onClick?: () => void
|
||||
part?: ToolPart
|
||||
spinner?: boolean
|
||||
}) {
|
||||
const { theme } = useTheme()
|
||||
const renderer = useRenderer()
|
||||
const [hover, setHover] = createSignal(false)
|
||||
@@ -1582,9 +1589,16 @@ function BlockTool(props: { title: string; children: JSX.Element; onClick?: () =
|
||||
props.onClick?.()
|
||||
}}
|
||||
>
|
||||
<text paddingLeft={3} fg={theme.textMuted}>
|
||||
{props.title}
|
||||
</text>
|
||||
<Show
|
||||
when={props.spinner}
|
||||
fallback={
|
||||
<text paddingLeft={3} fg={theme.textMuted}>
|
||||
{props.title}
|
||||
</text>
|
||||
}
|
||||
>
|
||||
<Spinner color={theme.textMuted}>{props.title.replace(/^# /, "")}</Spinner>
|
||||
</Show>
|
||||
{props.children}
|
||||
<Show when={error()}>
|
||||
<text fg={theme.error}>{error()}</text>
|
||||
@@ -1813,6 +1827,8 @@ function Task(props: ToolProps<typeof TaskTool>) {
|
||||
|
||||
const current = createMemo(() => tools().findLast((x) => x.state.status !== "pending"))
|
||||
|
||||
const isRunning = createMemo(() => props.part.state.status === "running")
|
||||
|
||||
return (
|
||||
<Switch>
|
||||
<Match when={props.input.description || props.input.subagent_type}>
|
||||
@@ -1824,6 +1840,7 @@ function Task(props: ToolProps<typeof TaskTool>) {
|
||||
: undefined
|
||||
}
|
||||
part={props.part}
|
||||
spinner={isRunning()}
|
||||
>
|
||||
<box>
|
||||
<text style={{ fg: theme.textMuted }}>
|
||||
|
||||
Reference in New Issue
Block a user