Compare commits

...

2 Commits

Author SHA1 Message Date
Aiden Cline a7e7646282 fix(tui): hide background badge on interrupted shells 2026-08-16 22:17:13 +00:00
opencode-agent[bot] fd2699b4d7 fix(tui): clarify saved permission copy (#41144)
Co-authored-by: Kit Langton <kit.langton@gmail.com>
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
2026-08-16 17:14:19 -05:00
5 changed files with 17 additions and 16 deletions
+2 -2
View File
@@ -722,7 +722,7 @@ describe("ShellTool", () => {
)
const settled = yield* executeTool(registry, call({ command: idleCommand, timeout: 50, background: true }))
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_")
const shell = yield* Shell.Service
@@ -807,7 +807,7 @@ describe("ShellTool", () => {
expect(yield* backgroundWhenReady()).toMatchObject([{ id: "call-background-signal", type: "shell" }])
const settled = yield* Fiber.join(waiting)
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({
type: "text",
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 color = createMemo(() => (permission() ? theme.text.feedback.warning.default : theme.text.default))
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 id = shellID()
return Boolean(id && data.shell.get(id))
@@ -3190,7 +3190,7 @@ function Subagent(props: ToolProps) {
if (id) navigate({ type: "session", sessionID: id })
}}
status={
isBackgroundSubagent(props.metadata, props.part.state.status) ? (
isBackgroundTool(props.metadata, props.part.state.status) ? (
<StatusBadge>Background</StatusBadge>
) : undefined
}
@@ -3200,7 +3200,7 @@ function Subagent(props: ToolProps) {
)
}
export function isBackgroundSubagent(
export function isBackgroundTool(
metadata: Record<string, unknown>,
status: SessionMessageAssistantTool["state"]["status"],
) {
+3 -3
View File
@@ -154,14 +154,14 @@ function wildcardDirectory(value: string) {
export function permissionAlwaysLines(input: { action: string; save?: ReadonlyArray<string> }): string[] {
const save = input.save ?? []
if (save.length === 1 && save[0] === "*") {
return [`This will allow ${input.action} until OpenCode is restarted.`]
return [`This will always allow ${input.action} for this project.`]
}
return ["This will allow the following patterns until OpenCode is restarted.", ...save.map((item) => `- ${item}`)]
return ["This will always allow the following patterns for this project.", ...save.map((item) => `- ${item}`)]
}
export function permissionOptionLabel(option: "once" | "always" | "reject" | "confirm" | "cancel") {
if (option === "once") return "Allow once"
if (option === "always") return "Allow always"
if (option === "always") return "Always allow"
if (option === "reject") return "Reject"
if (option === "confirm") return "Confirm"
return "Cancel"
@@ -4,7 +4,7 @@ import { testRender, type JSX } from "@opentui/solid"
import {
InlineToolRow,
executeCallSummary,
isBackgroundSubagent,
isBackgroundTool,
parseApplyPatchFiles,
parseDiagnostics,
parseQuestionAnswers,
@@ -214,11 +214,12 @@ describe("TUI inline tool wrapping", () => {
).toEqual([{ message: "valid", range: { start: { line: 2, character: 3 } } }])
})
test("labels only detached or async subagents as background", () => {
expect(isBackgroundSubagent({ status: "running" }, "running")).toBeFalse()
expect(isBackgroundSubagent({ status: "running" }, "completed")).toBeTrue()
expect(isBackgroundSubagent({ status: "running" }, "error")).toBeFalse()
expect(isBackgroundSubagent({ status: "completed" }, "completed")).toBeFalse()
test("labels only detached or async tools as background", () => {
expect(isBackgroundTool({ status: "running" }, "running")).toBeFalse()
expect(isBackgroundTool({ status: "running" }, "completed")).toBeTrue()
expect(isBackgroundTool({ status: "running" }, "error")).toBeFalse()
expect(isBackgroundTool({ status: "completed" }, "completed")).toBeFalse()
expect(isBackgroundTool({}, "completed")).toBeFalse()
})
test("snapshots consecutive grep, glob, and read rows at a narrow width", async () => {
@@ -183,11 +183,11 @@ describe("run permission shared", () => {
test("formats always-allow copy for wildcard and explicit patterns", () => {
expect(permissionAlwaysLines(req({ action: "bash", save: ["*"] }))).toEqual([
"This will allow bash until OpenCode is restarted.",
"This will always allow bash for this project.",
])
expect(permissionAlwaysLines(req({ save: ["src/**/*.ts", "src/**/*.tsx"] }))).toEqual([
"This will allow the following patterns until OpenCode is restarted.",
"This will always allow the following patterns for this project.",
"- src/**/*.ts",
"- src/**/*.tsx",
])