Visitar URL original
fix(tui): show the subagent card instead of launch instructions in mini scrollback by jlongster · Pull Request #63389 · anomalyco/opencode · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions packages/tui/src/mini/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,19 +504,24 @@ function emitPatch(state: State): void {
})
}

function subagentLaunch(sessionID: string) {
return {
output: [
`The subagent is working in the background (sessionID: ${sessionID}). You will receive a <subagent> message when it goes idle, and again after each later round of work.`,
"DO NOT sleep, poll for progress, ask the subagent for status, or duplicate this subagent's work; avoid working with the same files or topics it is using.",
"Work on non-overlapping tasks, or briefly tell the user what you launched and end your response.",
"To send it follow-ups or change its instructions while it runs, call subagent again with this sessionID.",
].join("\n"),
metadata: { sessionID, status: "running" },
}
}

function emitTask(state: State): void {
const ref = make(state, "subagent", {
description: "Scan run/* for reducer touchpoints",
agent: "explore",
})
doneTool(state, ref, {
output: "",
metadata: {
sessionID: "ses_demo_child",
status: "completed",
output: "",
},
})
doneTool(state, ref, subagentLaunch("ses_demo_child"))
const part = {
type: "tool",
id: "sub_demo_call_1",
Expand Down Expand Up @@ -666,14 +671,7 @@ function emitPermission(state: State, kind: PermissionKind = "edit"): void {
permission: "subagent",
patterns: ["explore"],
always: ["*"],
done: {
output: "",
metadata: {
sessionID: "sub_demo_perm_1",
status: "completed",
output: "",
},
},
done: subagentLaunch("sub_demo_perm_1"),
})
return
}
Expand Down Expand Up @@ -713,10 +711,7 @@ function emitPermission(state: State, kind: PermissionKind = "edit"): void {
permission: "doom_loop",
patterns: ["*"],
always: ["*"],
done: {
output: "Continuing after repeated failures.\n",
metadata: {},
},
done: subagentLaunch("sub_demo_doom_1"),
})
return
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tui/src/mini/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ export function toolEntryBody(
return undefined
}

if (commit.phase === "final" && ctx.status === "completed") {
if (commit.phase === "final" && ctx.status === "completed" && ctx.meta.status !== "running") {
const result = taskResult(ctx.output)
if (result) {
return markdownBody(result)
Expand Down
18 changes: 17 additions & 1 deletion packages/tui/test/mini/entry.body.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,23 @@ describe("run entry body", () => {
})
})

test("promotes subagent results to markdown and falls back to structured summaries", () => {
test("renders a task card for a completed background subagent launch", () => {
const launch = toolCommit({
tool: "subagent",
state: {
status: "completed",
input: { description: "Inspect reducer", agent: "explore" },
metadata: { sessionID: "ses-child-1", status: "running" },
content: [{ type: "text", text: "The subagent is working in the background (sessionID: ses-child-1)." }],
},
})
expect(entryBody(launch)).toEqual({
type: "structured",
snapshot: { kind: "task", title: "# Explore Subagent", rows: ["Inspect reducer"], tail: "" },
})
})

test("promotes legacy subagent results to markdown and falls back to structured summaries", () => {
const result = toolCommit({
tool: "subagent",
state: {
Expand Down