Symptom
In the session detail header (next to Status), the branch link is broken — the branch name is rendered correctly, but the link target is wrong. It points to the upstream repo instead of the actual PR's head branch (which lives in a fork or a different repo for cross-repo PRs).
Clicking the branch chip → 404 or the wrong tree view.
Expected
The branch link should resolve to the PR's actual head:
```
https://github.com/{headRepoOwner}/{headRepoName}/tree/{headRefName}
```
…not always upstream's tree. For sessions where the PR is from a fork or another repo (e.g. `harshitsinghbhandari/agent-orchestrator` → `ComposioHQ/agent-orchestrator`), the link should go to the fork's branch.
Repro
- Spawn a session that creates a PR from a fork (or use any session whose PR has `isCrossRepository: true` / `headRepositoryOwner` ≠ the upstream owner).
- Open the session detail view.
- Click the branch chip in the header.
- Lands on the upstream repo's branch tree (or 404 if that branch doesn't exist upstream), not the actual head branch on the fork.
Likely Location
- `packages/web/src/components/SessionDetailHeader.tsx` (or wherever the header renders) — search for the branch chip render and where the link `href` is built.
- The data layer needs to expose the PR's head repo, not just the branch name. `gh pr view N --json headRefName,headRepositoryOwner,headRepository,isCrossRepository` returns the right fields.
- Check the SCM plugin (`packages/plugins/scm-github`) — does it surface `headRepositoryOwner`/`headRepository` to the session metadata? If not, that's the missing data.
Fix Direction
- Ensure the SCM/PR enrichment includes `headRepositoryOwner` + `headRepository.name` in session metadata (or PR shape on `Session`).
- When the header builds the branch link, prefer `headRepositoryOwner/headRepository.name` over the upstream `owner/repo`. Fall back to upstream only when no PR is attached.
- For sessions with no PR yet, link to the local upstream branch only if it's been pushed; otherwise omit the link entirely (clicking shouldn't 404).
Related
Symptom
In the session detail header (next to Status), the branch link is broken — the branch name is rendered correctly, but the link target is wrong. It points to the upstream repo instead of the actual PR's head branch (which lives in a fork or a different repo for cross-repo PRs).
Clicking the branch chip → 404 or the wrong tree view.
Expected
The branch link should resolve to the PR's actual head:
```
https://github.com/{headRepoOwner}/{headRepoName}/tree/{headRefName}
```
…not always upstream's tree. For sessions where the PR is from a fork or another repo (e.g. `harshitsinghbhandari/agent-orchestrator` → `ComposioHQ/agent-orchestrator`), the link should go to the fork's branch.
Repro
Likely Location
Fix Direction
Related