Repository navigation
Talk to GitHub through its API instead of the gh CLI (#1528) - #1550
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87b4f31c87
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try { | ||
| const u = new URL(s); | ||
| if (!/^(https?|ssh|git):$/.test(u.protocol)) return null; | ||
| host = u.hostname; |
There was a problem hiding this comment.
Preserve custom ports when parsing GitHub remotes
For a GitHub Enterprise remote such as https://ghe.example:8443/org/repo.git, URL.hostname drops :8443. The resulting target therefore neither matches the saved githubHosts row (whose validator explicitly permits ports) nor sends API requests to the configured port, so token-backed PR operations silently fall back or fail against the wrong endpoint. Use the URL host, including its port, when constructing the API target.
Useful? React with 👍 / 👎.
| if (sub === "merge" && number != null && args.includes("--squash") && args.length === 4) { | ||
| await rest({ ...req, method: "PUT", path: `${repoPath}/pulls/${number}/merge`, body: { merge_method: "squash" } }); |
There was a problem hiding this comment.
Support configured merge modes on GitHub Enterprise
On a GitHub Enterprise remote, this condition translates only an exact four-argument squash merge. Existing callers also pass --merge, --rebase, --auto, or an optional squash --body; those forms throw Unsupported, and ghApiTryAsync explicitly refuses the normal gh fallback for non-githubproxy.fjygbaifeng.eu.org origins. Consequently those user-visible merge choices always fail on the newly supported Enterprise hosts, even when gh is available; translate the supported flags or permit the GHES fallback.
Useful? React with 👍 / 👎.
- electron/github.js: REST/GraphQL transport. Token per host: saved token from Settings, else `gh auth token --hostname h [--user <account>]` (cached host|account), so existing gh users change nothing. GHE via https://<host>/api/graphql and /api/v3. - Background refresher: one GraphQL query per repo instead of one `gh pr view` per thread; watched threads (#1493) keep the gh path. - Interactive PR and issue ops go through ghApiTryAsync: API first, gh as fallback; a timed-out write is not retried via gh. PR create/edit/comment keep the outbound secret scan. `gh pr checkout` stays on gh. - Settings › Source control: account per host, saved token (never sent to the renderer), Add host for GHE (#1533). Closes #1528, #1533, #1534. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87b4f31 to
85b4f7b
Compare
#1550 moved PR/issue ops to the GitHub API behind isGitHubPrRemote. Keep that at every call site and feed it the gh-host/ssh-alias aware isGitHubRemoteAsync (#1523), so GHE works through the API or gh. Planboard (issues.js) and revertPr.js also use the async check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1550 moved PR/issue ops to the GitHub API behind isGitHubPrRemote. Keep that at every call site and feed it the gh-host/ssh-alias aware isGitHubRemoteAsync (#1523), so GHE works through the API or gh. Planboard (issues.js) and revertPr.js also use the async check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #1528, closes #1533, closes #1534.
What changed
electron/github.js: a REST/GraphQL transport. It gets a token per host in this order: a token saved in Settings, thengh auth token --hostname <host> [--user <account>](cached per host and account), then gh's active account. Existing gh users don't need to change anything. GHE works throughhttps://<host>/api/graphqland/api/v3.worktrees-pr.js): one GraphQL query per repo instead of onegh pr viewper thread on every 5-minute tick. Threads with PR watch (Workflow round: review, PR loop, composer, compaction, real terminal #1493) keep the per-thread gh path, because they need gh's watch fields.ghApiTryAsync, which tries the API first and falls back to gh. A write that times out is not retried through gh, so nothing gets posted twice. PR create, edit and comment still run the outbound secret scan before sending.gh pr checkoutstays on gh because it does the git plumbing.gh auth status --json hosts), save a token, and "Add host" for GHE. Tokens are sealed the same way aslinearApiKeyand never sent to the renderer: settings come back as{host, account, hasToken}, and saving a row without atokenkey keeps the stored token.Testing
src/mermaidEngine.ts(72)TS2345 already fails the same way on main with the same node_modules.vite buildsucceeds.CODER_*, minimal PATH).pr view.Not in this PR
🤖 Generated with Claude Code