@@ -98,6 +98,8 @@ impl ForgeCommandManager {
9898 | "conversations"
9999 | "list"
100100 | "commit"
101+ | "rename"
102+ | "rn"
101103 )
102104 }
103105
@@ -107,6 +109,7 @@ impl ForgeCommandManager {
107109 . filter ( |command| !matches ! ( command, SlashCommand :: Custom ( _) ) )
108110 . filter ( |command| !matches ! ( command, SlashCommand :: Shell ( _) ) )
109111 . filter ( |command| !matches ! ( command, SlashCommand :: AgentSwitch ( _) ) )
112+ . filter ( |command| !matches ! ( command, SlashCommand :: Rename ( _) ) )
110113 . map ( |command| ForgeCommand {
111114 name : command. name ( ) . to_string ( ) ,
112115 description : command. usage ( ) . to_string ( ) ,
@@ -282,6 +285,16 @@ impl ForgeCommandManager {
282285 Ok ( SlashCommand :: Commit { max_diff_size } )
283286 }
284287 "/index" => Ok ( SlashCommand :: Index ) ,
288+ "/rename" | "/rn" => {
289+ let name = parameters. join ( " " ) ;
290+ let name = name. trim ( ) . to_string ( ) ;
291+ if name. is_empty ( ) {
292+ return Err ( anyhow:: anyhow!(
293+ "Usage: /rename <name>. Please provide a name for the conversation."
294+ ) ) ;
295+ }
296+ Ok ( SlashCommand :: Rename ( name) )
297+ }
285298 text => {
286299 let parts = text. split_ascii_whitespace ( ) . collect :: < Vec < & str > > ( ) ;
287300
@@ -420,6 +433,10 @@ pub enum SlashCommand {
420433 #[ strum( props( usage = "Delete a conversation permanently" ) ) ]
421434 Delete ,
422435
436+ /// Rename the current conversation
437+ #[ strum( props( usage = "Rename the current conversation. Usage: /rename <name>" ) ) ]
438+ Rename ( String ) ,
439+
423440 /// Switch directly to a specific agent by ID
424441 #[ strum( props( usage = "Switch directly to a specific agent" ) ) ]
425442 AgentSwitch ( String ) ,
@@ -467,6 +484,7 @@ impl SlashCommand {
467484 SlashCommand :: Retry => "retry" ,
468485 SlashCommand :: Conversations => "conversation" ,
469486 SlashCommand :: Delete => "delete" ,
487+ SlashCommand :: Rename ( _) => "rename" ,
470488 SlashCommand :: AgentSwitch ( agent_id) => agent_id,
471489 SlashCommand :: Index => "index" ,
472490 }
@@ -1242,4 +1260,55 @@ mod tests {
12421260 let expected = SlashCommand :: Dump { html : true } ;
12431261 assert_eq ! ( actual, expected) ;
12441262 }
1263+
1264+ #[ test]
1265+ fn test_parse_rename_command ( ) {
1266+ let fixture = ForgeCommandManager :: default ( ) ;
1267+ let actual = fixture. parse ( "/rename my-session" ) . unwrap ( ) ;
1268+ assert_eq ! ( actual, SlashCommand :: Rename ( "my-session" . to_string( ) ) ) ;
1269+ }
1270+
1271+ #[ test]
1272+ fn test_parse_rename_command_multi_word ( ) {
1273+ let fixture = ForgeCommandManager :: default ( ) ;
1274+ let actual = fixture. parse ( "/rename auth refactor work" ) . unwrap ( ) ;
1275+ assert_eq ! (
1276+ actual,
1277+ SlashCommand :: Rename ( "auth refactor work" . to_string( ) )
1278+ ) ;
1279+ }
1280+
1281+ #[ test]
1282+ fn test_parse_rename_command_no_name ( ) {
1283+ let fixture = ForgeCommandManager :: default ( ) ;
1284+ let result = fixture. parse ( "/rename" ) ;
1285+ assert ! ( result. is_err( ) ) ;
1286+ assert ! ( result. unwrap_err( ) . to_string( ) . contains( "provide a name" ) ) ;
1287+ }
1288+
1289+ #[ test]
1290+ fn test_parse_rename_alias ( ) {
1291+ let fixture = ForgeCommandManager :: default ( ) ;
1292+ let actual = fixture. parse ( "/rn my-session" ) . unwrap ( ) ;
1293+ assert_eq ! ( actual, SlashCommand :: Rename ( "my-session" . to_string( ) ) ) ;
1294+ }
1295+
1296+ #[ test]
1297+ fn test_parse_rename_trims_whitespace ( ) {
1298+ let fixture = ForgeCommandManager :: default ( ) ;
1299+ let actual = fixture. parse ( "/rename my title " ) . unwrap ( ) ;
1300+ assert_eq ! ( actual, SlashCommand :: Rename ( "my title" . to_string( ) ) ) ;
1301+ }
1302+
1303+ #[ test]
1304+ fn test_rename_is_reserved_command ( ) {
1305+ assert ! ( ForgeCommandManager :: is_reserved_command( "rename" ) ) ;
1306+ assert ! ( ForgeCommandManager :: is_reserved_command( "rn" ) ) ;
1307+ }
1308+
1309+ #[ test]
1310+ fn test_rename_command_name ( ) {
1311+ let cmd = SlashCommand :: Rename ( "test" . to_string ( ) ) ;
1312+ assert_eq ! ( cmd. name( ) , "rename" ) ;
1313+ }
12451314}
0 commit comments