import { IActionViewItemOptions } from "../../base/browser/ui/actionbar/actionViewItems.js"; import type { IManagedHoverContent, IManagedHoverOptions } from "../../base/browser/ui/hover/hover.js"; import { IAction } from "../../base/common/actions.js"; import { AnchorPosition } from "../../base/common/layout.js"; import { IObservable } from "../../base/common/observable.js"; import { ThemeIcon } from "../../base/common/themables.js"; import { IActionWidgetService } from "../../platform/actionWidget/browser/actionWidget.service.js"; import { ILanguageService } from "../../editor/common/languages/language.service.js"; import { IModelService } from "../../editor/common/services/model.service.js"; import { IFileService } from "../../platform/files/common/files.service.js"; import { IHoverService } from "../../platform/hover/browser/hover.service.js"; import { ChatPillActionViewItem, type IChatPill, type IChatPillEntry, type IChatPillSection } from "./chatPills.js"; import { IAccessibilityService } from "../../platform/accessibility/common/accessibility.service.js"; import type { ResourceLabels } from "./labels.js"; import type { IInstantiationService } from "../../platform/instantiation/common/instantiation.js"; /** * How a pill holding exactly one entry renders. Several entries always collapse * into the summary and its dropdown. */ export declare enum ChatPillSingleEntry { /** The entry itself — its own icon and label — activated directly. */ Inline = "inline", /** * The entry itself only when it is a resource, so a file keeps its name and * themed icon; anything else summarizes. */ InlineResource = "inlineResource", /** The summary and its dropdown, as for several entries. */ Summary = "summary" } /** Presentation of a {@link ChatDropdownPillActionViewItem}. */ export interface IChatDropdownPillOptions { /** Identifies the pill's dropdown to the action widget service. */ readonly widgetId: string; /** Icon of the summary shown for several entries. */ readonly icon: ThemeIcon | IObservable; /** Accessible name of the dropdown. */ readonly title: string; /** Summary label, e.g. `3 Artifacts`. */ readonly summaryLabel: (count: number) => string; /** Accessible summary label, e.g. `Show 3 artifacts`. */ readonly summaryAriaLabel: (count: number) => string; /** How a lone entry renders. Defaults to {@link ChatPillSingleEntry.Inline}. */ readonly singleEntry?: ChatPillSingleEntry; /** Preferred dropdown side, with fallback when the available space is insufficient. */ readonly preferredAnchorPosition?: AnchorPosition; /** Open expandable details on activation instead of running an entry's action. */ readonly openHoverOnSelect?: boolean; /** * Shows a lone inline entry's {@link IChatPillEntry.promotedAction} on the pill * itself, as a trailing icon button with this glyph and its own tooltip. Like a * dropdown row's hover, the pill's hover then leaves out the action it shows. * The button is a pointer shortcut: the pill's context menu keeps offering the * action to keyboard and screen reader users. */ readonly promotedActionIcon?: ThemeIcon; } /** * The entry a pill shows in place of its summary, or `undefined` when it * summarizes. The single place {@link IChatDropdownPillOptions.singleEntry} is * interpreted, shared by the factory that picks the rendering and the view item * that picks the label. A lone entry with its own {@link IChatPillEntry.inlinePill} * always renders inline. */ export declare function getChatPillInlineEntry(entries: readonly IChatPillEntry[], options: IChatDropdownPillOptions): IChatPillEntry | undefined; /** * The `icon + label` pill extended with a dropdown. A single entry renders as * that entry's own icon and label and opens it directly; several collapse into * a summary whose dropdown lists them grouped by section. */ export declare class ChatDropdownPillActionViewItem extends ChatPillActionViewItem { private readonly _sections; private readonly _pillOptions; private readonly _actionWidgetService; private readonly _languageService; private readonly _modelService; private readonly _fileService; private readonly _hoverService; private readonly _accessibilityService; protected get itemModifierClass(): string; protected get buttonModifierClass(): string; constructor(action: IAction, options: IActionViewItemOptions, _sections: IObservable, _pillOptions: IChatDropdownPillOptions, _actionWidgetService: IActionWidgetService, _languageService: ILanguageService, _modelService: IModelService, _fileService: IFileService, _hoverService: IHoverService, _accessibilityService: IAccessibilityService); private _dropdownVisible; private readonly _prefetchedEntries; private readonly _dropdownLabels; private _entries; private _summaryIcon; private readonly _mediaHoverContents; private readonly _dropdownHovers; private readonly _resourceDropdownHovers; protected renderContent(): void; private _getPresentation; /** * A summarized pill opens a listbox, so it has to advertise the popup and * whether it is open. A single-entry pill activates directly and must not. */ private _updatePopupState; private _updateAriaDescription; /** * Mirrors a lone entry's promoted action onto the pill. It is a sibling of the * pill's button, not a child, so its clicks and taps never reach the button that * opens the entry. */ private _updatePromotedAction; /** Whether the pill stands for its entries rather than showing a single one. */ protected get isSummarized(): boolean; private get opensDropdown(); protected get entries(): readonly IChatPillEntry[]; protected getIconElement(): HTMLElement | undefined; /** Renders a themed glyph, keeping a state color the button would otherwise flatten. */ protected createIconElement(icon: ThemeIcon): HTMLElement; protected getLabelText(): string; protected getAdditionalLabelContent(): Array; protected getTooltip(): string; protected getHoverContents(): IManagedHoverContent; protected getAriaLabel(): string | undefined; protected getHoverOptions(): IManagedHoverOptions | undefined; protected onDidClickButton(): void; protected hasOpenDropdown(): boolean; protected openEntry(entry: IChatPillEntry | undefined): void; protected showDropdown(): void; private _getDropdownItems; private _getDropdownHover; /** * Releases the hover cached for an entry that changed or was removed. An entry can * hand out the same hover disposable on every update, for content its source keeps * alive. That hover stays cached until the entry is removed or stops carrying the * disposable, so it is still released when the entry updates while the dropdown is closed. */ private _evictResourceHover; private _prefetchEntry; dispose(): void; } /** * Builds the pill for a set of sections, choosing the rendering that fits the * data: a lone resource entry renders as a resource pill, everything else as * the dropdown pill (which itself collapses to `icon + label` for one entry, * unless its {@link IChatDropdownPillOptions.singleEntry} policy says otherwise). * * The descriptor identity only changes when the rendering has to change, so the * toolbar rebuilds the view item on a shape flip and updates in place otherwise. */ export declare function createChatSectionPill(action: IAction, sections: IObservable, options: IChatDropdownPillOptions, resourceLabels: ResourceLabels, instantiationService: IInstantiationService): IObservable;