Skip to content

feat(studio): incident-aware AI assistant#433

Open
sagarsrc wants to merge 1 commit intomasterfrom
test-pr-423-41603-1767895698
Open

feat(studio): incident-aware AI assistant#433
sagarsrc wants to merge 1 commit intomasterfrom
test-pr-423-41603-1767895698

Conversation

@sagarsrc
Copy link

@sagarsrc sagarsrc commented Jan 8, 2026

What kind of change does this PR introduce?

  • Feature
  • Resolves DEPR-311

What is the current behavior?

  • Assistant has no knowledge of ongoing Statuspage incidents
  • Therefore, if a user attempts to debug an issue that is directly related to an ongoing assistant with Assistant, it does not let the user know about the relevant incident
    • This is a missed opportunity, as perhaps there is nothing wrong with the project itself, and we could have saved the user some time by pointing them to the Statuspage incident

What is the new behavior?

Assistant now receives context about any active incidents from our StatusPage. When a user asks about issues that may be related to an ongoing incident, Assistant will:

  • Inform them about the active incident(s)
  • Direct them to Statuspage for real-time updates

This reduces unnecessary support tickets during known outages and helps users understand that their issue may be infrastructure-related.

Direct Response
A Close Shave  Cheese n’ Crackers  Supabase
Vague question
A Close Shave  Cheese n’ Crackers  Supabase
Direct question

To test

This is a hard one to test as there probably (hopefully) aren’t active incidents as you review this. You can add the following MOCK_INCIDENT_STATUS bits to test with. You should be able to replicate everything in the above What is the new behavior? after restarting your dev environment and opening Assistant.

apps/studio/env.local

Add the following:

MOCK_INCIDENT_STATUS='[{"id":"123","name":"Elevated error rates for Postgres connections","status":"identified","impact":"major","active_since":"2025-01-15T08:00:00Z"},{"id":"456","name":"Partial outage affecting Auth and Realtime","status":"investigating","impact":"critical","active_since":"2025-01-15T10:30:00Z"},{"id":"789","name":"Increased latency and occasional timeouts on requests to Data APIs for projects in US-East-1","status":"monitoring","impact":"minor","active_since":"2025-01-14T15:20:00Z"}]'

pages/api/incident-status.ts

Change:

if (!IS_PLATFORM) {
  return res.status(404).end()
}

to:

const hasMockIncidents = !!process.env.MOCK_INCIDENT_STATUS
  if (!IS_PLATFORM && !hasMockIncidents) {
  return res.status(404).end()
}

studio/lib/incident-status.ts

Process the env variable:

const MOCK_INCIDENT_STATUS = process.env.MOCK_INCIDENT_STATUS

And, in getActiveIncidents(), parse this data:

if (MOCK_INCIDENT_STATUS) {
    try {
      const mockData = JSON.parse(MOCK_INCIDENT_STATUS)
      const result = IncidentInfoSchema.safeParse(mockData)
      if (result.success) {
        return result.data
      }
      console.warn('MOCK_INCIDENT_STATUS is invalid, ignoring:', result.error.issues)
    } catch (e) {
      console.warn('MOCK_INCIDENT_STATUS is not valid JSON, ignoring')
    }
  }

Additional context

  • Incident data is fetched in parallel with schema data to minimise latency impact
  • If incident fetching fails, Assistant continues normally without incident context
  • Extracted getActiveIncidents() into a reusable module for use by both the API route and AI assistant

Future work

  • Consider making IncidentBanner automatically active when there is 1+ incidents on Statuspage
    • Only show incident data if it relates to features that the person uses.
    • Give users the option to get notified directly, such as via SMS or email.

Test data recreated from supabase#41603
Target state: open

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.

1 participant