@@ -15,13 +15,12 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
15
15
import { IsLinuxContext , IsWindowsContext } from 'vs/platform/contextkey/common/contextkeys' ;
16
16
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
17
17
import { IQuickInputButton , IQuickInputService , IQuickPickItem } from 'vs/platform/quickinput/common/quickInput' ;
18
- import { ViewAction } from 'vs/workbench/browser/parts/views/viewPane' ;
19
18
import { CHAT_VIEW_ID , IChatWidgetService , showChatView } from 'vs/workbench/contrib/chat/browser/chat' ;
20
19
import { IChatEditorOptions } from 'vs/workbench/contrib/chat/browser/chatEditor' ;
21
20
import { ChatEditorInput } from 'vs/workbench/contrib/chat/browser/chatEditorInput' ;
22
21
import { ChatViewPane } from 'vs/workbench/contrib/chat/browser/chatViewPane' ;
23
22
import { ChatAgentLocation } from 'vs/workbench/contrib/chat/common/chatAgents' ;
24
- import { CONTEXT_CHAT_INPUT_CURSOR_AT_TOP , CONTEXT_CHAT_LOCATION , CONTEXT_IN_CHAT_INPUT , CONTEXT_IN_CHAT_SESSION , CONTEXT_CHAT_ENABLED } from 'vs/workbench/contrib/chat/common/chatContextKeys' ;
23
+ import { CONTEXT_CHAT_ENABLED , CONTEXT_CHAT_INPUT_CURSOR_AT_TOP , CONTEXT_CHAT_LOCATION , CONTEXT_IN_CHAT_INPUT , CONTEXT_IN_CHAT_SESSION } from 'vs/workbench/contrib/chat/common/chatContextKeys' ;
25
24
import { IChatDetail , IChatService } from 'vs/workbench/contrib/chat/common/chatService' ;
26
25
import { IChatRequestViewModel , IChatResponseViewModel , isRequestVM } from 'vs/workbench/contrib/chat/common/chatViewModel' ;
27
26
import { IChatWidgetHistoryService } from 'vs/workbench/contrib/chat/common/chatWidgetHistoryService' ;
@@ -102,10 +101,9 @@ class OpenChatGlobalAction extends Action2 {
102
101
}
103
102
}
104
103
105
- class ChatHistoryAction extends ViewAction < ChatViewPane > {
104
+ class ChatHistoryAction extends Action2 {
106
105
constructor ( ) {
107
106
super ( {
108
- viewId : CHAT_VIEW_ID ,
109
107
id : `workbench.action.chat.history` ,
110
108
title : localize2 ( 'chat.history.label' , "Show Chats..." ) ,
111
109
menu : {
@@ -121,12 +119,11 @@ class ChatHistoryAction extends ViewAction<ChatViewPane> {
121
119
} ) ;
122
120
}
123
121
124
- async runInView ( accessor : ServicesAccessor , view : ChatViewPane ) {
122
+ async run ( accessor : ServicesAccessor ) {
125
123
const chatService = accessor . get ( IChatService ) ;
126
124
const quickInputService = accessor . get ( IQuickInputService ) ;
127
125
const viewsService = accessor . get ( IViewsService ) ;
128
126
const editorService = accessor . get ( IEditorService ) ;
129
- const items = chatService . getHistory ( ) ;
130
127
131
128
const openInEditorButton : IQuickInputButton = {
132
129
iconClass : ThemeIcon . asClassName ( Codicon . file ) ,
@@ -140,25 +137,30 @@ class ChatHistoryAction extends ViewAction<ChatViewPane> {
140
137
interface IChatPickerItem extends IQuickPickItem {
141
138
chat : IChatDetail ;
142
139
}
143
- const picks : IChatPickerItem [ ] = items . map ( ( i ) : IChatPickerItem => ( {
144
- label : i . title ,
145
- chat : i ,
146
- buttons : [
147
- openInEditorButton ,
148
- deleteButton
149
- ]
150
- } ) ) ;
140
+
141
+ const getPicks = ( ) => {
142
+ const items = chatService . getHistory ( ) ;
143
+ return items . map ( ( i ) : IChatPickerItem => ( {
144
+ label : i . title ,
145
+ chat : i ,
146
+ buttons : [
147
+ openInEditorButton ,
148
+ deleteButton
149
+ ]
150
+ } ) ) ;
151
+ } ;
152
+
151
153
const store = new DisposableStore ( ) ;
152
154
const picker = store . add ( quickInputService . createQuickPick < IChatPickerItem > ( ) ) ;
153
155
picker . placeholder = localize ( 'interactiveSession.history.pick' , "Switch to chat" ) ;
154
- picker . items = picks ;
156
+ picker . items = getPicks ( ) ;
155
157
store . add ( picker . onDidTriggerItemButton ( context => {
156
158
if ( context . button === openInEditorButton ) {
157
159
editorService . openEditor ( { resource : ChatEditorInput . getNewEditorUri ( ) , options : < IChatEditorOptions > { target : { sessionId : context . item . chat . sessionId } , pinned : true } } , ACTIVE_GROUP ) ;
158
160
picker . hide ( ) ;
159
161
} else if ( context . button === deleteButton ) {
160
162
chatService . removeHistoryEntry ( context . item . chat . sessionId ) ;
161
- picker . items = picks . filter ( i => i !== context . item ) ;
163
+ picker . items = getPicks ( ) ;
162
164
}
163
165
} ) ) ;
164
166
store . add ( picker . onDidAccept ( async ( ) => {
0 commit comments