import { type CodeWindow } from "../../base/browser/window.js"; import { IActionViewItem } from "../../base/browser/ui/actionbar/actionbar.js"; import { BaseActionViewItem, IActionViewItemOptions } from "../../base/browser/ui/actionbar/actionViewItems.js"; import { Button } from "../../base/browser/ui/button/button.js"; import type { IManagedHoverContent, IManagedHoverOptions } from "../../base/browser/ui/hover/hover.js"; import { IAction, IActionRunner } from "../../base/common/actions.js"; import { CancellationToken } from "../../base/common/cancellation.js"; import { Event } from "../../base/common/event.js"; import { Disposable, IDisposable } from "../../base/common/lifecycle.js"; import { IObservable } from "../../base/common/observable.js"; import { ThemeIcon } from "../../base/common/themables.js"; import { URI } from "../../base/common/uri.js"; import type { IActionListItemHover } from "../../platform/actionWidget/browser/actionList.js"; import { IContextMenuService } from "../../platform/contextview/browser/contextView.service.js"; import { IFileService } from "../../platform/files/common/files.service.js"; import { IHoverService } from "../../platform/hover/browser/hover.service.js"; /** * A pill rendered by {@link ChatPillsWidget}. The caller owns the action and any * state captured by the optional view-item factory. */ export interface IChatPill { readonly action: IAction; readonly createActionViewItem?: (options: IActionViewItemOptions) => IActionViewItem | undefined; } /** Observable data consumed by {@link ChatPillsWidget}. */ export interface IChatPillsModel { readonly pills: IObservable; readonly context?: IObservable; } /** One entry a pill stands for. */ export interface IChatPillEntry { readonly id: string; readonly label: string; /** Optional metadata rendered after the dropdown row label by default. */ readonly badge?: string; /** Places the badge before the label, keeping resource identity ahead of a resolving title. */ readonly badgeBeforeLabel?: boolean; /** Keeps a resolved label stable until an open dropdown is dismissed. */ readonly preserveLabelOnRefresh?: boolean; /** Optional CSS class added to the dropdown row. */ readonly className?: string; /** Short label used when this entry renders as the pill itself. */ readonly pillLabel?: string; readonly icon?: ThemeIcon; /** Renders the entry with its resource's themed file icon. */ readonly resource?: URI; /** Displays a thumbnail above the resource location in the entry's hover. */ readonly imagePreview?: { readonly resource: URI; readonly mimeType: string; }; /** Plays a muted video above the resource location in the entry's hover. */ readonly videoPreview?: { readonly resource: URI; readonly mimeType: string; }; /** Actions shown at the trailing edge of the entry's dropdown row. */ readonly toolbarActions?: readonly IChatPillAction[]; /** Additional actions shown only in the rich hover footer. */ readonly hoverActions?: readonly IChatPillAction[]; /** * Action shown on the entry's dropdown row alongside {@link toolbarActions}, * which consumers may also promote onto the pill itself when this is its * only entry. */ readonly promotedAction?: IChatPillAction; /** Accessible name used when this entry is rendered as the pill itself. */ readonly ariaLabel?: string; /** Accessible name for the dropdown row when it differs from the compact pill. */ readonly dropdownAriaLabel?: string; /** Plain-text description of the content shown beside the dropdown entry. */ readonly ariaDescription?: string; /** Content shown beside the entry while it is focused or hovered. */ readonly hover?: IActionListItemHover; /** Tooltip for the pill when this is the only entry. */ readonly tooltip?: string; /** Rich hover content for the pill when this is the only entry. */ readonly pillHover?: IManagedHoverContent; /** * Optional structured rendering when this entry is the only item. The entry's owner owns its lifetime. Its view * item receives {@link IChatInlinePillViewItemOptions}, so it can show the entry's promoted action like the other * renderings of a lone entry do. */ readonly inlinePill?: IChatPill; /** Starts resolving metadata for this entry without opening it. */ readonly prefetch?: () => void; open(): void; } export interface IChatPillAction extends IAction { /** Concise label used in the hover footer; the full label remains the row-action tooltip. */ readonly hoverLabel?: string; } /** View item options of an entry's {@link IChatPillEntry.inlinePill}. */ export interface IChatInlinePillViewItemOptions extends IActionViewItemOptions { /** * The entry's {@link IChatPillEntry.promotedAction}, such as Unpin, to show as the pill's trailing button with * {@link promotedActionIcon}. Present when the pill showing the entry shows its promoted action. */ readonly promotedAction?: IObservable; readonly promotedActionIcon?: ThemeIcon; } export type ChatReferenceKind = "pullRequest" | "issue"; export declare function getChatReferencePillPresentation(kind: ChatReferenceKind, reference: string, title?: string, fallbackTitle?: string): { resourceLabel: string; entry: { label: string; badge: string; badgeBeforeLabel: true; pillLabel: string; className: string; preserveLabelOnRefresh: boolean; ariaLabel: string; dropdownAriaLabel: string; ariaDescription: undefined; }; }; export declare const chatPillCopyUrlHoverLabel: string; export declare const chatPillCopyHashHoverLabel: string; export declare const chatPillRemoveReferenceHoverLabel: string; export declare const chatPillRemoveArtifactHoverLabel: string; export declare function withChatPillHoverLabel(action: T, hoverLabel: string): T & IChatPillAction; export declare function getChatPillLocationHover(location: string): IActionListItemHover; export interface IChatPillMediaPreview { readonly element: HTMLElement; readonly disposable: IDisposable; /** Controls in the preview a keyboard user can reach, such as a video's playback controls. */ readonly getTabbableElements?: () => readonly HTMLElement[]; } /** Creates the visual preview shared by direct image pills and image rows in a dropdown. */ export declare function createChatPillImagePreview(entry: IChatPillEntry & { readonly imagePreview: NonNullable; }, fileService: IFileService, token?: Readonly): IChatPillMediaPreview; /** Options for {@link createChatPillMediaPreview}. */ export interface IChatPillMediaPreviewOptions { /** * Whether motion is reduced. Read each time a preview is created, so a change * to the preference applies the next time the hover opens. When reduced, a * video does not play on its own and shows its controls instead. */ readonly isMotionReduced?: () => boolean; } /** Creates the visual preview of an entry's image or video, or `undefined` when it has neither. */ export declare function createChatPillMediaPreview(entry: IChatPillEntry, fileService: IFileService, token?: Readonly, options?: IChatPillMediaPreviewOptions): IChatPillMediaPreview | undefined; /** Whether an entry previews its image or video in its hover. */ export declare function hasChatPillMediaPreview(entry: IChatPillEntry): boolean; /** * Creates a muted, looping video preview. The bytes are read through the file * service, so remote videos preview like local ones. */ export declare function createChatPillVideoPreview(entry: IChatPillEntry & { readonly videoPreview: NonNullable; }, fileService: IFileService, token?: Readonly, autoPlay?: boolean): IChatPillMediaPreview; /** Row actions for an entry: its {@link IChatPillEntry.toolbarActions} followed by any {@link IChatPillEntry.promotedAction}. */ export declare function getChatPillEntryToolbarActions(entry: IChatPillEntry): readonly IChatPillAction[]; /** Footer actions for a rich entry hover, including row actions and hover-only actions. */ export declare function getChatPillEntryHoverActions(entry: IChatPillEntry): readonly IChatPillAction[]; export declare function getChatPillEntryHoverContents(entry: IChatPillEntry | undefined, fileService: IFileService, mediaContents: WeakMap, options?: IChatPillMediaPreviewOptions): IManagedHoverContent | undefined; export declare function getChatPillEntryHoverOptions(entry: IChatPillEntry | undefined): IManagedHoverOptions | undefined; /** A titled group of entries, rendered as a dropdown section. */ export interface IChatPillSection { readonly title: string; readonly entries: readonly IChatPillEntry[]; } /** Describes a pill entry's target while keeping its accessible name action-oriented. */ export declare function getChatPillResourceLocation(uri: URI, label: string, ariaLabel?: string): Pick; export declare function getChatPillEntries(sections: readonly IChatPillSection[]): readonly IChatPillEntry[]; export interface IChatPillsWidgetOptions { readonly ariaLabel?: string; readonly actionRunner?: IActionRunner; /** * Lets `contextmenu` bubble out of the pills. The toolbar otherwise swallows * it per item, which would hide the pills from a surrounding context menu. */ readonly allowContextMenu?: boolean; } /** * The floating row's rendered height: 2px/4px vertical padding around a 22px * small button. Hosts reserve this much transcript space while the row is shown. */ export declare const CHAT_INPUT_PILLS_ROW_HEIGHT = 28; export type ChatPillsCompactMode = boolean | "auto"; export interface IChatPillsRowOptions { /** Collapses pills to icons; `auto` collapses only the trailing pills needed to fit, preserving accessible labels and tooltips. */ readonly compact?: ChatPillsCompactMode; /** Window that owns the row. Required when rendering in an auxiliary window. */ readonly targetWindow?: CodeWindow; } /** Shared horizontally scrollable row for pills mounted above a chat input. */ export declare class ChatPillsRow extends Disposable { readonly element: HTMLElement; readonly content: HTMLElement; private readonly _scrollable; private readonly _resizeObserver; private readonly _mutationObserver; private _getPillElements; private _pillMeasurements; private _isLayouting; private readonly _onDidChangeLayout; readonly onDidChangeLayout: Event; private readonly _onDidRequestContextMenu; readonly onDidRequestContextMenu: Event; private readonly _pendingFocus; constructor(debugName: string, options?: IChatPillsRowOptions); /** Observes size changes; supplying the current pill buttons enables automatic compaction. */ observe(element: HTMLElement, getPillElements?: () => readonly HTMLElement[]): void; layout(): void; scanDomNode(): void; private _observeMutations; setEmpty(empty: boolean, ariaLabel: string): void; restoreFocus(getPillElements: () => readonly HTMLElement[], fallback?: () => void): void; } /** * A reusable horizontal toolbar whose pill set and action context are observable. */ export declare class ChatPillsWidget extends Disposable { readonly element: HTMLElement; readonly isVisible: IObservable; private readonly _onDidChangePills; readonly onDidChangePills: Event; private readonly _onDidRemoveFocusedPill; readonly onDidRemoveFocusedPill: Event; private readonly _toolbar; private _pillByAction; private _pills; constructor(model: IChatPillsModel, options: IChatPillsWidgetOptions | undefined, contextMenuService: IContextMenuService); /** Returns the rendered button for each pill. */ getPillElements(): readonly HTMLElement[]; focusFirst(): boolean; /** * The pill whose rendered item contains `target`, if any. Toolbar items are * rendered in pill order, so their position identifies them without each * pill having to tag its own DOM. */ getPill(target: HTMLElement | null | undefined): IChatPill | undefined; } /** Creates a shared chat pill button. The caller owns its lifetime. */ export declare function createChatPillButton(container: HTMLElement, options?: { readonly supportIcons?: boolean; }): Button; /** * Shared plumbing for every chat pill: the button, click routing, enabled * state, and the roving-focus hooks the toolbar drives. Subclasses own only * what goes inside the button. */ export declare abstract class ChatPillActionViewItemBase extends BaseActionViewItem { protected button: Button | undefined; private _promotedAction; private _promotedActionElement; /** The rendered button owned by this pill. */ get buttonElement(): HTMLElement | undefined; /** * Per-pill modifier classes added alongside the shared `chat-pill-item` and * `chat-pill-button`. A single class each, since these are applied with * `classList.add`, which rejects space-separated values. */ protected get itemModifierClass(): string | undefined; protected get buttonModifierClass(): string | undefined; protected get buttonOptions(): { readonly supportIcons?: boolean; }; render(container: HTMLElement): void; /** Fills the button. Called once, after the button exists. */ protected abstract renderContent(button: Button): void; protected hasOpenDropdown(): boolean; protected onDidClickButton(): void; protected updatePromotedAction(action: IChatPillAction | undefined, icon: ThemeIcon | undefined, hoverService?: IHoverService): void; private _createPromotedActionElement; focus(): void; blur(): void; setFocusable(focusable: boolean): void; isFocused(): boolean; protected updateEnabled(): void; protected updateAriaLabel(): void; protected getAriaLabel(): string | undefined; protected getTooltip(): string | undefined; } /** The default `icon + label` rendering for chat pill actions. */ export declare class ChatPillActionViewItem extends ChatPillActionViewItemBase { constructor(context: unknown, action: IAction, options: IActionViewItemOptions); protected renderContent(): void; protected updateClass(): void; protected updateLabel(): void; private getLabelContent; protected getIconElement(): HTMLElement | undefined; protected getLabelText(): string; protected getAdditionalLabelContent(): Array; }