From ed8013d6ce9d77a41dbab9ae28e6eee5e7b8b216 Mon Sep 17 00:00:00 2001 From: worldmozara Date: Thu, 29 Oct 2026 18:29:20 +0800 Subject: [PATCH] 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. --- src/plyngent/cli/display.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plyngent/cli/display.py b/src/plyngent/cli/display.py index f097122..abdfd48 100644 --- a/src/plyngent/cli/display.py +++ b/src/plyngent/cli/display.py @@ -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: