import { Event } from "../../../../../base/common/event.js"; import { Disposable } from "../../../../../base/common/lifecycle.js"; import { URI } from "../../../../../base/common/uri.js"; import { ICommandService } from "../../../../../platform/commands/common/commands.service.js"; import { IConfigurationService } from "../../../../../platform/configuration/common/configuration.service.js"; import { ILogService } from "../../../../../platform/log/common/log.service.js"; import { IStorageService } from "../../../../../platform/storage/common/storage.service.js"; import { ITelemetryService } from "../../../../../platform/telemetry/common/telemetry.service.js"; import { IWorkbenchAssignmentService } from "../../../../services/assignment/common/assignmentService.service.js"; import { IChatModelFeedbackSurveyConfig } from "../../common/feedbackSurvey/chatModelFeedbackSurveyConfig.js"; import { ILanguageModelsService } from "../../common/languageModels.service.js"; import { IChatResponseViewModel } from "../../common/model/chatViewModel.js"; import { IChatSessionsService } from "../../common/chatSessionsService.service.js"; import { IChatService } from "../../common/chatService/chatService.service.js"; import { IChatModelFeedbackSurveyService } from "./chatModelFeedbackSurveyService.service.js"; /** Name of the experiment treatment carrying the survey payload. */ export declare const CHAT_MODEL_FEEDBACK_SURVEY_TREATMENT = "chatModelFeedbackSurvey"; export declare enum ChatModelFeedbackSurveyStatus { /** Available but not showing: only the feedback control is rendered. */ Collapsed = "collapsed", Open = "open" } /** What caused the survey to open, recorded so the funnel can separate the two paths. */ export type ChatModelFeedbackSurveyOpenTrigger = "manual" | "chance" | "modelSwitchedAway"; export interface IChatModelFeedbackSurveyState { readonly config: IChatModelFeedbackSurveyConfig; readonly instanceId: string; readonly status: ChatModelFeedbackSurveyStatus; /** Index into `config.steps` of the step currently being shown. */ readonly stepIndex: number; /** Answers so far, keyed by step id. Choice steps store an option id, text steps the comment. */ readonly answers: ReadonlyMap; /** Uncommitted free text, preserved across the widget being recycled by virtualization. */ readonly commentDraft: string; /** Whether this survey was submitted. Reopening it acknowledges rather than asks again. */ readonly isSubmitted: boolean; /** What opened the survey, so the UI can take focus only when the user asked for it. */ readonly openTrigger: ChatModelFeedbackSurveyOpenTrigger | undefined; } /** Identifies the response whose survey changed, without retaining its view model. */ export interface IChatModelFeedbackSurveyChangeEvent { readonly sessionResource: URI; readonly requestId: string; } export declare class ChatModelFeedbackSurveyService extends Disposable implements IChatModelFeedbackSurveyService { private readonly assignmentService; private readonly configurationService; private readonly storageService; private readonly telemetryService; private readonly commandService; private readonly languageModelsService; private readonly chatSessionsService; private readonly chatService; private readonly logService; readonly _serviceBrand: undefined; private readonly _onDidChangeSurveyState; readonly onDidChangeSurveyState: Event; private readonly _onDidChangeConfiguration; readonly onDidChangeConfiguration: Event; private _config; private _configResolved; /** Increments on every treatment refresh so a slow in-flight resolution cannot overwrite a newer one. */ private _configGeneration; private readonly _states; /** How many times the survey has opened itself in each session, keyed by session resource. */ private readonly _sessionPromptCounts; /** The most recent response carrying a survey in each session, for event-driven prompting. */ private readonly _lastSurveyedResponse; constructor(assignmentService: IWorkbenchAssignmentService, configurationService: IConfigurationService, storageService: IStorageService, telemetryService: ITelemetryService, commandService: ICommandService, languageModelsService: ILanguageModelsService, chatSessionsService: IChatSessionsService, chatService: IChatService, logService: ILogService); private resolveConfig; getSurvey(response: IChatResponseViewModel): IChatModelFeedbackSurveyState | undefined; toggle(response: IChatResponseViewModel): void; notifyModelSwitchedAway(sessionResource: URI, fromModelId: string, toModelId: string): void; /** Whether a model identifier is one the survey's `selectedModels` selectors name. */ private isSurveyedModel; /** The other identifiers a selector may name a model by. */ private getModelAliases; answerChoice(response: IChatResponseViewModel, stepId: string, optionId: string): void; submit(response: IChatResponseViewModel, comment?: string): void; dismiss(response: IChatResponseViewModel): void; setCommentDraft(response: IChatResponseViewModel, comment: string): void; /** * Decides whether a newly surveyed response should prompt on its own. The odds ramp with * every response that passed without prompting, so heavier users reach the survey sooner. */ private shouldPromptByChance; /** Releases response state on unload and session prompt budgets on deletion. */ private forgetSessions; /** Whether any survey is part way through, which an unrequested prompt must not displace. */ private hasSurveyInProgress; private hasPromptBudget; /** Opens the survey unprompted and charges it against the pacing budgets. */ private beginPrompt; private openState; private finish; private toChangeEvent; private getMatchingConfig; /** Answers that could never be sent must not be collected in the first place. */ private isFeedbackUiEnabled; private getResolvedModelId; /** Normalizes local and remote session types to one provider id, which is what a config targets. */ private getHarness; private readPromptMisses; private writePromptMisses; private readLastPromptAt; private writeLastPromptAt; private getKey; private toReadonly; /** * Closes whichever survey was already showing, since only one is open at a time. This is the * UI moving on rather than the user rejecting anything, so nothing is reported. */ private closeOtherOpenSurveys; /** * Within one session, keeps the newest response plus anything the user is part way through. * Other sessions are separate transcripts and are left alone. */ private dropSupersededStates; private reportShownOnce; private reportCommentOnce; private readDimensions; private report; }