Repository navigation
Add Copilot usage info - #22557
Add Copilot usage info#22557
Conversation
When multiple Copilot-enabled accounts are signed in, show per-account SnapshotCards instead of inline settings. Each card has a 'Configure Models…' button that opens a CopilotSettingsDialog for that account. Adds account-keyed maps (CopilotModelsByAccount, CopilotQuotaSnapshotsByAccount) to app state so models and quota data are tracked per account, and updates app-store fetching to populate all eligible accounts in parallel.
Add `PopupType.CopilotSettings` and render `CopilotSettingsDialog` from `App` popup handler with account-scoped models/quotas and BYOK actions. `CopilotPreferences` no longer owns dialog state or portal rendering; it now emits `onConfigureModels`, and `Preferences` dispatches popup opening. Also sync Copilot-related local state in `Preferences` on prop updates, and update unit tests to verify configure requests instead of in-component dialog behavior.
Replaces `PopupType.CopilotSettings` with `PopupType.CopilotUserSettings` across popup model, app popup rendering, and preferences dispatch to keep naming consistent with user-focused settings flow. Also adjusts Copilot settings dialog styles so the tab container has zero outer padding and content padding is applied inside `.copilot-tab-content` for cleaner layout.
Add a local Copilot quota snapshot type that includes `tokenBasedBilling` until SDK types catch up. Update quota caching, preferences UI, and tests to rely on that explicit flag instead of inferring token-based billing from quota heuristics.
Add a test-only popup for previewing Copilot snapshot cards with editable fake account data and quota snapshots. Wire it into the test menu and popup model, add presets for AI credits and rate limits, and include styles and unit coverage for the preview behavior.
Wrap snapshot account and scenario controls in a dedicated scrollable container so the card preview stays separate from the scrolling area. Update styles to use a column layout with hidden outer overflow, and add a UI test that locks in the preview-first structure.
Reworks the Copilot settings dialog to use a dedicated scrollable content area while keeping the usage snapshot section fixed at the bottom. The dialog now resets the settings scroll position when shown, removes the redundant "Usage" heading, and updates styles/tests to match the new structure.
Copilot preferences now split snapshot cards into GitHub.com and GitHub Enterprise sections, so mixed account lists read clearer. Snapshot card headers were refreshed to show name/login differently for dotcom vs enterprise accounts, enterprise endpoint now uses normalized HTML URL text, configure button label shortened, and related UI tests/styles were updated to match.
Adds a new `CopilotCustomProviders` popup and `CopilotCustomProvidersDialog` for add/edit/delete custom BYOK providers. Provider management is removed from `CopilotUserSettings` tabs, and model settings now stay in a single view. The model picker dropdown gains a header action (`Configure custom providers…`) that opens the new dialog, with shared popover support for header accessories and related style updates. Unit tests were updated and expanded to cover the new dialog flow and updated preferences behavior.
Updates the Copilot settings dialog title to follow platform casing conventions (`Copilot Settings` on macOS, `Copilot settings` elsewhere). It also moves the usage section into the scrollable settings area and places it before the main section content, with matching style tweaks (`margin-bottom` instead of fixed footer-like styling). Unit tests were updated to reflect the new DOM containment and ordering.
Wrap the two preset actions in a dedicated footer container and add scoped styles so they render as a vertical button stack with consistent spacing. This also clears default right margin on footer buttons to align the layout in the test Copilot snapshot card dialog.
There was a problem hiding this comment.
Pull request overview
This PR introduces UI and store support for showing a user’s GitHub Copilot usage/quota information inside GitHub Desktop preferences, including a new “snapshot card” presentation and account-scoped data for multi-account scenarios.
Changes:
- Fetch and cache Copilot quota snapshots from the Copilot SDK, including account-scoped storage and wiring through AppStore/Preferences.
- Add snapshot-card based UI for displaying usage (single-account inline, multi-account grouped cards with per-account “Configure…” actions).
- Refactor Copilot settings UX by introducing dedicated dialogs for per-account settings and custom provider management, plus associated tests and styling.
Show a summary per file
| File | Description |
|---|---|
| app/test/unit/ui/test-copilot-snapshot-card-dialog-test.tsx | Adds unit tests for the test-only snapshot card preview/config dialog. |
| app/test/unit/ui/copilot-preferences-test.tsx | Expands Copilot preferences tests for snapshot cards, multi-account behavior, and provider configuration entry points. |
| app/test/unit/ui/copilot-custom-providers-dialog-test.tsx | Adds unit tests for the custom providers management dialog. |
| app/styles/ui/_popover-dropdown.scss | Updates popover dropdown header layout to support an accessory element. |
| app/styles/ui/_dialog.scss | Adjusts Copilot tab dialog layout/scroll behavior in Preferences. |
| app/styles/ui/_copilot-preferences.scss | Adds extensive styling for snapshot cards, scrolling layout, and new dialogs. |
| app/src/ui/preferences/test-copilot-snapshot-card-dialog.tsx | Introduces a test-only dialog to preview and tweak snapshot card data. |
| app/src/ui/preferences/snapshot-card.tsx | Adds the SnapshotCard component and helpers for rendering quota/rate limit usage. |
| app/src/ui/preferences/preferences.tsx | Wires quota snapshot fetching and passes new Copilot props into CopilotPreferences. |
| app/src/ui/preferences/copilot.tsx | Refactors Copilot preferences UI flow: single-account user settings vs multi-account snapshot cards vs access-state messaging. |
| app/src/ui/preferences/copilot-user-settings.tsx | Extracts user-configurable Copilot settings and integrates usage display at top of the scroll area. |
| app/src/ui/preferences/copilot-settings-dialog.tsx | Adds a per-account Copilot settings dialog (popup) with scroll reset behavior. |
| app/src/ui/preferences/copilot-custom-providers-dialog.tsx | Adds a dialog dedicated to managing custom Copilot providers. |
| app/src/ui/lib/test-ui-components/test-ui-components.ts | Adds a test UI entry point to open the snapshot card test dialog. |
| app/src/ui/lib/popover-dropdown.tsx | Adds optional contentHeaderAccessory rendering in the popover header. |
| app/src/ui/lib/copilot-model-picker.tsx | Adds a “Configure custom providers…” header action to the model picker popover. |
| app/src/ui/dispatcher/dispatcher.ts | Exposes a dispatcher method for fetching Copilot quota snapshots. |
| app/src/ui/app.tsx | Adds new popup render paths for per-account settings, provider management, and the test snapshot dialog. |
| app/src/models/popup.ts | Adds new PopupTypes for Copilot user settings, provider management, and the test snapshot card dialog. |
| app/src/main-process/menu/menu-event.ts | Registers a test menu event for the Copilot snapshot card dialog. |
| app/src/main-process/menu/build-test-menu.ts | Adds a test menu item to open the Copilot snapshot card dialog. |
| app/src/lib/stores/copilot-store.ts | Implements quota snapshot types, caching, in-flight dedupe, and SDK fetch via RPC. |
| app/src/lib/stores/app-store.ts | Stores/wires account-scoped models and quota snapshots; fetches both across eligible accounts. |
| app/src/lib/app-state.ts | Extends app state to include quota snapshots and per-account mappings. |
Review details
- Files reviewed: 24/24 changed files
- Comments generated: 2
- Review effort level: Low
Simplifies `SnapshotCard` by replacing a no-op platform conditional with a single `Configure…` label on the model configuration button.
Removes `await` from `this.stopClient(client)` inside a `finally` block. This avoids blocking teardown on client shutdown while still triggering cleanup.
Move account snapshot groups inside `.copilot-settings-scroll` so multiple account cards live in the scrollable settings area. Remove redundant group padding from Copilot preferences styles, and add a unit test that asserts snapshot groups are nested in the scroll container when multiple accounts are present.
Apply the SDK commit message feature gate when selecting accounts for Copilot settings, matching AppStore fetching behavior. This prevents unflagged accounts from rendering with another account's model or quota fallback data.
Expose determinate progressbar range and value attributes for unlimited quotas, and use aria-valuetext to communicate that no usage limit applies. Add UI coverage for the accessibility contract.
Add account-scoped Copilot model selections across app state, store, dispatcher, and preferences UI. Selections now persist in a new by-account storage key, resolve per feature with fallback to legacy global selections, and are used for commit message generation and conflict resolution flows. Includes scrubbing logic for stale model IDs in both legacy and account-scoped data and updates unit/UI tests for new callback signatures and selection resolution behavior.
Removes legacy global `selectedCopilotModels` flow and makes account-scoped selections single source of truth across app state, store logic, and preferences UI. Adds migration helper that copies legacy feature selections into each known account while preserving account overrides, then deletes old localStorage keys. Updates stats lookup to read `selected-copilot-models-by-account` and adjusts unit/UI tests to match new account-scoped behavior.
Drop `copilotModels` and `copilotQuotaSnapshots` from app state, store, and preferences props, and rely only on account-keyed maps. This removes fallback-to-first-account behavior so model/quota data is resolved per selected account, including conflict resolution model lookup. Updated Copilot preferences tests to seed per-account maps (including default account helpers) and assert loading/empty states through account-scoped data.
| @@ -0,0 +1,73 @@ | |||
| import * as React from 'react' | |||
There was a problem hiding this comment.
This file is just a new dialog that wraps CopilotUserSettings. This is shown when there are multiple accounts with a Copilot license, and the user clicks on Configure… for any of them.
| } | ||
|
|
||
| /** User-configurable Copilot settings with optional provider management. */ | ||
| export class CopilotUserSettings extends React.Component<ICopilotUserSettingsProps> { |
There was a problem hiding this comment.
This component encapsulates the list of Copilot-based features, with their own model picker and any other additional controls. For a specific user.
It also includes, since this PR, the Copilot usage info card for the given user.
There was a problem hiding this comment.
This can be used either inline in the Copilot preferences section when there is only one account with a Copilot license, or in the new Copilot user settings dialog when there are multiple accounts with Copilot license, and the user clicks on Configure… for any of them.
Extend `INumberFormat` with optional `maximumFractionDigits` and apply it in `formatNumber` by truncating the decimal part before rendering. Add unit tests to cover decimal truncation for different separators and ensure integers remain unchanged when the limit is set.
Use shared `formatNumber` with `getNumberFormatPreference()` instead of ad-hoc `Intl.NumberFormat` instances in snapshot card formatting. This makes AI credit values and usage tooltip request counts follow the app’s number-format preference consistently, including the `<0.01` display.
| @@ -0,0 +1,502 @@ | |||
| import * as React from 'react' | |||
There was a problem hiding this comment.
Review details
Comments suppressed due to low confidence (1)
app/src/lib/stores/app-store.ts:10122
loadLegacyCopilotModelSelectionsno longer migrates the older single-value key (selected-copilot-model). Users upgrading from versions that persisted that key will silently lose their prior Copilot selection during the new by-account migration.
private loadLegacyCopilotModelSelections(): CopilotModelSelections {
const raw = localStorage.getItem(selectedCopilotModelsKey)
if (raw !== null) {
try {
const parsed: unknown = JSON.parse(raw)
- Files reviewed: 30/30 changed files
- Comments generated: 2
- Review effort level: Low
| } | ||
| } | ||
|
|
||
| // Migrate from the old single-model key |
There was a problem hiding this comment.
This code should've never been here, since we never got to release the previous storage approach, not even to beta 😅
There was a problem hiding this comment.
Nice work! 🎉 — pulled it down, tested the single and multi-account flows locally, and it works well. A few nits, none blocking so I am going ahead and merging so it can be in next beta:
- Duplicated constant — CopilotLicenseTypeNoAccess = 'NO_ACCESS' is defined in both app-store.ts and copilot.tsx. Could pull it into a shared constant to keep them from drifting.
- Legacy selection can be lost for signed-out users — app-store.ts:10166-10178. migrateCopilotModelSelections() calls localStorage.removeItem(selectedCopilotModelsKey) unconditionally, but migrateCopilotModelSelectionsToAccounts() only copies the legacy selection onto the accounts it iterates. If a user has a legacy selected-copilot-models entry but is signed out at load time (this.accounts === []), the migration is a no-op yet the legacy key is still deleted → their model choice is silently lost on next sign-in (they fall back to the default). Suggested fix: only remove the key when this.accounts.length > 0, so it's preserved until a launch where there are accounts to migrate into. Low severity, but easy to guard against - but also feel free to ignore if you think it is too small an edgecase to worry with. The repercussion is that those users would have to select their preferred model again.
- Minor UX (feel free to ignore) — when I open a feature's model dropdown, pick "Configure custom providers…", add a provider, and close that dialog, I'm returned to the settings screen with the dropdown unchanged. It'd be a nice touch to auto-select the newly added provider for the feature I clicked "Configure custom providers" from — though I realize wiring that transition through the popup stack cleanly may not be trivial.

Closes https://github.com/github/desktop/issues/1171
Description
This PR brings Copilot usage info to the app and introduces a few additional changes:
Configure custom providers…link within the Copilot model pickerConfigure…button will open a new dialog with the model pickers for Copilot features for that specific account.Screenshots
Screen.Recording.2026-07-15.at.10.23.52.mov
Release notes
Notes: [Added] Show user's Copilot usage info