Conversation
Provider CLIs report hosts inconsistently, so callers outside this module need the same port-stripping normalization that detection already uses.
A GitHub Enterprise host is named by whoever installed it, so matching on a "github" DNS label misses installs like git.example.edu. Those remotes were classified as unknown, which resolves to a stub that fails every operation, so the PR panel stayed empty with "No unknown source control provider is registered." GitLab already claimed unknown hosts through refineUnknownRemote; GitHub never implemented it, so the discovery spec was filtered out and gh was never asked. Add the GitHub refiner so any authenticated gh host claims its remote. Matching accepts any signed-in account on the host rather than only the active one, since gh selects an active account per host and a remote should resolve regardless of which login is currently selected. Both sides of the host comparison are normalized so a remote carrying a port still matches gh's bare hostnames.
Signing in with gh --hostname is now enough for T3 Code to recognize an enterprise install, whatever the host is called.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
Superseded by #7959 — same commits, renamed the head branch to something descriptive and GitHub closed this one when the old ref went away. Nothing to review here. |
ApprovabilityVerdict: Skipped Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically. |
What Changed
GitHubSourceControlProvider's discovery spec now implementsrefineUnknownRemote, the hook GitLab already used to claim hosts that hostname matching cannot identify. When a remote is detected askind: "unknown",gh auth status --json hostsis consulted, and any hostghis signed in to claims that remote as GitHub.apps/server/src/sourceControl/GitHubSourceControlProvider.ts— the refiner, +27 linespackages/shared/src/sourceControl.ts— export the existingparseHostNameso both sides of the host comparison drop portspackages/shared, five refiner cases inGitHubSourceControlProvider.test.ts, one end-to-endresolveHandlecase inSourceControlProviderRegistry.test.tsdocs/user/source-control.mdNothing changes for hosts that already resolve.
refineUnknownRemoteProviderreturns early unless the kind isunknown, sogithub.comandgithub.*remotes never reach the new code and spawn no extra process.Why
A GitHub Enterprise Server hostname is chosen by whoever installed it.
isGitHubHostmatches onlygithub.comor a host carryinggithubas a dot-separated DNS label, so an install atgit.example.eduorcode.acme.tldfalls through every branch tokind: "unknown". No provider is registered under"unknown", sounsupportedProvideris returned and every operation fails:The PR panel stays empty and that message repeats on every status refresh, through
VcsStatusBroadcaster.refreshStatus→remoteStatus→readRemoteStatus→lookupStatusPr→findLatestPrForHeadContext→listChangeRequests.ghresolves the PR correctly from the same cwd the whole time.The recovery path for exactly this case already exists:
refineUnknownRemoteProviderruns each CLI's auth command and lets a provider claim the host by name. GitLab implementsrefineUnknownRemote; GitHub did not, soisCliRemoteRefinementSpecfiltered the GitHub spec out andghwas never asked. Net effect was that GitLab self-hosted on an arbitrary domain worked while GitHub Enterprise on an arbitrary domain did not — which reads as unintended, since the contracts already modelgithub.comand a GHES install as separate identities under one provider kind.Everything needed was already in place:
authArgsis already["auth", "status", "--json", "hosts"], andparseGitHubAuthStatusalready decodes that JSON per host. No new parsing, no new process invocation, no config surface.Two details worth a reviewer's attention:
ghkeeps one active account per host, so gating onactivewould fail a user with two logins on the same GHES host who has switched to the other.unknowncontext carries the raw remote host inprovider.name, which retains:port, whileghkeys hosts by bare hostname — so both sides go throughparseHostName. GitLab's refiner deliberately still compares the raw name:glabreports hosts with the port, and there are existing tests forlocalhost:8080andself-hosted.example.test:8443.Verification
vp test runacross the four affected source-control test files: 46 tests pass. Targeted lint and typecheck are clean forapps/serverandpackages/shared.Also exercised against a real machine with
ghsigned in to bothgithub.comand a GHES install at once:https://github.com/pingdotgg/t3code.gitgithubby hostname; refiner never consultedhttps://<ghes-host>/org/repo.gitunknown, refined togithub/GitHub Self-Hostedghaccountnull; not claimedOne pre-existing limitation this PR does not address: with two hosts signed in, the Settings → Source Control row still reports a single identity, because
parseGitHubAuthcollapses the account list throughfindAuthenticatedGitHubAccount. That is display-only and does not affect which account serves PR lookup. Widening it would mean changingSourceControlProviderAuthinpackages/contracts, which belongs in its own PR.Checklist
Model: Claude Opus 5. Harness: Claude Code, driven from T3 Code.
Note
Medium Risk
Changes provider detection for unknown remotes using CLI auth status. Mis-matching a host could route GitHub operations to the wrong provider, but the path only runs for
unknownremotes and requires a signed-inghaccount.Overview
GitHub Enterprise remotes whose hostnames do not contain
github(e.g.git.example.edu) are now claimed as GitHub whenghhas a signed-in account for that host, instead of stayingunknownand failing every PR operation.GitHub discovery now implements
refineUnknownRemote, matching GitLab’s existing hook. Any authenticated account on the host counts (not only the active one). Host comparison goes through exportedparseHostNameso remotes with ports still matchgh’s bare hostnames. Hosts already classified by name are unchanged.Reviewed by Cursor Bugbot for commit 2640c97. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Detect GitHub Enterprise remotes that
ghis signed in to viarefineUnknownRemoterefineUnknownGitHubRemoteto GitHubSourceControlProvider.ts, which parsesgh auth statusstdout and maps an 'unknown' remote to a GitHub provider when any authenticated account matches the remote's host.parseHostNamefrom sourceControl.ts to normalize hosts (dropping ports) for matching againstgh's bare hostname keys.refineUnknownRemoteinto thediscoveryobject so unknown remotes are refined during discovery.ghauthentication.gh's bare hostname but preserve the original port inbaseUrl; verifyrefineUnknownGitHubRemoteport handling in GitHubSourceControlProvider.ts.📊 Macroscope summarized 2640c97. 3 files reviewed, 1 issue evaluated, 1 issue filtered, 0 comments posted
🗂️ Filtered Issues
apps/server/src/sourceControl/GitHubSourceControlProvider.ts — 0 comments posted, 1 evaluated, 1 filtered
refineUnknownGitHubRemotedrops the remote's port before matching it to aghhost. If one hostname serves GitHub Enterprise and another provider on a different port (for example,example.comfor GHES andexample.com:8443for GitLab), an authenticatedghentry forexample.commakes the unknown remote on port 8443 get incorrectly claimed as GitHub. The returned provider then routes operations to the wrong CLI; preserve or otherwise validate the remote port before claiming it. [ Out of scope (post-validation triage) ]