Skip to content

fix(seer): Trigger night shift autofix end-to-end and persist Seer run ids#113619

Merged
trevor-e merged 18 commits intomasterfrom
telkins/nightshift-quota
Apr 22, 2026
Merged

fix(seer): Trigger night shift autofix end-to-end and persist Seer run ids#113619
trevor-e merged 18 commits intomasterfrom
telkins/nightshift-quota

Conversation

@trevor-e
Copy link
Copy Markdown
Member

@trevor-e trevor-e commented Apr 21, 2026

Night shift candidates weren't actually producing Seer runs end-to-end, and the workflows dashboard showed - for every Seer run id. Fixes that and a couple of adjacent issues.

What changes

  • SeerNightShiftRunIssue.seer_run_id is now populated. Cron calls trigger_autofix_explorer synchronously per candidate and bulk_creates rows with the returned run ids. Failed triggers are logged and skipped (no row written).
  • PRs actually get opened. Pass stopping_point=OPEN_PR explicitly for AUTOFIX candidates — otherwise Seer falls back to the per-project preference, whose default (CODE_CHANGES) blocks PR creation.
  • ROOT_CAUSE_ONLY candidates now trigger too, with stopping_point=ROOT_CAUSE.
  • Quota + seat-based gating. check_seer_quota runs before triage; organizations:seat-based-seer-enabled added to FEATURE_NAMES.
  • Error paths record to SeerNightShiftRun.error_message (quota failure, eligible-projects exception, triage exception) instead of silently returning None. _triage_candidates now re-raises so explorer failures surface.
  • N+1 fix. Prefetch group.project / project.organization before the trigger loop.

Tests consolidated from 22 → 17 with stronger assertions.

trevor-e and others added 18 commits April 20, 2026 18:23
Add a new organization-scoped endpoint at
/api/0/organizations/{organization_id_or_slug}/seer/workflows/ that
returns paginated SeerNightShiftRun records with nested run issues.

This powers an internal, direct-link-only page for viewing historical
Night Shift workflow runs for an org. The endpoint is gated behind the
organizations:seer-night-shift feature flag and returns 404 when the
flag is off so the existence of the page is not revealed to orgs
without access.

The serializer bulk-fetches SeerNightShiftRunIssue rows in get_attrs to
avoid N+1 queries when listing runs with their nested issues.

Co-Authored-By: Claude <noreply@anthropic.com>
Swap the serializer's custom get_attrs bulk fetch for prefetch_related
on the endpoint queryset. Same two-query shape, but puts the fetch
alongside the filter and drops the get_attrs boilerplate.

Co-Authored-By: Claude <noreply@anthropic.com>
Move issue prefetching from the endpoint queryset into the serializer's
get_attrs via prefetch_related_objects, so any caller of
serialize(runs, user) gets N+1 protection automatically without having
to remember to prefetch in the queryset. Matches the pattern used by
AuditLogEntrySerializer and DashboardListSerializer.

Co-Authored-By: Claude <noreply@anthropic.com>
Store the Seer agentic triage run id on the SeerNightShiftRun row
(under extras["agent_run_id"]) so historical runs can be linked back to
their Seer Explorer run without needing to re-invoke the triage.

Uses extras rather than a new column because the mirror tables are
being migrated to first-class Sentry run models soon; adding a column
here would be throwaway.

Co-Authored-By: Claude <noreply@anthropic.com>
Add an internal, direct-link-only page at
/organizations/:orgSlug/seer/workflows/ that lists historical Night
Shift runs for the current org with an inline expandable drilldown
showing the issues processed and action taken for each run.

Backed by the endpoint added in the previous PR in this stack. The
page is not linked from any nav; it relies on the backend feature-flag
gate so orgs without Night Shift see a generic error state instead of
content.

Uses the SimpleTable primitive for the list and a plain HTML table for
the nested issues to keep the drilldown compact.

Co-Authored-By: Claude <noreply@anthropic.com>
Drop the page's custom styled components in favor of Container, Flex,
Grid, and Text primitives from @sentry/scraps. Only the SimpleTable
column-template wrapper remains, which is the documented pattern for
configuring SimpleTable grid widths.

Behavior is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
The expanded run detail felt cramped — sections and issue rows sat too
close together and the issue row contents weren't vertically aligned
when the linked group id rendered taller than adjacent text cells.

Bump container padding, separate each section with its own column flex,
widen the issues grid column gap, and center-align grid items.
Text primitive does not allow as="pre"; switch to div with pre-wrap
white-space so JSON formatting is preserved without a type error.
Surface an Explorer link on each run row when extras.agent_run_id is
present, opening /issues/?explorerRunId=<id> so reviewers can jump to
the underlying Seer agentic triage run. Mirrors the output of
bin/seer/trigger-night-shift.

Co-Authored-By: Claude <noreply@anthropic.com>
The raw extras JSON was useful while developing but is not something
reviewers want to stare at on the page. The only meaningful bit
(agent_run_id) is already surfaced via the Explorer button on the row.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 21, 2026
@trevor-e trevor-e marked this pull request as ready for review April 21, 2026 22:52
@trevor-e trevor-e requested a review from a team as a code owner April 21, 2026 22:52
Copy link
Copy Markdown
Contributor

@chromy chromy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@trevor-e trevor-e merged commit 639e828 into master Apr 22, 2026
58 checks passed
@trevor-e trevor-e deleted the telkins/nightshift-quota branch April 22, 2026 14:21
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