@@ -374,6 +374,8 @@ func (r *REPL) handleInput() error {
374374 return err
375375 }
376376
377+ skipMessage := strings .HasPrefix (input , " " )
378+
377379 input = strings .TrimSpace (input )
378380 if input == "" {
379381 return nil
@@ -383,42 +385,32 @@ func (r *REPL) handleInput() error {
383385 if strings .HasPrefix (input , "/" ) || strings .HasPrefix (input , "." ) || input == "_" {
384386 // Add to history
385387 r .addToHistory (input )
386- return r .handleCommand (input )
387- }
388-
389- // Handle # prompt commands
390- if strings .HasPrefix (input , "#" ) {
388+ err = r .handleCommand (input )
389+ } else if strings .HasPrefix (input , "#" ) {
391390 // Add to history (also added in handlePromptCommand, but keep here for consistency)
392391 r .addToHistory (input )
393- return r .handlePromptCommand (input )
394- }
395-
396- // Handle $ template commands
397- if strings .HasPrefix (input , "$" ) {
392+ err = r .handlePromptCommand (input )
393+ } else if strings .HasPrefix (input , "$" ) {
398394 // Add to history
399395 r .addToHistory (input )
400- return r .handleTemplateCommand (input )
401- }
402-
403- // Handle ? prompt commands
404- if strings .HasPrefix (input , "?" ) {
396+ err = r .handleTemplateCommand (input )
397+ } else if strings .HasPrefix (input , "?" ) {
405398 // Add to history (also added in handlePromptCommand, but keep here for consistency)
406399 r .addToHistory (input )
407- return r .handleCommand ("/help" )
408- }
409-
410- // Handle shell commands
411- if strings .HasPrefix (input , "!" ) {
400+ err = r .handleCommand ("/help" )
401+ } else if strings .HasPrefix (input , "!" ) {
412402 // Add to history
413403 r .addToHistory (input )
414- return r .executeShellCommand (input [1 :])
404+ err = r .executeShellCommand (input [1 :])
405+ } else {
406+ r .addToHistory (input )
407+ err = r .sendToAI (input )
415408 }
416-
417- // Add to history (original input with command substitutions preserved)
418- r .addToHistory (input )
419-
420- // Send to AI
421- return r .sendToAI (input )
409+ if skipMessage {
410+ r .handleCommand ("/chat undo" )
411+ r .handleCommand ("/chat undo" )
412+ }
413+ return err
422414}
423415
424416func (r * REPL ) readLine () (string , error ) {
@@ -2425,17 +2417,17 @@ func (r *REPL) undoLastMessage() {
24252417 }
24262418
24272419 // Get the last message to show what was removed
2428- lastMsg := r .messages [len (r .messages )- 1 ]
2420+ // lastMsg := r.messages[len(r.messages)-1]
24292421
24302422 // Remove the last message
24312423 r .messages = r .messages [:len (r .messages )- 1 ]
24322424
24332425 // Show information about the removed message
2434- role := formatRole (lastMsg .Role )
2435- content := truncateContent (lastMsg .Content .(string ))
2426+ // role := formatRole(lastMsg.Role)
2427+ // content := truncateContent(lastMsg.Content.(string))
24362428
2437- fmt .Printf ("Removed last message (%s: %s)\r \n " , role , content )
2438- fmt .Printf ("Remaining messages: %d\r \n " , len (r .messages ))
2429+ // fmt.Printf("Removed last message (%s: %s)\r\n", role, content)
2430+ // fmt.Printf("Remaining messages: %d\r\n", len(r.messages))
24392431}
24402432
24412433// clearPendingImages removes all pending images
0 commit comments