File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -159,12 +159,16 @@ fn build_structured_output(parsed: &ExecOutputJson) -> String {
159
159
parsed. metadata. duration_seconds
160
160
) ) ;
161
161
162
+ let mut output = parsed. output . clone ( ) ;
162
163
if let Some ( total_lines) = extract_total_output_lines ( & parsed. output ) {
163
164
sections. push ( format ! ( "Total output lines: {total_lines}" ) ) ;
165
+ if let Some ( stripped) = strip_total_output_header ( & output) {
166
+ output = stripped. to_string ( ) ;
167
+ }
164
168
}
165
169
166
170
sections. push ( "Output:" . to_string ( ) ) ;
167
- sections. push ( parsed . output . clone ( ) ) ;
171
+ sections. push ( output) ;
168
172
169
173
sections. join ( "\n " )
170
174
}
@@ -177,6 +181,13 @@ fn extract_total_output_lines(output: &str) -> Option<u32> {
177
181
total_segment. parse :: < u32 > ( ) . ok ( )
178
182
}
179
183
184
+ fn strip_total_output_header ( output : & str ) -> Option < & str > {
185
+ let after_prefix = output. strip_prefix ( "Total output lines: " ) ?;
186
+ let ( _, remainder) = after_prefix. split_once ( '\n' ) ?;
187
+ let remainder = remainder. strip_prefix ( '\n' ) . unwrap_or ( remainder) ;
188
+ Some ( remainder)
189
+ }
190
+
180
191
#[ derive( Debug ) ]
181
192
pub enum ResponseEvent {
182
193
Created ,
Original file line number Diff line number Diff line change @@ -255,17 +255,17 @@ async fn shell_output_reserializes_truncated_content() -> Result<()> {
255
255
Wall time: [0-9]+(?:\.[0-9]+)? seconds
256
256
Total output lines: 400
257
257
Output:
258
- Total output lines: 400
259
-
260
258
1
261
259
2
262
260
3
263
261
4
264
262
5
265
263
6
266
- .*\[\.{3} omitted \d+ of 400 lines \.{3}\]
264
+ .*
265
+ \[\.{3} omitted \d+ of 400 lines \.{3}\]
267
266
268
- .*\n396
267
+ .*
268
+ 396
269
269
397
270
270
398
271
271
399
Original file line number Diff line number Diff line change @@ -516,7 +516,6 @@ async fn shell_sandbox_denied_truncates_error_output() -> Result<()> {
516
516
Wall time: [0-9]+(?:\.[0-9]+)? seconds
517
517
Total output lines: \d+
518
518
Output:
519
- Total output lines: \d+
520
519
521
520
failed in sandbox: .*?(?:Operation not permitted|Permission denied|Read-only file system).*?
522
521
\[\.{3} omitted \d+ of \d+ lines \.{3}\]
@@ -601,7 +600,6 @@ execution error: .*$"#;
601
600
Wall time: [0-9]+(?:\.[0-9]+)? seconds
602
601
Total output lines: \d+
603
602
Output:
604
- Total output lines: \d+
605
603
606
604
execution error: .*$"# ;
607
605
let spawn_error_regex = Regex :: new ( spawn_error_pattern) ?;
You can’t perform that action at this time.
0 commit comments