Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83d0e48

Browse files
committed
tui: fix task status to show current tool state from message store
1 parent 6c9b2c3 commit 83d0e48

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Prefer single word variable names where possible
1313
- Use Bun APIs when possible, like `Bun.file()`
1414
- Rely on type inference when possible; avoid explicit type annotations or interfaces unless necessary for exports or clarity
15+
- Prefer functional array methods (flatMap, filter, map) over for loops; use type guards on filter to maintain type inference downstream
1516

1617
### Avoid let statements
1718

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,9 +1799,19 @@ function Task(props: ToolProps<typeof TaskTool>) {
17991799
const keybind = useKeybind()
18001800
const { navigate } = useRoute()
18011801
const local = useLocal()
1802+
const sync = useSync()
1803+
1804+
const tools = createMemo(() => {
1805+
const sessionID = props.metadata.sessionId
1806+
const msgs = sync.data.message[sessionID ?? ""] ?? []
1807+
return msgs.flatMap((msg) =>
1808+
(sync.data.part[msg.id] ?? [])
1809+
.filter((part): part is ToolPart => part.type === "tool")
1810+
.map((part) => ({ tool: part.tool, state: part.state })),
1811+
)
1812+
})
18021813

1803-
const current = createMemo(() => props.metadata.summary?.findLast((x) => x.state.status !== "pending"))
1804-
const color = createMemo(() => local.agent.color(props.input.subagent_type ?? "unknown"))
1814+
const current = createMemo(() => tools().findLast((x) => x.state.status !== "pending"))
18051815

18061816
return (
18071817
<Switch>
@@ -1817,13 +1827,17 @@ function Task(props: ToolProps<typeof TaskTool>) {
18171827
>
18181828
<box>
18191829
<text style={{ fg: theme.textMuted }}>
1820-
{props.input.description} ({props.metadata.summary?.length ?? 0} toolcalls)
1830+
{props.input.description} ({tools().length} toolcalls)
18211831
</text>
18221832
<Show when={current()}>
1823-
<text style={{ fg: current()!.state.status === "error" ? theme.error : theme.textMuted }}>
1824-
{Locale.titlecase(current()!.tool)}{" "}
1825-
{current()!.state.status === "completed" ? current()!.state.title : ""}
1826-
</text>
1833+
{(item) => {
1834+
const title = item().state.status === "completed" ? (item().state as any).title : ""
1835+
return (
1836+
<text style={{ fg: item().state.status === "error" ? theme.error : theme.textMuted }}>
1837+
{Locale.titlecase(item().tool)} {title}
1838+
</text>
1839+
)
1840+
}}
18271841
</Show>
18281842
</box>
18291843
<Show when={props.metadata.sessionId}>

packages/opencode/src/tool/task.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ export const TaskTool = Tool.define("task", async (ctx) => {
130130
ctx.metadata({
131131
title: params.description,
132132
metadata: {
133-
summary: Object.values(parts).sort((a, b) => a.id.localeCompare(b.id)),
134133
sessionId: session.id,
135134
model,
136135
},

0 commit comments

Comments
 (0)