Prefer fetched PR head SHA over cached status SHA for PR checks

On mobile, a create command can commit before opening the review,
meaning the fetched PR's head SHA is fresher than the route's cached
status SHA. Prioritizing the fetched PR head SHA ensures we fetch checks
for the most up-to-date commit.
This commit is contained in:
Jinjing
2026-06-27 16:09:17 -07:00
parent c04dcc5c8c
commit c756981337
2 changed files with 5 additions and 3 deletions
@@ -103,7 +103,9 @@ export async function loadPrSidebarData(
const pr = prOutcome.result
const checksOutcome = await deps.fetchPRChecks(args.worktreeId, {
prNumber: pr.number,
headSha: args.headSha ?? pr.headSha ?? null,
// Why: mobile create can commit before opening the review; the fetched PR
// head is fresher than the route's cached git.status head.
headSha: pr.headSha ?? args.headSha ?? null,
// Prefer the fetched PR's own repo identity so fork PRs key their cached
// checks correctly; fall back to an explicit override then null.
prRepo: pr.prRepo ?? args.prRepo ?? null
@@ -85,10 +85,10 @@ describe('loadPrSidebarData', () => {
expect(d.fetchWorkItemDetails).not.toHaveBeenCalled()
// forBranch's PR number is threaded into prForBranch as the linked hint.
expect(d.fetchPRForBranch).toHaveBeenCalledWith('w', { branch: 'feat', linkedPRNumber: 7 })
// headSha forwarded to checks (status SHA wins over pr.headSha).
// The fetched PR head wins over the route's cached status SHA.
expect(d.fetchPRChecks).toHaveBeenCalledWith('w', {
prNumber: 7,
headSha: 'sha-status',
headSha: 'sha-pr',
prRepo: null
})
})