@@ -43,6 +43,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
43
43
import { IModelDeltaDecoration } from 'vs/editor/common/model' ;
44
44
import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
45
45
import { chatAgentLeader , chatSubcommandLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
46
+ import { renderMarkdownAsPlaintext } from 'vs/base/browser/markdownRenderer' ;
46
47
47
48
export const enum State {
48
49
CREATE_SESSION = 'CREATE_SESSION' ,
@@ -564,6 +565,7 @@ export class InlineChatController implements IEditorContribution {
564
565
private async [ State . MAKE_REQUEST ] ( ) : Promise < State . APPLY_RESPONSE | State . PAUSE | State . CANCEL | State . ACCEPT > {
565
566
assertType ( this . _editor . hasModel ( ) ) ;
566
567
assertType ( this . _activeSession ) ;
568
+ assertType ( this . _strategy ) ;
567
569
assertType ( this . _activeSession . lastInput ) ;
568
570
569
571
const requestCts = new CancellationTokenSource ( ) ;
@@ -586,7 +588,6 @@ export class InlineChatController implements IEditorContribution {
586
588
wholeRange : this . _activeSession . wholeRange . value ,
587
589
live : this . _activeSession . editMode !== EditMode . Preview // TODO@jrieken let extension know what document is used for previewing
588
590
} ;
589
- this . _chatAccessibilityService . acceptRequest ( ) ;
590
591
591
592
const modelAltVersionIdNow = this . _activeSession . textModelN . getAlternativeVersionId ( ) ;
592
593
const progressEdits : TextEdit [ ] [ ] = [ ] ;
@@ -646,6 +647,11 @@ export class InlineChatController implements IEditorContribution {
646
647
this . _zone . value . widget . updateMarkdownMessage ( markdownContents ) ;
647
648
}
648
649
} ) ;
650
+
651
+ let a11yResponse : string | undefined ;
652
+ const a11yVerboseInlineChat = this . _configurationService . getValue < boolean > ( 'accessibility.verbosity.inlineChat' ) === true ;
653
+ this . _chatAccessibilityService . acceptRequest ( ) ;
654
+
649
655
const task = this . _activeSession . provider . provideResponse ( this . _activeSession . session , request , progress , requestCts . token ) ;
650
656
this . _log ( 'request started' , this . _activeSession . provider . debugName , this . _activeSession . session , request ) ;
651
657
@@ -666,24 +672,32 @@ export class InlineChatController implements IEditorContribution {
666
672
if ( reply ?. type === InlineChatResponseType . Message ) {
667
673
markdownContents . appendMarkdown ( reply . message . value ) ;
668
674
response = new MarkdownResponse ( this . _activeSession . textModelN . uri , reply , markdownContents ) ;
675
+ a11yResponse = renderMarkdownAsPlaintext ( markdownContents ) ;
669
676
} else if ( reply ) {
670
677
const editResponse = new EditResponse ( this . _activeSession . textModelN . uri , modelAltVersionIdNow , reply , progressEdits ) ;
671
678
for ( let i = progressEdits . length ; i < editResponse . allLocalEdits . length ; i ++ ) {
672
679
await this . _makeChanges ( editResponse . allLocalEdits [ i ] , undefined ) ;
673
680
}
674
681
response = editResponse ;
682
+ a11yResponse = this . _strategy . checkChanges ( editResponse ) && a11yVerboseInlineChat
683
+ ? localize ( 'editResponseMessage' , "Review proposed changes in the diff editor." )
684
+ : '' ;
675
685
} else {
676
686
response = new EmptyResponse ( ) ;
687
+ a11yResponse = localize ( 'empty' , "No results, please refine your input and try again" ) ;
677
688
}
678
689
679
690
} catch ( e ) {
680
691
response = new ErrorResponse ( e ) ;
692
+ a11yResponse = ( < ErrorResponse > response ) . message ;
693
+
681
694
} finally {
682
695
this . _ctxHasActiveRequest . set ( false ) ;
683
696
this . _zone . value . widget . updateProgress ( false ) ;
684
697
this . _zone . value . widget . updateInfo ( '' ) ;
685
698
this . _zone . value . widget . updateToolbar ( true ) ;
686
699
this . _log ( 'request took' , requestClock . elapsed ( ) , this . _activeSession . provider . debugName ) ;
700
+ this . _chatAccessibilityService . acceptResponse ( a11yResponse ) ;
687
701
}
688
702
689
703
progressiveEditsCts . dispose ( true ) ;
@@ -760,8 +774,6 @@ export class InlineChatController implements IEditorContribution {
760
774
761
775
const { response } = this . _activeSession . lastExchange ! ;
762
776
763
- let status : string | undefined ;
764
-
765
777
this . _ctxLastResponseType . set ( response instanceof EditResponse || response instanceof MarkdownResponse
766
778
? response . raw . type
767
779
: undefined ) ;
@@ -785,27 +797,22 @@ export class InlineChatController implements IEditorContribution {
785
797
786
798
if ( response instanceof EmptyResponse ) {
787
799
// show status message
788
- status = localize ( 'empty' , "No results, please refine your input and try again" ) ;
800
+ const status = localize ( 'empty' , "No results, please refine your input and try again" ) ;
789
801
this . _zone . value . widget . updateStatus ( status , { classes : [ 'warn' ] } ) ;
790
- this . _chatAccessibilityService . acceptResponse ( status ) ;
791
802
return State . WAIT_FOR_INPUT ;
792
803
793
804
} else if ( response instanceof ErrorResponse ) {
794
805
// show error
795
806
if ( ! response . isCancellation ) {
796
- status = response . message ;
797
- this . _zone . value . widget . updateStatus ( status , { classes : [ 'error' ] } ) ;
807
+ this . _zone . value . widget . updateStatus ( response . message , { classes : [ 'error' ] } ) ;
798
808
}
799
809
800
810
} else if ( response instanceof MarkdownResponse ) {
801
811
// clear status, show MD message
802
812
803
813
this . _zone . value . widget . updateStatus ( '' ) ;
804
- const content = this . _zone . value . widget . updateMarkdownMessage ( response . mdContent ) ;
814
+ this . _zone . value . widget . updateMarkdownMessage ( response . mdContent ) ;
805
815
this . _zone . value . widget . updateToolbar ( true ) ;
806
- if ( content ) {
807
- status = localize ( 'markdownResponseMessage' , "{0}" , content ) ;
808
- }
809
816
this . _activeSession . lastExpansionState = this . _zone . value . widget . expansionState ;
810
817
811
818
} else if ( response instanceof EditResponse ) {
@@ -815,13 +822,10 @@ export class InlineChatController implements IEditorContribution {
815
822
816
823
const canContinue = this . _strategy . checkChanges ( response ) ;
817
824
if ( ! canContinue ) {
818
- this . _chatAccessibilityService . acceptResponse ( ) ;
819
825
return State . CANCEL ;
820
826
}
821
- status = this . _configurationService . getValue ( 'accessibility.verbosity.inlineChat' ) === true ? localize ( 'editResponseMessage' , "Review proposed changes in the diff editor." ) : '' ;
822
827
await this . _strategy . renderChanges ( response ) ;
823
828
}
824
- this . _chatAccessibilityService . acceptResponse ( status ) ;
825
829
this . _showWidget ( false ) ;
826
830
827
831
return State . WAIT_FOR_INPUT ;
0 commit comments