|
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 { |
| 21 | + AI_CHAT_NEW_CHAT_WINDOW_COMMAND, |
| 22 | + AI_CHAT_NEW_WITH_TASK_CONTEXT, |
| 23 | + AI_CHAT_OPEN_SUMMARY_FOR_CURRENT_SESSION, |
| 24 | + AI_CHAT_SHOW_CHATS_COMMAND, |
| 25 | + AI_CHAT_SUMMARIZE_CURRENT_SESSION, |
| 26 | + ChatCommands |
| 27 | +} from './chat-view-commands'; |
21 | 28 | import { ChatAgentLocation, ChatService } from '@theia/ai-chat'; |
22 | 29 | import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution'; |
23 | 30 | import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; |
@@ -45,7 +52,6 @@ export class AIChatContribution extends AbstractViewContribution<ChatViewWidget> |
45 | 52 | @inject(TaskContextService) |
46 | 53 | protected readonly taskContextService: TaskContextService; |
47 | 54 |
|
48 | | - |
49 | 55 | protected static readonly RENAME_CHAT_BUTTON: QuickInputButton = { |
50 | 56 | iconClass: 'codicon-edit', |
51 | 57 | tooltip: nls.localize('theia/ai/chat-ui/renameChat', 'Rename Chat'), |
@@ -109,11 +115,29 @@ export class AIChatContribution extends AbstractViewContribution<ChatViewWidget> |
109 | 115 | isVisible: widget => { |
110 | 116 | if (widget && !this.withWidget(widget)) { return false; } |
111 | 117 | const activeSession = this.chatService.getActiveSession(); |
112 | | - return !!activeSession?.model.getRequests().length |
113 | | - && activeSession?.model.location === ChatAgentLocation.Panel |
| 118 | + return activeSession?.model.location === ChatAgentLocation.Panel |
| 119 | + && !this.taskContextService.hasSummary(activeSession); |
| 120 | + }, |
| 121 | + isEnabled: widget => { |
| 122 | + if (widget && !this.withWidget(widget)) { return false; } |
| 123 | + const activeSession = this.chatService.getActiveSession(); |
| 124 | + return activeSession?.model.location === ChatAgentLocation.Panel |
| 125 | + && !activeSession.model.isEmpty() |
114 | 126 | && !this.taskContextService.hasSummary(activeSession); |
115 | 127 | } |
116 | 128 | }); |
| 129 | + registry.registerCommand(AI_CHAT_OPEN_SUMMARY_FOR_CURRENT_SESSION, { |
| 130 | + execute: async () => { |
| 131 | + const id = await this.summarizeActiveSession(); |
| 132 | + if (!id) { return; } |
| 133 | + await this.taskContextService.open(id); |
| 134 | + }, |
| 135 | + isVisible: widget => { |
| 136 | + if (widget && !this.withWidget(widget)) { return false; } |
| 137 | + const activeSession = this.chatService.getActiveSession(); |
| 138 | + return !!activeSession && this.taskContextService.hasSummary(activeSession); |
| 139 | + } |
| 140 | + }); |
117 | 141 | registry.registerCommand(AI_CHAT_SHOW_CHATS_COMMAND, { |
118 | 142 | execute: () => this.selectChat(), |
119 | 143 | isEnabled: widget => this.withWidget(widget) && this.chatService.getSessions().length > 1, |
@@ -172,6 +196,11 @@ export class AIChatContribution extends AbstractViewContribution<ChatViewWidget> |
172 | 196 | command: AI_CHAT_SUMMARIZE_CURRENT_SESSION.id, |
173 | 197 | onDidChange: sessionSummarizibilityChangedEmitter.event |
174 | 198 | }); |
| 199 | + registry.registerItem({ |
| 200 | + id: 'chat-view.' + AI_CHAT_OPEN_SUMMARY_FOR_CURRENT_SESSION.id, |
| 201 | + command: AI_CHAT_OPEN_SUMMARY_FOR_CURRENT_SESSION.id, |
| 202 | + onDidChange: sessionSummarizibilityChangedEmitter.event |
| 203 | + }); |
175 | 204 | } |
176 | 205 |
|
177 | 206 | protected async selectChat(sessionId?: string): Promise<void> { |
|
0 commit comments