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

This commit is contained in:
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
- 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
- Prefer functional array methods (flatMap, filter, map) over for loops; use type guards on filter to maintain type inference downstream
### Avoid let statements

View File

@@ -1799,9 +1799,19 @@ function Task(props: ToolProps<typeof TaskTool>) {
const keybind = useKeybind()
const { navigate } = useRoute()
const local = useLocal()
const sync = useSync()
const current = createMemo(() => props.metadata.summary?.findLast((x) => x.state.status !== "pending"))
const color = createMemo(() => local.agent.color(props.input.subagent_type ?? "unknown"))
const tools = createMemo(() => {
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 (
<Switch>
@@ -1817,13 +1827,17 @@ function Task(props: ToolProps<typeof TaskTool>) {
>
<box>
<text style={{ fg: theme.textMuted }}>
{props.input.description} ({props.metadata.summary?.length ?? 0} toolcalls)
{props.input.description} ({tools().length} toolcalls)
</text>
<Show when={current()}>
<text style={{ fg: current()!.state.status === "error" ? theme.error : theme.textMuted }}>
{Locale.titlecase(current()!.tool)}{" "}
{current()!.state.status === "completed" ? current()!.state.title : ""}
</text>
{(item) => {
const title = item().state.status === "completed" ? (item().state as any).title : ""
return (
<text style={{ fg: item().state.status === "error" ? theme.error : theme.textMuted }}>
{Locale.titlecase(item().tool)} {title}
</text>
)
}}
</Show>
</box>
<Show when={props.metadata.sessionId}>

View File

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