Skip to content

Add chat quota trajectory nudge - #320683

Merged
Paul (pwang347) merged 60 commits into
microsoft:mainfrom
rfeltis:rfeltis/quota-trajectory-nudge
Jun 27, 2026
Merged

Paul (pwang347) merged 60 commits into
microsoft:mainfrom
rfeltis:rfeltis/quota-trajectory-nudge

Conversation

@rfeltis

@rfeltis Ralph Feltis (rfeltis) commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add a Copilot Chat quota trajectory nudge behind the chatQuotaTrajectoryNudge treatment
  • show the nudge only after quota/window/model eligibility is met and TAS assigns treatment, so users who can never see it are not exposed
  • move paid self-serve SKU eligibility to ExP targeting via copilotsku instead of enforcing a Pro/Pro+/Max allowlist in product code
  • render the nudge as a single Learn about optimizing usage link that opens https://aka.ms/token-usage-tips
  • show the nudge at most once per billing period, and let users dismiss it
  • add telemetry and tests for enrollment, learn-more clicks, gating, dismissal, usage windows, and one-display-per-billing-period behavior
  • update chat input notification links so visited links keep VS Code themed link colors

Screenshots

Treatment arm — the nudge is shown with the Learn about optimizing usage link:

Quota trajectory nudge shown in the treatment arm with the learn-more link

Treatment arm — chatQuotaTrajectoryNudgeEnrolled is emitted with treatment:1 in the live Telemetry output (real TAS assignment, chatquotatrajectorynudge-enabled:-9):

Telemetry output showing chatQuotaTrajectoryNudgeEnrolled with treatment 1 in the treatment arm

Treatment arm — after clicking the link, chatQuotaTrajectoryNudgeLinkClicked is emitted (the nudge dismisses on click):

Telemetry output showing chatQuotaTrajectoryNudgeLinkClicked after clicking the learn-more link

Control arm — no nudge is shown:

Control arm with no nudge shown

Control arm — chatQuotaTrajectoryNudgeEnrolled is emitted with treatment:0 (real TAS assignment, chatquotatrajectorynudge-control:-9):

Telemetry output showing chatQuotaTrajectoryNudgeEnrolled with treatment 0 in the control arm

Experiment targeting

  • Feature: Chat Quota Trajectory Nudge (config.chatQuotaTrajectoryNudge)
  • SKU targeting lives in ExP on the Insiders and Public experiments with copilotsku In ("monthly_subscriber_quota","yearly_subscriber_quota","plus_monthly_subscriber_quota","plus_yearly_subscriber_quota","max_monthly_subscriber_quota")
  • Product code resolves the treatment through the workbench assignment service (IWorkbenchAssignmentService.getTreatment) and still gates on quota state, billing-window projection, Copilot-model selection, and the TAS treatment result
  • The treatment is requested only once every non-experiment condition is met, and enrollment telemetry is emitted only when the user is actually assigned to a flight, so unassigned users are never counted

Telemetry

  • chatQuotaTrajectoryNudgeEnrolled — emitted for both arms once the gates pass and TAS resolves; carries treatment (true/false), entitlement, averageDailyUsage, and percentUsed to measure exposure
  • chatQuotaTrajectoryNudgeLinkClicked — emitted when the learn-more link is clicked (treatment arm)

Validation

  • npm run compile
  • npm run transpile-client
  • scripts\\test.bat --grep ChatQuotaNotification
  • End-to-end validation used real ExP assignment (real TAS treatment via per-arm devDeviceId overrides); only quota/model eligibility was faked with generated-output-only patches. Screenshots, Playwright traces, and screen recordings were captured from the full native 1600×1000 Code OSS window with the right-side Chat bar visible/asserted for both arms, and each asserted telemetry event was verified visible in the live Telemetry output stream (Developer: Show Telemetry).
  • Control arm (chatquotatrajectorynudge-control:-9, devDeviceId 728565ad-7e67-419e-8d48-a642f7e22480): no nudge shown; chatQuotaTrajectoryNudgeEnrolled emitted with treatment:0.
  • Treatment arm (chatquotatrajectorynudge-enabled:-9, devDeviceId 1a69d410-8d55-4e7e-b072-f6b2de8f3e58): nudge shown; chatQuotaTrajectoryNudgeEnrolled emitted with treatment:1, and chatQuotaTrajectoryNudgeLinkClicked emitted on click.

Copilot AI review requested due to automatic review settings June 9, 2026 21:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new “quota trajectory” (fast credit usage) nudge to chat quota notifications, including telemetry + dismissal persistence, and refines notification action styling/behavior.

Changes:

  • Add trajectory-based quota warning logic gated by assignment treatment + stored dismissal per quota period, with telemetry for “shown” and “action clicked”.
  • Extend chat input notification actions to support explicit secondary styling and a custom run hook (used for telemetry).
  • Update notification widget CSS for improved warning/error visuals and more flexible action/layout wrapping.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/browser/chatQuotaNotification.test.ts Adds trajectory warning test coverage, including assignment + telemetry mocks and dismissal behavior.
src/vs/workbench/contrib/chat/browser/widget/input/media/chatInputNotificationWidget.css Tweaks severity colors, wraps body layout, and updates secondary button styling.
src/vs/workbench/contrib/chat/browser/widget/input/chatInputNotificationWidget.ts Uses explicit secondary action flag and calls optional action.run before command execution.
src/vs/workbench/contrib/chat/browser/widget/input/chatInputNotificationService.ts Extends action API with secondary?: boolean and run?: () => void.
src/vs/workbench/contrib/chat/browser/chatQuotaNotification.ts Implements trajectory nudge gating, telemetry, dismissal persistence, and hooks into assignment + dismiss events.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/browser/widget/input/chatInputNotificationWidget.ts:1

  • action.run?.() is invoked inline without error isolation. If a consumer-provided run throws, the command execution will be skipped and the click handler will reject. Wrap action.run in a try/catch (or otherwise ensure failures don’t block executeCommand) so telemetry hooks can’t break the primary action behavior.
/*---------------------------------------------------------------------------------------------
  • Files reviewed: 5/5 changed files
  • Comments generated: 3

@rfeltis

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

@rfeltis
Ralph Feltis (rfeltis) force-pushed the rfeltis/quota-trajectory-nudge branch from e45d1ff to 8adc7ce Compare June 19, 2026 21:08
@rfeltis
Ralph Feltis (rfeltis) marked this pull request as ready for review June 22, 2026 17:57
@rfeltis
Ralph Feltis (rfeltis) force-pushed the rfeltis/quota-trajectory-nudge branch from e6a8908 to c45e86d Compare June 25, 2026 19:02
Restore package files and the Copilot configuration test workaround now that the quota experiment no longer uses a Copilot setting.

Co-authored-by: Copilot <[email protected]>
Ralph Feltis (rfeltis) and others added 9 commits June 25, 2026 13:41
Route treatment resolution failures through ILogService and simplify the trajectory treatment request path/comment.

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Revert the chatInputPart.ts additions (Auto is assumed always available) and
move 'is auto selected' into the common chatSelectedModel module as
isSelectedModelAuto, mirroring the sibling isSelectedModelCopilot. Export the
existing AUTO_MODEL_IDENTIFIER from languageModels.ts as the single source of
truth, reused by both the nudge's switch-to-Auto command and the detection
helper.

Co-authored-by: Copilot <[email protected]>
The quota trajectory nudge's Try Auto link was hardcoded to the 'copilot/auto' identifier for both detection and switching. In a Copilot CLI agent-host session the Auto model is registered as 'copilotcli:auto' and the general 'copilot/auto' is filtered out of the session's model pool, so the link silently no-opped and 'already Auto' was never detected.

Key Auto off the canonical metadata.id === 'auto' marker instead: add AUTO_MODEL_ID + ILanguageModelChatMetadata.isAutoModel, use it in isSelectedModelAuto, and add a session-aware ChatInputPart.switchToAutoModel() that the nudge calls. Works for both the Copilot panel and the Copilot CLI harness.

Co-authored-by: Copilot <[email protected]>
Drop the "switch to Auto" capability and all Auto-model detection from the
quota trajectory nudge. The nudge now shows only a learn-more link to
https://aka.ms/token-usage-tips and logs chatQuotaTrajectoryNudgeLinkClicked
when clicked.

Revert the Auto-detection/switching scaffolding back to its pre-PR state:
- languageModels.ts: remove AUTO_MODEL_ID export, isAutoModel/isAutoModelIdentifier
- chatSelectedModel.ts: remove isSelectedModelAuto
- chatInputPart.ts: remove switchToAutoModel
- languageModels.test.ts: remove the corresponding suites

Co-authored-by: Copilot <[email protected]>
@pwang347
Paul (pwang347) enabled auto-merge (squash) June 27, 2026 19:18
@pwang347
Paul (pwang347) merged commit 2ed2473 into microsoft:main Jun 27, 2026
29 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.127.0 milestone Jun 27, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Aug 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants