import { IStringDictionary } from "../../../../../../base/common/collections.js"; import { Event } from "../../../../../../base/common/event.js"; import { Disposable } from "../../../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../../../base/common/observable.js"; import { IHoverService } from "../../../../../../platform/hover/browser/hover.service.js"; import { IInstantiationService } from "../../../../../../platform/instantiation/common/instantiation.js"; import { IContextKeyService } from "../../../../../../platform/contextkey/common/contextkey.service.js"; import { IStorageService } from "../../../../../../platform/storage/common/storage.service.js"; import { IConfigurationService } from "../../../../../../platform/configuration/common/configuration.service.js"; import { IChatRequestModel } from "../../../common/model/chatModel.js"; import { ILanguageModelConfigurationSchema } from "../../../common/languageModels.js"; import { ILanguageModelsService } from "../../../common/languageModels.service.js"; import { IChatContextUsageData } from "./chatContextUsageDetails.js"; import type { IChatWidget } from "../../chat.js"; /** * Resolves the configured input-token limit, falling back to the schema default tier and then the optional input budget. * This mirrors the request path's `applyContextSizeOverride`. */ export declare function resolveContextWindowInputTokens(modelConfiguration: IStringDictionary | undefined, configurationSchema: ILanguageModelConfigurationSchema | undefined, maxInputTokens?: number): number | undefined; /** * Equality comparer for {@link IChatContextUsageData} used to suppress redundant updates. * * @internal - exported for testing */ export declare function isSameContextUsageData(a: IChatContextUsageData | undefined, b: IChatContextUsageData | undefined): boolean; /** * A reusable circular progress indicator that displays a ring. * The ring fills clockwise from the top based on the percentage value. */ export declare class CircularProgressIndicator { readonly domNode: SVGSVGElement; private readonly progressCircle; private readonly circumference; private static readonly CENTER_X; private static readonly CENTER_Y; private static readonly RADIUS; constructor(); /** * Updates the ring to display the given percentage (0-100). * @param percentage The percentage of the ring to fill (clamped to 0-100) */ setProgress(percentage: number): void; } /** * Widget that displays the context/token usage for the current chat session. * Shows a circular progress icon that expands on hover/focus to show token counts, * and on click shows the detailed context usage widget. */ export declare class ChatContextUsageWidget extends Disposable { private readonly hoverService; private readonly instantiationService; private readonly languageModelsService; private readonly contextKeyService; private readonly storageService; private readonly configurationService; private readonly _onDidChangeVisibility; readonly onDidChangeVisibility: Event; readonly domNode: HTMLElement; private readonly progressIndicator; private readonly percentageLabel; private readonly _isVisible; get isVisible(): IObservable; private readonly _lastRequestDisposable; private readonly _modelConfigurationListener; private _currentResponse; private _currentModelId; /** * The model the user currently has selected in the picker. When set it * overrides the last request's model for computing the context-window * denominator, so switching models updates the widget before the next * request is sent. The usage numerator still comes from the last response. */ private _selectedModelId; private readonly _hoverDisposable; private readonly _contextUsageDetails; private _chatWidget; private readonly _currentData; private static readonly _OPENED_STORAGE_KEY; private static readonly _HOVER_ID; private readonly _contextUsageOpenedKey; private _enabled; /** * Per-editor resolver for a model's configuration (e.g. user-selected * context size). When unset the widget falls back to the profile-global * value from {@link ILanguageModelsService.getModelConfiguration}, which can * lag the editor's actual selection (see issue #320393). */ private _modelConfigurationResolver; constructor(hoverService: IHoverService, instantiationService: IInstantiationService, languageModelsService: ILanguageModelsService, contextKeyService: IContextKeyService, storageService: IStorageService, configurationService: IConfigurationService); setChatWidget(widget: IChatWidget): void; /** * Shows the sticky context usage details hover and records that the user * has opened it. Returns `true` if the details were shown. */ showDetails(): boolean; private readonly _hoverOptions; private _createDetails; private _markOpened; private setupHover; /** * Updates the widget with the latest request/response data. * The model is retrieved from the request's modelId. * @param lastRequest The last request in the session */ update(lastRequest: IChatRequestModel | undefined): void; updateSessionCost(sessionCost: number): void; /** * Provides a per-editor resolver for the selected model's configuration * (notably the user-selected context size). The widget re-renders whenever * the supplied event fires for the currently displayed model. Without this, * the widget falls back to the profile-global value, which can drift from * the editor's actual selection (see issue #320393). */ setModelConfigurationResolver(resolver: (modelId: string) => IStringDictionary | undefined, onDidChange: Event): void; /** * Sets the model the user currently has selected in the picker. The * context-window denominator then reflects this model immediately, even * before a request is sent with it. The usage numerator still comes from the * last completed response. */ setSelectedModel(modelId: string | undefined): void; /** * Resolves a model's context-window dimensions, or `undefined` when it has no usable window. A meta-model such as * "auto" advertises a zero-sized window, so it resolves to `undefined` and the caller falls back to the model that * actually served the request (see issue #321781). */ private resolveContextWindow; private updateFromResponse; private render; private show; private hide; }