import { IHoverDelegate } from "../../../../base/browser/ui/hover/hoverDelegate.js"; import { CancellationTokenSource } from "../../../../base/common/cancellation.js"; import { ThemeIcon } from "../../../../base/common/themables.js"; import { Disposable } from "../../../../base/common/lifecycle.js"; import { Event } from "../../../../base/common/event.js"; import { IObservable } from "../../../../base/common/observable.js"; import { URI } from "../../../../base/common/uri.js"; import { IActionWidgetService } from "../../../../platform/actionWidget/browser/actionWidget.service.js"; import { IInstantiationService } from "../../../../platform/instantiation/common/instantiation.js"; import { ILabelService } from "../../../../platform/label/common/label.service.js"; import { ISessionWorkspaceBrowseAction } from "../../../services/sessions/common/session.js"; import { INestedChatFolderInfo, INestedChatWorkspace, INestedChatWorkspaceSupport } from "../../../services/sessions/common/sessionsProvider.js"; import { INoWorkspaceChoicePresentation } from "./noWorkspaceChoice.js"; import { IComposerRepositoryControls } from "./newChatComposerInput.js"; /** The folder chosen for a new nested chat: a folder, or "No workspace" (the chat's own scratch folder). */ export type NestedChatFolderChoice = { readonly kind: "folder"; readonly folder: URI; } | { readonly kind: "scratch"; }; /** What the folder picker offers for a session. */ export interface INestedChatFolderOptions { readonly choices: readonly NestedChatFolderChoice[]; /** Browse actions offered after the folders; empty when the agent can't give a chat a folder of its own. */ readonly browseActions: readonly ISessionWorkspaceBrowseAction[]; /** Whether "Open Folder…" (a local folder dialog) is offered after the browse actions. */ readonly openFolder: boolean; } /** Where else a nested chat may find a folder, like New Session: recent folders and a local folder dialog. */ export interface INestedChatFolderSources { /** Recently used folders of the session's provider, most recent first. */ readonly recentFolders: readonly URI[]; /** Whether the session's provider runs on this computer, so a local folder dialog applies. */ readonly canOpenLocalFolder: boolean; } /** The preselected folder: the session's folder, or "No workspace" in a session without one. */ export declare function getDefaultNestedChatFolder(support: INestedChatWorkspaceSupport): NestedChatFolderChoice; /** * The folders offered for a nested chat, like New Session: the session's own folder, recent folders and * "No workspace". An agent that supports only one folder gets only the session's own folder, or * "No workspace" in a session without one: any other choice would be refused. A session folder that no * longer exists is not offered to an agent that can give the chat another folder. */ export declare function getNestedChatFolderOptions(support: INestedChatWorkspaceSupport, sources: INestedChatFolderSources, sessionFolderMissing?: boolean): INestedChatFolderOptions; /** Whether `choice` is one the support offers: any folder or "No workspace" with multiple folders, otherwise only the default. */ export declare function isNestedChatFolderOffered(support: INestedChatWorkspaceSupport, choice: NestedChatFolderChoice): boolean; export declare function isSameNestedChatFolder(a: NestedChatFolderChoice, b: NestedChatFolderChoice): boolean; export declare function isSameNestedChatWorkspace(a: INestedChatWorkspace, b: INestedChatWorkspace): boolean; /** * The workspace to request for a nested chat, or `undefined` when the choice equals the default: * then the chat created when the composer opened already works there and is used as is. * A worktree is only requested for a folder the host offers worktrees for. */ export declare function toNestedChatWorkspace(support: INestedChatWorkspaceSupport, choice: NestedChatFolderChoice, worktree: boolean, folderInfo: INestedChatFolderInfo | undefined, branch: string | undefined): INestedChatWorkspace | undefined; /** * How a folder choice is marked in the picker: the folder's icon, and the note naming it the session's own worktree. * Only the session folder of a session that runs in a git worktree is marked. */ export declare function getNestedChatFolderMark(support: INestedChatWorkspaceSupport, choice: NestedChatFolderChoice, noWorkspaceIcon: ThemeIcon): { readonly icon: ThemeIcon; readonly worktreeNote: string | undefined; }; /** How a folder reads in the folder picker, like a New Session workspace picker row. */ export interface INestedChatFolderLabel { /** The folder's name. */ readonly label: string; /** Where the folder is, e.g. its parent folder. */ readonly description: string | undefined; } /** The provider operations the picker needs for the parent session. */ export interface INestedChatWorkspaceHost { readonly support: IObservable; resolveFolder(folder: URI, token: CancellationTokenSource["token"]): Promise; getBranches(folder: URI, token: CancellationTokenSource["token"]): Promise; /** Recent folders and whether a local folder dialog applies, read when the folder picker opens. */ getFolderSources(): INestedChatFolderSources; /** How New Session's workspace picker presents choosing no workspace for the session's provider. */ describeNoWorkspace(): INoWorkspaceChoicePresentation; /** How the session's provider labels a folder in New Session's workspace picker, if it does. */ describeFolder(folder: URI): INestedChatFolderLabel | undefined; /** * Whether the folder is still there (a session folder whose worktree was deleted is not), or `undefined` * when that can't be told, e.g. the host is disconnected or `token` is cancelled. Never rejects. */ folderExists(folder: URI, token: CancellationTokenSource["token"]): Promise; /** Shows a local folder dialog. */ openLocalFolder(): Promise; } /** * Folder, isolation and branch pickers of the New Nested Session composer, rendered where the New * Session composer has its workspace and repository pickers. The agent and the environment come from * the parent session, so there is no harness or environment picker. */ export declare class NestedChatWorkspaceControls extends Disposable { private readonly _host; private readonly _actionWidgetService; private readonly _instantiationService; private readonly _labelService; private readonly _folder; private readonly _worktree; private readonly _branch; private readonly _folderInfo; /** Whether the session's folder was found to no longer exist, so "No workspace" is preselected instead. */ private readonly _sessionFolderMissing; /** Checks whether the preselected session folder still exists; settles once it is known or can't be told. */ private _folderCheck; /** Settles once a {@link refresh} has re-read its folder (or was superseded), which restores the kept worktree choice. */ private _refreshResolution; private readonly _branches; private readonly _resolve; private readonly _folderRenderStore; private _folderTrigger; private _folderSlot; private _isOpen; private readonly _onDidChangeChatPetPlatform; readonly onDidChangeChatPetPlatform: Event; /** Whether the isolation and branch pickers are offered: for a picked Git folder only, never for "No workspace" or other folders. */ readonly offersWorktree: import("../../../../base/common/observable.js").IObservableWithChange; constructor(_host: INestedChatWorkspaceHost, _actionWidgetService: IActionWidgetService, _instantiationService: IInstantiationService, _labelService: ILabelService); /** The workspace to request for the new chat, `undefined` to keep the composer's chat as is. */ getWorkspace(): INestedChatWorkspace | undefined; /** {@link getWorkspace} once a pending check of the session folder is done, so a chat never starts in a missing folder. */ resolveWorkspace(): Promise; /** Back to the session's default, e.g. after the chat was sent. */ reset(): void; /** * Re-reads the facts of the chosen folder, e.g. after the new chat's agent changed. A choice the current * support no longer offers goes back to the session's default (its folder, without a worktree); otherwise * the worktree choice and branch are kept where the folder still supports them. */ refresh(): void; private _select; private _loadBranches; /** * Renders the folder picker into the options row of the composer, styled like the New Session * workspace picker. */ renderFolderPicker(row: HTMLElement, hoverDelegate?: IHoverDelegate): void; /** Elements the chat pet can stand on, like the New Session workspace picker. */ getChatPetPlatformElements(): readonly HTMLElement[]; /** * Renders the isolation and branch pickers into the composer's repository controls, which the * composer places like the New Session ones: in the options row or below the input. The isolation * picker is New Session's (Branch or New Worktree); the branch picker only applies to a worktree. */ renderRepositoryControls(container: HTMLElement, hoverDelegate?: IHoverDelegate): IComposerRepositoryControls; private _setWorktree; private _getFolderLabel; private _showFolderPicker; private _describeChoice; }