Skip to content

feat(seer): Serialize linked pull requests with state on Seer runs#119795

Draft
jshchnz wants to merge 3 commits into
masterfrom
jc-seer-runs-pr-state
Draft

feat(seer): Serialize linked pull requests with state on Seer runs#119795
jshchnz wants to merge 3 commits into
masterfrom
jc-seer-runs-pr-state

Conversation

@jshchnz

@jshchnz jshchnz commented Jul 16, 2026

Copy link
Copy Markdown
Member

Why

The runs list endpoint (/organizations/{org}/seer/runs/) currently exposes nothing about the PRs a run opened. The autofix state's repo_pr_states.pr_creation_status tops out at "PR created", while merge status lives on sentry.PullRequest.state (stamped merged + merged_at by the GitHub webhook, integrations/github/webhook.py), reachable via the SeerRunPullRequest link table (seer/pull_requests.py creates one per Seer-opened PR on the pr_created webhook).

Consequence: any UI listing runs cannot distinguish a merged autofix from one still awaiting review — merged wins are permanently disguised as "needs review". (Merging also doesn't auto-resolve the group, so these rows stay visible forever.)

What

Adds pullRequests to SeerRunResponse:

"pullRequests": [
  {"key": "119122", "state": "merged", "mergedAt": "2026-07-14T…"},
  {"key": "119123", "state": null,     "mergedAt": null}  // no webhook state yet
]
  • One bulk query in SeerRunSerializer.get_attrs through SeerRunPullRequest → PullRequest (select_related, no N+1), following the same join pattern as GroupPullRequestsEndpoint.
  • Empty list when a run opened no PRs; state is null until a provider webhook reports one.

Consumer

The Autofix overview UI (#119794, sibling branch off the same base) already consumes this field defensively: its Merged badge, live "Merged PRs" stat card, and merged quick filter activate automatically once this deploys — until then it renders an honest disabled state.

Testing

test_pull_requests_serialized_with_state in tests/sentry/seer/endpoints/test_organization_seer_runs.py: a run with a merged PR (state + mergedAt serialized), an open PR with no webhook state (nulls), and a run with no PRs (empty list). Existing serializer tests use key-based assertions and are unaffected by the added field.

🤖 Generated with Claude Code

chromy and others added 3 commits July 7, 2026 20:07
Add two demo views under issues/autofix/:

- /issues/autofix/runs/ lists the organization's recent Seer runs from the
  seer/runs/ endpoint (with ?expand=questions) and renders each run's one-shot
  question answers via SeerMarkdown, one collapsible section per run. Sends a
  hardcoded DEMO_QUESTIONS list via the repeatable `question` param instead of
  the server-side set, rendering each echoed question text as the answer
  heading so prompts can be iterated on without a backend change. Requests a
  small page since expansion can trigger one-shot calls per run on a cold cache.

- /issues/autofix/issues/ lists issues Seer has run autofix on
  (has:issue.seer_last_run) and enriches each with its most recent explorer run
  and one-shot outputs. Data-fetching lives behind a single paginated
  useAutofixIssues hook: it queries the issue stream, then makes one
  group-scoped runs request so we only fetch runs for the issues on the page.
  Each issue also shows its autofix phase as a colored Status tag
  (Root cause -> Planning -> Coding -> PR open), derived by reusing
  getOrderedAutofixSections. Reuses the standard IssueListSearchBar with the
  required has:issue.seer_last_run filter always applied by the hook.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Send a fixed list of demo questions as repeatable `question` params to the
seer runs endpoint instead of the generic `outputs` flag, and render each
answer under its echoed-back question text rather than the raw output key.

Refs the seer runs demo UI.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/3OId6GAKdIxHX-BkJJm4ZZFHtF_4YouJOyG0ewb-xEQ
The runs list endpoint knew nothing about the PRs a run opened: the
autofix state's repo_pr_states tops out at "PR created", and merge
status only exists on sentry.PullRequest (stamped by the GitHub
webhook), reachable through the SeerRunPullRequest link table. As a
result, UIs listing runs can never show that a fix actually merged --
a merged autofix looks identical to one still awaiting review.

Add a pullRequests field to SeerRunResponse: one bulk query through
SeerRunPullRequest -> PullRequest in get_attrs (no N+1), emitting
{key, state, mergedAt} per linked PR, empty list when a run opened
none. state is null until a provider webhook reports one.

The Autofix overview UI (#119794) already consumes this field
defensively -- its Merged badge, stat card, and quick filter light up
once this deploys.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 16, 2026
@chromy
chromy force-pushed the chromy/2026-07-01-seer-runs-demo-ui branch 3 times, most recently from c2b28fe to eb3f45f Compare July 16, 2026 14:08
Base automatically changed from chromy/2026-07-01-seer-runs-demo-ui to master July 16, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants