Skip to content

Add chat quota trajectory nudge#320683

Draft
rfeltis wants to merge 24 commits into
microsoft:mainfrom
rfeltis:rfeltis/quota-trajectory-nudge
Draft

Add chat quota trajectory nudge#320683
rfeltis wants to merge 24 commits into
microsoft:mainfrom
rfeltis:rfeltis/quota-trajectory-nudge

Conversation

@rfeltis

@rfeltis 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 for eligible Pro, Pro+, and Max users between 10-35% monthly usage when projected usage is >= 4.5% per day
  • add shown/closed/click telemetry and tests for gating, dismissal, usage windows, and telemetry
  • update chat input notification links so visited links keep VS Code themed link colors
image

Validation

  • npm run compile-check-ts-native -- --pretty false
  • npm run transpile-client
  • scripts\\test.bat --run src/vs/workbench/contrib/chat/test/browser/chatQuotaNotification.test.ts --timeout 10000 (50 passing)
  • node --experimental-strip-types build\\hygiene.ts ...
  • npm run valid-layers-check
  • npm run precommit
  • E2E verified in Code OSS with helper extension via vscode.chat.updateQuotas

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

Comment thread src/vs/workbench/contrib/chat/browser/chatQuotaNotification.ts
Comment thread src/vs/workbench/contrib/chat/browser/chatQuotaNotification.ts Outdated
@rfeltis

rfeltis commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

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

Comment thread src/vs/workbench/contrib/chat/browser/widget/input/chatInputNotificationWidget.ts Outdated
Comment thread src/vs/workbench/contrib/chat/browser/chatQuotaNotification.ts Outdated
rfeltis and others added 19 commits June 19, 2026 13:55
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove redundant trajectory-shown signature dedup, duplicate storeTrajectoryShown calls, the redundant terminal baseline capture, dead canUpgradePlan test scaffolding, and cosmetic churn. Inline the single-use link-click handler.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Defer the getTreatment exposure until the user has met every condition
required to render the nudge, so treatment and control cohorts are
assigned at the same point and users who would never see the nudge are
not enrolled. Moves the locale check into candidate computation and
removes the eager-enrollment gate, restoring the original update flow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the just-in-time experiment enrollment into
_computeQuotaTrajectoryWarning so _update stays lean. The method
dispatches the async assignment once every render condition is met and
returns a warning only for the treatment cohort; while assignment is
pending it returns undefined and the remainder of _update falls through.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rfeltis and others added 4 commits June 19, 2026 13:59
getTreatment returns undefined when the user is not in the experiment
flight (or assignments are unavailable), which is distinct from being
assigned to a control cohort. Store the raw treatment value and render
the nudge only on an explicit 'enabled' value, instead of coercing a
missing assignment into a synthetic 'control' enrollment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Log a chatQuotaTrajectoryNudgeEnrolled event with the resolved treatment
value when the experiment service assigns the user to a flight (treatment
is defined), to measure experiment exposure across both arms. No
telemetry is emitted when TAS returns no assignment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… experiment

ExP for VS Code requires experiment treatment keys to be prefixed with
config. The treatment is a simple yes/no, so use a boolean type instead
of a string.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove trajectory nudge shown and dismissed interaction telemetry now that
generic chat input notification telemetry covers those interactions. Keep the
learn more link click event because it is specific to this nudge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rfeltis rfeltis force-pushed the rfeltis/quota-trajectory-nudge branch from e45d1ff to 8adc7ce Compare June 19, 2026 21:08
Comment thread src/vs/workbench/contrib/chat/browser/chatQuotaNotification.ts Outdated
Comment thread src/vs/workbench/contrib/chat/browser/chatQuotaNotification.ts Outdated
Comment thread src/vs/workbench/contrib/chat/browser/chatQuotaNotification.ts Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants