fix(source-control): forge SSH hosts key to their web host's repository #34937
Repository keys keep the remote's host unless that forge's definition rewrites it with repositoryKeyFromRemote, and only Azure DevOps did. The GitHub definition now rewrites keys on ssh.github.com/ (GitHub's SSH-over-443 host) to github.com/.... The Bitbucket definition rewrites keys on ssh.bitbucket.org/ and altssh.bitbucket.org/ (the port-443 host Bitbucket documents; the issue only names ssh.bitbucket.org) to bitbucket.org/.... Projects on those remotes now get the same key as their pull requests, so review guides, Create PR, PR lookup and opening a PR in the app match again. The GitHub API host comes from the remote URL separately (gitHubApiHostForRemote -> apiHostForSshAlias), so that function now maps ssh.github.com to github.com; before, listChangeRequests posted to https://ssh.github.com/api/graphql. No new regex: the rewrites use only startsWith, slice and exact equality, linear in key length on any input. Reproduced first: both repro-branch table rows failed (ssh.bitbucket.org/workspace/repo and ssh.github.com/t3tools/t3code). Fixes pingdotgg/t3code#22620.
Fixes pingdotgg/t3code#22620
Reproduction on main#
Commit 4e0b52806b (origin/main). Created two sample git checkouts: one with origin git@ssh.bitbucket.org:owner/repo.git, one with origin ssh://git@ssh.github.com:443/pingdotgg/t3code.git. Started T3CODE_DEV_SEED=0 vp run dev (fresh database), registered both with t3 project add, paired the web client, and opened a new thread draft in each project. For the ssh.github.com project the server's branch PR lookup (GitManager.findLatestPrForHeadContext -> GitHubSourceControlProvider.listChangeRequests) posted to https://ssh.github.com/api/graphql and failed: 'Source control provider github failed in listChangeRequests: Could not reach GitHub at ssh.github.com.' (server.trace.ndjson span attribute github.host=ssh.github.com). The Bitbucket project made no API call because the VM has no Bitbucket credential, so its key mismatch was shown with a unit test: two rows added to the existing 'sourceControlClients repository keys' table fail on main: ssh://git@ssh.github.com:443/T3Tools/T3Code.git keys as ssh.github.com/t3tools/t3code (expected github.com/t3tools/t3code), and git@ssh.bitbucket.org:Workspace/Repo.git keys as ssh.bitbucket.org/workspace/repo (expected bitbucket.org/workspace/repo).
Evidence#
Real web client, Chromium, 1280×800, light theme, fresh synthetic database per commit. Register a checkout with origin ssh://git@ssh.github.com:443/pingdotgg/t3code.git, open a new thread draft, and search for #34898 in the composer. The identical scenario fails on base and passes on head (scenarios:prove, exit 0).
| Before | After | |
|---|---|---|
| Commit | 4e0b52806b | fdbdec782c |
| Result | Pull requests could not be read | Matching pull request appears |
| Capture | ![]() | ![]() |
| Recording | Before recording | After recording |
AI-assisted; verified with the tests and tools listed above.
Not shown:
- Bitbucket live PR matching was not exercised because no Bitbucket credential was available.
- Review guides, Create PR, sidebar PR opening, desktop, and mobile were not exercised; this proof covers GitHub SSH-host PR lookup in the web composer.
Tests#
vp test run packages/client-runtime/src/sourceControlClients.test.ts -t 'repository keys' before the fix: 2 failed (the repro rows). After: vp test run packages/client-runtime/src/sourceControlClients.test.ts packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts: 57 passed, including a new assertion that gitHubApiHostForRemote('ssh://git@ssh.github.com:443/acme/web.git') is github.com. vp run check:changed: format, lint, knip, graphql, typecheck (12 packages) and tests (5 files, 76 tests) all passed.
Not in this change#
- GitLab's port-443 SSH host altssh.gitlab.com has the same key mismatch (open PR #22625 also covers it); not in this issue, left unchanged.
- Projects whose canonical key was already saved as ssh./... are not migrated; this change only fixes how keys are computed from the remote.
AI-assisted; verified with the tests and tools listed above.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
fdbdec7Macroscope's review found this PR approvable — Normalizes GitHub and Bitbucket SSH service hosts to their web repository identities and routes GitHub API requests to github.com. The mappings are narrowly scoped to explicit forge hosts, with no product-default or permission changes.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 1 1 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Baseline:
9bcca04· PR result:fdbdec7· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
No actionable comments were generated in the recent review.
Walkthrough
-
The repository-key handlers normalize supported Bitbucket and GitHub SSH host aliases to their web hosts. GitHub API-host resolution also maps
ssh.github.comtogithub.com.Changes: SSH host normalization
Layer / File(s) Summary Repository-key normalization
packages/source-control-bitbucket/src/shared/definition.ts,packages/source-control-github/src/shared/definition.ts,packages/client-runtime/src/sourceControlClients.test.tsThe Bitbucket and GitHub handlers normalize supported SSH host keys to their web-host keys and return nullfor other keys. Client tests cover the Bitbucket and GitHub aliases.GitHub API-host resolution
packages/source-control-github/src/server/gitHubRepositoryResolution.ts,packages/source-control-github/src/server/gitHubRepositoryResolution.test.tsGitHub API-host resolution maps ssh.github.comtogithub.com. A test covers an SSH URL using port 443.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Possibly related PRs
- pingdotgg/t3code#23909: Resolves GitHub SSH aliases to the
github.comAPI host, including aliases not covered by this change. - pingdotgg/t3code#22625: Implements overlapping SSH repository-key and GitHub API-host mappings.
Suggested reviewers:
maria-rcks,t3dotgg,macroscopeapp - pingdotgg/t3code#23909: Resolves GitHub SSH aliases to the
Merge Risk:
Minimal · up tofdbde-
Projects with GitHub or Bitbucket SSH-alias remotes will now match their pull requests. No remaining merge-blocking risk was found.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: SSH host keys for forges are mapped to the web host's repository key. It follows the conventional commit form and is specific. It is a fix, and the change matches it. … Linked Issues check Issue #22620requires that projects on Bitbucket's ssh.bitbucket.org host get the same repository key as their PRs (bitbucket.org/owner/repo). The suggested fix also names ssh.github.com to github.com…Out of Scope Changes check All changed files map to issue #22620. The Bitbucket change covers ssh.bitbucket.org and altssh.bitbucket.org. The issue names only ssh.bitbucket.org, but altssh.bitbucket.org is the same forge's docu…Description check The description covers the Problem (repository keys for ssh.github.com and ssh.bitbucket.org remotes do not match PR keys, so PR lookup fails), the Change (GitHub and Bitbucket repositoryKeyFromRemote… Full details: Title check
-
Explanation
The title names the main change: SSH host keys for forges are mapped to the web host's repository key. It follows the conventional commit form and is specific. It is a fix, and the change matches it. The title is 71 characters, which is acceptable.
Full details: Linked Issues check
-
Explanation
Issue
#22620requires that projects on Bitbucket's ssh.bitbucket.org host get the same repository key as their PRs (bitbucket.org/owner/repo). The suggested fix also names ssh.github.com to github.com. At the reviewed head: (1) packages/source-control-bitbucket/src/shared/definition.ts adds repositoryKeyFromRemote, mapping keys starting with ssh.bitbucket.org/ or altssh.bitbucket.org/ to bitbucket.org/<path>. (2) packages/source-control-github/src/shared/definition.ts adds repositoryKeyFromRemote, mapping keys starting with ssh.github.com/ to github.com/<path>. (3) packages/source-control-github/src/server/gitHubRepositoryResolution.ts apiHostForSshAlias maps ssh.github.com to github.com, so API calls do not go to the SSH host. The string handling uses startsWith, slice and indexOf, with no new regex. The PR adds test rows for both hosts in the sourceControlClients repository-keys table and an API-host assertion in gitHubRepositoryResolution.test.ts. I did not run the tests. Test results are taken from the PR description. The Evidence section is incomplete, but it is not a coding requirement. Both directly linked requirements are implemented in source.
Full details: Out of Scope Changes check
-
Explanation
All changed files map to issue
#22620. The Bitbucket change covers ssh.bitbucket.org and altssh.bitbucket.org. The issue names only ssh.bitbucket.org, but altssh.bitbucket.org is the same forge's documented SSH host, so it is closely related and not unrelated work. The GitHub key rewrite and the GitHub API-host mapping for ssh.github.com are named in the issue's suggested fix. The matching test changes support these behaviors. The PR does not change GitLab (altssh.gitlab.com) and does not migrate saved keys, both stated as non-goals. No unrelated change was found in the diffs reviewed.
Full details: Description check
-
Explanation
The description covers the Problem (repository keys for ssh.github.com and ssh.bitbucket.org remotes do not match PR keys, so PR lookup fails), the Change (GitHub and Bitbucket repositoryKeyFromRemote rewrites and the GitHub API host mapping), Scope (links issue
#22620and states the bug), and Verification (reproduction on main, a before/after table with screenshots and recordings, unit test runs with results, and a list of what was not checked). It also states the AI assistance and the items left out of scope. The template's sections are all present and substantively filled. Minor gaps: the description does not name the model and harness used, which the template asks for when an agent was used, and the 'Fixes' line is duplicated. Neither gap is critical.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: factory/issue-22620
- File: .coderabbit.config.ts
- Commit: fdbdec7
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
64611ee3-8c08-4c94-937f-bfdf8264c69e
Commits-
Reviewing files that changed from the base of the PR and between 9bcca0443c1ebe4bfa73ba5e1e4eed58412e7859 and fdbdec782c94678ed950c693576f0ed029d27987.
Files selected for processing: 5-
packages/client-runtime/src/sourceControlClients.test.tspackages/source-control-bitbucket/src/shared/definition.tspackages/source-control-github/src/server/gitHubRepositoryResolution.test.tspackages/source-control-github/src/server/gitHubRepositoryResolution.tspackages/source-control-github/src/shared/definition.ts
Limit details: You’ve used all 10 included reviews currently available.
-
-
tanstack-source added labelsbug
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes