Skip to content

feat(rate-limits): add GitHub Copilot usage tracking - #18210

Open
TellMeAlex wants to merge 3 commits into
stablyai:mainfrom
TellMeAlex:feature/feature-add-github-copilot-usage-tracking-status
Open

TellMeAlex wants to merge 3 commits into
stablyai:mainfrom
TellMeAlex:feature/feature-add-github-copilot-usage-tracking-status

Conversation

@TellMeAlex

Copy link
Copy Markdown

Summary

  • Adds copilot as 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 (service copilot-cli, no alternate names probed) or ~/.config/github-copilot/{apps.json,hosts.json} on Linux/Windows (honoring XDG_CONFIG_HOME/%LOCALAPPDATA%), exchanges it via GET https://api.github.com/copilot_internal/v2/token, and maps quota_snapshots.premium_interactions to the shared monthly rate-limit window.
  • Threads the new '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 new CopilotAccountsSection.tsx in 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).
  • Adds i18n keys across all 5 locales (en/es/ja/ko/zh).
  • Orca never writes/refreshes/invalidates the user's Copilot credentials — strictly read-only, same invariant as the Kimi fetcher.
  • Out of scope (per issue discussion): Copilot's own device-flow OAuth, and a Stats-tab usage-analytics view for Copilot.

Closes #6892

Test plan

  • copilot-fetcher.test.ts — missing/corrupt credentials, success path, 401/403, timeout
  • service.test.ts extended with Copilot success/error/stale cases
  • Renderer store, status-bar visibility, and settings-search test suites extended and passing
  • npm run typecheck (main + web) — clean (pre-existing unrelated monaco-setup.ts type mismatch untouched)
  • npm run lint — clean
  • Manual smoke test in the running app (no CLI on PATH, empty Keychain, valid login, confirm zero credential writes)

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
@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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 51dec

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 t… 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. Com…
Out of Scope Changes check ⚠️ Warning The PR includes extensive GitHub Projects hierarchy work unrelated to issue #6892, including Phase 1b–3 reports, hierarchy reads and mutations, sub-issue UI, nested tree rendering, IPC/RPC/preload cha… Remove the GitHub Projects hierarchy and related column-width changes from this PR, or split them into separate focused pull requests with their own linked issues and descriptions.
Docstring Coverage ⚠️ Warning Docstring coverage is 21.98% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 91 functions across 49 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive Most requirements in issue #6892 are addressed, including read-only credential access, provider integration, status-bar and Accounts support, localization, and graceful error handling. The provided co… Confirm the intended API contract and update either the implementation or issue #6892. Verify the endpoint, HTTP method, authentication scheme, required headers, quota mapping, and reset handling with tests. Confirm whether the device-flow …
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies GitHub Copilot usage tracking, which is the stated primary objective and is reflected in the rate-limit, status-bar, Accounts, and localization changes.
Full details: Description check

Explanation

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 check

Explanation

Most requirements in issue #6892 are addressed, including read-only credential access, provider integration, status-bar and Accounts support, localization, and graceful error handling. The provided context is inconsistent about the quota API: issue #6892 specifies POST /copilot_internal/v2/token, while the PR summary and source summary describe GET /copilot_internal/user. The issue also mentions a device-flow fallback, while the PR excludes it.

Resolution

Confirm the intended API contract and update either the implementation or issue #6892. Verify the endpoint, HTTP method, authentication scheme, required headers, quota mapping, and reset handling with tests. Confirm whether the device-flow fallback is formally excluded from this issue.

Full details: Out of Scope Changes check

Explanation

The PR includes extensive GitHub Projects hierarchy work unrelated to issue #6892, including Phase 1b–3 reports, hierarchy reads and mutations, sub-issue UI, nested tree rendering, IPC/RPC/preload changes, and column-width changes.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch feature/feature-add-github-copilot-usage-tracking-status

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 13

🧹 Nitpick comments (1)
src/renderer/src/components/settings/accounts-search.ts (1)

217-221: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use 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

📥 Commits

Reviewing files that changed from the base of the PR and between f737f34 and 67b1ef6.

📒 Files selected for processing (74)
  • docs/reference/2026-07-14-github-projects-hierarchy-traceability-design.md
  • docs/reference/2026-07-15-github-projects-hierarchy-phase2-plan.md
  • docs/reference/2026-07-15-github-projects-hierarchy-phase3-plan.md
  • docs/reference/phase-1b-issue-report.md
  • docs/reference/phase-2-issue-report.md
  • docs/reference/phase-3-issue-report.md
  • src/main/github/project-view.test.ts
  • src/main/github/project-view.ts
  • src/main/github/project-view/error-classification.ts
  • src/main/github/project-view/hierarchy-mutations.ts
  • src/main/github/project-view/hierarchy.test.ts
  • src/main/github/project-view/hierarchy.ts
  • src/main/github/project-view/internals.ts
  • src/main/ipc/github.ts
  • src/main/rate-limits/copilot-fetcher.test.ts
  • src/main/rate-limits/copilot-fetcher.ts
  • src/main/rate-limits/service.test.ts
  • src/main/rate-limits/service.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/main/runtime/runtime-rpc.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/GitHubItemDialog.tsx
  • src/renderer/src/components/github-project/ColumnResizeHandle.tsx
  • src/renderer/src/components/github-project/ProjectCell.test.tsx
  • src/renderer/src/components/github-project/ProjectCell.tsx
  • src/renderer/src/components/github-project/ProjectHeaderRow.tsx
  • src/renderer/src/components/github-project/ProjectRow.tsx
  • src/renderer/src/components/github-project/ProjectViewList.test.tsx
  • src/renderer/src/components/github-project/ProjectViewList.tsx
  • src/renderer/src/components/github-project/SubIssuesSection.test.tsx
  • src/renderer/src/components/github-project/SubIssuesSection.tsx
  • src/renderer/src/components/github-project/column-widths.test.ts
  • src/renderer/src/components/github-project/column-widths.ts
  • src/renderer/src/components/github-project/columns.ts
  • src/renderer/src/components/github-project/group-sort.test.ts
  • src/renderer/src/components/github-project/project-row-filtering.test.ts
  • src/renderer/src/components/settings/AccountsPane.tsx
  • src/renderer/src/components/settings/AppearanceWindowSidebarSection.tsx
  • src/renderer/src/components/settings/CopilotAccountsSection.tsx
  • src/renderer/src/components/settings/accounts-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-copilot-toggle-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-kimi-toggle-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-search.test.ts
  • src/renderer/src/components/settings/appearance-status-bar-search.ts
  • src/renderer/src/components/stats/GrokUsagePane.test.tsx
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/components/status-bar/StatusBarUsageEmptyCta.tsx
  • src/renderer/src/components/status-bar/status-bar-agent-gating.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/store/slices/rate-limits.ts
  • src/renderer/src/store/slices/ui.test.ts
  • src/renderer/src/store/slices/ui.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/github-issue-hierarchy-rollup.test.ts
  • src/shared/github-issue-hierarchy-rollup.ts
  • src/shared/github-project-group-sort.ts
  • src/shared/github-project-hierarchy-tree.test.ts
  • src/shared/github-project-hierarchy-tree.ts
  • src/shared/github-project-types.ts
  • src/shared/rate-limit-types.test.ts
  • src/shared/rate-limit-types.ts
  • src/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.

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.

📐 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]

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.

🎯 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.

Comment on lines +251 to +272
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 }

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.

🎯 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.

Comment on lines +109 to +110
if (error) {
resolve(null)

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.

🎯 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)

Comment on lines +81 to 85
const floor = minColumnWidthFor(field)
if (typeof stored === 'number' && stored >= floor) {
return stored
}
return defaultWidthFor(field)

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.

🎯 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',

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.

🎯 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}`)
}
NODE

Repository: 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.tsx

Repository: 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 -300

Repository: 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

Comment on lines +29 to +31
if (provider === 'copilot') {
return 'GitHub Copilot'
}

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.

📐 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

Comment on lines +1977 to +1978
"chevronCollapse": "Collapse sub-issues",
"chevronExpand": "Expand sub-issues"

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.

🎯 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-L1978
  • src/renderer/src/i18n/locales/ja.json#L1976-L1978
  • src/renderer/src/i18n/locales/ko.json#L1976-L1978

Comment on lines +7029 to +7030
"9b3e7a1c5f": "GitHub Copilot Usage",
"6d0f2b8e4a": "OAuth sign-in via Copilot CLI for premium interactions usage."

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.

🎯 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

Comment on lines +25 to +31
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
}

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.

🎯 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.

@pullfrog pullfrog Bot 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.

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 copilot rate-limit provider (copilot-fetcher.ts) that reads the Copilot CLI's OAuth token and maps premium_interactions into the shared monthly window, wired through service.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-view GraphQL additions, issue-level hierarchy read/write, a tree-mode toggle in ProjectViewList, and a new SubIssuesSection in 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Comment thread src/main/rate-limits/copilot-fetcher.ts Outdated
// 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'

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.

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')]

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.

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.

@coderabbitai coderabbitai Bot 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.

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 win

Treat an unlimited entitlement as a successful response.

When premium_interactions.unlimited is true, mapMonthlyWindow returns null. Lines 212-213 then mark the valid entitlement as an error and show “did not include a premium interactions quota.” Return status: '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

📥 Commits

Reviewing files that changed from the base of the PR and between 67b1ef6 and 51dec89.

📒 Files selected for processing (2)
  • src/main/rate-limits/copilot-fetcher.test.ts
  • src/main/rate-limits/copilot-fetcher.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

This branch has not been deployed

No deployments
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.

[Feature]: Add GitHub Copilot usage tracking (status-bar rate limits + Accounts pane)

1 participant