Repository navigation
feat(rate-limits): add GitHub Copilot usage tracking - #18210
TellMeAlex wants to merge 3 commits into
Conversation
Ships GitHub Projects hierarchy traceability end-to-end, per an RFC that
scoped the work into three sequential phases (each TDD'd red-to-green
and verified live against a real GitHub Project before the next phase
started):
Phase 1b — flat, read-only hierarchy columns (Parent issue, Sub-issues
progress, Tracks, Tracked by) in the existing table view, sourced from
Issue.parent/subIssuesSummary/trackedIssues/trackedInIssues (the
ProjectV2 field-value union has no hierarchy member). Fixed two bugs
found during live verification: an invalid `//` comment inside a
GraphQL template that silently broke every real project fetch, and a
sub-issues-progress counter clipped to 0px at default column width.
Phase 2 — issue-level hierarchy navigation and writes in the work-item
drawer's new "Sub-issues" section: shows the parent, direct sub-issues
with a recursive roll-up, and lets the user add/remove/reorder
sub-issues without leaving Orca. addSubIssue/removeSubIssue/
reprioritizeSubIssue are GraphQL mutations (confirmed via a live spike;
the RFC's schema excerpt had left this ambiguous), reusing the existing
rate-limit circuit breaker.
Phase 3 — opt-in "Show hierarchy" tree mode for TABLE_LAYOUT views.
Nests a row under its parent (by content.parentIssue.url, never
content.number, which collides across repos in multi-repo org
Projects) when both are rows in the same rendered group. Zero new IPC
calls, zero main-process changes, zero changes to
github-project-group-sort.ts or ProjectCell.tsx — a pure renderer
feature built on data Phase 1b already fetches. Defaults to off,
persisted per view in localStorage.
Also clears 9 pre-existing lint errors accumulated across Phase 1b/2's
work in this branch: 6 missing-brace `if` statements, one useless JSX
fragment, and two files over the 300-line oxlint cap
(project-view/internals.ts, project-view/hierarchy.ts) split along
their natural seams (error classification; write-path mutations) with
their public import surfaces preserved.
See docs/reference/2026-07-14-github-projects-hierarchy-traceability-design.md
for the RFC and docs/reference/phase-{1b,2,3}-issue-report.md for each
phase's evidence (tests, live CDP verification, known limitations).
Add copilot as a read-only rate-limit provider mirroring the Kimi fetcher pattern: read the OAuth token from macOS Keychain (copilot-cli) or ~/.config/github-copilot on Linux/Windows, exchange it for quota via the Copilot internal token endpoint, and surface premium interactions usage in the status bar and Accounts pane. Closes stablyai#6892
📝 WalkthroughWalkthroughThe change adds GitHub Projects hierarchy support in three phases: read-only traceability fields, drawer-based hierarchy reads and mutations, and opt-in table tree rendering. It adds shared hierarchy types, GraphQL normalization, IPC and runtime routes, sub-issue controls, roll-up calculations, persistence, and tests. It also adds GitHub Copilot rate-limit fetching, service integration, settings and status-bar displays, provider state, UI migration, localization, and tests. Merge Risk: 🟠 High · up to The PR adds GitHub issue-hierarchy mutations alongside Copilot quota reporting. At the current head, failed hierarchy writes can be presented as successful, hierarchy data can produce incorrect results, and authenticated runtime clients can target repositories covered by the user's GitHub permissions; Copilot can also misclassify unreadable credentials and unlimited entitlements. These concrete correctness and permission risks make the PR unsafe to merge until fixed. 🚥 Pre-merge checks | ✅ 1 | ❌ 4❌ Failed checks (3 warnings, 1 inconclusive)
✅ Passed checks (1 passed)
Full details: Description checkExplanation The description provides a summary, linked issue, scope notes, and test information, but it omits most required template sections, including ELI5, What Changed, Why, Visual Proof, Review, Notes, and the completed checklist. Resolution Rewrite the description using the repository template. Add the required ELI5, What Changed, Why, Visual Proof, Review, Notes, and Checklist sections. Attach before/after UI proof because this PR changes the status bar and Accounts pane. Complete the manual-testing and AI-disclosure fields. Full details: Linked Issues checkExplanation Most requirements in issue Resolution Confirm the intended API contract and update either the implementation or issue Full details: Out of Scope Changes checkExplanation The PR includes extensive GitHub Projects hierarchy work unrelated to issue
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 13
🧹 Nitpick comments (1)
src/renderer/src/components/settings/accounts-search.ts (1)
217-221: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse intent-named localization IDs for new Copilot strings.
Both new Copilot search catalogs introduce hash-like IDs for user-facing strings. Replace the new IDs with intent-named IDs and add the matching locale entries.
src/renderer/src/components/settings/accounts-search.ts#L217-L221: rename the Copilot Accounts title and description IDs.src/renderer/src/components/settings/accounts-search.ts#L223-L231: rename the new Copilot-specific keyword IDs.src/renderer/src/components/settings/appearance-status-bar-copilot-toggle-search.ts#L14-L17: rename the Copilot status-bar title and description IDs.src/renderer/src/components/settings/appearance-status-bar-copilot-toggle-search.ts#L24-L26: rename the new Copilot-specific keyword IDs.Based on learnings: new user-facing strings should use intent-named localization IDs; existing hash-based IDs are grandfathered.
Source: Learnings
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 1398cbf5-e1c7-4710-ab7a-c94483d5caa4
📒 Files selected for processing (74)
docs/reference/2026-07-14-github-projects-hierarchy-traceability-design.mddocs/reference/2026-07-15-github-projects-hierarchy-phase2-plan.mddocs/reference/2026-07-15-github-projects-hierarchy-phase3-plan.mddocs/reference/phase-1b-issue-report.mddocs/reference/phase-2-issue-report.mddocs/reference/phase-3-issue-report.mdsrc/main/github/project-view.test.tssrc/main/github/project-view.tssrc/main/github/project-view/error-classification.tssrc/main/github/project-view/hierarchy-mutations.tssrc/main/github/project-view/hierarchy.test.tssrc/main/github/project-view/hierarchy.tssrc/main/github/project-view/internals.tssrc/main/ipc/github.tssrc/main/rate-limits/copilot-fetcher.test.tssrc/main/rate-limits/copilot-fetcher.tssrc/main/rate-limits/service.test.tssrc/main/rate-limits/service.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/client-ui-schemas.tssrc/main/runtime/rpc/methods/github.tssrc/main/runtime/runtime-rpc.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/GitHubItemDialog.tsxsrc/renderer/src/components/github-project/ColumnResizeHandle.tsxsrc/renderer/src/components/github-project/ProjectCell.test.tsxsrc/renderer/src/components/github-project/ProjectCell.tsxsrc/renderer/src/components/github-project/ProjectHeaderRow.tsxsrc/renderer/src/components/github-project/ProjectRow.tsxsrc/renderer/src/components/github-project/ProjectViewList.test.tsxsrc/renderer/src/components/github-project/ProjectViewList.tsxsrc/renderer/src/components/github-project/SubIssuesSection.test.tsxsrc/renderer/src/components/github-project/SubIssuesSection.tsxsrc/renderer/src/components/github-project/column-widths.test.tssrc/renderer/src/components/github-project/column-widths.tssrc/renderer/src/components/github-project/columns.tssrc/renderer/src/components/github-project/group-sort.test.tssrc/renderer/src/components/github-project/project-row-filtering.test.tssrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/components/settings/AppearanceWindowSidebarSection.tsxsrc/renderer/src/components/settings/CopilotAccountsSection.tsxsrc/renderer/src/components/settings/accounts-search.tssrc/renderer/src/components/settings/appearance-status-bar-copilot-toggle-search.tssrc/renderer/src/components/settings/appearance-status-bar-kimi-toggle-search.tssrc/renderer/src/components/settings/appearance-status-bar-search.test.tssrc/renderer/src/components/settings/appearance-status-bar-search.tssrc/renderer/src/components/stats/GrokUsagePane.test.tsxsrc/renderer/src/components/status-bar/StatusBar.tsxsrc/renderer/src/components/status-bar/StatusBarUsageEmptyCta.tsxsrc/renderer/src/components/status-bar/status-bar-agent-gating.tssrc/renderer/src/components/status-bar/status-bar-provider-visibility.test.tssrc/renderer/src/components/status-bar/status-bar-provider-visibility.tssrc/renderer/src/components/status-bar/tooltip.tsxsrc/renderer/src/components/status-bar/usage-error-copy.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/slices/rate-limits.tssrc/renderer/src/store/slices/ui.test.tssrc/renderer/src/store/slices/ui.tssrc/renderer/src/web/web-preload-api.test.tssrc/renderer/src/web/web-preload-api.tssrc/shared/github-issue-hierarchy-rollup.test.tssrc/shared/github-issue-hierarchy-rollup.tssrc/shared/github-project-group-sort.tssrc/shared/github-project-hierarchy-tree.test.tssrc/shared/github-project-hierarchy-tree.tssrc/shared/github-project-types.tssrc/shared/rate-limit-types.test.tssrc/shared/rate-limit-types.tssrc/shared/types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
|
||
| ### Recommendation | ||
|
|
||
| Combine **A + C** for Phase 1, add **B (+ C for writes)** for Phase 2, and treat **D** as a distinct, separately-scoped Phase 3 initiative requiring its own design review before commitment. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Update stale hierarchy mutation transport references.
These design documents still describe REST mutations even though the shipped hierarchy mutation surface uses GraphQL. Update the phase descriptions, sequencing, open question 2, and validation wording to reflect the confirmed GraphQL transport and avoid misleading future implementation work.
📍 Affects 2 files
docs/reference/2026-07-14-github-projects-hierarchy-traceability-design.md#L217-L217(this comment)docs/reference/2026-07-15-github-projects-hierarchy-phase2-plan.md#L13-L13
| const childrenTotalCount = raw.subIssues?.totalCount ?? subIssues.length | ||
| const topLevelMore = childrenTotalCount > subIssues.length | ||
| const grandchildMore = subIssues.some((child, i) => { | ||
| const rawChild = childNodesRaw[i] |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep each raw child paired with its normalized child.
subIssues has already removed malformed nodes. Line 106 then reads childNodesRaw[i] with an index from that filtered array. If a malformed child precedes a valid child with an incomplete grandchild page, this checks the wrong totalCount and can return hasMoreChildren: false. Preserve raw/normalized pairs before filtering, and add a regression case for that sequence.
| if (args.beforeNumber !== undefined && args.afterNumber !== undefined) { | ||
| return { | ||
| ok: false, | ||
| error: { | ||
| type: 'validation_error', | ||
| message: 'Provide at most one of beforeNumber/afterNumber, not both.' | ||
| } | ||
| } | ||
| } | ||
| if (args.beforeNumber !== undefined && args.beforeNumber === args.subIssueNumber) { | ||
| return { | ||
| ok: false, | ||
| error: { type: 'validation_error', message: 'A sub-issue cannot be reordered before itself.' } | ||
| } | ||
| } | ||
| if (args.afterNumber !== undefined && args.afterNumber === args.subIssueNumber) { | ||
| return { | ||
| ok: false, | ||
| error: { type: 'validation_error', message: 'A sub-issue cannot be reordered after itself.' } | ||
| } | ||
| } | ||
| return { ok: true } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Validate optional sibling numbers before resolving IDs.
beforeNumber and afterNumber can be 0, negative, fractional, or NaN and still pass this validator. reprioritizeSubIssueBySlug then sends the value to resolveIssueNodeIds, which spends a GraphQL request and returns a remote error instead of a local validation error. Validate each supplied value with assertPositiveInt before comparing or resolving it.
| if (error) { | ||
| resolve(null) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Return an error for unreadable Keychain credentials.
A locked, denied, timed-out, or unavailable macOS Keychain makes security fail. This branch converts every failure to null, so readOAuthToken reports missing and the settings UI shows “Not signed in” even when the credential could not be read.
Map only the known not-found result to missing. Return CredentialsReadResult with status: 'error' for other command failures.
🧰 Tools
🪛 ast-grep (0.45.2)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { execFile } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
| const floor = minColumnWidthFor(field) | ||
| if (typeof stored === 'number' && stored >= floor) { | ||
| return stored | ||
| } | ||
| return defaultWidthFor(field) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Clamp stored widths to the field floor instead of resetting them to the default.
resolveWidth now rejects any stored width below minColumnWidthFor(field). For SUB_ISSUES_PROGRESS, a width already persisted in the 60–95px range is discarded and replaced by DEFAULT_FIELD_WIDTH (140px). The column therefore becomes wider than the user last set it, instead of settling at the new 96px floor. setColumnPair already clamps new resizes with Math.max(floor, ...), so only legacy stored values hit this path.
♻️ Proposed fix to clamp instead of discard
const stored = widths[field.id]
const floor = minColumnWidthFor(field)
- if (typeof stored === 'number' && stored >= floor) {
- return stored
+ if (typeof stored === 'number' && Number.isFinite(stored)) {
+ return Math.max(floor, stored)
}
return defaultWidthFor(field)
}Note: column-widths.test.ts line 44 asserts only expect(width).not.toBe(70), so it passes under either behavior. Tighten it to the expected value once you pick one.
| <h3 className="flex items-center gap-2 text-sm font-semibold"> | ||
| <AgentIcon agent="copilot" size={16} /> | ||
| {translate( | ||
| 'auto.components.settings.CopilotAccountsSection.a1b2c3d4e5', |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
node <<'NODE'
const crypto = require('node:crypto')
const file = 'src/renderer/src/components/settings/CopilotAccountsSection.tsx'
const texts = [
'GitHub Copilot',
'Shows premium interactions usage from your Copilot CLI sign-in.',
'Copilot CLI docs',
'Loading…',
'Signed in',
'Signed in. Orca only reads your Copilot CLI credentials — run copilot again if usage fails.',
'Not signed in to Copilot CLI',
'In a terminal, run copilot and sign in, then click Refresh usage here.',
'Refresh usage',
'Premium interactions',
'Same monthly premium interactions quota shown in your Copilot billing settings.',
'Resets {{when}}'
]
for (const text of texts) {
const key = crypto.createHash('sha1').update(`${file}:${text}`).digest('hex').slice(0, 10)
console.log(`${key} ${text}`)
}
NODERepository: stablyai/orca
Length of output: 733
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- applicable repository conventions ---'
find /tmp/coderabbit-repo-knowledge/stablyai/orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print \
| sort
printf '%s\n' '--- convention excerpts ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai/orca-89dc44e4/conventions/*.md; do
[ -f "$f" ] && { head -120 "$f"; printf '\n'; }
done
printf '%s\n' '--- component ---'
sed -n '1,180p' src/renderer/src/components/settings/CopilotAccountsSection.tsx
printf '%s\n' '--- locale catalog candidates ---'
fd -i 'en.json' src/renderer/src
printf '%s\n' '--- matching locale IDs/text ---'
rg -n -C 1 \
'a1b2c3d4e5|70e990bd65|40e28d7bd7|8413e3519a|ea31f29243|37d02222d7|45226c47e0|bf4bb4c2b1|c42e169705|63b61ab725|72baf21566|89259c2ff5|3d7dde34c8|GitHub Copilot|Premium interactions' \
src/renderer/src -g 'en.json' -g '*.ts' -g '*.tsx' -g '*.js' -g '*.mjs'Repository: stablyai/orca
Length of output: 282
🏁 Script executed:
#!/bin/bash
set -euo pipefail
root=/tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4
printf '%s\n' '--- available repository knowledge ---'
find "$root" -maxdepth 2 -type f -name '*.md' -print | sort
printf '%s\n' '--- scoped convention excerpts ---'
for f in "$root"/conventions/*.md; do
[ -f "$f" ] && { head -120 "$f"; printf '\n'; }
done
printf '%s\n' '--- component ---'
sed -n '1,180p' src/renderer/src/components/settings/CopilotAccountsSection.tsx
printf '%s\n' '--- locale catalog candidates ---'
fd -i 'en.json' src/renderer/src
printf '%s\n' '--- matching locale IDs and text ---'
rg -n -C 1 \
'a1b2c3d4e5|70e990bd65|40e28d7bd7|8413e3519a|ea31f29243|37d02222d7|45226c47e0|bf4bb4c2b1|c42e169705|63b61ab725|72baf21566|89259c2ff5|3d7dde34c8|GitHub Copilot|Premium interactions' \
src/renderer/src -g 'en.json' -g '*.ts' -g '*.tsx' -g '*.js' -g '*.mjs'Repository: stablyai/orca
Length of output: 21952
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- applicable localization guidance ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/config-localization-extraction.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-renderer-src-components-settings.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-renderer-src-i18n-locales.md
printf '%s\n' '--- localization implementation and scripts ---'
rg -n -C 3 \
'createHash|sha1|locale|extract|auto\.' \
src/renderer/src/i18n scripts package.json pnpm-workspace.yaml 2>/dev/null \
| head -300
printf '%s\n' '--- catalog section ---'
sed -n '9055,9080p' src/renderer/src/i18n/locales/en.json
printf '%s\n' '--- related component localization ---'
sed -n '45,150p' src/renderer/src/components/settings/GrokAccountsSection.tsxRepository: stablyai/orca
Length of output: 34302
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- catalog verifier implementation ---'
sed -n '1,260p' config/scripts/verify-localization-catalog.mjs
printf '%s\n' '--- locale IDs for the component section across catalogs ---'
for f in src/renderer/src/i18n/locales/{en,es,ja,ko,zh}.json; do
printf '%s\n' "--- $f ---"
sed -n '9058,9080p' "$f"
done
printf '%s\n' '--- exact generated-key contract references ---'
rg -n -C 4 \
'SHA1|sha1|createHash|source text|default text|generated key|hash-based|auto-key' \
config/scripts config src/renderer/src/i18n package.json \
-g '*.mjs' -g '*.js' -g '*.ts' -g '*.tsx' -g '*.json' \
| head -300Repository: stablyai/orca
Length of output: 24405
Generate the locale IDs and update the catalogs.
config/scripts/localize-renderer-strings.mjs derives keys from the first 10 SHA-1 characters of <filePath>:<default text>. Replace all 12 placeholder IDs in CopilotAccountsSection.tsx and update the matching catalog entries.
Source: Learnings
| if (provider === 'copilot') { | ||
| return 'GitHub Copilot' | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Localize the new provider label.
getProviderDisplayName feeds the status-bar tooltip. The new GitHub Copilot label is hardcoded, so locale translation cannot apply. Add an intent-named localization key in each locale and return it through translate.
Based on learnings: new user-facing strings in TypeScript and TSX files should use intent-named localization IDs with named interpolation placeholders.
Source: Learnings
| "chevronCollapse": "Collapse sub-issues", | ||
| "chevronExpand": "Expand sub-issues" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Complete the non-English locale entries for the new hierarchy and Copilot UI.
Several added values remain English or expose the raw DRAFT_ISSUE identifier, causing mixed-language controls, labels, and accessibility text. Add real translations in each affected locale, or omit entries where the inline English fallback is intended. Preserve {{value0}} and {{when}} placeholders.
📍 Affects 4 files
src/renderer/src/i18n/locales/es.json#L1977-L1978(this comment)src/renderer/src/i18n/locales/zh.json#L1977-L1978src/renderer/src/i18n/locales/ja.json#L1976-L1978src/renderer/src/i18n/locales/ko.json#L1976-L1978
| "9b3e7a1c5f": "GitHub Copilot Usage", | ||
| "6d0f2b8e4a": "OAuth sign-in via Copilot CLI for premium interactions usage." |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Add Spanish search terms for Copilot usage.
These settings-search values contain only English terms. Spanish queries such as uso de Copilot cannot match through this metadata. Keep the product name and add Spanish equivalents in both search blocks.
Also applies to: 7254-7255
| if (node.subIssues.length === 0) { | ||
| if (node.subIssuesSummary && node.subIssuesSummary.total > 0) { | ||
| return { | ||
| totalDescendants: node.subIssuesSummary.total, | ||
| completedDescendants: node.subIssuesSummary.completed, | ||
| percentCompleted: node.subIssuesSummary.percentCompleted | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Use subIssuesSummary when a child page is partial.
Line 25 ignores subIssuesSummary whenever at least one child was fetched. getIssueHierarchy caps direct children at 25 and grandchildren at 10. A node with 26 direct children therefore reports only 25 descendants here, with an incorrect completion percentage.
Use subIssuesSummary.total and subIssuesSummary.completed for direct children when available. Then add the recursive totals for fetched descendants. Add a regression test with a non-empty truncated child page.
There was a problem hiding this comment.
Caution
The Copilot usage fetcher reads quota from an endpoint that does not return quota, so the feature reports error for every signed-in user.
Reviewed changes
- Copilot usage tracking — a new read-only
copilotrate-limit provider (copilot-fetcher.ts) that reads the Copilot CLI's OAuth token and mapspremium_interactionsinto the shared monthly window, wired throughservice.ts, the renderer store, status bar, and a new Accounts-pane section, with i18n across 5 locales. - GitHub Projects nested hierarchy (unrelated) — a separate feature (RFC/phase docs,
project-viewGraphQL additions, issue-level hierarchy read/write, a tree-mode toggle inProjectViewList, and a newSubIssuesSectionin the work-item drawer) that the PR title and body do not describe.
⚠️ This PR bundles a second, unrelated feature
The branch carries two commits — 67b1ef6 (Copilot) and 5239199 ("nested hierarchy tree for Projects table view") — but the title and body only describe Copilot. The hierarchy work spans ~60 files including its own RFC and phase docs, and it will land under this PR's title if merged. It should be split into its own PR (or the base retargeted) so the two changes can be reviewed and reverted independently.
Technical details
# Split the GitHub Projects hierarchy feature out of this PR
## Affected sites
- Everything under `src/main/github/project-view/`, `src/shared/github-issue-hierarchy-rollup.ts`, `src/shared/github-project-hierarchy-tree.ts`, `src/renderer/src/components/github-project/` (tree mode + `SubIssuesSection`), and the `docs/reference/*hierarchy*` / `phase-*` docs belong to commit `5239199`, not to the Copilot feature.
## Required outcome
- The Copilot PR (#18210) should contain only the Copilot rate-limit changes; the hierarchy commit should be its own PR (or the base of this PR should be that unmerged branch, so the Copilot diff is scoped to just its own commit).
## Open questions for the human
- Is `5239199` intended to be a lower PR in a stack? If so, retarget this PR to that branch so its diff stops including the hierarchy work.DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| // Why: GitHub's Copilot token exchange endpoint is shared by every Copilot | ||
| // client (CLI, Chat, Neovim) — see IEntitlementsData/IQuotaSnapshotData in | ||
| // microsoft/vscode's defaultAccount.ts for the authoritative response shape. | ||
| const TOKEN_EXCHANGE_URL = 'https://api.github.com/copilot_internal/v2/token' |
There was a problem hiding this comment.
This endpoint returns a bearer token, not quota. GET https://api.github.com/copilot_internal/v2/token returns { token: string } (VS Code's tokenEntitlementUrl); quota_snapshots.premium_interactions lives on GET https://api.github.com/copilot_internal/user (VS Code's entitlementUrl). As written, mapMonthlyWindow never finds premium_interactions, so every validly signed-in user gets status: 'error' with "did not include a premium interactions quota".
Technical details
# Point the fetcher at the quota endpoint
## Affected sites
- src/main/rate-limits/copilot-fetcher.ts:11 — `TOKEN_EXCHANGE_URL` is `copilot_internal/v2/token`, which returns only `{ token }`.
- src/main/rate-limits/copilot-fetcher.ts:174-186 — `mapMonthlyWindow` reads `data.quota_snapshots?.premium_interactions`, which never appears in that response.
- src/main/rate-limits/copilot-fetcher.test.ts:41-50 — `TOKEN_EXCHANGE_RESPONSE` encodes the wrong shape, so the test passes while the real endpoint would not.
## Required outcome
- Fetch `GET https://api.github.com/copilot_internal/user` (bearer OAuth token) and read `quota_snapshots.premium_interactions.percent_remaining` / `unlimited` / `quota_reset_at` from that response; or, if using `v2/token`, exchange it first and then call the entitlements endpoint for the quota.
- Update the test fixture to the real entitlements response shape so the test can actually fail against reality.
## Sources
- microsoft/vscode `src/vs/base/common/defaultAccount.ts` — `IEntitlementsData.quota_snapshots.premium_interactions`.
- microsoft/vscode `src/vs/workbench/services/accounts/browser/defaultAccount.ts` — `ITokenEntitlementsResponse { token: string }` from `tokenEntitlementUrl` (v2/token), vs `getEntitlements` from `entitlementUrl` (copilot_internal/user).|
|
||
| function getCredentialsFilePaths(): string[] { | ||
| const base = join(getConfigHome(), 'github-copilot') | ||
| return [join(base, 'hosts.json'), join(base, 'apps.json')] |
There was a problem hiding this comment.
The Linux/Windows token path points at the wrong store. The Copilot CLI keeps its OAuth token in the system keyring on Linux (secret-tool/libsecret) and Windows Credential Manager; ~/.config/github-copilot/hosts.json (and apps.json) is the VS Code Copilot extension's cache, not the CLI's. So this path returns unavailable for a signed-in CLI user. The macOS keychain service name copilot-cli is correct.
Technical details
# Correct the Linux/Windows credential source
## Affected sites
- src/main/rate-limits/copilot-fetcher.ts:31-34 — `getCredentialsFilePaths` reads `hosts.json`/`apps.json`.
- src/main/rate-limits/copilot-fetcher.ts:58-78 — `readTokenFromConfigFiles` returns `missing` when neither file exists.
## Required outcome
- On Linux, read the token from the Secret Service keyring (e.g. `secret-tool lookup service copilot-cli`) and on Windows from Credential Manager, with the file path retained only as a fallback; or document explicitly that the file-based path is the VS Code extension cache, not the CLI's.
## Sources
- GitHub docs — Troubleshoot Copilot CLI auth: macOS uses `security ... -s copilot-cli`; Linux uses the system keyring (`secret-tool`); Windows uses Credential Manager.…heme, and headers The v2/token endpoint with Bearer auth hits GitHub's anti-scraping WAF and blanket-403s. Switch to /copilot_internal/user with the legacy token auth scheme and the Editor-Version/Editor-Plugin-Version/ User-Agent/X-Github-Api-Version headers every Copilot editor plugin sends, verified against the live API and cross-checked against steipete/CodexBar and getagentseal/codeburn. Also fixes resolveResetTimestamp treating quota_reset_at: 0 as a valid epoch timestamp instead of falling back to the ISO reset date.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/rate-limits/copilot-fetcher.ts (1)
212-213: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winTreat an unlimited entitlement as a successful response.
When
premium_interactions.unlimitedistrue,mapMonthlyWindowreturnsnull. Lines 212-213 then mark the valid entitlement as an error and show “did not include a premium interactions quota.” Returnstatus: 'ok'with no monthly window for this case, and add a regression test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: f7d0da92-1af9-45a4-9d9a-b21d778e54d2
📒 Files selected for processing (2)
src/main/rate-limits/copilot-fetcher.test.tssrc/main/rate-limits/copilot-fetcher.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Summary
copilotas a read-only rate-limit provider, mirroring the Kimi fetcher pattern (src/main/rate-limits/copilot-fetcher.ts): reads the OAuth token read-only from macOS Keychain (servicecopilot-cli, no alternate names probed) or~/.config/github-copilot/{apps.json,hosts.json}on Linux/Windows (honoringXDG_CONFIG_HOME/%LOCALAPPDATA%), exchanges it viaGET https://api.github.com/copilot_internal/v2/token, and mapsquota_snapshots.premium_interactionsto the sharedmonthlyrate-limit window.'copilot'provider through the shared types, Zod schema, main-process orchestration (service.ts), renderer store, status bar (badge, tooltip, empty-state CTA, gating, appearance toggle search), and a newCopilotAccountsSection.tsxin the Accounts pane (no dedicated sign-in IPC — it derives status directly from the fetcher's own snapshot, same as MiniMax's generic refresh pattern).Closes #6892
Test plan
copilot-fetcher.test.ts— missing/corrupt credentials, success path, 401/403, timeoutservice.test.tsextended with Copilot success/error/stale casesnpm run typecheck(main + web) — clean (pre-existing unrelatedmonaco-setup.tstype mismatch untouched)npm run lint— clean