cli/display: read past the approval line when rendering a detail

The line is for the model, and the human already saw the prompt. A detail that
parses the result (write_file's char count) must not see a header in front of
it; the verbose `[tool ok]` view keeps the whole text.
This commit is contained in:
2026-10-29 18:29:20 +08:00
parent 05166f2f76
commit ed8013d6ce
+13 -1
View File
@@ -1069,9 +1069,21 @@ def _pretty_line_for(name: str) -> PrettyLine | None:
return _PRETTY_LINES.get(name) or _mcp_line(name)
_APPROVAL_LINE = re.compile(r"\A\[approval\] [^\n]*\n")
def _without_approval_line(result: str) -> str:
"""The tool's own text, without the leading ``[approval]`` line.
That line is for the model (the human already saw the prompt); a pretty
detail reads the result it knows, not a header in front of it.
"""
return _APPROVAL_LINE.sub("", result, count=1)
def _pretty_parts(line: PrettyLine, args_json: str, result: str) -> tuple[str, str]:
"""Prefix + detail for a resolved pretty tool call."""
return line.prefix(args_json), line.detail(args_json, result)
return line.prefix(args_json), line.detail(args_json, _without_approval_line(result))
def _echo_stream(text: str) -> None: