Skip to content

Session header branch link points to wrong repo (uses upstream, not PR head) #1946

@harshitsinghbhandari

Description

@harshitsinghbhandari

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

  1. Spawn a session that creates a PR from a fork (or use any session whose PR has `isCrossRepository: true` / `headRepositoryOwner` ≠ the upstream owner).
  2. Open the session detail view.
  3. Click the branch chip in the header.
  4. 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

  1. Ensure the SCM/PR enrichment includes `headRepositoryOwner` + `headRepository.name` in session metadata (or PR shape on `Session`).
  2. 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.
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions