tui: fix task status to show current tool state from message store

pull/11714/head
Dax Raad 2026-02-01 20:52:17 -05:00
parent 6c9b2c37a5
commit 83d0e48e38
3 changed files with 22 additions and 8 deletions

View File

@ -12,6 +12,7 @@
- Prefer single word variable names where possible - Prefer single word variable names where possible
- Use Bun APIs when possible, like `Bun.file()` - Use Bun APIs when possible, like `Bun.file()`
- Rely on type inference when possible; avoid explicit type annotations or interfaces unless necessary for exports or clarity - Rely on type inference when possible; avoid explicit type annotations or interfaces unless necessary for exports or clarity
- Prefer functional array methods (flatMap, filter, map) over for loops; use type guards on filter to maintain type inference downstream
### Avoid let statements ### Avoid let statements

View File

@ -1799,9 +1799,19 @@ function Task(props: ToolProps<typeof TaskTool>) {
const keybind = useKeybind() const keybind = useKeybind()
const { navigate } = useRoute() const { navigate } = useRoute()
const local = useLocal() const local = useLocal()
const sync = useSync()
const current = createMemo(() => props.metadata.summary?.findLast((x) => x.state.status !== "pending")) const tools = createMemo(() => {
const color = createMemo(() => local.agent.color(props.input.subagent_type ?? "unknown")) const sessionID = props.metadata.sessionId
const msgs = sync.data.message[sessionID ?? ""] ?? []
return msgs.flatMap((msg) =>
(sync.data.part[msg.id] ?? [])
.filter((part): part is ToolPart => part.type === "tool")
.map((part) => ({ tool: part.tool, state: part.state })),
)
})
const current = createMemo(() => tools().findLast((x) => x.state.status !== "pending"))
return ( return (
<Switch> <Switch>
@ -1817,13 +1827,17 @@ function Task(props: ToolProps<typeof TaskTool>) {
> >
<box> <box>
<text style={{ fg: theme.textMuted }}> <text style={{ fg: theme.textMuted }}>
{props.input.description} ({props.metadata.summary?.length ?? 0} toolcalls) {props.input.description} ({tools().length} toolcalls)
</text> </text>
<Show when={current()}> <Show when={current()}>
<text style={{ fg: current()!.state.status === "error" ? theme.error : theme.textMuted }}> {(item) => {
{Locale.titlecase(current()!.tool)}{" "} const title = item().state.status === "completed" ? (item().state as any).title : ""
{current()!.state.status === "completed" ? current()!.state.title : ""} return (
</text> <text style={{ fg: item().state.status === "error" ? theme.error : theme.textMuted }}>
{Locale.titlecase(item().tool)} {title}
</text>
)
}}
</Show> </Show>
</box> </box>
<Show when={props.metadata.sessionId}> <Show when={props.metadata.sessionId}>

View File

@ -130,7 +130,6 @@ export const TaskTool = Tool.define("task", async (ctx) => {
ctx.metadata({ ctx.metadata({
title: params.description, title: params.description,
metadata: { metadata: {
summary: Object.values(parts).sort((a, b) => a.id.localeCompare(b.id)),
sessionId: session.id, sessionId: session.id,
model, model,
}, },