4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import { renderMarkdown } from 'vs/base/browser/markdownRenderer' ;
7
+ import * as aria from 'vs/base/browser/ui/aria/aria' ;
7
8
import { Barrier , raceCancellationError } from 'vs/base/common/async' ;
8
9
import { CancellationTokenSource } from 'vs/base/common/cancellation' ;
9
10
import { toErrorMessage } from 'vs/base/common/errorMessage' ;
@@ -32,7 +33,7 @@ import { EditResponse, EmptyResponse, ErrorResponse, ExpansionState, IInlineChat
32
33
import { EditModeStrategy , LivePreviewStrategy , LiveStrategy , PreviewStrategy } from 'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies' ;
33
34
import { InlineChatZoneWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatWidget' ;
34
35
import { CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST , CTX_INLINE_CHAT_LAST_FEEDBACK , IInlineChatRequest , IInlineChatResponse , INLINE_CHAT_ID , EditMode , InlineChatResponseFeedbackKind , CTX_INLINE_CHAT_LAST_RESPONSE_TYPE , InlineChatResponseType , CTX_INLINE_CHAT_DID_EDIT , CTX_INLINE_CHAT_HAS_STASHED_SESSION , InlineChateResponseTypes , CTX_INLINE_CHAT_RESPONSE_TYPES } from 'vs/workbench/contrib/inlineChat/common/inlineChat' ;
35
- import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat' ;
36
+ import { IChatAccessibilityService , IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat' ;
36
37
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService' ;
37
38
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService' ;
38
39
import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
@@ -115,6 +116,7 @@ export class InlineChatController implements IEditorContribution {
115
116
@IContextKeyService contextKeyService : IContextKeyService ,
116
117
@IAccessibilityService private readonly _accessibilityService : IAccessibilityService ,
117
118
@IKeybindingService private readonly _keybindingService : IKeybindingService ,
119
+ @IChatAccessibilityService private readonly _chatAccessibilityService : IChatAccessibilityService
118
120
) {
119
121
this . _ctxHasActiveRequest = CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST . bindTo ( contextKeyService ) ;
120
122
this . _ctxDidEdit = CTX_INLINE_CHAT_DID_EDIT . bindTo ( contextKeyService ) ;
@@ -412,6 +414,7 @@ export class InlineChatController implements IEditorContribution {
412
414
if ( options . message ) {
413
415
this . _zone . value . widget . value = options . message ;
414
416
this . _zone . value . widget . selectAll ( ) ;
417
+ aria . alert ( options . message ) ;
415
418
delete options . message ;
416
419
}
417
420
@@ -506,6 +509,7 @@ export class InlineChatController implements IEditorContribution {
506
509
selection : this . _editor . getSelection ( ) ,
507
510
wholeRange : this . _activeSession . wholeRange . value ,
508
511
} ;
512
+ this . _chatAccessibilityService . acceptRequest ( ) ;
509
513
const task = this . _activeSession . provider . provideResponse ( this . _activeSession . session , request , requestCts . token ) ;
510
514
this . _log ( 'request started' , this . _activeSession . provider . debugName , this . _activeSession . session , request ) ;
511
515
@@ -596,6 +600,8 @@ export class InlineChatController implements IEditorContribution {
596
600
const { response } = this . _activeSession . lastExchange ! ;
597
601
this . _showWidget ( false ) ;
598
602
603
+ let status : string | undefined ;
604
+
599
605
this . _ctxLastResponseType . set ( response instanceof EditResponse || response instanceof MarkdownResponse
600
606
? response . raw . type
601
607
: undefined ) ;
@@ -618,13 +624,15 @@ export class InlineChatController implements IEditorContribution {
618
624
619
625
if ( response instanceof EmptyResponse ) {
620
626
// show status message
621
- this . _zone . value . widget . updateStatus ( localize ( 'empty' , "No results, please refine your input and try again" ) , { classes : [ 'warn' ] } ) ;
627
+ status = localize ( 'empty' , "No results, please refine your input and try again" ) ;
628
+ this . _zone . value . widget . updateStatus ( status , { classes : [ 'warn' ] } ) ;
622
629
return State . WAIT_FOR_INPUT ;
623
630
624
631
} else if ( response instanceof ErrorResponse ) {
625
632
// show error
626
633
if ( ! response . isCancellation ) {
627
- this . _zone . value . widget . updateStatus ( response . message , { classes : [ 'error' ] } ) ;
634
+ status = response . message ;
635
+ this . _zone . value . widget . updateStatus ( status , { classes : [ 'error' ] } ) ;
628
636
}
629
637
630
638
} else if ( response instanceof MarkdownResponse ) {
@@ -633,6 +641,10 @@ export class InlineChatController implements IEditorContribution {
633
641
this . _zone . value . widget . updateStatus ( '' ) ;
634
642
this . _zone . value . widget . updateMarkdownMessage ( renderedMarkdown . element ) ;
635
643
this . _zone . value . widget . updateToolbar ( true ) ;
644
+ const content = renderedMarkdown . element . textContent ;
645
+ if ( content ) {
646
+ status = localize ( 'markdownResponseMessage' , "{0}" , content ) ;
647
+ }
636
648
this . _activeSession . lastExpansionState = this . _zone . value . widget . expansionState ;
637
649
638
650
} else if ( response instanceof EditResponse ) {
@@ -644,9 +656,10 @@ export class InlineChatController implements IEditorContribution {
644
656
if ( ! canContinue ) {
645
657
return State . ACCEPT ;
646
658
}
647
-
659
+ status = localize ( 'editResponseMessage' , "Navigate to the diff editor to review proposed changes." ) ;
648
660
await this . _strategy . renderChanges ( response ) ;
649
661
}
662
+ this . _chatAccessibilityService . acceptResponse ( status ) ;
650
663
651
664
return State . WAIT_FOR_INPUT ;
652
665
}
0 commit comments