Fix clarify icon alignment and spurious error-red on non-zero exit
- clarify-tool: top-align the help icon (items-start + mt-px) so it sits beside the first line of a multi-line question instead of floating centered against the whole block. - tool-fallback: a non-zero exit code alone no longer paints the whole terminal/execute_code card red. grep no-match, diff differences, and piped commands routinely exit non-zero while producing useful output; only flag an error when the command produced no output. Explicit error signals (error field, success=false, status=error, isError) still go red. - Add regression tests covering the exit-code -> status matrix.
This commit is contained in:
@@ -742,9 +742,20 @@ function toolErrorText(part: ToolPart, result: Record<string, unknown>): string
|
||||
return firstStringField(result, ['message', 'reason', 'detail']) || `Tool returned status "${result.status}".`
|
||||
}
|
||||
|
||||
// A non-zero exit code alone is a weak failure signal: grep returns 1 on
|
||||
// no-match, diff returns 1 on differences, piped commands surface the last
|
||||
// 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).
|
||||
const exit = numberValue(result.exit_code)
|
||||
|
||||
return exit !== null && exit !== 0 ? `Command failed with exit code ${exit}.` : ''
|
||||
if (exit !== null && exit !== 0) {
|
||||
const hasOutput = Boolean(firstStringField(result, ['output', 'stdout', 'stderr'])?.trim())
|
||||
|
||||
return hasOutput ? '' : `Command failed with exit code ${exit}.`
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
function toolStatus(part: ToolPart, resultRecord: Record<string, unknown>): ToolStatus {
|
||||
|
||||
Reference in New Issue
Block a user