@@ -161,7 +161,10 @@ func runRewindInteractive(ctx context.Context, w, errW io.Writer) error { //noli
161161 )
162162
163163 if err := form .Run (); err != nil {
164- return fmt .Errorf ("selection cancelled: %w" , err )
164+ if errors .Is (err , huh .ErrUserAborted ) {
165+ return nil
166+ }
167+ return fmt .Errorf ("selection failed: %w" , err )
165168 }
166169
167170 if selectedID == "cancel" {
@@ -208,7 +211,9 @@ func runRewindInteractive(ctx context.Context, w, errW io.Writer) error { //noli
208211
209212 // Preview rewind to show warnings about files that will be deleted
210213 preview , previewErr := start .PreviewRewind (ctx , * selectedPoint )
211- if previewErr == nil && preview != nil && len (preview .FilesToDelete ) > 0 {
214+ if previewErr != nil {
215+ fmt .Fprintf (errW , "Warning: could not preview rewind effects: %v\n " , previewErr )
216+ } else if preview != nil && len (preview .FilesToDelete ) > 0 {
212217 fmt .Fprintf (errW , "\n Warning: The following untracked files will be DELETED:\n " )
213218 for _ , f := range preview .FilesToDelete {
214219 fmt .Fprintf (errW , " - %s\n " , f )
@@ -229,7 +234,10 @@ func runRewindInteractive(ctx context.Context, w, errW io.Writer) error { //noli
229234 )
230235
231236 if err := confirmForm .Run (); err != nil {
232- return fmt .Errorf ("confirmation cancelled: %w" , err )
237+ if errors .Is (err , huh .ErrUserAborted ) {
238+ return nil
239+ }
240+ return fmt .Errorf ("confirmation failed: %w" , err )
233241 }
234242
235243 if ! confirm {
@@ -433,7 +441,9 @@ func runRewindToInternal(ctx context.Context, w, errW io.Writer, commitID string
433441
434442 // Preview rewind to show warnings about files that will be deleted
435443 preview , previewErr := start .PreviewRewind (ctx , * selectedPoint )
436- if previewErr == nil && preview != nil && len (preview .FilesToDelete ) > 0 {
444+ if previewErr != nil {
445+ fmt .Fprintf (errW , "Warning: could not preview rewind effects: %v\n " , previewErr )
446+ } else if preview != nil && len (preview .FilesToDelete ) > 0 {
437447 fmt .Fprintf (errW , "\n Warning: The following untracked files will be DELETED:\n " )
438448 for _ , f := range preview .FilesToDelete {
439449 fmt .Fprintf (errW , " - %s\n " , f )
@@ -798,7 +808,10 @@ func handleLogsOnlyRewindInteractive(ctx context.Context, w, errW io.Writer, sta
798808 )
799809
800810 if err := form .Run (); err != nil {
801- return fmt .Errorf ("action selection cancelled: %w" , err )
811+ if errors .Is (err , huh .ErrUserAborted ) {
812+ return nil
813+ }
814+ return fmt .Errorf ("action selection failed: %w" , err )
802815 }
803816
804817 switch action {
@@ -891,7 +904,10 @@ func handleLogsOnlyCheckout(ctx context.Context, w, errW io.Writer, start *strat
891904 )
892905
893906 if err := confirmForm .Run (); err != nil {
894- return fmt .Errorf ("confirmation cancelled: %w" , err )
907+ if errors .Is (err , huh .ErrUserAborted ) {
908+ return nil
909+ }
910+ return fmt .Errorf ("confirmation failed: %w" , err )
895911 }
896912
897913 if ! confirm {
@@ -986,7 +1002,10 @@ func handleLogsOnlyReset(ctx context.Context, w, errW io.Writer, start *strategy
9861002 )
9871003
9881004 if err := confirmForm .Run (); err != nil {
989- return fmt .Errorf ("confirmation cancelled: %w" , err )
1005+ if errors .Is (err , huh .ErrUserAborted ) {
1006+ return nil
1007+ }
1008+ return fmt .Errorf ("confirmation failed: %w" , err )
9901009 }
9911010
9921011 if ! confirm {
0 commit comments