11use std:: collections:: HashSet ;
2+ use std:: fmt:: Write as _;
23use std:: path:: { Component , Path , PathBuf } ;
34use std:: sync:: { LazyLock , Mutex } ;
45
@@ -114,12 +115,12 @@ fn append_message_search_hit(md: &mut Md, hit: &Value) {
114115
115116 let mut header = format ! ( "**{role}** · {provider} · score {score:.1}" ) ;
116117 if let Some ( ts) = timestamp {
117- header . push_str ( & format ! ( " · t={ts}" ) ) ;
118+ let _ = write ! ( header , " · t={ts}" ) ;
118119 }
119120 md. bullet ( & header) ;
120121 let mut locator = format ! ( "session `{session_id}`" ) ;
121122 if let Some ( title) = title {
122- locator . push_str ( & format ! ( " — {title}" ) ) ;
123+ let _ = write ! ( locator , " — {title}" ) ;
123124 }
124125 md. line ( & format ! ( " {locator}" ) ) ;
125126 let text = message
@@ -133,7 +134,7 @@ fn append_message_search_hit(md: &mut Md, hit: &Value) {
133134}
134135
135136/// Best-effort single-line plain-text snippet from a stored message body.
136- /// Message text is frequently itself JSON (tool_use / tool_result blocks), so
137+ /// Message text is frequently itself JSON (` tool_use` / ` tool_result` blocks), so
137138/// pull the human-readable fields out rather than showing an escaped blob.
138139fn message_text_snippet ( text : & str , max_chars : usize ) -> String {
139140 let readable = readable_message_text ( text, max_chars. saturating_mul ( 8 ) ) ;
@@ -171,7 +172,6 @@ fn collect_readable_text(value: &Value, out: &mut String, budget: usize) {
171172 }
172173 out. push_str ( s) ;
173174 }
174- Value :: String ( _) => { }
175175 Value :: Array ( arr) => {
176176 for item in arr {
177177 collect_readable_text ( item, out, budget) ;
@@ -269,11 +269,7 @@ fn registry_session_db_candidates(
269269 Ok ( candidates)
270270}
271271
272- fn lcm_preflight_tool_json (
273- project_root : Option < & Path > ,
274- args : & Value ,
275- value : & Value ,
276- ) -> ToolResult {
272+ fn lcm_preflight_tool_json ( project_root : Option < & Path > , args : & Value , value : & Value ) -> ToolResult {
277273 if !render:: wants_json ( args) {
278274 // Markdown default: route through the normal renderer so an oversized
279275 // preflight payload is truncated *with* a retrieval handle. Passing the
@@ -575,7 +571,12 @@ fn bounded_lcm_expand_query_floor_text(
575571
576572 // Drop the unbounded arrays entirely; the synthesis prompt below tells the
577573 // bridge the context was elided and pagination/node ids are recoverable.
578- for key in [ "context_blocks" , "matches" , "node_ids" , "context_pagination" ] {
574+ for key in [
575+ "context_blocks" ,
576+ "matches" ,
577+ "node_ids" ,
578+ "context_pagination" ,
579+ ] {
579580 object. insert ( key. to_string ( ) , json ! ( [ ] ) ) ;
580581 object. insert ( format ! ( "{key}_truncated_for_mcp" ) , json ! ( true ) ) ;
581582 }
@@ -604,10 +605,7 @@ fn bounded_lcm_expand_query_floor_text(
604605 if let Some ( record) = & handle {
605606 object. insert ( "response_handle" . to_string ( ) , json ! ( record. handle) ) ;
606607 object. insert ( "retrieve_tool" . to_string ( ) , json ! ( RESPONSE_RETRIEVE_TOOL ) ) ;
607- object. insert (
608- "retrieve_expires_at" . to_string ( ) ,
609- json ! ( record. expires_at) ,
610- ) ;
608+ object. insert ( "retrieve_expires_at" . to_string ( ) , json ! ( record. expires_at) ) ;
611609 object. insert (
612610 "retrieve_instruction" . to_string ( ) ,
613611 json ! ( format!(
@@ -631,7 +629,7 @@ fn bounded_lcm_expand_query_floor_text(
631629 "needs_synthesis" : value
632630 . get( "needs_synthesis" )
633631 . cloned( )
634- . unwrap_or_else ( || json!( true ) ) ,
632+ . unwrap_or ( json!( true ) ) ,
635633 "context_blocks" : [ ] ,
636634 "matches" : [ ] ,
637635 "mcp_response_truncated" : true ,
@@ -2375,10 +2373,10 @@ mod tests {
23752373 "session_id" : "sess-abc-123" ,
23762374 "message_id" : "msg-1" ,
23772375 "role" : "assistant" ,
2378- "timestamp" : 1783117588 ,
2376+ "timestamp" : 1_783_117_588 ,
23792377 "text" : "[{\" type\" :\" tool_result\" ,\" tool_use_id\" :\" toolu_x\" ,\" content\" :\" the database backup completed successfully at 03:00 UTC\" }]" ,
23802378 "source_path" : "/home/zack/.claude/projects/x/sess-abc-123.jsonl" ,
2381- "source_offset" : 1676581 ,
2379+ "source_offset" : 1_676_581 ,
23822380 "metadata_json" : "{\" raw_type\" :\" assistant\" }" ,
23832381 } ,
23842382 } ] ,
@@ -2439,7 +2437,8 @@ mod tests {
24392437
24402438 #[ test]
24412439 fn message_text_snippet_extracts_readable_content_from_json ( ) {
2442- let text = "[{\" type\" :\" tool_result\" ,\" content\" :\" hello world\" ,\" tool_use_id\" :\" toolu_1\" }]" ;
2440+ let text =
2441+ "[{\" type\" :\" tool_result\" ,\" content\" :\" hello world\" ,\" tool_use_id\" :\" toolu_1\" }]" ;
24432442 let snippet = message_text_snippet ( text, 240 ) ;
24442443 assert_eq ! ( snippet, "hello world" ) ;
24452444 assert ! ( !snippet. contains( "tool_use_id" ) ) ;
@@ -2456,10 +2455,7 @@ mod tests {
24562455 #[ test]
24572456 fn message_text_snippet_plain_text_is_collapsed ( ) {
24582457 let text = "line one\n \n line two\t tabbed" ;
2459- assert_eq ! (
2460- message_text_snippet( text, 240 ) ,
2461- "line one line two tabbed"
2462- ) ;
2458+ assert_eq ! ( message_text_snippet( text, 240 ) , "line one line two tabbed" ) ;
24632459 }
24642460
24652461 #[ test]
0 commit comments