import { ChatAgent, ChatAgentService, ChatModel, ChatRequestModel, ChatResponseContent, ChatResponseModel, ChatService, EditableChatRequestModel, type ChatRequest, type ChatHierarchyBranch } from '@theia/ai-chat'; import { AIVariableService } from '@theia/ai-core'; import { AIActivationService } from '@theia/ai-core/lib/browser'; import { CommandRegistry, ContributionProvider, DisposableCollection, Emitter, Event, ILogger } from '@theia/core'; import { ContextMenuRenderer, HoverService, Message, NodeProps, OpenerService, TreeModel, TreeNode, TreeProps, TreeWidget, type ReactWidget } from '@theia/core/lib/browser'; import { ContextKey, ContextKeyService } from '@theia/core/lib/browser/context-key-service'; import { ChatFindHighlighter } from '../chat-find/chat-find-highlighter.js'; import { ChatFindMatch } from '../chat-find/chat-find-matcher.js'; import { ChatFindState, ChatFindWidget } from '../chat-find/chat-find-widget.js'; import * as React from '@theia/core/shared/react'; import { ChatNodeToolbarActionContribution } from '../chat-node-toolbar-action-contribution.js'; import { ChatResponsePartRenderer } from '../chat-response-part-renderer.js'; import { AIChatTreeInputFactory, type AIChatTreeInputWidget } from './chat-view-tree-input-widget.js'; export interface RequestNode extends TreeNode { request: ChatRequestModel; branch: ChatHierarchyBranch; sessionId: string; } export declare const isRequestNode: (node: TreeNode) => node is RequestNode; export interface EditableRequestNode extends RequestNode { request: EditableChatRequestModel; } export declare const isEditableRequestNode: (node: TreeNode) => node is EditableRequestNode; export interface ResponseNode extends TreeNode { response: ChatResponseModel; sessionId: string; } export declare const isResponseNode: (node: TreeNode) => node is ResponseNode; export declare function isEnterKey(e: React.KeyboardEvent): boolean; export declare const ChatWelcomeMessageProvider: unique symbol; export interface ChatWelcomeMessageProvider { renderWelcomeMessage?(): React.ReactNode; renderDisabledMessage?(): React.ReactNode; readonly hasReadyModels?: boolean; readonly modelRequirementBypassed?: boolean; readonly defaultAgent?: string; readonly onStateChanged?: Event; /** Optional priority for rendering order. Higher values render first. Default: 0 */ readonly priority?: number; } export declare class ChatViewTreeWidget extends TreeWidget { static readonly ID = "chat-tree-widget"; static readonly CONTEXT_MENU: string[]; /** How long typing in the find bar must pause before a match in a collapsed message expands it. */ protected static readonly FIND_EXPAND_DELAY_MS = 300; protected readonly chatResponsePartRenderers: ContributionProvider>; protected readonly chatNodeToolbarActionContributions: ContributionProvider; protected chatAgentService: ChatAgentService; protected readonly variableService: AIVariableService; protected commandRegistry: CommandRegistry; protected readonly openerService: OpenerService; protected hoverService: HoverService; protected readonly welcomeMessageProviders: ContributionProvider; protected inputWidgetFactory: AIChatTreeInputFactory; protected readonly activationService: AIActivationService; protected readonly chatService: ChatService; protected readonly contextKeyService: ContextKeyService; protected readonly logger: ILogger; protected chatResponseFocusKey: ContextKey; protected readonly findWidget: ChatFindWidget; protected readonly findHighlighter: ChatFindHighlighter; protected readonly onDidSubmitEditEmitter: Emitter; onDidSubmitEdit: Event; protected readonly chatInputs: Map; /** Ids of the request and response nodes whose message the user has collapsed. */ protected readonly collapsedNodeIds: Set; /** The query of the find bar with its options, to tell a reveal after typing from a step to another match. */ protected findQuery: string | undefined; protected findQueryChanged: boolean; /** The pending reveal of a match in a collapsed message, see {@link handleFindRevealRequest}. */ protected findRevealTimeout: ReturnType | undefined; protected _shouldScrollToEnd: boolean; protected isEnabled: boolean; protected chatModelId: string; /** Tracks if we are at the bottom for showing the scroll-to-bottom button. */ protected atBottom: boolean; /** * Track the visibility of the scroll button. */ protected _showScrollButton: boolean; onScrollLockChange?: (temporaryLocked: boolean) => void; set shouldScrollToEnd(shouldScrollToEnd: boolean); get shouldScrollToEnd(): boolean; constructor(props: TreeProps, model: TreeModel, contextMenuRenderer: ContextMenuRenderer); protected init(): void; setEnabled(enabled: boolean): void; /** Opens the find bar over the response tree (or refocuses it when already open). */ showFind(): void; hideFind(): void; get isFindVisible(): boolean; /** Whether the tracked session has content to search; false while the welcome/session-list screen shows. */ get canFind(): boolean; protected handleFindStateChange(state: ChatFindState): void; /** * Reveals a match requested by the find bar. While a query is typed or an option toggled, a match in a collapsed * message is only revealed once typing pauses, as expanding the message of each intermediate match would make the * view jump. Stepping to the next or previous match reveals it right away. */ protected handleFindRevealRequest(match: ChatFindMatch): void; /** * Reveals a match: mounts the owning row via virtuoso when it is not rendered yet, then re-applies the highlights * and scrolls the matched text itself into view (rows can be taller than the viewport). */ protected revealFindMatch(match: ChatFindMatch): void; protected onAfterAttach(msg: Message): void; protected onBeforeDetach(msg: Message): void; /** Toggles auto-scroll and the scroll-to-bottom button based on whether the viewport includes the bottom of the list. */ protected handleAtBottomStateChange(isAtBottom: boolean): void; protected setTemporaryScrollLock(enabled: boolean): void; protected renderTree(model: TreeModel): React.ReactNode; /** Shows the scroll to bottom button if not at the bottom (debounced). */ protected renderScrollToBottomButton(): React.ReactNode; /** Scrolls to the bottom row and updates atBottom state. */ protected handleScrollToBottomButtonClick(): void; /** * Returns providers sorted by priority (highest first). */ protected getSortedWelcomeMessageProviders(): ChatWelcomeMessageProvider[]; /** * Returns the highest-priority provider for backward-compatible property access. */ protected get welcomeMessageProvider(): ChatWelcomeMessageProvider | undefined; protected renderDisabledMessage(): React.ReactNode; protected renderWelcomeMessage(): React.ReactNode; protected renderContributedWelcomeContent(containerClass: string, nodes: React.ReactNode[]): React.ReactNode; protected mapRequestToNode(branch: ChatHierarchyBranch): RequestNode; protected mapResponseToNode(response: ChatResponseModel): ResponseNode; protected readonly toDisposeOnChatModelChange: DisposableCollection; /** * Tracks the ChatModel handed over. * Tracking multiple chat models will result in a weird UI */ trackChatModel(chatModel: ChatModel): void; protected disposeChatInputWidget(request: ChatRequestModel): void; protected doUpdateRows(): void; protected getScrollToRow(): number | undefined; protected recreateModelTree(chatModel: ChatModel): Promise; protected renderNode(node: TreeNode, props: NodeProps): React.ReactNode; protected renderAgent(node: RequestNode | ResponseNode): React.ReactNode; /** The toggle stays in place while the message cannot be collapsed, so that the header does not shift. */ protected renderCollapseToggle(node: RequestNode | ResponseNode): React.ReactNode; /** * A request being edited and a response in progress always show their content: hiding it would cancel the edit, or * hide pending interactions such as tool confirmations and questions, including those of delegated agents. */ protected canCollapse(node: RequestNode | ResponseNode): boolean; protected isCollapsed(node: RequestNode | ResponseNode): boolean; protected toggleCollapsed(node: RequestNode | ResponseNode): void; protected getAgentLabel(node: RequestNode | ResponseNode): string; protected getAgent(node: RequestNode | ResponseNode): ChatAgent | undefined; protected getAgentIconClassName(node: RequestNode | ResponseNode): string | undefined; protected renderDetail(node: RequestNode | ResponseNode): React.ReactNode; protected renderChatRequest(node: RequestNode): React.ReactNode; protected renderChatResponse(node: ResponseNode): React.ReactNode; protected getChatResponsePartRenderer(content: ChatResponseContent, node: ResponseNode): React.ReactNode; protected handleContextMenu(node: TreeNode | undefined, event: React.MouseEvent): void; protected handleSpace(event: KeyboardEvent): boolean; } export declare const ChatRequestRender: ({ node, hoverService, chatAgentService, variableService, openerService, provideChatInputWidget }: { node: RequestNode; hoverService: HoverService; chatAgentService: ChatAgentService; variableService: AIVariableService; openerService: OpenerService; provideChatInputWidget: () => ReactWidget | undefined; }) => React.JSX.Element; //# sourceMappingURL=chat-view-tree-widget.d.ts.map