mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 03:56:55 +03:00
fix(tui): strip ANSI from tool errors and generic output (#58545)
This commit is contained in:
committed by
GitHub
Unverified
parent
c272a63cb4
commit
ddaf06adaf
@@ -207,7 +207,7 @@ function executeCode(input: SessionMessageAssistantTool["state"]["input"]) {
|
||||
}
|
||||
|
||||
function outputText(state: SessionMessageAssistantTool["state"]) {
|
||||
if (state.status === "error") return state.error.message || undefined
|
||||
if (state.status === "error") return stripAnsi(state.error.message) || undefined
|
||||
if (state.status !== "completed") return
|
||||
const text = stripAnsi(
|
||||
state.content
|
||||
|
||||
@@ -2730,7 +2730,7 @@ type ToolProps = {
|
||||
}
|
||||
function GenericTool(props: ToolProps) {
|
||||
const theme = useTheme()
|
||||
const output = createMemo(() => props.output?.trim() ?? "")
|
||||
const output = createMemo(() => stripAnsi(props.output?.trim() ?? ""))
|
||||
const input = createMemo(() => Object.entries(props.input))
|
||||
const [expanded, setExpanded] = createSignal(false)
|
||||
const expandable = createMemo(() => input().length > 0 || output().length > 0)
|
||||
@@ -2816,7 +2816,7 @@ function InlineTool(props: {
|
||||
const permission = useToolPermission(() => props.part)
|
||||
|
||||
const error = createMemo(() =>
|
||||
!props.running && props.part.state.status === "error" ? props.part.state.error.message : undefined,
|
||||
!props.running && props.part.state.status === "error" ? stripAnsi(props.part.state.error.message) : undefined,
|
||||
)
|
||||
|
||||
const denied = createMemo(
|
||||
@@ -2896,8 +2896,8 @@ function BlockTool(props: BlockToolProps) {
|
||||
const ctx = use()
|
||||
const renderer = useRenderer()
|
||||
const [hover, setHover] = createSignal(false)
|
||||
const error = createMemo(
|
||||
() => props.error ?? (props.part?.state.status === "error" ? props.part.state.error.message : undefined),
|
||||
const error = createMemo(() =>
|
||||
stripAnsi(props.error ?? (props.part?.state.status === "error" ? props.part.state.error.message : "")),
|
||||
)
|
||||
const permission = useToolPermission(() => props.part)
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user