Skip to content

fix(inbox): reconcile merged/closed PR state in the Pull requests tab#3371

Draft
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-code/inbox-reconcile-merged-pr-state
Draft

fix(inbox): reconcile merged/closed PR state in the Pull requests tab#3371
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-code/inbox-reconcile-merged-pr-state

Conversation

@posthog

@posthog posthog Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Problem

A merged PostHog Code pull request stayed listed as reviewable in the Inbox. The report kept its primary yellow Review button in the Pull requests tab and offered a Continue PR action that claimed an open PR already existed — directly conflicting with the merged/branch-deleted state on GitHub. Users couldn't tell an already-shipped report from active work, and could try to continue a PR that had already merged.

Root cause: tab membership and the PR action affordances trust the cloud report status, which lags GitHub. It stays ready until the backend reconciles a merge/close, so a merged report never dropped out of the actionable state on the client.

Changes

The app already fetches live GitHub PR state — the diff-stats batch on the list and getPrDetailsByUrl on the detail — but only used it to render the merged/closed badge. This reuses that same state for the action affordances:

  • PullRequestCard de-emphasises the CTA to a neutral outline View button once the linked PR is merged/closed, so a shipped report reads differently from active work (alongside the existing violet "Merged" badge).
  • ReportDetailActions drops the "Continue existing PR" path — and its "an open pull request already exists" copy — when the linked PR is no longer open, so users are never invited to continue a merged PR.
  • The decision lives in a pure, unit-tested isImplementationPrClosedOrMerged helper in @posthog/core so both surfaces stay aligned. It handles both data shapes (GraphQL batch state: "merged" and the REST endpoint's state: "closed", merged: true).

No extra network cost: the detail hook reuses the getPrDetailsByUrl query the header PR badge already primes, and the card reads from the existing list batch.

How did you test this?

  • pnpm --filter @posthog/core vitest on reportActions.test.ts — added 10 cases covering the new helper (open/draft/merged/closed across both data shapes); all 29 pass.
  • Full core inbox suite (src/inbox): 168 pass.
  • pnpm --filter @posthog/core --filter @posthog/ui typecheck — clean.
  • biome lint on the changed files and packages/core (no noRestrictedImports) — clean.

Not verified in the running app: reproducing the live symptom needs a desktop Electron session with a real inbox report whose PR has merged but whose cloud status hasn't reconciled, which isn't reproducible in this environment. The behavioural change is gated purely on the already-fetched live PR state, and the pure reconciliation logic is unit-tested.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code from an inbox report.

The cloud report `status` lags GitHub — it stays `ready` until the backend
reconciles a merge/close — so a merged PR left its inbox report stuck in the
Pull requests tab, showing a primary "Review" button and offering a "Continue
PR" action that falsely claimed an open PR still existed.

The app already fetches live GitHub PR state (the diff-stats batch on the list,
`getPrDetailsByUrl` on the detail) but only used it for the merged/closed badge.
Reuse it for the action affordances too:

- `PullRequestCard` de-emphasises the CTA to a neutral outline "View" once the
  PR is merged/closed, so a shipped report reads differently from active work.
- `ReportDetailActions` drops the "Continue existing PR" path (and its
  "an open pull request already exists" copy) when the linked PR is no longer
  open.

The decision lives in a pure, unit-tested `isImplementationPrClosedOrMerged`
helper in core so both surfaces stay aligned.

Generated-By: PostHog Code
Task-Id: 32b42a1b-55c3-4afd-9415-bcdc1712bc76
@trunk-io

trunk-io Bot commented Jul 13, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 2ad3c4c.

Biome's organize-imports assist (run by the `quality` CI check via `biome
check`) flagged the new `usePrDiffStatsFromBatch` import as out of order.
`biome lint` doesn't run assist actions, so it wasn't caught locally.

Generated-By: PostHog Code
Task-Id: 32b42a1b-55c3-4afd-9415-bcdc1712bc76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants