import { Event } from "../../../../base/common/event.js"; import { 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 { EditorInputCapabilities, GroupIdentifier, IUntypedEditorInput, Verbosity } from "../../../common/editor.js"; import { EditorInput } from "../../../common/editor/editorInput.js"; import { IEditorGroupsService } from "../../../services/editor/common/editorGroupsService.service.js"; import { IWorkbenchEnvironmentService } from "../../../services/environment/common/environmentService.service.js"; import type { IBrowserViewModel } from "../../browserView/common/browserView.js"; /** Reveals a live canvas beside its owning chat, reopening its closed tab. Takes an {@link ICanvasReference}. */ export declare const REVEAL_CANVAS_COMMAND_ID = "workbench.action.agentSessions.revealCanvas"; export interface ICanvas { readonly resource: URI; readonly instanceId: string | undefined; readonly title: string; readonly status?: string; readonly source: URI | undefined; /** Owning extension identifier, when the host reports it. */ readonly extensionId?: string; /** Provider-local canvas type identifier, when the host reports it. */ readonly canvasId?: string; } /** Where a registered canvas definition was contributed from. */ export type CanvasExtensionSource = "user" | "project" | "session" | "plugin" | "unknown"; /** One canvas type registered for a live chat. */ export interface ICanvasDefinition { readonly canvasId: string; readonly extensionId: string; readonly extensionSource: CanvasExtensionSource; readonly extensionName?: string; readonly displayName: string; readonly description: string; readonly requiresInput: boolean; } /** `undefined` is unsettled; an array, including an empty one, is authoritative. */ export type CanvasDefinitionSnapshot = readonly ICanvasDefinition[] | undefined; /** Lists and opens registered canvas types for one canvas context. */ export interface ICanvasDefinitionProvider { readonly onDidChangeDefinitions: Event; /** Returns `undefined` while unsettled, then fires {@link onDidChangeDefinitions} when an authoritative snapshot is available. */ listCanvases(): Promise; openCanvas(canvas: ICanvasDefinition, instanceId: string): Promise; } export interface ICanvasOwner { readonly providerId: string; readonly session: URI; readonly chat: URI; } export interface ICanvasReference extends ICanvasOwner { readonly canvas: URI; } export interface ICanvasReopenTarget { readonly reference: ICanvasReference; readonly canvas: ICanvas; } export interface ICanvasContext { readonly owner: ICanvasOwner; readonly canvases: IObservable; readonly openRequests?: IObservable>; /** Present when this chat can list and directly open registered canvas types. */ readonly definitionProvider?: ICanvasDefinitionProvider; /** * Closes a live canvas, which notifies its provider; the canvas then leaves * {@link canvases}. Unlike closing its tab, this ends the canvas. Absent when * the owner's host cannot close canvases. */ readonly closeCanvas?: (canvas: ICanvas) => Promise; } export interface ICanvasOpenRequest { readonly id: string; readonly succeeded: boolean; readonly pending?: boolean; } export interface ICanvasModelResolution { readonly model: IBrowserViewModel; readonly reused: boolean; } /** * The owner of an editor working set: a whole session, or a single chat of it * when the window scopes its layout to chats. */ export interface ICanvasWorkingSetOwner { readonly sessionResource: URI; /** The owning chat, or `undefined` when the working set belongs to the whole session. */ readonly chatResource: URI | undefined; } export interface ICanvasWorkingSetState { /** The owner whose working set was restored most recently, or `undefined` for an empty working set. */ readonly owner: ICanvasWorkingSetOwner | undefined; /** Whether a restore that replaces every open editor is queued or running. */ readonly restoring: boolean; /** Whether the queued restore is currently replacing the editor working set. */ readonly applying: boolean; } /** * Editor working sets of a window that replaces its open editors when the user * switches owners. Canvases follow them through opaque live identities. */ export interface ICanvasWorkingSets { readonly state: IObservable; /** Keeps a live canvas alive while a presentation-only layout change hides the editor area. */ registerEditorToRetain(input: EditorInput): IDisposable; /** Prevents reopening a canvas that a restore could not reconstruct from revealing a hidden editor area. */ suppressEditorPartAutoVisibility(): IDisposable; } export declare function canvasOwnerKey(owner: ICanvasOwner): string; export declare function getCanvasReferenceKey(reference: ICanvasReference): string; export declare function isCanvasOwner(first: ICanvasOwner, second: ICanvasOwner): boolean; /** Labels canvases by title, disambiguating repeated titles by their instance identifiers or positions. */ export declare function getCanvasInstanceLabels(canvases: readonly ICanvas[]): readonly string[]; /** Labels registered canvas types while disambiguating extension and identifier collisions. */ export declare function getCanvasDefinitionLabels(canvases: readonly ICanvasDefinition[]): readonly string[]; /** Produces the stable instance identifier used when directly opening a registered canvas type. */ export declare function getCanvasDefinitionInstanceId(canvas: ICanvasDefinition): string; /** Returns whether a registered extension canvas can be opened without another input flow. */ export declare function isOpenableExtensionCanvasDefinition(canvas: ICanvasDefinition): boolean; /** Orders registered canvas types by extension and display name. */ export declare function compareCanvasDefinitions(first: ICanvasDefinition, second: ICanvasDefinition): number; export declare const CANVAS_INPUT_SCHEME = "session-canvas"; /** Returns the resource of the editor input that presents `reference`. */ export declare function getCanvasInputResource(reference: ICanvasReference): URI; export declare class CanvasInput extends EditorInput { readonly reference: ICanvasReference; private readonly editorGroupsService; private readonly environmentService; static readonly ID = "sessions.editorInput.canvas"; static readonly EDITOR_ID = "sessions.editor.canvas"; readonly resource: URI; readonly canvas: import("../../../../base/common/observable.js").ISettableObservable; readonly membershipPending: import("../../../../base/common/observable.js").ISettableObservable; private _serializationId; constructor(reference: ICanvasReference, canvas: ICanvas | undefined, editorGroupsService: IEditorGroupsService, environmentService: IWorkbenchEnvironmentService); get typeId(): string; get editorId(): string; get capabilities(): EditorInputCapabilities; getName(): string; getDescription(): undefined; getIcon(): ThemeIcon; getTitle(verbosity?: Verbosity): string; private getReopenInstructions; canReopen(): boolean; canMove(_sourceGroup: GroupIdentifier, targetGroup: GroupIdentifier): true | string; get serializationId(): string | undefined; setSerializationId(serializationId: string): void; setCanvas(canvas: ICanvas | undefined, membershipPending?: boolean): void; matches(other: EditorInput | IUntypedEditorInput): boolean; }