import { ISerializableView, IViewSize } from "../../../base/browser/ui/grid/grid.js"; import { Event } from "../../../base/common/event.js"; import { Disposable } from "../../../base/common/lifecycle.js"; import { IAction } from "../../../base/common/actions.js"; import { IObservable } from "../../../base/common/observable.js"; import { URI } from "../../../base/common/uri.js"; import { CancellationToken } from "../../../base/common/cancellation.js"; import { IAgentsWindowDraft } from "../../../platform/window/common/window.js"; import { IChat, ISession } from "../../services/sessions/common/session.js"; import { WorkspaceSelectionOrigin } from "../../common/workspaceSelection.js"; import { ISessionPickerVisibility } from "../../services/sessions/common/sessionPickerVisibility.js"; import type { IChatSessionHistoryStatus } from "../../../platform/chat/common/chatSessionHistory.js"; /** * Discriminates between concrete {@link AbstractChatView} subclasses without * requiring core code (`sessions/browser/`) to import them from contrib. */ export type ChatViewKind = "newSession" | "newChatInSession" | "chat"; /** * Options passed to a chat view when it is created. */ export interface IChatViewOptions { /** Visibility of the owning session slot, preserved across composer/preparation/transcript handoffs. */ readonly hostVisible?: IObservable; /** Keep the custom view hosting this composer visible while preparing its draft. */ readonly preserveCustomView?: boolean; /** Send new-session requests without navigating away from the hosting view. */ readonly backgroundSend?: boolean; readonly renderChatPet?: boolean; /** Host only the composer, without transcript content, input interactions, or transcript view-state persistence. */ readonly inputOnly?: boolean; } export interface ISelectWorkspaceOptions { readonly providerId?: string; readonly preferDevContainer?: boolean; readonly selectionOrigin?: WorkspaceSelectionOrigin; /** Only replace an automatic default in a fresh, empty composer. */ readonly isDefault?: boolean; } export interface ISelectNoWorkspaceOptions { readonly userSelection?: boolean; readonly preserveNavigation?: boolean; } export type WorkspaceSelectionResult = "applied" | "notReady" | "preserved"; /** * Base class for a view that lives inside the {@link SessionsPart} internal grid. * Each instance occupies a single grid leaf. Subclasses populate {@link element} * with their content and forward sizing to whatever widget they host by * overriding {@link doLayout}. * * Concrete implementations (e.g. `NewChatView`, `ChatView`) live in the * `sessions/contrib/chat/` layer where the chat widgets they host are defined. * Core code obtains instances via {@link IChatViewFactory}. */ export declare abstract class AbstractChatView extends Disposable implements ISerializableView { readonly element: HTMLElement; readonly minimumWidth = 200; readonly maximumWidth: number; readonly minimumHeight = 200; readonly maximumHeight: number; private readonly _onDidChange; readonly onDidChange: Event; /** A user request accepted for sending or queuing from this view, identified by its originating chat. */ readonly onDidSubmitRequest: Event; /** * Lazily-created progress indicator scoped to this leaf. Mirrors how each * editor group owns its own {@link ProgressBar} + `ScopedProgressIndicator`. */ private _progressIndicator; /** * Discriminates the concrete subclass. Used by the session view host to * decide whether the current concrete view can be reused or must be * replaced when `openSession` is called. */ abstract readonly kind: ChatViewKind; readonly pickerVisibility: IObservable; get activityBarActions(): IObservable; /** Retain the composer while it clears a draft as part of an in-place selection change. */ get preserveOnSessionClear(): boolean; focusWorkspacePicker(): void; focusHarnessPicker(): void; focusEnvironmentPicker(): void; focusBranchPicker(): void; focusWorktreePicker(): void; focusSyncAction(): void; openModelComparison(): void; /** * Intrinsic composer content for input-only hosts to measure and observe. * Includes new-session pickers where present; ownership stays with the view. */ get inputContentElement(): HTMLElement | undefined; /** * Whether the view has a visible transcript turn to retain when a remote * host disconnects. New and unbound views intentionally report no content. */ readonly hasVisibleTranscriptContent: IObservable; /** * Whether this view is still resolving its chat model, during which * {@link hasVisibleTranscriptContent} is not yet meaningful — it reads `false` for a transcript * that simply has not arrived yet as well as for one that does not exist. Views that never load * a model report `false`, since for them the answer is already final. */ readonly isLoadingTranscript: IObservable; /** Whether an input notification already explains a temporary sending restriction. */ readonly isInputBlocked: IObservable; readonly historyStatus: IObservable; /** * Show the given chat in this view. The default implementation is a * no-op; subclasses that host a chat widget (e.g. `ChatView`) override * this to load the chat model and feed it into the widget. */ setChat(_chat: IChat, _historyKey?: string, _session?: ISession, _onInput?: () => void): void; /** Retry a failed load when the user explicitly opens the selected chat again. */ reopenChat(_resource: URI): Promise; /** * Select a workspace folder, acknowledging application or preservation of an existing choice. * Views without a ready workspace picker return notReady. */ selectWorkspace(_folderUri: URI, _options?: ISelectWorkspaceOptions): WorkspaceSelectionResult; applyDraft(_draft: IAgentsWindowDraft, _folderUri: URI | undefined, _options: ISelectWorkspaceOptions, _token: CancellationToken): Promise; selectNoWorkspace(_options?: ISelectNoWorkspaceOptions): void; /** * Prefill the input with the given text. The default implementation is * a no-op; subclasses that host an input widget (e.g. `NewChatView`) * override this. */ prefillInput(_text: string): void; /** * Submit the given text as a chat query. The default implementation is * a no-op; subclasses that host an input widget (e.g. `NewChatView`) * override this. */ sendQuery(_text: string): void; /** Submit the current composer input, returning whether it was sent. */ submitInput(): Promise; /** * Attach the given resources as context to this view's chat input. The * default implementation is a no-op; subclasses that host a chat widget * (e.g. `ChatView`) override this to add the attachments to the widget. */ attach(_uris: URI[]): void; /** * Notifies the view whether it is the currently active session in the * sessions grid. Subclasses may use this to adjust their visual styling * (e.g. the chat list's background color). The default implementation * is a no-op. */ setActive(_active: boolean): void; /** * Notifies the view whether it is currently shown. Unlike {@link setActive}, * inactive sessions displayed side by side are still visible. */ setVisible(_visible: boolean): void; /** * Notifies the view of its position and whether the chat grid is split. * Session-scoped UI can use this to avoid repeating across split groups and adapt its layout. */ setPrimary(_primary: boolean, _split?: boolean): void; /** * Shows an indeterminate progress bar at the top of this leaf while the * given promise is pending, mirroring how each editor group surfaces * progress on its own {@link ProgressBar} (see `EditorGroupView` / * `ScopedProgressIndicator`). The bar is scoped to this view, so concurrent * loads in other grid leaves are unaffected. Overlapping loads on this leaf * are joined by the indicator so the bar only hides once all have settled. * The optional `delay` avoids flashing the bar for fast (e.g. cached) loads. */ protected showProgressWhile(promise: Promise, delay?: number): void; /** * Called by the workbench grid to size this leaf. Sizes {@link element} * to the allocated dimensions and then delegates to {@link doLayout} so * subclasses can forward sizing to their hosted widget. */ layout(width: number, height: number, top: number, left: number): void; protected abstract doLayout(width: number, height: number, top: number, left: number): void; abstract toJSON(): object; abstract focus(): void; }