fix(seer): Trigger night shift autofix end-to-end and persist Seer run ids#113619
Merged
fix(seer): Trigger night shift autofix end-to-end and persist Seer run ids#113619
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_idis now populated. Cron callstrigger_autofix_explorersynchronously per candidate andbulk_creates rows with the returned run ids. Failed triggers are logged and skipped (no row written).stopping_point=OPEN_PRexplicitly forAUTOFIXcandidates — otherwise Seer falls back to the per-project preference, whose default (CODE_CHANGES) blocks PR creation.ROOT_CAUSE_ONLYcandidates now trigger too, withstopping_point=ROOT_CAUSE.check_seer_quotaruns before triage;organizations:seat-based-seer-enabledadded toFEATURE_NAMES.SeerNightShiftRun.error_message(quota failure, eligible-projects exception, triage exception) instead of silently returning None._triage_candidatesnow re-raises so explorer failures surface.group.project/project.organizationbefore the trigger loop.Tests consolidated from 22 → 17 with stronger assertions.