@@ -526,43 +526,56 @@ export class VsCodeMessenger {
526526 return ;
527527 }
528528
529- // Stash any uncommitted changes
529+ // Ask user what to do with uncommitted changes
530530 if (
531531 repo . state . workingTreeChanges . length > 0 ||
532532 repo . state . indexChanges . length > 0
533533 ) {
534- try {
535- await vscode . window . withProgress (
536- {
537- location : vscode . ProgressLocation . Notification ,
538- title : "Stashing local changes..." ,
539- cancellable : false ,
540- } ,
541- async ( ) => {
542- // Convert URI to file system path
543- const workspacePath =
544- vscode . Uri . parse ( matchingWorkspace ) . fsPath ;
545-
546- await this . ide . subprocess (
547- `git stash push -m "Continue: Stashed before opening agent ${ agentSessionId } "` ,
548- workspacePath ,
549- ) ;
550- } ,
551- ) ;
552- vscode . window . showInformationMessage (
553- "Local changes have been stashed." ,
554- ) ;
555- } catch ( e ) {
556- console . error ( "Failed to stash changes:" , e ) ;
557- const choice = await vscode . window . showWarningMessage (
558- "Failed to stash changes. Continue anyway?" ,
559- "Yes" ,
560- "No" ,
561- ) ;
562- if ( choice !== "Yes" ) {
563- return ;
534+ const changeCount =
535+ repo . state . workingTreeChanges . length +
536+ repo . state . indexChanges . length ;
537+
538+ const choice = await vscode . window . showWarningMessage (
539+ `You have ${ changeCount } uncommitted change(s). What would you like to do?` ,
540+ "Stash & Continue" ,
541+ "Continue Without Stashing" ,
542+ "Cancel" ,
543+ ) ;
544+
545+ if ( choice === "Cancel" || ! choice ) {
546+ return ;
547+ }
548+
549+ if ( choice === "Stash & Continue" ) {
550+ try {
551+ await vscode . window . withProgress (
552+ {
553+ location : vscode . ProgressLocation . Notification ,
554+ title : "Stashing local changes..." ,
555+ cancellable : false ,
556+ } ,
557+ async ( ) => {
558+ const workspacePath =
559+ vscode . Uri . parse ( matchingWorkspace ) . fsPath ;
560+ await this . ide . subprocess (
561+ `git stash push -m "Continue: Stashed before opening agent ${ agentSessionId } "` ,
562+ workspacePath ,
563+ ) ;
564+ } ,
565+ ) ;
566+ vscode . window . showInformationMessage (
567+ "Local changes have been stashed." ,
568+ ) ;
569+ } catch ( e ) {
570+ console . error ( "Failed to stash changes:" , e ) ;
571+ const errorMsg = e instanceof Error ? e . message : String ( e ) ;
572+ vscode . window . showErrorMessage (
573+ `Failed to stash changes: ${ errorMsg } ` ,
574+ ) ;
575+ return ; // Stop on stash failure
564576 }
565577 }
578+ // If "Continue Without Stashing" was chosen, just proceed
566579 }
567580
568581 // Check if we're already on the target branch
0 commit comments