Compare commits

...

1 Commits

Author SHA1 Message Date
Aiden Cline a7e7646282 fix(tui): hide background badge on interrupted shells 2026-08-16 22:17:13 +00:00
3 changed files with 12 additions and 11 deletions
+2 -2
View File
@@ -722,7 +722,7 @@ describe("ShellTool", () => {
) )
const settled = yield* executeTool(registry, call({ command: idleCommand, timeout: 50, background: true })) const settled = yield* executeTool(registry, call({ command: idleCommand, timeout: 50, background: true }))
const shellID = typeof settled.metadata?.shellID === "string" ? settled.metadata.shellID : undefined const shellID = typeof settled.metadata?.shellID === "string" ? settled.metadata.shellID : undefined
expect(settled.metadata).toMatchObject({ truncated: false }) expect(settled.metadata).toMatchObject({ status: "running", truncated: false })
expect(shellID).toStartWith("sh_") expect(shellID).toStartWith("sh_")
const shell = yield* Shell.Service const shell = yield* Shell.Service
@@ -807,7 +807,7 @@ describe("ShellTool", () => {
expect(yield* backgroundWhenReady()).toMatchObject([{ id: "call-background-signal", type: "shell" }]) expect(yield* backgroundWhenReady()).toMatchObject([{ id: "call-background-signal", type: "shell" }])
const settled = yield* Fiber.join(waiting) const settled = yield* Fiber.join(waiting)
const shellID = typeof settled.metadata?.shellID === "string" ? settled.metadata.shellID : undefined const shellID = typeof settled.metadata?.shellID === "string" ? settled.metadata.shellID : undefined
expect(settled.metadata).toMatchObject({ truncated: false }) expect(settled.metadata).toMatchObject({ status: "running", truncated: false })
expect(settled.content?.[0]).toEqual({ expect(settled.content?.[0]).toEqual({
type: "text", type: "text",
text: "The command was moved to the background.", text: "The command was moved to the background.",
+3 -3
View File
@@ -2930,7 +2930,7 @@ function Shell(props: ToolProps) {
const permission = useToolPermission(() => props.part) const permission = useToolPermission(() => props.part)
const color = createMemo(() => (permission() ? theme.text.feedback.warning.default : theme.text.default)) const color = createMemo(() => (permission() ? theme.text.feedback.warning.default : theme.text.default))
const shellID = createMemo(() => stringValue(props.metadata.shellID)) const shellID = createMemo(() => stringValue(props.metadata.shellID))
const background = createMemo(() => Boolean(shellID()) && props.part.state.status !== "running") const background = createMemo(() => isBackgroundTool(props.metadata, props.part.state.status))
const backgroundRunning = createMemo(() => { const backgroundRunning = createMemo(() => {
const id = shellID() const id = shellID()
return Boolean(id && data.shell.get(id)) return Boolean(id && data.shell.get(id))
@@ -3190,7 +3190,7 @@ function Subagent(props: ToolProps) {
if (id) navigate({ type: "session", sessionID: id }) if (id) navigate({ type: "session", sessionID: id })
}} }}
status={ status={
isBackgroundSubagent(props.metadata, props.part.state.status) ? ( isBackgroundTool(props.metadata, props.part.state.status) ? (
<StatusBadge>Background</StatusBadge> <StatusBadge>Background</StatusBadge>
) : undefined ) : undefined
} }
@@ -3200,7 +3200,7 @@ function Subagent(props: ToolProps) {
) )
} }
export function isBackgroundSubagent( export function isBackgroundTool(
metadata: Record<string, unknown>, metadata: Record<string, unknown>,
status: SessionMessageAssistantTool["state"]["status"], status: SessionMessageAssistantTool["state"]["status"],
) { ) {
@@ -4,7 +4,7 @@ import { testRender, type JSX } from "@opentui/solid"
import { import {
InlineToolRow, InlineToolRow,
executeCallSummary, executeCallSummary,
isBackgroundSubagent, isBackgroundTool,
parseApplyPatchFiles, parseApplyPatchFiles,
parseDiagnostics, parseDiagnostics,
parseQuestionAnswers, parseQuestionAnswers,
@@ -214,11 +214,12 @@ describe("TUI inline tool wrapping", () => {
).toEqual([{ message: "valid", range: { start: { line: 2, character: 3 } } }]) ).toEqual([{ message: "valid", range: { start: { line: 2, character: 3 } } }])
}) })
test("labels only detached or async subagents as background", () => { test("labels only detached or async tools as background", () => {
expect(isBackgroundSubagent({ status: "running" }, "running")).toBeFalse() expect(isBackgroundTool({ status: "running" }, "running")).toBeFalse()
expect(isBackgroundSubagent({ status: "running" }, "completed")).toBeTrue() expect(isBackgroundTool({ status: "running" }, "completed")).toBeTrue()
expect(isBackgroundSubagent({ status: "running" }, "error")).toBeFalse() expect(isBackgroundTool({ status: "running" }, "error")).toBeFalse()
expect(isBackgroundSubagent({ status: "completed" }, "completed")).toBeFalse() expect(isBackgroundTool({ status: "completed" }, "completed")).toBeFalse()
expect(isBackgroundTool({}, "completed")).toBeFalse()
}) })
test("snapshots consecutive grep, glob, and read rows at a narrow width", async () => { test("snapshots consecutive grep, glob, and read rows at a narrow width", async () => {