t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: PR review guides fail to match pull requests on a GitHub fork when canonicalKey resolves to upstream

Open wuyouchao opened this issue 1 week ago • 0 comments

Summary

When a local T3 Code project is a GitHub fork whose repositoryIdentity resolves canonicalKey to the upstream parent repository (while origin.canonicalKey points to the user's fork), write_pull_request_guides (and the PR Guide tab) fails to match pull requests opened against the fork itself.

Reproduction

  1. Register a local checkout of a GitHub fork (origin -> https://github.com/<user>/<repo>.git, forked from <upstream>/<repo>).
  2. Inspect the project via t3_project_read:
    {
      "repositoryIdentity": {
        "canonicalKey": "github.com/<upstream>/<repo>",
        "locator": {
          "source": "git-remote",
          "remoteName": "upstream",
          "remoteUrl": "https://github.com/<upstream>/<repo>.git"
        },
        "origin": {
          "canonicalKey": "github.com/<user>/<repo>",
          "remoteUrl": "https://github.com/<user>/<repo>.git"
        }
      }
    }
    
    (Note: even after renaming the local upstream remote to another name and re-registering the project with t3_project_delete + t3_project_create, canonicalKey still resolves to the upstream parent repo.)
  3. Open a pull request targeting a branch inside the fork (https://github.com/<user>/<repo>/pull/<N>).
  4. Call write_pull_request_guides for that PR URL (or open the PR Guide tab).

Actual Behavior

write_pull_request_guides fails with:

No project in this environment is a checkout of <user>/<repo>, so its pull requests cannot be read here. Add one with t3_project_create.

Expected Behavior

Because the registered project's repositoryIdentity.origin.canonicalKey already equals github.com/<user>/<repo>, T3 Code should match pull requests hosted on the fork (origin.canonicalKey) as well as canonicalKey when resolving a project checkout for PR review guides (and related PR reads).

Suggested Fix

When matching a PR's target repository against registered projects, check both project.repositoryIdentity.canonicalKey and project.repositoryIdentity.origin?.canonicalKey (preferring an exact match on origin.canonicalKey if the PR targets the fork directly).

wuyouchao avatar Nov 20 '26 08:11 wuyouchao