From 4ea8954535a36a576920fce328d62b180fc252ed Mon Sep 17 00:00:00 2001 From: xintaofei Date: Sat, 28 Mar 2026 17:22:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AE=9E=E6=97=B6=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E6=97=B6=E8=A7=A3=E6=9E=90=E8=AF=BB=E5=8F=96=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=9A=84=E4=BB=A3=E7=A0=81=E8=A1=8C=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/acp/connection.rs | 15 +++++++++++++-- src-tauri/src/parsers/mod.rs | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/acp/connection.rs b/src-tauri/src/acp/connection.rs index da30f58..1528c6a 100644 --- a/src-tauri/src/acp/connection.rs +++ b/src-tauri/src/acp/connection.rs @@ -1887,6 +1887,15 @@ fn serialize_tool_call_content(content: &[ToolCallContent]) -> Option { } } +/// If the output looks like numbered lines (` 115→content`), strip them +/// and return `{"start_line":N,"content":"..."}` — same as the historical path. +fn structurize_live_output(text: &str) -> String { + if let Some(json) = crate::parsers::strip_numbered_lines(text) { + return json; + } + text.to_string() +} + /// Resolve line numbers for live tool call input. /// /// - For apply_patch with bare `@@`: resolve line numbers in place. @@ -2025,7 +2034,8 @@ fn emit_conversation_update( let content = serialize_tool_call_content(&tc.content); let raw_input = json_value_to_text(&tc.raw_input) .map(|text| resolve_live_tool_input(&text, cwd)); - let raw_output = json_value_to_text(&tc.raw_output); + let raw_output = json_value_to_text(&tc.raw_output) + .map(|text| structurize_live_output(&text)); crate::web::event_bridge::emit_event( app_handle, "acp://event", @@ -2049,7 +2059,8 @@ fn emit_conversation_update( .and_then(serialize_tool_call_content); let raw_input = json_value_to_text(&tcu.fields.raw_input) .map(|text| resolve_live_tool_input(&text, cwd)); - let raw_output = json_value_to_text(&tcu.fields.raw_output); + let raw_output = json_value_to_text(&tcu.fields.raw_output) + .map(|text| structurize_live_output(&text)); crate::web::event_bridge::emit_event( app_handle, "acp://event", diff --git a/src-tauri/src/parsers/mod.rs b/src-tauri/src/parsers/mod.rs index 6b0dac5..a01ac55 100644 --- a/src-tauri/src/parsers/mod.rs +++ b/src-tauri/src/parsers/mod.rs @@ -362,7 +362,7 @@ fn split_line_number(line: &str) -> Option<(u64, &str)> { /// If most lines have a recognized line-number prefix, strip them all /// and return `{"start_line":N,"content":"clean text"}`. -fn strip_numbered_lines(text: &str) -> Option { +pub fn strip_numbered_lines(text: &str) -> Option { let raw_lines: Vec<&str> = text.lines().collect(); if raw_lines.len() < 2 { return None;