@@ -252,9 +252,17 @@ impl EventLoop {
252252 }
253253 Ok ( Some ( Ok ( ResponseEvent :: ToolCall ( tool_call) ) ) ) => {
254254 // Parse arguments from JSON string
255- let arguments = serde_json:: from_str( & tool_call. arguments)
256- . unwrap_or_else( |_| serde_json:: json!( { "raw" : tool_call. arguments, "remote" : tool_call. remote} ) ) ;
255+ let mut arguments = serde_json:: from_str( & tool_call. arguments)
256+ . unwrap_or_else( |_| {
257+ serde_json:: json!( { "raw" : tool_call. arguments} )
258+ } ) ;
259+ if tool_call. remote
260+ && let Some ( obj) = arguments. as_object_mut( )
261+ {
262+ obj. insert( "remote" . into( ) , serde_json:: json!( true ) ) ;
263+ }
257264 if tool_call. remote {
265+ // Cloud-executed tools: first-class row only, no local re-exec.
258266 if tx
259267 . send( StreamEvent :: ToolCallStart {
260268 id: tool_call. id. clone( ) ,
@@ -265,8 +273,7 @@ impl EventLoop {
265273 {
266274 break ;
267275 }
268- }
269- if tx
276+ } else if tx
270277 . send( StreamEvent :: ToolCall {
271278 id: tool_call. id. clone( ) ,
272279 name: tool_call. name. clone( ) ,
@@ -280,13 +287,16 @@ impl EventLoop {
280287 }
281288 Ok ( Some ( Ok ( ResponseEvent :: ToolResult { id, success, output } ) ) ) => {
282289 if tx
283- . send( StreamEvent :: ToolCallComplete { id: id. clone( ) } )
290+ . send( StreamEvent :: ToolCallComplete {
291+ id: id. clone( ) ,
292+ success,
293+ output,
294+ } )
284295 . await
285296 . is_err( )
286297 {
287298 break ;
288299 }
289- let _ = ( success, output) ;
290300 }
291301 Ok ( Some ( Err ( e) ) ) => {
292302 let _ = tx. send( StreamEvent :: Error ( e. to_string( ) ) ) . await ;
@@ -362,9 +372,23 @@ impl EventLoop {
362372 self . app_state
363373 . update_tool_status ( & id, crate :: views:: tool_call:: ToolStatus :: Running ) ;
364374 }
365- StreamEvent :: ToolCallComplete { id } => {
366- self . app_state
367- . update_tool_status ( & id, crate :: views:: tool_call:: ToolStatus :: Completed ) ;
375+ StreamEvent :: ToolCallComplete {
376+ id,
377+ success,
378+ output,
379+ } => {
380+ let summary = if success {
381+ "↳ done" . to_string ( )
382+ } else {
383+ "↳ error" . to_string ( )
384+ } ;
385+ if !output. is_empty ( ) || !success {
386+ self . app_state
387+ . update_tool_result ( & id, output, success, summary) ;
388+ } else {
389+ self . app_state
390+ . update_tool_status ( & id, crate :: views:: tool_call:: ToolStatus :: Completed ) ;
391+ }
368392 }
369393 _ => {
370394 // Other variants not specifically handled
@@ -867,23 +891,38 @@ impl EventLoop {
867891 break ;
868892 }
869893 Ok ( Some ( Ok ( ResponseEvent :: ToolCall ( tool_call) ) ) ) => {
870- let arguments = serde_json:: from_str( & tool_call. arguments)
871- . unwrap_or_else( |_| serde_json:: json!( { "raw" : tool_call. arguments, "remote" : tool_call. remote} ) ) ;
872- if tx
873- . send( StreamEvent :: ToolCall {
894+ let mut arguments = serde_json:: from_str( & tool_call. arguments)
895+ . unwrap_or_else( |_| {
896+ serde_json:: json!( { "raw" : tool_call. arguments} )
897+ } ) ;
898+ if tool_call. remote
899+ && let Some ( obj) = arguments. as_object_mut( )
900+ {
901+ obj. insert( "remote" . into( ) , serde_json:: json!( true ) ) ;
902+ }
903+ let event = if tool_call. remote {
904+ StreamEvent :: ToolCallStart {
905+ id: tool_call. id. clone( ) ,
906+ name: tool_call. name. clone( ) ,
907+ }
908+ } else {
909+ StreamEvent :: ToolCall {
874910 id: tool_call. id. clone( ) ,
875911 name: tool_call. name. clone( ) ,
876912 arguments,
877- } )
878- . await
879- . is_err( )
880- {
913+ }
914+ } ;
915+ if tx. send( event) . await . is_err( ) {
881916 break ;
882917 }
883918 }
884- Ok ( Some ( Ok ( ResponseEvent :: ToolResult { id, .. } ) ) ) => {
919+ Ok ( Some ( Ok ( ResponseEvent :: ToolResult { id, success , output } ) ) ) => {
885920 if tx
886- . send( StreamEvent :: ToolCallComplete { id } )
921+ . send( StreamEvent :: ToolCallComplete {
922+ id,
923+ success,
924+ output,
925+ } )
887926 . await
888927 . is_err( )
889928 {
0 commit comments