diff --git a/packages/ai-chat-ui/src/browser/ai-chat-ui-contribution.ts b/packages/ai-chat-ui/src/browser/ai-chat-ui-contribution.ts index 3c7c25eac7472..7afe2c39aa1d4 100644 --- a/packages/ai-chat-ui/src/browser/ai-chat-ui-contribution.ts +++ b/packages/ai-chat-ui/src/browser/ai-chat-ui-contribution.ts @@ -17,8 +17,8 @@ import { inject, injectable } from '@theia/core/shared/inversify'; import { CommandRegistry, QuickInputButton, QuickInputService, QuickPickItem } from '@theia/core'; import { Widget } from '@theia/core/lib/browser'; -import { AI_CHAT_NEW_CHAT_WINDOW_COMMAND, AI_CHAT_SHOW_CHATS_COMMAND, ChatCommands } from './chat-view-commands'; -import { ChatAgentLocation, ChatService } from '@theia/ai-chat'; +import { AI_CHAT_NEW_CHAT_WINDOW_COMMAND, AI_CHAT_NEW_CHAT_WINDOW_WITH_PINNED_AGENT_COMMAND, AI_CHAT_SHOW_CHATS_COMMAND, ChatCommands } from './chat-view-commands'; +import { ChatAgent, ChatAgentLocation, ChatService } from '@theia/ai-chat'; import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution'; import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; import { ChatViewWidget } from './chat-view-widget'; @@ -79,6 +79,12 @@ export class AIChatContribution extends AbstractViewContribution isEnabled: widget => this.withWidget(widget, () => true), isVisible: widget => this.withWidget(widget, () => true), }); + registry.registerCommand(AI_CHAT_NEW_CHAT_WINDOW_WITH_PINNED_AGENT_COMMAND, { + // TODO - not working if function arg is set to type ChatAgent | undefined ? + execute: (...args: unknown[]) => this.chatService.createSession(ChatAgentLocation.Panel, {focus: true}, args[1] as ChatAgent | undefined), + isEnabled: widget => this.withWidget(widget, () => true), + isVisible: widget => this.withWidget(widget, () => true), + }); registry.registerCommand(AI_CHAT_SHOW_CHATS_COMMAND, { execute: () => this.selectChat(), isEnabled: widget => this.withWidget(widget, () => true) && this.chatService.getSessions().length > 1, diff --git a/packages/ai-chat-ui/src/browser/chat-input-widget.tsx b/packages/ai-chat-ui/src/browser/chat-input-widget.tsx index 1ea74f5d31856..435975cfc474b 100644 --- a/packages/ai-chat-ui/src/browser/chat-input-widget.tsx +++ b/packages/ai-chat-ui/src/browser/chat-input-widget.tsx @@ -249,7 +249,7 @@ const ChatInput: React.FunctionComponent = (props: ChatInpu const handleUnpin = () => { props.onUnpin(); - } + }; return
diff --git a/packages/ai-chat-ui/src/browser/chat-view-commands.ts b/packages/ai-chat-ui/src/browser/chat-view-commands.ts index f513e32690444..082c819dff22e 100644 --- a/packages/ai-chat-ui/src/browser/chat-view-commands.ts +++ b/packages/ai-chat-ui/src/browser/chat-view-commands.ts @@ -39,6 +39,11 @@ export const AI_CHAT_NEW_CHAT_WINDOW_COMMAND: Command = { iconClass: codicon('add') }; +export const AI_CHAT_NEW_CHAT_WINDOW_WITH_PINNED_AGENT_COMMAND: Command = { + id: 'ai-chat-ui.new-chat-with-pinned-agent', + iconClass: codicon('add') +}; + export const AI_CHAT_SHOW_CHATS_COMMAND: Command = { id: 'ai-chat-ui.show-chats', iconClass: codicon('history') diff --git a/packages/ai-chat-ui/src/browser/chat-view-widget.tsx b/packages/ai-chat-ui/src/browser/chat-view-widget.tsx index 015506d705be3..b032e832ad5fe 100644 --- a/packages/ai-chat-ui/src/browser/chat-view-widget.tsx +++ b/packages/ai-chat-ui/src/browser/chat-view-widget.tsx @@ -91,7 +91,7 @@ export class ChatViewWidget extends BaseWidget implements ExtractableWidget, Sta this.chatSession = this.chatService.createSession(); this.inputWidget.onQuery = this.onQuery.bind(this); - this.inputWidget.onUnpin = this.onUnpin.bind(this) + this.inputWidget.onUnpin = this.onUnpin.bind(this); this.inputWidget.onCancel = this.onCancel.bind(this); this.inputWidget.chatModel = this.chatSession.model; this.inputWidget.pinnedAgent = this.chatSession.pinnedAgent; diff --git a/packages/ai-chat-ui/src/browser/style/index.css b/packages/ai-chat-ui/src/browser/style/index.css index 5799e1cc9b8cc..2ef0b364b4980 100644 --- a/packages/ai-chat-ui/src/browser/style/index.css +++ b/packages/ai-chat-ui/src/browser/style/index.css @@ -163,10 +163,10 @@ div:last-child>.theia-ChatNode { position: relative; bottom: -5px; right: -2px; - padding-top: 7px; + padding-top: 9px; padding-left: 10px; padding-right: 10px; - padding-bottom: 9px; + padding-bottom: 11px; display: flex; flex-direction: row; align-items: start; diff --git a/packages/ai-chat/src/common/chat-service.ts b/packages/ai-chat/src/common/chat-service.ts index 85b0fe1bff0e8..075149bddbafa 100644 --- a/packages/ai-chat/src/common/chat-service.ts +++ b/packages/ai-chat/src/common/chat-service.ts @@ -35,7 +35,7 @@ import { ChatAgent, ChatAgentLocation } from './chat-agents'; import { ParsedChatRequestAgentPart, ParsedChatRequestVariablePart, ParsedChatRequest } from './parsed-chat-request'; import { AIVariableService } from '@theia/ai-core'; import { Event } from '@theia/core/shared/vscode-languageserver-protocol'; -import { OrchestratorChatAgentId } from "./orchestrator-chat-agent"; +import { OrchestratorChatAgentId } from './orchestrator-chat-agent'; export interface ChatRequestInvocation { /** @@ -80,7 +80,7 @@ export interface ChatService { getSession(id: string): ChatSession | undefined; getSessions(): ChatSession[]; - createSession(location?: ChatAgentLocation, options?: SessionOptions): ChatSession; + createSession(location?: ChatAgentLocation, options?: SessionOptions, pinnedAgent?: ChatAgent): ChatSession; deleteSession(sessionId: string): void; setActiveSession(sessionId: string, options?: SessionOptions): void; @@ -124,13 +124,13 @@ export class ChatServiceImpl implements ChatService { return this._sessions.find(session => session.id === id); } - createSession(location = ChatAgentLocation.Panel, options?: SessionOptions): ChatSession { + createSession(location = ChatAgentLocation.Panel, options?: SessionOptions, pinnedAgent?: ChatAgent): ChatSession { const model = new ChatModelImpl(location); const session: ChatSessionInternal = { id: model.id, model, isActive: true, - pinnedAgent: undefined + pinnedAgent: pinnedAgent }; this._sessions.push(session); this.setActiveSession(session.id, options);