-
Notifications
You must be signed in to change notification settings - Fork 41.9k
Add experiment driven inline model feedback survey #331850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Logan Ramos (lramos15)
merged 3 commits into
main
from
lramos15/inline-model-feedback-survey
Aug 20, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
...nsions/copilot/src/extension/telemetry/vscode/chatModelFeedbackSurveyForwardingContrib.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { commands } from 'vscode'; | ||
| import { ITelemetryService, TelemetryEventMeasurements, TelemetryEventProperties } from '../../../platform/telemetry/common/telemetry'; | ||
| import { Disposable } from '../../../util/vs/base/common/lifecycle'; | ||
| import { IExtensionContribution } from '../../common/contributions'; | ||
|
|
||
| /** | ||
| * Command the workbench invokes to report inline model feedback survey results. | ||
| * | ||
| * Keep in sync with `CHAT_MODEL_FEEDBACK_SURVEY_TELEMETRY_COMMAND_ID` in | ||
| * `src/vs/workbench/contrib/chat/common/feedbackSurvey/chatModelFeedbackSurveyTelemetry.ts`. | ||
| */ | ||
| const REPORT_SURVEY_COMMAND_ID = '_github.copilot.chat.reportModelFeedbackSurvey'; | ||
|
|
||
| const TELEMETRY_EVENT_NAME = 'vscode.chatModelFeedbackSurvey'; | ||
|
|
||
| const KNOWN_EVENT_KINDS: readonly string[] = ['shown', 'opened', 'step', 'submitted', 'dismissed']; | ||
|
|
||
| /** Mirrors the workbench payload in `chatModelFeedbackSurveyTelemetry.ts`. */ | ||
| interface IChatModelFeedbackSurveyTelemetryEvent { | ||
| readonly kind: 'shown' | 'opened' | 'step' | 'submitted' | 'dismissed'; | ||
| readonly surveyId: string; | ||
| readonly surveyInstanceId: string; | ||
| readonly stepCount: number; | ||
| readonly trigger?: 'manual' | 'chance' | 'modelSwitchedAway'; | ||
| readonly stepId?: string; | ||
| readonly stepIndex?: number; | ||
| readonly answerId?: string; | ||
| readonly comment?: string; | ||
| readonly modelId?: string; | ||
| readonly resolvedModelId?: string; | ||
| readonly modeId?: string; | ||
| readonly harness?: string; | ||
| readonly sessionType?: string; | ||
| readonly requestId: string; | ||
| } | ||
|
|
||
| /** | ||
| * Forwards inline model feedback survey results to GitHub restricted telemetry. | ||
| * | ||
| * The workbench cannot reach that endpoint, so it hands each result over as a command, which | ||
| * also activates this extension so early results are not lost. Every event is sent enhanced, | ||
| * including the ones carrying no answer, so the whole funnel shares one consent boundary. When | ||
| * the user has not opted in to restricted telemetry the send is a no op. | ||
| * | ||
| * Core already has a sender for the same table in | ||
| * `src/vs/platform/agentHost/node/agentHostRestrictedTelemetry.ts`, using the same enhanced | ||
| * ingestion key. It is node layer and lives in the agent host process with no channel to the | ||
| * renderer, so it cannot serve workbench events today. Exposing it to the renderer would let | ||
| * this contribution and `GithubTelemetryForwardingContrib` both go away. | ||
| */ | ||
| export class ChatModelFeedbackSurveyForwardingContrib extends Disposable implements IExtensionContribution { | ||
|
|
||
| constructor( | ||
| @ITelemetryService private readonly _telemetryService: ITelemetryService, | ||
| ) { | ||
| super(); | ||
|
|
||
| this._register(commands.registerCommand(REPORT_SURVEY_COMMAND_ID, (event: unknown) => { | ||
| this._report(event); | ||
| })); | ||
| } | ||
|
|
||
| private _report(event: unknown): void { | ||
| if (!isSurveyEvent(event)) { | ||
| return; | ||
| } | ||
|
|
||
| const properties: Record<string, string> = { | ||
| kind: event.kind, | ||
| surveyId: event.surveyId, | ||
| surveyInstanceId: event.surveyInstanceId, | ||
| }; | ||
| const measurements: Record<string, number> = { | ||
| stepCount: event.stepCount, | ||
| }; | ||
|
|
||
| addProperty(properties, 'trigger', event.trigger); | ||
| addProperty(properties, 'stepId', event.stepId); | ||
| addProperty(properties, 'answerId', event.answerId); | ||
| addProperty(properties, 'comment', event.comment); | ||
| addProperty(properties, 'modelId', event.modelId); | ||
| addProperty(properties, 'resolvedModelId', event.resolvedModelId); | ||
| addProperty(properties, 'modeId', event.modeId); | ||
| addProperty(properties, 'harness', event.harness); | ||
| addProperty(properties, 'sessionType', event.sessionType); | ||
| addProperty(properties, 'requestId', event.requestId); | ||
|
|
||
| if (typeof event.stepIndex === 'number') { | ||
| measurements.stepIndex = event.stepIndex; | ||
| } | ||
|
|
||
| const telemetryProperties: TelemetryEventProperties = properties; | ||
| const telemetryMeasurements: TelemetryEventMeasurements = measurements; | ||
| this._telemetryService.sendEnhancedGHTelemetryEvent(TELEMETRY_EVENT_NAME, telemetryProperties, telemetryMeasurements); | ||
| } | ||
| } | ||
|
|
||
| function isSurveyEvent(event: unknown): event is IChatModelFeedbackSurveyTelemetryEvent { | ||
| if (typeof event !== 'object' || event === null) { | ||
| return false; | ||
| } | ||
| const candidate = event as IChatModelFeedbackSurveyTelemetryEvent; | ||
| return KNOWN_EVENT_KINDS.includes(candidate.kind) | ||
| && typeof candidate.surveyId === 'string' | ||
| && typeof candidate.surveyInstanceId === 'string' | ||
| && typeof candidate.stepCount === 'number' | ||
| && typeof candidate.requestId === 'string'; | ||
| } | ||
|
|
||
| function addProperty(properties: Record<string, string>, key: string, value: string | undefined): void { | ||
| if (typeof value === 'string' && value.length > 0) { | ||
| properties[key] = value; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
163 changes: 163 additions & 0 deletions
163
src/vs/workbench/contrib/chat/browser/actions/chatModelFeedbackSurveyActions.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import * as dom from '../../../../../base/browser/dom.js'; | ||
| import { Codicon } from '../../../../../base/common/codicons.js'; | ||
| import { Disposable, markAsSingleton } from '../../../../../base/common/lifecycle.js'; | ||
| import { ThemeIcon } from '../../../../../base/common/themables.js'; | ||
| import { ServicesAccessor } from '../../../../../editor/browser/editorExtensions.js'; | ||
| import { localize2 } from '../../../../../nls.js'; | ||
| import { IAction } from '../../../../../base/common/actions.js'; | ||
| import { IActionViewItemService } from '../../../../../platform/actions/browser/actionViewItemService.js'; | ||
| import { MenuEntryActionViewItem } from '../../../../../platform/actions/browser/menuEntryActionViewItem.js'; | ||
| import { Action2, MenuId, MenuItemAction, registerAction2 } from '../../../../../platform/actions/common/actions.js'; | ||
| import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js'; | ||
| import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js'; | ||
| import { IWorkbenchContribution } from '../../../../common/contributions.js'; | ||
| import { ChatContextKeys } from '../../common/actions/chatContextKeys.js'; | ||
| import { isResponseVM } from '../../common/model/chatViewModel.js'; | ||
| import { IChatModelFeedbackSurveyService } from '../feedbackSurvey/chatModelFeedbackSurveyService.js'; | ||
| import '../feedbackSurvey/media/chatModelFeedbackSurvey.css'; | ||
| import { CHAT_CATEGORY } from './chatActions.js'; | ||
|
|
||
| export const ChatModelFeedbackSurveyActionId = 'workbench.action.chat.openModelFeedbackSurvey'; | ||
|
|
||
| const thumbsUpIconClasses = ThemeIcon.asClassNameArray(Codicon.thumbsup); | ||
| const thumbsDownIconClasses = ThemeIcon.asClassNameArray(Codicon.thumbsdown); | ||
|
|
||
| /** | ||
| * The combined thumbs up and down control that stands in for the helpful and unhelpful actions | ||
| * while a survey applies. It is neutral and opens the survey rather than recording a vote. | ||
| */ | ||
| class ChatModelFeedbackSurveyActionViewItem extends MenuEntryActionViewItem { | ||
|
|
||
| override render(container: HTMLElement): void { | ||
| super.render(container); | ||
|
|
||
| if (!this.element || !this.label) { | ||
| return; | ||
| } | ||
|
|
||
| // The label is the focusable anchor that carries the accessible name, so the styling and | ||
| // the icons hang off it rather than off the outer list item. | ||
| this.label.classList.add('chat-feedback-survey-pill'); | ||
| this.resetLabel(); | ||
|
|
||
| const icons = dom.append(this.label, dom.$('.chat-feedback-survey-pill-icons')); | ||
| icons.setAttribute('aria-hidden', 'true'); | ||
| for (const iconClasses of [thumbsUpIconClasses, thumbsDownIconClasses]) { | ||
| const icon = dom.append(icons, dom.$('.chat-feedback-survey-pill-icon')); | ||
| icon.classList.add(...iconClasses); | ||
| } | ||
| } | ||
|
|
||
| protected override updateClass(): void { | ||
| super.updateClass(); | ||
| this.resetLabel(); | ||
| } | ||
|
|
||
| /** | ||
| * The control discloses a panel rather than holding a pressed state, so it reports | ||
| * `aria-expanded` instead of the `aria-pressed` the base item would apply. | ||
| */ | ||
| protected override updateChecked(): void { | ||
| super.updateChecked(); | ||
| this.label?.removeAttribute('aria-pressed'); | ||
| this.label?.setAttribute('aria-expanded', String(!!this.action.checked)); | ||
| } | ||
|
|
||
| /** | ||
| * The base item paints one icon onto the label, so that has to be cleared before drawing two. | ||
| * The label keeps its `aria-label` and only the icons are hidden from screen readers. | ||
| */ | ||
| private resetLabel(): void { | ||
| if (!this.label) { | ||
| return; | ||
| } | ||
| this.label.classList.remove('icon', ...thumbsUpIconClasses, ...thumbsDownIconClasses); | ||
| this.label.style.backgroundImage = ''; | ||
| this.label.textContent = ''; | ||
| } | ||
| } | ||
|
|
||
| export class ChatModelFeedbackSurveyActionRendering extends Disposable implements IWorkbenchContribution { | ||
|
|
||
| static readonly ID = 'chat.modelFeedbackSurveyActionRendering'; | ||
|
|
||
| constructor( | ||
| @IActionViewItemService actionViewItemService: IActionViewItemService, | ||
| @IInstantiationService instantiationService: IInstantiationService, | ||
| ) { | ||
| super(); | ||
|
|
||
| const disposable = this._register(actionViewItemService.register(MenuId.ChatMessageFooter, ChatModelFeedbackSurveyActionId, (action, options) => { | ||
| if (!(action instanceof MenuItemAction)) { | ||
| return undefined; | ||
| } | ||
| return instantiationService.createInstance(ChatModelFeedbackSurveyActionViewItem, action, options); | ||
| })); | ||
|
|
||
| markAsSingleton(disposable); | ||
| } | ||
| } | ||
|
|
||
| /** The part of a toolbar needed to find and focus one of its actions. */ | ||
| export interface IFeedbackSurveyToolBar { | ||
| getItemsLength(): number; | ||
| getItemAction(index: number): IAction | undefined; | ||
| focus(index?: number): void; | ||
| } | ||
|
|
||
| /** | ||
| * Puts focus on the feedback control in `toolbar`, used when the survey panel it opened is torn | ||
| * down. Falls back to the toolbar itself when the control is not currently shown. | ||
| */ | ||
| export function focusChatModelFeedbackSurveyAction(toolbar: IFeedbackSurveyToolBar): void { | ||
| for (let i = 0; i < toolbar.getItemsLength(); i++) { | ||
| if (toolbar.getItemAction(i)?.id === ChatModelFeedbackSurveyActionId) { | ||
| toolbar.focus(i); | ||
| return; | ||
| } | ||
| } | ||
| toolbar.focus(); | ||
| } | ||
|
|
||
| export function registerChatModelFeedbackSurveyActions(): void { | ||
| registerAction2(class OpenModelFeedbackSurveyAction extends Action2 { | ||
| constructor() { | ||
| super({ | ||
| id: ChatModelFeedbackSurveyActionId, | ||
| title: localize2('chat.feedbackSurvey.open.label', "Give Feedback"), | ||
| f1: false, | ||
| category: CHAT_CATEGORY, | ||
| icon: Codicon.thumbsup, | ||
| toggled: ChatContextKeys.responseFeedbackSurveyOpen, | ||
| menu: [{ | ||
| id: MenuId.ChatMessageFooter, | ||
| group: 'navigation', | ||
| order: 2, | ||
| // The survey service checks these too, so a shown report is never sent for a | ||
| // control that cannot render. This drops the vote actions' | ||
| // `lockedToCodingAgent.negate()` because every agent host session is locked to | ||
| // its agent, which would make the `harnesses` selector unreachable. | ||
| when: ContextKeyExpr.and( | ||
| ChatContextKeys.responseHasFeedbackSurvey, | ||
| ChatContextKeys.isResponse, | ||
| ChatContextKeys.responseHasError.negate(), | ||
| ContextKeyExpr.has('config.telemetry.feedback.enabled'), | ||
| ), | ||
| }], | ||
| }); | ||
| } | ||
|
|
||
| run(accessor: ServicesAccessor, ...args: unknown[]): void { | ||
| const item = args[0]; | ||
| if (!isResponseVM(item)) { | ||
| return; | ||
| } | ||
| accessor.get(IChatModelFeedbackSurveyService).toggle(item); | ||
| } | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.