fix(tui): animate pending inline tools
This commit is contained in:
parent
672b8c4762
commit
b3cafd7bdb
2 changed files with 9 additions and 3 deletions
|
|
@ -587,6 +587,7 @@ function InlineTool(props: {
|
||||||
const [showError, setShowError] = createSignal(false)
|
const [showError, setShowError] = createSignal(false)
|
||||||
const error = createMemo(() => (props.part.state.status === "error" ? props.part.state.error.message : undefined))
|
const error = createMemo(() => (props.part.state.status === "error" ? props.part.state.error.message : undefined))
|
||||||
const complete = createMemo(() => !!props.complete)
|
const complete = createMemo(() => !!props.complete)
|
||||||
|
const active = createMemo(() => props.part.state.status === "pending" || props.part.state.status === "running")
|
||||||
const denied = createMemo(() => {
|
const denied = createMemo(() => {
|
||||||
const message = error()
|
const message = error()
|
||||||
if (!message) return false
|
if (!message) return false
|
||||||
|
|
@ -632,7 +633,7 @@ function InlineTool(props: {
|
||||||
>
|
>
|
||||||
<box flexShrink={0}>
|
<box flexShrink={0}>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Match when={props.spinner}>
|
<Match when={props.spinner || (!complete() && active())}>
|
||||||
<Spinner color={theme.text} />
|
<Spinner color={theme.text} />
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={complete()}>
|
<Match when={complete()}>
|
||||||
|
|
|
||||||
|
|
@ -1795,6 +1795,7 @@ function InlineTool(props: {
|
||||||
const sync = useSync()
|
const sync = useSync()
|
||||||
const renderer = useRenderer()
|
const renderer = useRenderer()
|
||||||
const [hover, setHover] = createSignal(false)
|
const [hover, setHover] = createSignal(false)
|
||||||
|
const active = createMemo(() => props.part.state.status === "pending" || props.part.state.status === "running")
|
||||||
|
|
||||||
const permission = createMemo(() => {
|
const permission = createMemo(() => {
|
||||||
const callID = sync.data.permission[ctx.sessionID]?.at(0)?.tool?.callID
|
const callID = sync.data.permission[ctx.sessionID]?.at(0)?.tool?.callID
|
||||||
|
|
@ -1854,8 +1855,12 @@ function InlineTool(props: {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Match when={props.spinner}>
|
<Match when={props.spinner || (!props.complete && active())}>
|
||||||
<Spinner color={fg()} children={props.children} />
|
<Spinner color={fg()}>
|
||||||
|
<Show when={props.complete} fallback={props.pending}>
|
||||||
|
{props.children}
|
||||||
|
</Show>
|
||||||
|
</Spinner>
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={true}>
|
<Match when={true}>
|
||||||
<text paddingLeft={3} fg={fg()} attributes={denied() ? TextAttributes.STRIKETHROUGH : undefined}>
|
<text paddingLeft={3} fg={fg()} attributes={denied() ? TextAttributes.STRIKETHROUGH : undefined}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue