|
17 | 17 | import { inject, injectable } from '@theia/core/shared/inversify'; |
18 | 18 | import { CommandRegistry, Emitter, isOSX, nls, QuickInputButton, QuickInputService, QuickPickItem } from '@theia/core'; |
19 | 19 | import { Widget } from '@theia/core/lib/browser'; |
20 | | -import { AI_CHAT_NEW_CHAT_WINDOW_COMMAND, AI_CHAT_NEW_WITH_TASK_CONTEXT, AI_CHAT_SHOW_CHATS_COMMAND, AI_CHAT_SUMMARIZE_CURRENT_SESSION, ChatCommands } from './chat-view-commands'; |
| 20 | +import { AI_CHAT_NEW_CHAT_WINDOW_COMMAND, AI_CHAT_NEW_WITH_TASK_CONTEXT, AI_CHAT_OPEN_SUMMARY_FOR_CURRENT_SESSION, AI_CHAT_SHOW_CHATS_COMMAND, AI_CHAT_SUMMARIZE_CURRENT_SESSION, ChatCommands } from './chat-view-commands'; |
21 | 21 | import { ChatAgentLocation, ChatService } from '@theia/ai-chat'; |
22 | 22 | import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution'; |
23 | 23 | import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; |
@@ -109,11 +109,29 @@ export class AIChatContribution extends AbstractViewContribution<ChatViewWidget> |
109 | 109 | isVisible: widget => { |
110 | 110 | if (widget && !this.withWidget(widget)) { return false; } |
111 | 111 | const activeSession = this.chatService.getActiveSession(); |
112 | | - return !!activeSession?.model.getRequests().length |
113 | | - && activeSession?.model.location === ChatAgentLocation.Panel |
| 112 | + return activeSession?.model.location === ChatAgentLocation.Panel |
| 113 | + && !this.taskContextService.hasSummary(activeSession); |
| 114 | + }, |
| 115 | + isEnabled: widget => { |
| 116 | + if (widget && !this.withWidget(widget)) { return false; } |
| 117 | + const activeSession = this.chatService.getActiveSession(); |
| 118 | + return activeSession?.model.location === ChatAgentLocation.Panel |
| 119 | + && !activeSession.model.isEmpty() |
114 | 120 | && !this.taskContextService.hasSummary(activeSession); |
115 | 121 | } |
116 | 122 | }); |
| 123 | + registry.registerCommand(AI_CHAT_OPEN_SUMMARY_FOR_CURRENT_SESSION, { |
| 124 | + execute: async () => { |
| 125 | + const id = await this.summarizeActiveSession(); |
| 126 | + if (!id) { return; } |
| 127 | + await this.taskContextService.open(id); |
| 128 | + }, |
| 129 | + isVisible: widget => { |
| 130 | + if (widget && !this.withWidget(widget)) { return false; } |
| 131 | + const activeSession = this.chatService.getActiveSession(); |
| 132 | + return !!activeSession && this.taskContextService.hasSummary(activeSession); |
| 133 | + } |
| 134 | + }); |
117 | 135 | registry.registerCommand(AI_CHAT_SHOW_CHATS_COMMAND, { |
118 | 136 | execute: () => this.selectChat(), |
119 | 137 | isEnabled: widget => this.withWidget(widget) && this.chatService.getSessions().length > 1, |
@@ -172,6 +190,11 @@ export class AIChatContribution extends AbstractViewContribution<ChatViewWidget> |
172 | 190 | command: AI_CHAT_SUMMARIZE_CURRENT_SESSION.id, |
173 | 191 | onDidChange: sessionSummarizibilityChangedEmitter.event |
174 | 192 | }); |
| 193 | + registry.registerItem({ |
| 194 | + id: 'chat-view.' + AI_CHAT_OPEN_SUMMARY_FOR_CURRENT_SESSION.id, |
| 195 | + command: AI_CHAT_OPEN_SUMMARY_FOR_CURRENT_SESSION.id, |
| 196 | + onDidChange: sessionSummarizibilityChangedEmitter.event |
| 197 | + }); |
175 | 198 | } |
176 | 199 |
|
177 | 200 | protected async selectChat(sessionId?: string): Promise<void> { |
|
0 commit comments