import { IChatExternalEdit, IChatMarkdownContent, IChatThinkingPart, IChatToolInvocation, IChatToolInvocationSerialized } from "../../../common/chatService/chatService.js"; import { IChatContentPart, IChatContentPartDiffData, IChatContentPartDiffSource, IChatContentPartRenderContext } from "./chatContentParts.js"; import { IChatRendererContent } from "../../../common/model/chatViewModel.js"; import { ThinkingDisplayMode } from "../../../common/constants.js"; import { ChatTreeItem } from "../../chat.js"; import { IInstantiationService } from "../../../../../../platform/instantiation/common/instantiation.js"; import { IConfigurationService } from "../../../../../../platform/configuration/common/configuration.service.js"; import { IContextKeyService } from "../../../../../../platform/contextkey/common/contextkey.service.js"; import { IMarkdownString } from "../../../../../../base/common/htmlContent.js"; import { IMarkdownRenderer } from "../../../../../../platform/markdown/browser/markdownRenderer.js"; import { ChatThinkingStyleContentPart, createThinkingIcon } from "./chatThinkingStyleContentPart.js"; export { createThinkingIcon }; import { ThemeIcon } from "../../../../../../base/common/themables.js"; import { IDisposable } from "../../../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../../../base/common/observable.js"; import { IChatMarkdownAnchorService } from "./chatMarkdownAnchorService.service.js"; import { IHoverService } from "../../../../../../platform/hover/browser/hover.service.js"; import { ITelemetryService } from "../../../../../../platform/telemetry/common/telemetry.service.js"; import { IEditSessionDiffStats } from "../../../common/editing/chatEditingService.js"; import { IUriIdentityService } from "../../../../../../platform/uriIdentity/common/uriIdentity.service.js"; /** * Read-only chats and phone layouts use collapsed preview regardless of the configured thinking style. */ export declare function getEffectiveThinkingDisplayMode(configurationService: IConfigurationService, contextKeyService: IContextKeyService, readOnly?: boolean): ThinkingDisplayMode; /** * Splits a reasoning-summary value into one markdown string per display row. * Rows are delimited by bold header lines. When {@link dropLeadingHeader} is set * and the value starts with a header, that header is dropped because it is * surfaced as the collapsible title. Returns `undefined` unless the value has at * least two header lines, so ordinary reasoning prose keeps single-block rendering. */ export declare function splitReasoningSummaryRows(text: string, dropLeadingHeader?: boolean, headers?: { lineIndex: number; title: string; }[]): string[] | undefined; type ChatThinkingTitle = string | IMarkdownString; /** * Metadata passed to {@link ChatThinkingContentPart.appendItem} to drive * title / icon extraction. The `kind` discriminates which payload is * available; the thinking part inspects it to compute a label like * "Edited foo.ts" without rendering the actual content itself (the * factory provides the DOM). */ export type ChatThinkingItemMetadata = IChatToolInvocation | IChatToolInvocationSerialized | IChatMarkdownContent | IChatExternalEdit; export declare const defaultThinkingMessages: string[]; /** Returns an easter-egg message ~1 in {@link FUN_WORKING_MESSAGE_RATE}, else `undefined`. */ export declare function maybePickFunWorkingMessage(configurationService: IConfigurationService, random?: () => number): string | undefined; /** * Builds a phrase pool from defaults and user-configured custom phrases. * In 'replace' mode, only custom phrases are used; in 'append' mode (default), * custom phrases are added to the defaults. */ export declare function buildPhrasePool(defaults: string[], configurationService: IConfigurationService): string[]; export declare class ChatThinkingContentPart extends ChatThinkingStyleContentPart implements IChatContentPart { private readonly context; private readonly chatContentMarkdownRenderer; private streamingCompleted; private readonly instantiationService; private readonly configurationService; private readonly chatMarkdownAnchorService; private readonly uriIdentityService; private static _codeBlockRendererSync; readonly codeblocks: undefined; readonly codeblocksPartId: undefined; readonly isToolChain: boolean; private readonly isVerboseToolChain; private readonly isPersistentReasoning; /** Reasoning and tool calls share this collapsed section in the Conversation progress layout. */ private readonly isConversation; /** The latest reasoning or tool call in a conversation section, which its collapsed title names. */ private conversationActivity; /** Wipes a conversation section's header between the activities it names and its summary. */ private readonly conversationTitleTransition; private conversationTitleTarget; private conversationTitleShown; private isShowingConversationTitle; /** A conversation's latest reasoning part, whose text has not arrived to name the section yet. */ private pendingConversationReasoningId; private readonly _onDidChangeHeight; private readonly _asyncRenderCallback; private id; private content; private currentThinkingValue; private currentTitle; private fallbackTitle; private readonly thinkingTitle; private defaultTitle; private readonly workingTitle; private textContainer; private readonly _markdownResult; private readonly renderedThinkingHeaders; private readonly renderedThinkingParts; private readonly reasoningDurationSnapshots; private summaryRowItems; private summaryRowResults; private summaryRowTexts; private readonly retiredSummaryRowResults; private wrapper; private fixedScrollingMode; private autoScrollEnabled; private scrollableElement; private lastExtractedTitle; private toolInvocationCount; private appendedItemCount; private isActive; private toolInvocations; private allThinkingParts; private thinkingPartSources; private readonly thinkingHeadersByPart; private readonly titleGeneration; private readonly renderedWhileStreaming; private hookCount; private singleItemInfo; private lazyItems; private hasExpandedOnce; private workingSpinnerElement; private workingSpinnerLabel; private availableMessagesByCategory; private readonly toolWrappersByCallId; private readonly toolIconsByCallId; private readonly hiddenToolCallIds; private readonly toolDisposables; private readonly ownedToolParts; private pendingRemovals; private pendingRemovalFlushDisposable; private pendingScrollDisposable; private wrapperResizeObserverDisposable; private readonly pendingFocusCollapse; private childResizeObserver; private isUpdatingDimensions; private lastKnownContentHeight; private lastKnownScrollTop; private titleDetailContainer; private lastRenderedTitle; private collapsedTitleBeforeExpansion; private readonly _externalResourceWidget; private readonly _pendingExternalResources; private readonly _titleDetailRendered; private readonly _pendingAppendRefresh; private readonly diffDataByPartId; private readonly editResourcesByPartId; private readonly _diffData; readonly diffData: IObservable; private readonly diffButtonStore; private diffButton; private containsReasoning; private containsGroupedItems; get aggregatedDiff(): IEditSessionDiffStats; private getRandomWorkingMessage; constructor(content: IChatThinkingPart, context: IChatContentPartRenderContext, chatContentMarkdownRenderer: IMarkdownRenderer, streamingCompleted: boolean, instantiationService: IInstantiationService, configurationService: IConfigurationService, chatMarkdownAnchorService: IChatMarkdownAnchorService, hoverService: IHoverService, telemetryService: ITelemetryService, contextKeyService: IContextKeyService, uriIdentityService: IUriIdentityService); /** * Records the latest reasoning or item in a conversation section and names it in the * collapsed header while the section is still running. */ private setConversationActivity; /** Names reasoning by its latest summary heading, which changes as the summary streams, or says Thinking without one. */ private getReasoningActivity; /** Follows the reasoning that names a conversation section, or that will once its text arrives. */ private updateReasoningActivity; /** Stops naming a tool call that left the section, such as one hidden once it finished streaming. */ private forgetConversationActivity; /** * Keeps a running conversation section's header in step with its disclosure, however it * was toggled: the open section lists its activities, so the header only names the current * one while closed. A finished section names its summary either way, without waiting on a wipe. */ private syncConversationTitleWithExpansion; /** * Shows a title in a conversation section's header. The header wipes between titles * naming different things unless `animate` is false, such as when the user toggles it. */ private showConversationTitle; private renderConversationTitle; /** * Titles with links sit beside the header button; others fill its label, which stays * in place as the title changes. */ private getConversationTitleElement; /** Titles rendered outside the header's transition stop it, so they are not wiped away. */ private interruptConversationTitle; protected shouldInitEarly(): boolean; protected shouldAnimateContent(): boolean; protected shouldPrepareContentAnimation(): boolean; protected contentDidInitialize(): void; protected get collapsibleKind(): string; protected expansionDidChange(expanded: boolean): void; protected getThinkingIcon(_active: boolean, expanded: boolean): ThemeIcon; protected initContent(): HTMLElement; private handleScroll; private updateFadeClasses; private syncDimensionsAndScheduleScroll; /** * Re-read scrollHeight from the DOM and update cached height if changed. */ private refreshContentHeight; private updateScrollDimensionsFromCache; private scrollToBottom; /** * updates scroll dimensions when streaming is complete. */ private updateScrollDimensionsForCompletion; private updateCompletedScrollAnimationState; private renderMarkdown; private renderThinkingMarkdownWithHeader; private renderThinkingMarkdown; /** Renders one summary row, reusing the row's element while its text only grows. */ private renderSummaryRow; private renderSummaryRows; /** Removes the extra summary rows and resets tracking, keeping the text container. */ private clearSummaryRows; /** Keeps a prior part's rendered rows in the DOM; defers disposal to teardown. */ private retireSummaryRows; private setFinalizedTitle; private renderDiffButton; private clearDiffButton; hasReasoningContent(): boolean; hasReasoningTiming(): boolean; hasActiveReasoningTiming(): boolean; hasGroupedItems(): boolean; private recordReasoningContent; private setDropdownClickable; private shouldAllowExpansion; private updateDropdownClickability; private updateToolChainVisibility; private appendToWrapper; private updateWorkingSpinnerVisibility; resetId(): void; collapseContent(): void; /** * Collapses the content once keyboard focus leaves it, so an auto-collapse never makes the * element a user is interacting with inert. */ collapseContentWhenUnfocused(): void; getPendingCollapseAnimation(): Promise | undefined; private waitForCollapseAnimation; expandContent(): void; updateReasoningTiming(content: IChatThinkingPart): void; updateThinking(content: IChatThinkingPart): void; getIsActive(): boolean; /** * Returns true when this thinking part has no meaningful content to display: * no tool invocations, no lazy items, no hooks, and no thinking text. * This happens when a tool is removed from thinking (e.g. due to confirmation) * and the thinking part was only created to hold that tool. */ isEffectivelyEmpty(): boolean; markAsInactive(): void; finalizeTitleIfDefault(): void; private getTitleHeaders; private getTitleGenerationContent; private acceptGeneratedTitle; private restoreSingleItemToOriginalPosition; private updateAggregatedDiff; private getFallbackTitle; private updateReasoningDurationLabels; private setFallbackTitle; /** Shows a finished section's title, which a conversation section wipes in after its last activity. */ private showFinalizedTitle; /** * Appends an item lazily until the group is expanded. * Pass any already-created part as `eagerDisposable` to transfer ownership immediately. */ appendItem(factory: () => { domNode: HTMLElement; disposable?: IDisposable; isVisible?: IObservable; }, toolInvocationId?: string, toolInvocationOrMarkdown?: ChatThinkingItemMetadata, originalParent?: HTMLElement, diffSource?: IChatContentPartDiffSource, eagerDisposable?: IDisposable): void; removeMaterializedItem(toolCallId: string): void; /** Transfers ownership of a materialized tool to the caller while its thinking group is rebuilt. */ detachToolPart(toolCallId: string): IDisposable | undefined; /** * Removes a markdown edit pill child by its part ID (codeblocksPartId). */ removeEditPillByPartId(partId: string): void; /** * removes/re-establishes a lazy item from the thinking container * this is needed so we can check if there are confirmations still needed * @param toolCallId Identifies a tool call among lazy items for the same tool. */ removeLazyItem(toolInvocationId: string, toolCallId?: string): boolean; private processPendingRemovals; private schedulePendingRemovalsFlush; private removeStreamingToolEntry; private trackToolMetadata; private updateExternalResourceParts; private flushPendingExternalResources; private appendItemToDOM; private scheduleAppendRefresh; private materializeLazyItem; /** Persists generated titles on the original model part rather than only on its display fragments. */ setThinkingPartSource(content: IChatThinkingPart, source: IChatThinkingPart): void; setupThinkingContainer(content: IChatThinkingPart, source?: IChatThinkingPart): void; protected setTitle(title: ChatThinkingTitle, omitPrefix?: boolean): void; private clearTitleDetail; hasSameContent(other: IChatRendererContent, _followingContent: IChatRendererContent[], _element: ChatTreeItem): boolean; dispose(): void; }