import { Disposable } from "../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../base/common/observable.js"; import { URI } from "../../../../base/common/uri.js"; import { Action2 } from "../../../../platform/actions/common/actions.js"; import { IClipboardService } from "../../../../platform/clipboard/common/clipboardService.service.js"; import { IInstantiationService, ServicesAccessor } from "../../../../platform/instantiation/common/instantiation.js"; import { ILogService } from "../../../../platform/log/common/log.service.js"; import { INotificationService } from "../../../../platform/notification/common/notification.service.js"; import { IChatEntitlementService } from "../../../services/chat/common/chatEntitlementService.service.js"; import { IWorkbenchEnvironmentService } from "../../../services/environment/common/environmentService.service.js"; import { IChatSideChatService } from "../common/chatSideChatService.service.js"; import { IChatWidget } from "./chat.js"; import type { IChatWidgetContrib } from "@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/chat/browser/widget/chatWidget"; import { IResolvedResponseSelection } from "./responseSelectionResolver.js"; export interface IResponseSelectionSideChatOptions { readonly useActionMenu: () => boolean; readonly showOnSelection?: boolean; readonly onAction?: (variant: "askQuestionInput" | "actionMenu", action: "shown" | "askQuestionOpened" | "askQuestionSubmitted" | "quote" | "copy") => void; } /** * Owns actions and an anchored question input for text selected within one assistant response. */ export declare class ResponseSelectionSideChatController extends Disposable { private readonly _widget; private readonly _responseSelectionSupported; private readonly _options; private readonly _sideChatService; private readonly _logService; private readonly _notificationService; private readonly _clipboardService; private readonly _chatEntitlementService; private readonly _input; private readonly _menuDomNode; private readonly _menu; private readonly _askQuestionAction; private readonly _quoteAction; private readonly _chatInteractivity; private readonly _selectionChangeScheduler; private _pointerSelectionId; private _pointerSelectionChanged; private _verticalPlacement; private _lastFocusRect; private _lastTranscriptBounds; private _visibleSurface; private _visibleVariant; private _resolved; /** Range currently painted via the CSS custom highlight, if any. */ private _paintedRange; /** Pins the transcript while a selection or the question input is active. */ private readonly _autoScrollHold; private _chatResource; private _isReadOnly; /** Bumped on a genuine chat navigation/force-dismiss so a stale submission's completion/error handler can no-op. */ private _generation; constructor(_widget: IChatWidget, _responseSelectionSupported: boolean, _options: IResponseSelectionSideChatOptions, _sideChatService: IChatSideChatService, _logService: ILogService, _notificationService: INotificationService, _clipboardService: IClipboardService, _chatEntitlementService: IChatEntitlementService); /** * Tracks which chat the current transcript belongs to, for side-chat * creation. `ChatView` re-invokes this for the same chat on unrelated * observable changes, so only force-dismiss on a genuine resource change. */ setChat(resource: URI | undefined, isReadOnly: IObservable): void; private _beginPointerSelection; private _finishPointerSelection; private _onSelectionChange; private _applySelectionChange; /** * Pins the transcript while the user is working with a selection: a growing * response that scrolls itself to the bottom would otherwise drag the text * out from under the selection (and the affordance anchored to it). Covers * any selection in the transcript, not just ones that resolve to a single * response, since auto-scrolling mid-drag is disruptive either way. */ private _updateAutoScrollHold; private _hasTranscriptSelection; /** * Keeps the captured selection visible. The native selection disappears as * soon as focus moves into the "Ask Question" input, so a CSS custom * highlight takes over painting the range for as long as the affordance is * open; while the native selection still covers it the browser paints it * and the highlight stays off so the two never stack. */ private _syncHighlight; private _paintHighlight; private _showFor; private _openQuestionInput; openQuestionInput(selection: IResolvedResponseSelection): void; private _quoteSelection; private _copySelection; private _getConfiguredVariant; private _canAskInSideChat; private _hasAffordanceFocus; /** * Re-anchors the affordance to the (live) selection range. Called on every * transcript scroll so the overlay tracks the text it belongs to instead of * staying pinned where the selection used to be. */ private _reposition; /** * Box the overlay is confined to, in viewport coordinates: the scrollable * transcript, further clipped to the window so it can never render out of * sight on a small window. */ private _transcriptBounds; /** * Dismisses the input. While a submission is pending (`_input.isBusy`), * only a genuine view change (`force`, from {@link setChat}) may dismiss * it — outside interactions like Escape or selection invalidation must not * race the in-flight create/open/send. */ private _dismiss; private _submit; } /** Mounts the shared selection affordance on persistent editor-window chats. */ export declare class EditorResponseSelectionSideChatContribution extends Disposable implements IChatWidgetContrib { static readonly ID = "chat.responseSelectionSideChat"; readonly id = "chat.responseSelectionSideChat"; private readonly _controller; constructor(widget: IChatWidget, environmentService: IWorkbenchEnvironmentService, instantiationService: IInstantiationService); openQuestionInput(selection: IResolvedResponseSelection): void; } export declare class AskSelectionInSideChatAction extends Action2 { constructor(); run(accessor: ServicesAccessor, context: unknown): void; }