@@ -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 , IChatWidget , IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat' ;
25
+ import { ChatTreeItem , 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' ;
@@ -128,30 +128,29 @@ class ChatAccessibleViewContribution extends Disposable {
128
128
const widgetService = accessor . get ( IChatWidgetService ) ;
129
129
const editorUri = editor ?. getModel ( ) ?. uri ;
130
130
const widget : IChatWidget | undefined = widgetService . lastFocusedWidget ;
131
- const focused = widget ?. getFocus ( ) ;
132
- if ( ! widget || ! focused ) {
131
+ const focusedItem : ChatTreeItem | undefined = widget ?. getFocus ( ) ;
132
+ if ( ! widget || ! focusedItem ) {
133
133
return false ;
134
134
}
135
- function provideContent ( ) : string {
136
- if ( ! widget ) {
137
- return 'No response data' ;
138
- }
139
- const curCodeBlockInfo = editorUri ? widget . getCodeBlockInfoForEditor ( editorUri ) : undefined ;
140
-
141
- const currentResponse = curCodeBlockInfo ?
142
- curCodeBlockInfo . element :
143
- ( focused ?? widget . viewModel ?. getItems ( ) . reverse ( ) . find ( ( item ) : item is IChatResponseViewModel => isResponseVM ( item ) ) ) ;
144
- if ( ! currentResponse ) {
145
- return 'No response data' ;
146
- }
147
- // TODO: allow this for requests
148
- return isResponseVM ( currentResponse ) ? currentResponse . response . value : 'No response data' ;
135
+ const codeBlockInfo = editorUri ? widget ! . getCodeBlockInfoForEditor ( editorUri ) : undefined ;
136
+ let responseItem : ChatTreeItem | undefined ;
137
+ if ( codeBlockInfo ) {
138
+ responseItem = codeBlockInfo . element ;
139
+ } else {
140
+ responseItem = widget ! . viewModel ?. getItems ( ) . reverse ( ) . find ( ( item ) : item is IChatResponseViewModel => isResponseVM ( item ) ) ;
141
+ }
142
+ if ( ! isResponseVM ( responseItem ) ) {
143
+ return false ;
144
+ }
145
+ const responseContent = responseItem ?. response . value ;
146
+ if ( ! responseContent ) {
147
+ return false ;
149
148
}
150
149
const provider = accessibleViewService . registerProvider ( {
151
150
id : 'panelChat' ,
152
- provideContent,
151
+ provideContent ( ) : string { return responseContent ; } ,
153
152
onClose ( ) {
154
- widget . reveal ( focused , true ) ;
153
+ widget . reveal ( focusedItem , true ) ;
155
154
provider . dispose ( ) ;
156
155
} ,
157
156
options : { ariaLabel : nls . localize ( 'chatAccessibleView' , "Chat Accessible View" ) , language : 'typescript' , type : AccessibleViewType . View }
0 commit comments