@@ -44,6 +44,7 @@ import { IModelDeltaDecoration } from 'vs/editor/common/model';
4444import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
4545import { chatAgentLeader , chatSubcommandLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
4646import { renderMarkdownAsPlaintext } from 'vs/base/browser/markdownRenderer' ;
47+ import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService' ;
4748
4849export const enum State {
4950 CREATE_SESSION = 'CREATE_SESSION' ,
@@ -144,6 +145,7 @@ export class InlineChatController implements IEditorContribution {
144145 @IKeybindingService private readonly _keybindingService : IKeybindingService ,
145146 @IChatAccessibilityService private readonly _chatAccessibilityService : IChatAccessibilityService ,
146147 @IChatAgentService private readonly _chatAgentService : IChatAgentService ,
148+ @IBulkEditService private readonly _bulkEditService : IBulkEditService ,
147149 ) {
148150 this . _ctxHasActiveRequest = CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST . bindTo ( contextKeyService ) ;
149151 this . _ctxDidEdit = CTX_INLINE_CHAT_DID_EDIT . bindTo ( contextKeyService ) ;
@@ -270,7 +272,7 @@ export class InlineChatController implements IEditorContribution {
270272 this . _zone . value . setContainerMargins ( ) ;
271273 }
272274
273- if ( this . _activeSession && this . _activeSession . hasChangedText ) {
275+ if ( this . _activeSession && ( this . _activeSession . hasChangedText || this . _activeSession . lastExchange ) ) {
274276 widgetPosition = this . _activeSession . wholeRange . value . getStartPosition ( ) . delta ( - 1 ) ;
275277 }
276278 if ( this . _activeSession ) {
@@ -688,15 +690,15 @@ export class InlineChatController implements IEditorContribution {
688690 if ( reply . message ) {
689691 markdownContents . appendMarkdown ( reply . message . value ) ;
690692 }
691- const replyResponse = response = new ReplyResponse ( reply , markdownContents , this . _activeSession . textModelN . uri , modelAltVersionIdNow , progressEdits ) ;
693+ const replyResponse = response = this . _instaService . createInstance ( ReplyResponse , reply , markdownContents , this . _activeSession . textModelN . uri , modelAltVersionIdNow , progressEdits ) ;
692694
693695 for ( let i = progressEdits . length ; i < replyResponse . allLocalEdits . length ; i ++ ) {
694696 await this . _makeChanges ( replyResponse . allLocalEdits [ i ] , undefined ) ;
695697 }
696698
697699 const a11yMessageResponse = renderMarkdownAsPlaintext ( replyResponse . mdContent ) ;
698700
699- a11yResponse = this . _strategy . checkChanges ( replyResponse ) && a11yVerboseInlineChat
701+ a11yResponse = a11yVerboseInlineChat
700702 ? a11yMessageResponse ? localize ( 'editResponseMessage2' , "{0}, also review proposed changes in the diff editor." , a11yMessageResponse ) : localize ( 'editResponseMessage' , "Review proposed changes in the diff editor." )
701703 : a11yMessageResponse ;
702704 }
@@ -741,14 +743,10 @@ export class InlineChatController implements IEditorContribution {
741743 assertType ( this . _strategy ) ;
742744
743745 const { response } = this . _activeSession . lastExchange ! ;
744- if ( response instanceof ReplyResponse ) {
745- // edit response -> complex...
746- this . _zone . value . widget . updateMarkdownMessage ( undefined ) ;
747-
748- const canContinue = this . _strategy . checkChanges ( response ) ;
749- if ( ! canContinue ) {
750- return State . CANCEL ;
751- }
746+ if ( response instanceof ReplyResponse && response . workspaceEdit ) {
747+ // this reply cannot be applied in the normal inline chat UI and needs to be handled off to workspace edit
748+ this . _bulkEditService . apply ( response . workspaceEdit , { showPreview : true } ) ;
749+ return State . CANCEL ;
752750 }
753751 return State . SHOW_RESPONSE ;
754752 }
@@ -782,7 +780,7 @@ export class InlineChatController implements IEditorContribution {
782780 }
783781 }
784782
785- private async [ State . SHOW_RESPONSE ] ( ) : Promise < State . WAIT_FOR_INPUT | State . CANCEL > {
783+ private async [ State . SHOW_RESPONSE ] ( ) : Promise < State . WAIT_FOR_INPUT | State . CANCEL > {
786784 assertType ( this . _activeSession ) ;
787785 assertType ( this . _strategy ) ;
788786
@@ -826,18 +824,14 @@ export class InlineChatController implements IEditorContribution {
826824 this . _activeSession . lastExpansionState = this . _zone . value . widget . expansionState ;
827825 this . _zone . value . widget . updateToolbar ( true ) ;
828826
829- const canContinue = this . _strategy . checkChanges ( response ) ;
830- if ( ! canContinue ) {
831- return State . CANCEL ;
832- }
833827 await this . _strategy . renderChanges ( response ) ;
834828 }
835829 this . _showWidget ( false ) ;
836830
837831 return State . WAIT_FOR_INPUT ;
838832 }
839833
840- private async [ State . PAUSE ] ( ) {
834+ private async [ State . PAUSE ] ( ) {
841835
842836 this . _ctxDidEdit . reset ( ) ;
843837 this . _ctxUserDidEdit . reset ( ) ;
@@ -858,7 +852,7 @@ export class InlineChatController implements IEditorContribution {
858852 this . _activeSession = undefined ;
859853 }
860854
861- private async [ State . ACCEPT ] ( ) {
855+ private async [ State . ACCEPT ] ( ) {
862856 assertType ( this . _activeSession ) ;
863857 assertType ( this . _strategy ) ;
864858 this . _sessionStore . clear ( ) ;
@@ -876,7 +870,7 @@ export class InlineChatController implements IEditorContribution {
876870 this [ State . PAUSE ] ( ) ;
877871 }
878872
879- private async [ State . CANCEL ] ( ) {
873+ private async [ State . CANCEL ] ( ) {
880874 assertType ( this . _activeSession ) ;
881875 assertType ( this . _strategy ) ;
882876 this . _sessionStore . clear ( ) ;
0 commit comments