Skip to content

feat: sign in to GitHub through the T3 Code for GitHub app [internal testing only] - #26245

Merged
juliusmarminge merged 11 commits into
mainfrom
t3/add-github-app-auth
Oct 28, 2026
Merged

juliusmarminge merged 11 commits into
mainfrom
t3/add-github-app-auth

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

GitHub requests from T3 Code share the user's personal 5,000/hr API limit with everything else they run, so busy days stall PR status and reviews. A GitHub App owned by an Enterprise Cloud org gets a higher per-user limit, so this adds an optional way to sign in through the T3 Code for GitHub app.

How it works

  • Sign in with GitHub sits in Settings → Source Control → GitHub (when enabled), next to saved tokens, GH_TOKEN and the gh login. The order is: saved token, then the app sign-in, then GH_TOKEN, then gh. Nothing changes for anyone who doesn't sign in.
  • The server runs GitHub's device flow with the app's public client ID. There is no client secret and no private key in the code. Clients only show the code (sourceControl.signInStart / signInWait / signInCancel), so it works over remote, relay and tunnel, and on a phone that leaves the app to approve.
  • The session is a secret setting (signIns) next to the saved tokens, so it uses the same secret store and redaction. Tokens refresh 5 minutes before they expire, and concurrent requests share one refresh. If GitHub rejects the refresh token, the server signs out and falls back to GH_TOKEN/gh. Sign out clears the setting.
  • Credentials are chosen per request in GitHubRequestPolicy: a saved token, then the app, then GH_TOKEN/gh. When the app token gets not found or "not accessible by integration" (REST 404/403, GraphQL NOT_FOUND/FORBIDDEN), the request is asked once more with the user's own credential, so repositories the app isn't installed on keep working. Work pinned to one credential (routing, stack pushes) picks one that reaches its repository up front.
  • GitHubAppAccess reads the app's installations and signed-in login through GitHubRest with the app credential pinned, so they share the quota, pause and concurrency of every other GitHub request.
  • Nudges, only for servers signed in with the app: the PR view (web, desktop, mobile) shows a notice when the app can't reach the repo, and cloning or publishing a project to such a repo offers "Give T3 Code for GitHub access" (sourceControl.appAccess).
  • github.com only. Enterprise hosts keep using tokens or gh. Agents get no sign-in tool, because approving needs a person in a browser.

Screenshots

Settings → Source Control → GitHub, signed out, entering the code, signed in, and a failed attempt (dark):

Sign-in card with the T3 Code for GitHub icon and a Sign in with GitHub button, divider above the token form
Device code in character cells, Copy code & open GitHub, expiry time
Signed in: app icon with green check, blurred account, Sign out, install and manage links
Failed in dark mode: red-tinted card with the message and Try again

The PR view and a fresh clone, for a repo the app isn't installed on:

PR panel notice: T3 Code for GitHub isn't installed on octocat, Install on octocat
Toast after cloning octocat/Hello-World: Give T3 Code for GitHub access to octocat, Install

Verification

  • A real sign-in completed end to end against the live app (App ID 5503720) on a dev server. The PR view of a repo the app isn't installed on loaded through the gh fallback.
  • New tests in GitHubAppSignIn.test.ts cover: the device flow (pending, slow down, success, denied, expired, unsupported host); refresh (shared, after a rejected token, refresh token rejected, network failure); credential order; credential choice by installation coverage; and repo detection from repository and from a checkout's remote. Also added: tests for the remote parsing behind the clone toast.
  • vp run check:changed passes (format, lint, knip, typecheck of 32 packages, tests).
  • Mobile typechecks, but its rows, alerts and notice weren't checked on a device.

Notes for review

  • scopeMethodsToRepository (GitHubRequestPolicy.ts) wraps the GitHub providers' methods so each call runs in its repository's scope. It is generic, so one Effect diagnostic is suppressed on the line that forwards each method's effect. The typed alternative is wrapping about 35 methods by hand.
  • Not done: the app token currently gets 5,000/hr from GitHub. The higher limit has to be applied to App ID 5503720 on GitHub's side; no code change is needed when it is.

Built with Claude Opus 5.5 in Claude Code, driven from T3 Code.

🤖 Generated with Claude Code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant