import { IActionListItem } from "../../../../../platform/actionWidget/browser/actionList.js"; import { IActionWidgetService } from "../../../../../platform/actionWidget/browser/actionWidget.service.js"; import { BaseActionViewItem, IActionViewItemOptions } from "../../../../../base/browser/ui/actionbar/actionViewItems.js"; import { IHoverDelegate } from "../../../../../base/browser/ui/hover/hoverDelegate.js"; import { IAction } from "../../../../../base/common/actions.js"; import { Delayer } from "../../../../../base/common/async.js"; import { Disposable, DisposableStore, IDisposable } from "../../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../../base/common/observable.js"; import { URI } from "../../../../../base/common/uri.js"; import { ThemeIcon } from "../../../../../base/common/themables.js"; import { IActionViewItemService } from "../../../../../platform/actions/browser/actionViewItemService.service.js"; import { IConfigurationService } from "../../../../../platform/configuration/common/configuration.service.js"; import { IContextKeyService } from "../../../../../platform/contextkey/common/contextkey.service.js"; import { IDialogService } from "../../../../../platform/dialogs/common/dialogs.service.js"; import { IHoverService } from "../../../../../platform/hover/browser/hover.service.js"; import { IKeybindingService } from "../../../../../platform/keybinding/common/keybinding.service.js"; import { ISessionInputPickerVisibility } from "../../../../services/sessions/common/sessionPickerVisibility.service.js"; import { INotificationService } from "../../../../../platform/notification/common/notification.service.js"; import { ITelemetryService } from "../../../../../platform/telemetry/common/telemetry.service.js"; import { IStorageService } from "../../../../../platform/storage/common/storage.service.js"; import type { ResolveSessionConfigResult, SessionConfigPropertySchema, SessionConfigValueItem } from "../../../../../platform/agentHost/common/state/protocol/commands.js"; import { IQuickInputService } from "../../../../../platform/quickinput/common/quickInput.service.js"; import { IWorkbenchContribution } from "../../../../../workbench/common/contributions.js"; import { IChatInputPickerResponsiveState } from "../../../../../workbench/contrib/chat/browser/widget/input/chatInputPickerResponsiveLayout.js"; import { IViewsService } from "../../../../../workbench/services/views/common/viewsService.service.js"; import { IAgentWorkbenchLayoutService } from "../../../../browser/workbench.service.js"; import { IWorkbenchLayoutService } from "../../../../../workbench/services/layout/browser/layoutService.service.js"; import { ISessionChangesService } from "../../../changes/browser/sessionChangesService.js"; import { ISessionsProvidersService } from "../../../../services/sessions/browser/sessionsProvidersService.service.js"; import { IActiveSession } from "../../../../services/sessions/common/sessionsManagement.js"; import { ISessionsService } from "../../../../services/sessions/browser/sessionsService.service.js"; import { type IAgentHostSessionsProvider } from "../../../../common/agentHostSessionsProvider.js"; import { type ISessionChangeset } from "../../../../services/sessions/common/session.js"; import { IWorktreeSuggestionService } from "../../../worktreeSuggestion/browser/worktreeSuggestionService.service.js"; export interface IConfigPickerItem { readonly id?: string; readonly value: string; readonly label: string; readonly description?: string; readonly checked?: boolean; readonly disabled?: boolean; /** Text shown after the label, such as "Recommended". */ readonly badge?: string; /** Runs instead of selecting a value, for rows that are not options, such as reviewing uncommitted changes. */ readonly run?: () => void; } export declare function getConfigIcon(property: string, value: unknown | undefined, hasUncommittedChanges?: boolean): ThemeIcon | undefined; export declare class AgentHostSessionConfigPicker extends Disposable { protected readonly _session: IObservable; private readonly _property; protected readonly _actionWidgetService: IActionWidgetService; protected readonly _configurationService: IConfigurationService; protected readonly _contextKeyService: IContextKeyService; protected readonly _dialogService: IDialogService; protected readonly _hoverService: IHoverService; protected readonly _sessionsProvidersService: ISessionsProvidersService; protected readonly _telemetryService: ITelemetryService; protected readonly _layoutService: IAgentWorkbenchLayoutService; protected readonly _storageService: IStorageService; private readonly _sessionChangesService; protected readonly _viewsService: IViewsService; private readonly _notificationService; private readonly _quickInputService; private readonly _pickerVisibility; private readonly _keybindingService; private readonly _worktreeSuggestionService; protected readonly _renderDisposables: DisposableStore; private readonly _providerListeners; private readonly _isolationCheckbox; private readonly _hostMarker; /** Refreshes the uncommitted files listed in the open isolation picker as they load or change. */ private readonly _listedFilesUpdates; protected readonly _filterDelayer: Delayer[]>; private _container; private _focusableElement; private _openedPickerSessionId; private _focusable; private _hoverDelegate; /** * Session/property-scoped value→label cache for `enumDynamic` * properties (e.g. branch), populated whenever `_getItems` fetches * completions. `enumDynamic` completions are transient protocol * data — only `value` is persisted via `setSessionConfigValue`/ * `resolveSessionConfig` — so this is the only place a completion's * `label` for a previously-picked value can be recovered once the * dropdown/sheet closes. Static `enum` properties don't need this: * their label is always derivable from `schema.enum`/`enumLabels`. * * Keyed by session so entries don't leak across sessions: this picker * is only ever created for the new-session composer (`Menus.NewSession- * RepositoryConfig`), and that composer's `_session` tracks the * globally active session — so the *same* picker instance can observe * a sequence of different (not-yet-created) draft sessions as the user * switches between them. `_renderConfigPickers` evicts entries for any * session other than the current one on every render, so the map never * grows beyond the properties of the currently active session. */ private readonly _dynamicValueLabels; constructor(_session: IObservable, _property: string | undefined, _actionWidgetService: IActionWidgetService, _configurationService: IConfigurationService, _contextKeyService: IContextKeyService, _dialogService: IDialogService, _hoverService: IHoverService, _sessionsProvidersService: ISessionsProvidersService, _telemetryService: ITelemetryService, _layoutService: IAgentWorkbenchLayoutService, _storageService: IStorageService, _sessionChangesService: ISessionChangesService, _viewsService: IViewsService, _notificationService: INotificationService, _quickInputService: IQuickInputService, _pickerVisibility: ISessionInputPickerVisibility, _keybindingService: IKeybindingService, _worktreeSuggestionService: IWorktreeSuggestionService); private _watchProviders; render(container: HTMLElement, hoverDelegate?: IHoverDelegate): HTMLElement | undefined; setFocusable(focusable: boolean): void; focus(): void; private _renderConfigPickers; /** * Order the schema properties for rendering. The base implementation * enforces a stable visual sequence for well-known properties: * Isolation (worktree/folder) first, then Branch. Any other properties * keep their original schema order after these two. Subclasses can * override to impose a different deterministic visual sequence * (e.g. the mobile chip row groups Approvals | Branch | Worktree). */ protected _orderProperties(properties: ReadonlyArray<[ string, SessionConfigPropertySchema ]>): ReadonlyArray<[ string, SessionConfigPropertySchema ]>; /** * Decide whether a property's chip should be rendered for the current * session. The base implementation hides non-mutable properties in * running sessions (they would render as dead pills). Subclasses can * override to keep specific properties visible as readonly chips — * see {@link _isReadOnlyChip}. */ protected _shouldRenderProperty(property: string, schema: SessionConfigPropertySchema, isNewSession: boolean): boolean; /** * Decide whether a property's trigger should render as readonly * (no chevron, no popup). The base implementation defers to the * schema's `readOnly` flag. Subclasses that opt in to rendering * non-mutable chips via {@link _shouldRenderProperty} should * override this to also mark them readonly at runtime. */ protected _isReadOnlyChip(property: string, schema: SessionConfigPropertySchema, isNewSession: boolean): boolean; protected _setSessionConfigValue(provider: IAgentHostSessionsProvider, sessionId: string, property: string, value: unknown): Promise; private _invokeCheckoutOperation; protected _requiresBranchCheckout(provider: IAgentHostSessionsProvider, sessionId: string, property: string): boolean; /** The chat this picker configures for `sessionId`: the shown session's active chat, or the session's main chat. */ protected _getChat(provider: IAgentHostSessionsProvider, sessionId: string): URI | undefined; private _requireChat; protected _getSessionConfig(provider: IAgentHostSessionsProvider, sessionId: string): ResolveSessionConfigResult | undefined; protected _isSessionConfigResolving(provider: IAgentHostSessionsProvider, sessionId: string): boolean; protected _getCheckoutChangeset(sessionId: string): ISessionChangeset | undefined; protected _renderTrigger(trigger: HTMLElement, sessionId: string, property: string, schema: SessionConfigPropertySchema, value: unknown | undefined, isReadOnly: boolean): void; /** * Keeps the Branch chip's glyph, aria label, and hover in sync with the * checked-out branch and uncommitted-changes count reported by the agent host. * * The chip only adopts the dirty state when its selected base branch matches * the repository's checked-out branch. Picker rows apply the same rule. * * The state is patched onto the existing nodes rather than routed through * `_renderConfigPickers`, which tears the whole chip row down: the host * re-probes git whenever it observes a file change, so a flip while the * user has the branch dropdown open would otherwise destroy its anchor. */ private _trackBranchRepositoryState; /** * Shows the number of uncommitted files after Branch on the isolation trigger of a new session while the * uncommitted files count presentation applies, and owns the trigger's label and hover, which describe it. * Like the Branch chip, the trigger is patched in place so a change in Git state never tears down an open * picker's anchor. */ private _trackWorktreeSuggestion; /** The worktree suggestion whose uncommitted files the isolation picker of `sessionId` counts and lists, if any. */ private _getCountedSuggestion; /** * The worktree suggestion for which the isolation picker of `sessionId` recommends New Worktree when it * opens, if any. The inline hint opens the picker for the user to choose, so the picker recommends New * Worktree for it until the user closes the hint or keeps Branch. */ private _getIsolationPickerRecommendation; /** * Lists a few of the suggestion's uncommitted files below the isolation picker's options, so focus starts * on the selected one, followed by a row that counts the rest. */ private _withListedFiles; /** The worktree suggestion for `sessionId` when it is the session the picker configures. */ private _getWorktreeSuggestion; /** * Whether the isolation property should render as a checkbox * (Worktree on/off) rather than a dropdown. Only on non-phone * layouts and only when the schema offers both folder and worktree. */ protected _shouldRenderIsolationAsCheckbox(schema: SessionConfigPropertySchema): boolean; private _renderIsolationCheckbox; private _isDevContainerWorktreeEnabled; private _applyIsolationValue; /** Shows the picker for `property` below `trigger`, focusing the option for `focusValue`, if any, rather than the selected one. */ protected _showPicker(provider: IAgentHostSessionsProvider, sessionId: string, property: string, schema: SessionConfigPropertySchema, trigger: HTMLElement, focusValue?: string): Promise; protected _isCurrentSession(provider: IAgentHostSessionsProvider, sessionId: string): boolean; private _showChanges; protected _getRepositoryBranchState(sessionId: string): { branchName: string | undefined; upstreamBranchName: string | undefined; defaultBranchName: string | undefined; defaultRemoteBranchName: string | undefined; uncommittedChanges: number | undefined; }; /** * Returns the picker items for `property`. Base branch results are filtered by `query` * and, when `branchResultLimit` is set, capped at that many results. */ protected _getItems(provider: IAgentHostSessionsProvider, sessionId: string, property: string, schema: SessionConfigPropertySchema, query?: string, branchCompletions?: readonly SessionConfigValueItem[], branchResultLimit?: number): Promise; private _fromCompletionItem; private _dynamicValueLabelsKey; private _cacheDynamicValueLabels; /** * Drops cached labels for any session other than `sessionId`. Called on * every render so the cache tracks whichever session the picker is * currently bound to, instead of accumulating entries for every draft * session this (potentially long-lived) picker instance has ever shown. */ private _evictDynamicValueLabelsForOtherSessions; private _getLabel; private _isNewSessionIsolationPicker; protected _getProvider(providerId: string): IAgentHostSessionsProvider | undefined; protected _presentationProperty(sessionId: string, property: string): string; } interface IConfigPickerWidget extends IDisposable { render(container: HTMLElement, hoverDelegate?: IHoverDelegate): HTMLElement | void; focus?(): void; setFocusable?(focusable: boolean): void; showPicker?(anchor: HTMLElement, onHide?: () => void): boolean | void; } export declare class PickerActionViewItem extends BaseActionViewItem implements IChatInputPickerResponsiveState { private readonly _picker; private readonly _manageFocusableElement; private _compact; private _focusableElement; constructor(_picker: IConfigPickerWidget, disposable?: IDisposable, _manageFocusableElement?: boolean, options?: IActionViewItemOptions, /** The menu action this picker renders, so toolbars can identify the picker. */ action?: IAction); render(container: HTMLElement): void; focus(): void; isFocused(): boolean; blur(): void; setFocusable(focusable: boolean): void; private _focusFirstTabStop; isCompact(): boolean; setCompact(compact: boolean): void; show(anchor?: HTMLElement): void; dispose(): void; } export declare class AgentHostSessionConfigPickerContribution extends Disposable implements IWorkbenchContribution { private readonly _layoutService; private readonly _contextKeyService; private readonly _sessionsProvidersService; private readonly _sessionsService; static readonly ID = "sessions.contrib.agentHostSessionConfigPicker"; private readonly _repositoryMenuItems; private readonly _repositoryPropertyRegistrations; private readonly _providerListeners; constructor(actionViewItemService: IActionViewItemService, _layoutService: IWorkbenchLayoutService, _contextKeyService: IContextKeyService, _sessionsProvidersService: ISessionsProvidersService, _sessionsService: ISessionsService); private _watchProviders; private _refreshRepositoryMenuItems; private _registerRepositoryProperty; /** * On the new-chat page (left of the toolbar), use the sessions * {@link PermissionPicker} so the styling matches the surrounding sessions * pickers (font size, padding, icon size). */ private _createNewSessionPermissionPicker; /** * Inside a running chat widget, use the workbench * {@link PermissionPickerActionItem} so it matches the standard chat-input * picker presentation in either toolbar. */ private _createRunningSessionPermissionPickerFactory; } export {};