/** * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ /** * @module ai/aichat/ui/aichatfeedview */ import { type Locale } from "@ckeditor/ckeditor5-utils"; import { View, type ViewCollection, type BodyCollection } from "@ckeditor/ckeditor5-ui"; import { type AIChatFeedItemView } from "./feed/aichatfeeditemview.js"; import { type AIContentRenderingStrategy } from "../../aicore/ui/suggestioncontainer/aisuggestionstreamablecontentview.js"; import { type Document } from "../../aicore/utils/htmlparser.js"; import { AIChatFeedSuggestionItemView } from "./feed/aichatfeedsuggestionitemview.js"; import { AIChatFeedReplyItemView } from "./feed/aichatfeedreplyitemview.js"; import { AIChatFeedUserMessageItemView } from "./feed/aichatfeedusermessageitem.js"; import { AIChatFeedErrorItemView } from "./feed/aichatfeederroritemview.js"; import { AIChatFeedInteractionHeaderView } from "./feed/aichatfeedinteractionheaderview.js"; import { type AISuggestionContentPartDefinition } from "../../aicore/utils/getsuggestionpartsfromreply.js"; import { AIChatFeedCustomElementView } from "./feed/aichatfeedcustomelementview.js"; import { type AIReplyChangeGroupState, type AIReplyChangeGroupOutdatedReason } from "../../aicore/model/aireply.js"; import { type AISource } from "../../aicore/aiconnector.js"; import { type AISuggestionGating } from "../../aicore/ui/suggestioncontainer/aisuggestionbodyview.js"; /** * A view that displays the chat feed with various items. */ export declare class AIChatFeedView extends View { /** * A collection of feed items. */ readonly children: ViewCollection; /** * The loading message displayed when the feed is processing a response. * * When set, it gets displayed together with a loader spinner. * * @observable */ loadingMessage: string; /** * @observable */ isTrackChangesOn: boolean; /** * @inheritDoc */ constructor(locale: Locale, bodyCollection: BodyCollection); override render(): void; override destroy(): void; /** * Removes all items from the feed. */ clear(): void; /** * Adds a new item to the feed. */ addItem(itemType: T, options: ChatFeedAddItemTypesInstances[T]["options"]): ChatFeedAddItemTypesInstances[T]; /** * Updates the content of an item in the feed. * * **Note**: The content is updated (streamed) asynchronously. */ updateReplyItem({ id, parsedContent, renderingStrategy, abortSignal }: { id: string; parsedContent: Document; renderingStrategy: AIContentRenderingStrategy; abortSignal: AbortSignal; }): Promise; updateWebSources(id: string, sources: Array): Promise; updateSuggestionItem({ id, parts, abortSignal, skipLoadingEffects }: { id: string; parts: Array; abortSignal: AbortSignal; skipLoadingEffects?: boolean; }): Promise; updateSuggestionPartState({ id, index, state, outdatedReason }: { id: string; index: number; state: AIReplyChangeGroupState; outdatedReason?: AIReplyChangeGroupOutdatedReason; }): void; updateSuggestionGating(replyId: string, gating: AISuggestionGating): void; /** * Sets the part active or not (active parts are those currently previewed in a dialog by the user). */ setSuggestionPartActive({ id, index, isActive }: { id: string; index: number; isActive: boolean; }): void; /** * Marks an item as done. * * **Note**: Marking the item as done cleans up the streaming animations. */ markItemAsDone(id: string): void; /** * Returns all item ids. */ getItemIds(): Array; /** * Removes an item from the feed. */ removeItem(id: string): void; /** * Checks if an item exists in the feed. */ hasItem(id: string): boolean; scrollToSuggestion(replyId: string, partIndex: number): void; /** * Sets the loading message of the chat feed. */ setLoadingMessage(message: string): void; /** * Toggles the loading skeleton in the feed. */ toggleLoadingSkeleton(isLoading: boolean): void; /** * Starts the auto-scrolling of the feed. * * @param options.smooth When `false`, the scroll jumps instantly instead of animating. Defaults to `true`. */ startAutoScroll(options?: { smooth?: boolean; }): void; /** * Stops the auto-scrolling of the feed. */ stopAutoScroll(): void; } export interface ChatFeedAddItemTypesInstances { "interaction-header": AIChatFeedInteractionHeaderView; "ai-reply": AIChatFeedReplyItemView; "ai-suggestion-reply": AIChatFeedSuggestionItemView; "user-message": AIChatFeedUserMessageItemView; "error-message": AIChatFeedErrorItemView; "custom-element": AIChatFeedCustomElementView; }