Repository navigation
fix(menubar): follow the credential's GitHub host for Copilot quota - #1291
Closed
ozymandiashh wants to merge 2 commits into
Closed
ozymandiashh wants to merge 2 commits into
ozymandiashh wants to merge 2 commits into
Conversation
Both Copilot quota readers hardcoded https://api.github.com/copilot_internal/user and dropped the host their credential was read from, so an enterprise on a GitHub Enterprise Cloud data-residency host (<tenant>.ghe.com) could only ever report "Temporarily unavailable": its token is not a dotcom token, and dotcom is not an endpoint it may be sent to. A discovered credential now carries its host. hosts.json is keyed by GitHub host and newer apps.json files key by "<host>:<app id>", so the token and the host always come from the same entry; the rungs that carry no host of their own (an app-name apps.json key, COPILOT_GITHUB_TOKEN / GH_TOKEN / GITHUB_TOKEN, gh auth token, a pasted token) mean dotcom. The endpoint follows the host: api.github.com for github.com, and api.<tenant>.ghe.com for an Enterprise Cloud host. With several hosts signed in github.com wins, otherwise the first .ghe.com tenant in sorted order, which keeps the pick stable across reads; with exactly one, that host is used. A host neither rule can address, such as a self-hosted GitHub Enterprise Server install, fails with a message naming that host instead of falling back to dotcom, and network and HTTP failures name the host that was tried. macOS Settings now says which host answered in the Copilot connection row. Tokens are still never logged and sanitizeForUI is unchanged. Closes getagentseal#1286
The fake credential reader keyed its files by splitting the path on "/", but the adapter builds the path with path.join, which uses a backslash on Windows: every lookup missed there, so the credential read as absent and the six adapter-level cases saw no request and a "disconnected" quota. path.basename is separator-correct on both platforms. Test-only; the reader itself is unchanged and the existing Windows path test still covers the real directories.
This was referenced Sep 12, 2026
Member
|
Landed as #1305 (ef86348) with your commits and authorship intact, rebased onto current main, plus one hardening commit: the normalized host is character-validated before URL construction, since a hosts.json key such as evil.com?.ghe.com passes the suffix check but builds a URL whose host is api.evil.com. Verified on this machine for github.com (same URL as main, HTTP 200, expected keys); the ghe.com path is covered by tests only, no enterprise account here. #1306 tracks the rungs that still carry no host. Thank you. |
ozymandiashh
added a commit
to ozymandiashh/codeburn
that referenced
this pull request
Sep 12, 2026
…IX paths Two CI failures on getagentseal#1327, both ours. macOS `swift test`: five tests in CodexQuotaSummaryTests assert Codex's `footerLines` exactly, and got three lines instead of one. Appending the forecast there was the wrong call, not a stale expectation. `QuotaSummary.footerLines` is the adapter's normalized output, consumed verbatim by the Capacity Dock, the hover card and those tests; an estimate derived from a public record is not something the account reported, and stacking it in there puts words in the adapter's mouth and couples every consumer to a feature none of them asked for. getagentseal#1322 adds Codex lines to the same array, so the collision was going to get worse. `QuotaSummary` gains `forecastLines`, defaulted empty, so every other adapter's construction site and every other provider's summary are untouched. The hover card draws it under its own divider, below the provider's own facts. The five existing tests are unchanged and now cannot be affected: the Codex `footerLines` array is built from the credit rows alone. Windows `test-platforms`: the dataset-parity test compared `datasetPaths()` against paths written with '/'. The separator is '\' there, so two identical path lists compared unequal - getagentseal#1291's lesson again. The expected side is now built with `join`, the invariant is pinned as tail segments rather than as a spelling, and a case with a Windows path exercises the splitter on both separators. The byte-identical check also normalizes line endings and compares the parsed documents, because a Windows checkout can hand back CRLF for a file the refresh script wrote with '\n'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
api.github.comforgithub.com(and for any rung that carries no host — an app-name
apps.jsonkey,COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN,gh auth token, a pasted token), andhttps://api.<tenant>.ghe.com/copilot_internal/userfor a GitHub Enterprise Cloud data-residency host. Both readers hardcoded
api.github.comand dropped thehost, so a
*.ghe.comenterprise could only ever report "Temporarily unavailable". Fixes [Feature Request] Support Copilot Enterprise on custom*.ghe.comhosts #1286.hosts.jsonis keyed by host, newerapps.jsonfiles by<host>:<app id>). With several hosts signed ingithub.comwins, otherwise thefirst
.ghe.comtenant in sorted order; with exactly one, that host is used. A host neither rule canaddress — a self-hosted GitHub Enterprise Server install — fails with a message naming that host rather
than sending the credential to dotcom, and unreachable-host and HTTP failures name the host that was tried
(the CLI prints it instead of the bare "Temporarily unavailable").
docs/providers/copilot.mdgains aGHE-hosts section. Tokens are still never logged and
sanitizeForUIis unchanged. The issue's second ask,a configurable 1.10 data-residency credit multiplier for estimated credits, is not part of this PR.
Testing
*.ghe.comenterprise account was available, so the tenant path is covered by unit tests and by compiling the new
host-policy type standalone against the expected values.
npm testpassesnpm run buildsucceedscd mac && swift buildsucceeds.swift testcannot run on this machine (Command Line Tools only, noswift-testing module — the test target fails to compile in files this PR does not touch), so the new
XCTest cases rely on CI.