@@ -120,15 +120,20 @@ pub async fn get_session_detail(
120120 tool_operations. len( )
121121 ) ;
122122
123+ // Create a map of tool_operation_id -> tool_operation for efficient lookup
124+ log:: debug!( "Building tool operation lookup map" ) ;
125+ let tool_op_by_id: std:: collections:: HashMap < _ , _ > = tool_operations
126+ . into_iter ( )
127+ . map ( |op| ( op. id , op) )
128+ . collect ( ) ;
129+
123130 // Create a map of message_id -> tool_operation
124- log:: debug!( "Building tool operation map" ) ;
131+ log:: debug!( "Building message -> tool operation map" ) ;
125132 let mut tool_op_map = std:: collections:: HashMap :: new ( ) ;
126- for tool_op in tool_operations {
127- // Find the message that references this tool operation
128- for msg in & response. messages {
129- if msg. tool_operation_id == Some ( tool_op. id ) {
133+ for msg in & response. messages {
134+ if let Some ( tool_op_id) = msg. tool_operation_id {
135+ if let Some ( tool_op) = tool_op_by_id. get ( & tool_op_id) {
130136 tool_op_map. insert ( msg. id , tool_op. clone ( ) ) ;
131- break ;
132137 }
133138 }
134139 }
@@ -159,6 +164,8 @@ pub async fn get_session_detail(
159164 timestamp : op. timestamp . to_rfc3339 ( ) ,
160165 success : op. success ,
161166 result_summary : op. result_summary . clone ( ) ,
167+ raw_input : op. raw_input . clone ( ) ,
168+ raw_result : op. raw_result . clone ( ) ,
162169 file_metadata : op. file_metadata . as_ref ( ) . map ( |fm| FileMetadataItem {
163170 file_path : fm. file_path . clone ( ) ,
164171 file_extension : fm. file_extension . clone ( ) ,
0 commit comments