@@ -97,6 +97,10 @@ fn execute_eval(args: EvalArgs) -> Result<()> {
9797fn should_render_inline_images ( args : & EvalArgs , result : & pcb_mcp:: ExecutionResult ) -> bool {
9898 args. output_dir . is_none ( )
9999 && !result. images . is_empty ( )
100+ && result
101+ . images
102+ . iter ( )
103+ . all ( |image| image. mime_type == "image/png" )
100104 && crate :: tty:: is_interactive ( )
101105 && matches ! ( detect_inline_image_protocol( ) , InlineImageProtocol :: Kitty )
102106}
@@ -122,21 +126,15 @@ fn detect_inline_image_protocol() -> InlineImageProtocol {
122126 InlineImageProtocol :: None
123127}
124128
125- fn render_inline_images_to_terminal ( images : & [ pcb_mcp:: ImageData ] ) -> Result < usize > {
126- let mut rendered = 0usize ;
129+ fn render_inline_images_to_terminal ( images : & [ pcb_mcp:: ImageData ] ) -> Result < ( ) > {
127130 for image in images {
128- if image. mime_type != "image/png" {
129- continue ;
130- }
131-
132131 use base64:: Engine ;
133132 let bytes = base64:: engine:: general_purpose:: STANDARD
134133 . decode ( & image. data )
135134 . context ( "Failed to decode image for inline terminal rendering" ) ?;
136135 render_kitty_png ( & bytes) ?;
137- rendered += 1 ;
138136 }
139- Ok ( rendered )
137+ Ok ( ( ) )
140138}
141139
142140fn render_kitty_png ( png_bytes : & [ u8 ] ) -> Result < ( ) > {
@@ -145,15 +143,21 @@ fn render_kitty_png(png_bytes: &[u8]) -> Result<()> {
145143 let encoded = base64:: engine:: general_purpose:: STANDARD . encode ( png_bytes) ;
146144 let mut stdout = std:: io:: stdout ( ) . lock ( ) ;
147145 let mut i = 0usize ;
146+ let mut first_chunk = true ;
148147 while i < encoded. len ( ) {
149148 let end = std:: cmp:: min ( i + 4096 , encoded. len ( ) ) ;
150149 let more = if end < encoded. len ( ) { 1 } else { 0 } ;
151- write ! (
152- stdout,
153- "\x1b _Gf=100,a=T,m={};{}\x1b \\ " ,
154- more,
155- & encoded[ i..end]
156- ) ?;
150+ if first_chunk {
151+ write ! (
152+ stdout,
153+ "\x1b _Gf=100,a=T,m={};{}\x1b \\ " ,
154+ more,
155+ & encoded[ i..end]
156+ ) ?;
157+ first_chunk = false ;
158+ } else {
159+ write ! ( stdout, "\x1b _Gm={};{}\x1b \\ " , more, & encoded[ i..end] ) ?;
160+ }
157161 i = end;
158162 }
159163 writeln ! ( stdout) ?;
@@ -182,8 +186,8 @@ fn resolve_eval_output_dir(output_dir: Option<&Path>) -> Result<PathBuf> {
182186 return Ok ( std:: env:: current_dir ( ) ?. join ( path) ) ;
183187 }
184188
185- Ok ( std:: env:: current_dir ( ) ?
186- . join ( "mcp-eval-artifacts" )
189+ Ok ( std:: env:: temp_dir ( )
190+ . join ( "pcb- mcp-eval-artifacts" )
187191 . join ( "inline" ) )
188192}
189193
0 commit comments