feat(github): connect-repo installs the App from a terminal when the repo's account lacks it - #213
Draft
tonychang04 wants to merge 1 commit into
Draft
feat(github): connect-repo installs the App from a terminal when the repo's account lacks it#213tonychang04 wants to merge 1 commit into
tonychang04 wants to merge 1 commit into
Conversation
…repo's account lacks it The device flow (#207) linked the terminal's GitHub identity, but with no App installation granted to the org the command could only say "install it in the console". GitHub has no API that installs an App, so the terminal now prints the install page instead and then claims what the person installed, proved by the identity it already linked — the platform's new POST /orgs/:orgId/github/installations/claim (insta-platform #428). - After the caller-scoped listing has no hit, claim with accountLogin = the repo's owner. Granted → list again and connect. Install URL → print it (stderr, so --json stays one document), poll the claim every 5s for up to ten minutes with the device flow's backoff on 429/dropped links, then list again. No reader (--json, a bare pipe) → fail with the URL in hand. Several accounts → name them. - 400 "not linked" on the claim runs the device flow once, then claims again. - 404 on the claim (a backend from before it) keeps today's console messages. - connect-repo's description says so. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GvKBDKEyErsLvNdqErtVoR
Member
Author
|
On hold, do not merge (Tony, 2026-09-11). We are going the Railway route instead: the GitHub App's Setup URL moves to a platform backend callback that claims the installation server-side and redirects to the console, so no parked browser session and no CLI device dance is needed. Kept as a draft for reference; the claim route in instacloud-platform #428 may still be useful for the already-installed case. |
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.
Why
Tested on prod today: with a linked GitHub identity but no App installation granted to the org,
insta compute connect-repo tonychang04/insta-monorepo-demo webstops atthe InstaCloud GitHub App reaches none of your repositories — install it on the account that owns this one (console → …). The device flow (#207) authorizes the terminal; nothing lets it get past the install. GitHub has no API that installs an App, so the terminal prints GitHub's install page and afterwards claims what the person installed, proved by the identity it already linked.What
findCallerRepo, after the caller-scoped listing has no hit for the repo:POST /orgs/{org}/github/installations/claimwith{ accountLogin: <repo owner> }(insta-platform #428).{ installation }→ list again once and connect. Still absent →acme/app is not one the App's installation on acme can reach — grant the App access to it on GitHub (Settings → Applications → InstaCloud → Repository access), or pass --public ….{ installUrl }→ with a reader (a terminal, or agent mode), prints to stderr:--json, bare pipe) it fails with the URL in the message instead of waiting.{ installations }(several accounts, none matching) → names them and says to install on the owner.connect-repo's description mentions the install step. No new flags.Companions
Follow-ups
services add compute"Next" hint only mentionsinsta deploy, notconnect-repo— not in this PR.Tests
test/github-connect.test.ts(+13, 52 pass): claim lands → re-list; partial list still claims; granted-but-excluded message; no-reader message carries the URL; terminal prints the URL, polls ([5, 5]), resolves; 429 +TypeErrorback off ([5, 10, 15]); a 403 poll ends with that reason; ten-minute timeout; 404 keeps both old messages; not-linked → authorize once, claim twice; not-linked without a reader; choices; empty answer. The two pre-existing "console" message tests now fake a 404 on the claim, which is the backend they describe.npm run buildclean;npm test918 passed.test/github-source.integration.test.tsfails to load on my machine only because the local git predatesgit init --initial-branch(its 8 tests are skipped anyway; unrelated).🤖 Generated with Claude Code
https://claude.ai/code/session_01GvKBDKEyErsLvNdqErtVoR