@@ -22,7 +22,7 @@ import { registerChatExecuteActions } from 'vs/workbench/contrib/chat/browser/ac
22
22
import { registerChatQuickQuestionActions } from 'vs/workbench/contrib/chat/browser/actions/chatQuickInputActions' ;
23
23
import { registerChatTitleActions } from 'vs/workbench/contrib/chat/browser/actions/chatTitleActions' ;
24
24
import { registerChatExportActions } from 'vs/workbench/contrib/chat/browser/actions/chatImportExport' ;
25
- import { IChatAccessibilityService , IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat' ;
25
+ import { IChatAccessibilityService , IChatWidget , IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat' ;
26
26
import { ChatContributionService } from 'vs/workbench/contrib/chat/browser/chatContributionServiceImpl' ;
27
27
import { ChatEditor , IChatEditorOptions } from 'vs/workbench/contrib/chat/browser/chatEditor' ;
28
28
import { ChatEditorInput , ChatEditorInputSerializer } from 'vs/workbench/contrib/chat/browser/chatEditorInput' ;
@@ -37,6 +37,12 @@ import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle
37
37
import '../common/chatColors' ;
38
38
import { registerMoveActions } from 'vs/workbench/contrib/chat/browser/actions/chatMoveActions' ;
39
39
import { registerClearActions } from 'vs/workbench/contrib/chat/browser/actions/chatClearActions' ;
40
+ import { AccessibilityViewAction } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution' ;
41
+ import { IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView' ;
42
+ import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding' ;
43
+ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
44
+ import { IChatResponseViewModel , isResponseVM } from 'vs/workbench/contrib/chat/common/chatViewModel' ;
45
+ import { KeyCode } from 'vs/base/common/keyCodes' ;
40
46
41
47
// Register configuration
42
48
const configurationRegistry = Registry . as < IConfigurationRegistry > ( ConfigurationExtensions . Configuration ) ;
@@ -119,8 +125,58 @@ class ChatResolverContribution extends Disposable {
119
125
}
120
126
}
121
127
128
+ class ChatAccessibileViewContribution extends Disposable {
129
+ static ID : 'chatAccessibleViewContribution' ;
130
+ constructor ( ) {
131
+ super ( ) ;
132
+ this . _register ( AccessibilityViewAction . addImplementation ( 100 , 'chat' , accessor => {
133
+ const accessibleViewService = accessor . get ( IAccessibleViewService ) ;
134
+ const codeEditorService = accessor . get ( ICodeEditorService ) ;
135
+ const editor = codeEditorService . getActiveCodeEditor ( ) || codeEditorService . getFocusedCodeEditor ( ) ;
136
+ const editorUri = editor ?. getModel ( ) ?. uri ;
137
+ const widgetService = accessor . get ( IChatWidgetService ) ;
138
+ const widget : IChatWidget | undefined = widgetService . lastFocusedWidget ;
139
+ const focused = widget ?. getFocus ( ) ;
140
+ if ( ! widget || ! focused ) {
141
+ return false ;
142
+ }
143
+ function provideContent ( ) : string {
144
+ if ( ! widget ) {
145
+ return 'No response data' ;
146
+ }
147
+ const curCodeBlockInfo = editorUri ? widget . getCodeBlockInfoForEditor ( editorUri ) : undefined ;
148
+
149
+ const currentResponse = curCodeBlockInfo ?
150
+ curCodeBlockInfo . element :
151
+ ( focused ?? widget . viewModel ?. getItems ( ) . reverse ( ) . find ( ( item ) : item is IChatResponseViewModel => isResponseVM ( item ) ) ) ;
152
+ if ( ! currentResponse ) {
153
+ return 'No response data' ;
154
+ }
155
+ // TODO: allow this for requests
156
+ return isResponseVM ( currentResponse ) ? currentResponse . response . value : 'No response data' ;
157
+ }
158
+ accessibleViewService . registerProvider ( {
159
+ id : 'chat' ,
160
+ provideContent,
161
+ onClose ( ) {
162
+ widget . reveal ( focused , true ) ;
163
+ } ,
164
+ onKeyDown ( e : IKeyboardEvent ) {
165
+ if ( e . keyCode === KeyCode . Escape ) {
166
+ widget . reveal ( focused , true ) ;
167
+ }
168
+ } ,
169
+ options : { ariaLabel : nls . localize ( 'chatAccessibleView' , "Chat Accessible View" ) }
170
+ } ) ;
171
+ accessibleViewService . show ( 'chat' ) ;
172
+ return true ;
173
+ } ) ) ;
174
+ }
175
+ }
176
+
122
177
const workbenchContributionsRegistry = Registry . as < IWorkbenchContributionsRegistry > ( WorkbenchExtensions . Workbench ) ;
123
178
workbenchContributionsRegistry . registerWorkbenchContribution ( ChatResolverContribution , LifecyclePhase . Starting ) ;
179
+ workbenchContributionsRegistry . registerWorkbenchContribution ( ChatAccessibileViewContribution , LifecyclePhase . Eventually ) ;
124
180
Registry . as < IEditorFactoryRegistry > ( EditorExtensions . EditorFactory ) . registerEditorSerializer ( ChatEditorInput . TypeID , ChatEditorInputSerializer ) ;
125
181
126
182
registerChatActions ( ) ;
0 commit comments