From c756981337545cc9c49f52c49ca3af20ecd2b565 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sat, 27 Jun 2026 16:09:17 -0700 Subject: [PATCH] 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. --- mobile/src/session/mobile-pr-sidebar-state.ts | 4 +++- mobile/src/session/use-mobile-pr-sidebar-controller.test.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mobile/src/session/mobile-pr-sidebar-state.ts b/mobile/src/session/mobile-pr-sidebar-state.ts index 16b7533f7ba..5f5b679b210 100644 --- a/mobile/src/session/mobile-pr-sidebar-state.ts +++ b/mobile/src/session/mobile-pr-sidebar-state.ts @@ -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 diff --git a/mobile/src/session/use-mobile-pr-sidebar-controller.test.ts b/mobile/src/session/use-mobile-pr-sidebar-controller.test.ts index 5fc684acfe8..005c4dc0e5b 100644 --- a/mobile/src/session/use-mobile-pr-sidebar-controller.test.ts +++ b/mobile/src/session/use-mobile-pr-sidebar-controller.test.ts @@ -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 }) })