fix(desktop): count output_preview as command output

The nonzero-exit guard already knew a failing exit code with real output
usually isn't a failure worth painting red. It only looked at output /
stdout / stderr, but background-process polls report their text under
output_preview — so a poll of any process that exited nonzero rendered
destructive-red with no error to show, even when the output was routine
npm chatter. Half the red process rows in a real session history were
this case.
This commit is contained in:
Brooklyn Nicholson 2026-07-26 02:23:25 -05:00
parent 717746ecf8
commit 87ee6a52fa

View file

@ -676,10 +676,12 @@ function toolErrorText(part: ToolPart, result: Record<string, unknown>): string
// stage's code, etc. — all routinely produce useful output and aren't
// failures. Only treat it as an error when the command produced no real
// output to show; otherwise render the output normally (not red).
// `output_preview` counts as output: background-process polls report their
// text under that name, so omitting it painted healthy `process` rows red.
const exit = numberValue(result.exit_code)
if (exit !== null && exit !== 0) {
const hasOutput = Boolean(firstStringField(result, ['output', 'stdout', 'stderr'])?.trim())
const hasOutput = Boolean(firstStringField(result, ['output', 'stdout', 'stderr', 'output_preview'])?.trim())
return hasOutput ? '' : `Command failed with exit code ${exit}.`
}