@@ -156,6 +156,7 @@ pub(crate) struct ToolSuggestionRequest {
156156struct McpToolApprovalDisplayParam {
157157 name : String ,
158158 value : Value ,
159+ display_name : String ,
159160}
160161
161162#[ derive( Clone , Debug , PartialEq ) ]
@@ -423,6 +424,7 @@ fn parse_tool_approval_display_params(meta: Option<&Value>) -> Vec<McpToolApprov
423424 . map ( |( name, value) | McpToolApprovalDisplayParam {
424425 name : name. clone ( ) ,
425426 value : value. clone ( ) ,
427+ display_name : name. clone ( ) ,
426428 } )
427429 . collect :: < Vec < _ > > ( )
428430 } )
@@ -437,9 +439,18 @@ fn parse_tool_approval_display_param(value: &Value) -> Option<McpToolApprovalDis
437439 if name. is_empty ( ) {
438440 return None ;
439441 }
442+ let display_name = value
443+ . get ( "display_name" )
444+ . and_then ( Value :: as_str)
445+ . unwrap_or ( name)
446+ . trim ( ) ;
447+ if display_name. is_empty ( ) {
448+ return None ;
449+ }
440450 Some ( McpToolApprovalDisplayParam {
441451 name : name. to_string ( ) ,
442452 value : value. get ( "value" ) ?. clone ( ) ,
453+ display_name : display_name. to_string ( ) ,
443454 } )
444455}
445456
@@ -472,7 +483,7 @@ fn format_tool_approval_display_message(
472483fn format_tool_approval_display_param_line ( param : & McpToolApprovalDisplayParam ) -> String {
473484 format ! (
474485 "{}: {}" ,
475- param. name ,
486+ param. display_name ,
476487 format_tool_approval_display_param_value( & param. value)
477488 )
478489}
@@ -1668,7 +1679,7 @@ mod tests {
16681679 fn tool_approval_meta (
16691680 persist_modes : & [ & str ] ,
16701681 tool_params : Option < Value > ,
1671- tool_params_display : Option < Vec < ( & str , Value ) > > ,
1682+ tool_params_display : Option < Vec < ( & str , Value , & str ) > > ,
16721683 ) -> Option < Value > {
16731684 let mut meta = serde_json:: Map :: from_iter ( [ (
16741685 APPROVAL_META_KIND_KEY . to_string ( ) ,
@@ -1694,10 +1705,11 @@ mod tests {
16941705 Value :: Array (
16951706 tool_params_display
16961707 . into_iter ( )
1697- . map ( |( name, value) | {
1708+ . map ( |( name, value, display_name ) | {
16981709 serde_json:: json!( {
16991710 "name" : name,
17001711 "value" : value,
1712+ "display_name" : display_name,
17011713 } )
17021714 } )
17031715 . collect ( ) ,
@@ -1961,8 +1973,16 @@ mod tests {
19611973 "alpha" : 1 ,
19621974 } ) ) ,
19631975 Some ( vec ! [
1964- ( "Calendar" , Value :: String ( "primary" . to_string( ) ) ) ,
1965- ( "Title" , Value :: String ( "Roadmap review" . to_string( ) ) ) ,
1976+ (
1977+ "calendar_id" ,
1978+ Value :: String ( "primary" . to_string( ) ) ,
1979+ "Calendar" ,
1980+ ) ,
1981+ (
1982+ "title" ,
1983+ Value :: String ( "Roadmap review" . to_string( ) ) ,
1984+ "Title" ,
1985+ ) ,
19661986 ] ) ,
19671987 ) ,
19681988 ) ,
@@ -1973,12 +1993,14 @@ mod tests {
19731993 request. approval_display_params,
19741994 vec![
19751995 McpToolApprovalDisplayParam {
1976- name: "Calendar " . to_string( ) ,
1996+ name: "calendar_id " . to_string( ) ,
19771997 value: Value :: String ( "primary" . to_string( ) ) ,
1998+ display_name: "Calendar" . to_string( ) ,
19781999 } ,
19792000 McpToolApprovalDisplayParam {
1980- name: "Title " . to_string( ) ,
2001+ name: "title " . to_string( ) ,
19812002 value: Value :: String ( "Roadmap review" . to_string( ) ) ,
2003+ display_name: "Title" . to_string( ) ,
19822004 } ,
19832005 ]
19842006 ) ;
@@ -2348,13 +2370,26 @@ mod tests {
23482370 "ignored_after_limit" : "fourth param" ,
23492371 } ) ) ,
23502372 Some ( vec ! [
2351- ( "Calendar" , Value :: String ( "primary" . to_string( ) ) ) ,
2352- ( "Title" , Value :: String ( "Roadmap review" . to_string( ) ) ) ,
23532373 (
2354- "Notes" ,
2374+ "calendar_id" ,
2375+ Value :: String ( "primary" . to_string( ) ) ,
2376+ "Calendar" ,
2377+ ) ,
2378+ (
2379+ "title" ,
2380+ Value :: String ( "Roadmap review" . to_string( ) ) ,
2381+ "Title" ,
2382+ ) ,
2383+ (
2384+ "notes" ,
23552385 Value :: String ( "This is a deliberately long note that should truncate before it turns the approval body into a giant wall of text in the TUI overlay." . to_string( ) ) ,
2386+ "Notes" ,
2387+ ) ,
2388+ (
2389+ "ignored_after_limit" ,
2390+ Value :: String ( "fourth param" . to_string( ) ) ,
2391+ "Ignored" ,
23562392 ) ,
2357- ( "Ignored" , Value :: String ( "fourth param" . to_string( ) ) ) ,
23582393 ] ) ,
23592394 ) ,
23602395 ) ,
0 commit comments