-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(status): surface major service incidents #6987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
1 change: 1 addition & 0 deletions
1
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/status-notice/index.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { StatusNotice } from './status-notice' |
106 changes: 106 additions & 0 deletions
106
...kspace/[workspaceId]/w/components/sidebar/components/status-notice/status-notice.test.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| /** | ||
| * @vitest-environment jsdom | ||
| */ | ||
|
|
||
| import { act } from 'react' | ||
| import { createRoot, type Root } from 'react-dom/client' | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| const { mockUseStatusPage } = vi.hoisted(() => ({ | ||
| mockUseStatusPage: vi.fn(), | ||
| })) | ||
|
|
||
| vi.mock('@/hooks/queries/status-page', () => ({ | ||
| useStatusPage: mockUseStatusPage, | ||
| })) | ||
|
|
||
| import { StatusNotice } from '@/app/workspace/[workspaceId]/w/components/sidebar/components/status-notice/status-notice' | ||
|
|
||
| let container: HTMLDivElement | ||
| let root: Root | ||
|
|
||
| beforeEach(() => { | ||
| ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true | ||
| vi.clearAllMocks() | ||
| mockUseStatusPage.mockReturnValue({ data: undefined, error: null }) | ||
| container = document.createElement('div') | ||
| document.body.appendChild(container) | ||
| root = createRoot(container) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| act(() => root.unmount()) | ||
| container.remove() | ||
| vi.restoreAllMocks() | ||
| }) | ||
|
|
||
| function render() { | ||
| act(() => root.render(<StatusNotice />)) | ||
| } | ||
|
|
||
| describe('StatusNotice', () => { | ||
| it('shows the local status alert without fetching live status in preview mode', () => { | ||
| act(() => root.render(<StatusNotice preview />)) | ||
|
|
||
| const notice = container.querySelector('[role="alert"]') | ||
| expect(notice?.textContent).toContain('Sim is having issues') | ||
| expect(notice?.className).toContain('bg-[var(--terminal-status-error-bg)]') | ||
| expect(notice?.className).toContain('border-[var(--terminal-status-error-border)]') | ||
| expect(container.querySelector('svg')?.classList.contains('text-[var(--text-icon)]')).toBe(true) | ||
| expect(mockUseStatusPage).toHaveBeenCalledWith({ enabled: false }) | ||
| }) | ||
|
|
||
| it('stays hidden while loading and for operational or minor incidents', () => { | ||
| render() | ||
| expect(container.textContent).toBe('') | ||
|
|
||
| mockUseStatusPage.mockReturnValue({ | ||
| data: { status: { description: 'All Systems Operational', indicator: 'none' } }, | ||
| error: null, | ||
| }) | ||
| render() | ||
|
|
||
| expect(container.textContent).toBe('') | ||
|
|
||
| mockUseStatusPage.mockReturnValue({ | ||
| data: { status: { description: 'Minor Service Outage', indicator: 'minor' } }, | ||
| error: null, | ||
| }) | ||
| render() | ||
|
|
||
| expect(container.textContent).toBe('') | ||
| }) | ||
|
|
||
| it('shows the notice for a major incident and opens the status page', () => { | ||
| mockUseStatusPage.mockReturnValue({ | ||
| data: { status: { description: 'Major Service Outage', indicator: 'major' } }, | ||
| error: null, | ||
| }) | ||
|
|
||
| render() | ||
|
|
||
| const notice = container.querySelector('[role="alert"]') | ||
| const action = container.querySelector<HTMLAnchorElement>('a') | ||
| expect(notice?.className).toContain('border-[var(--terminal-status-error-border)]') | ||
| expect(notice?.className).toContain('shadow-[var(--shadow-overlay)]') | ||
| expect(notice?.className).toContain( | ||
| '[--surface-hover:color-mix(in_srgb,var(--text-error)_8%,transparent)]' | ||
| ) | ||
| expect(action?.textContent).toContain('View status') | ||
| expect(action?.className).not.toContain('bg-[var(--text-error)]') | ||
| expect(action?.getAttribute('href')).toBe('https://status.sim.ai') | ||
| expect(action?.getAttribute('target')).toBe('_blank') | ||
| expect(action?.getAttribute('rel')).toBe('noopener noreferrer') | ||
| }) | ||
|
|
||
| it('stays hidden when the optional status query fails', () => { | ||
| mockUseStatusPage.mockReturnValue({ | ||
| data: undefined, | ||
| error: new Error('status unavailable'), | ||
| }) | ||
|
|
||
| render() | ||
|
|
||
| expect(container.textContent).toBe('') | ||
| }) | ||
| }) |
51 changes: 51 additions & 0 deletions
51
...p/workspace/[workspaceId]/w/components/sidebar/components/status-notice/status-notice.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| 'use client' | ||
|
|
||
| import { ChipLink } from '@sim/emcn' | ||
| import { CircleAlert } from '@sim/emcn/icons' | ||
| import { STATUS_PAGE_URL } from '@/lib/status-page' | ||
| import { useStatusPage } from '@/hooks/queries/status-page' | ||
|
|
||
| const PREVIEW_STATUS = { | ||
| description: 'Major Service Outage', | ||
| indicator: 'critical', | ||
| } as const | ||
|
|
||
| interface StatusNoticeProps { | ||
| preview?: boolean | ||
| } | ||
|
|
||
| function StatusAlert() { | ||
| return ( | ||
| <div | ||
| role='alert' | ||
| className='flex w-full flex-col gap-2 rounded-xl border border-[var(--terminal-status-error-border)] bg-[var(--terminal-status-error-bg)] p-2 shadow-[var(--shadow-overlay)] [--surface-hover:color-mix(in_srgb,var(--text-error)_8%,transparent)]' | ||
| > | ||
| <div className='flex min-w-0 items-center gap-1.5'> | ||
| <CircleAlert className='size-[16px] flex-shrink-0 text-[var(--text-icon)]' /> | ||
| <p className='min-w-0 text-[var(--text-body)] text-sm leading-5'>Sim is having issues</p> | ||
| </div> | ||
| <ChipLink | ||
| fullWidth | ||
| variant='border' | ||
| className='justify-center' | ||
| href={STATUS_PAGE_URL} | ||
| target='_blank' | ||
| rel='noopener noreferrer' | ||
| > | ||
| View status | ||
| </ChipLink> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export function StatusNotice({ preview = false }: StatusNoticeProps) { | ||
| const { data } = useStatusPage({ enabled: !preview }) | ||
|
|
||
| const status = preview ? PREVIEW_STATUS : data?.status | ||
|
|
||
| if (status?.indicator !== 'major' && status?.indicator !== 'critical') { | ||
| return null | ||
| } | ||
|
|
||
| return <StatusAlert /> | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { useQuery } from '@tanstack/react-query' | ||
| import { fetchStatusPageSummary } from '@/lib/status-page' | ||
|
|
||
| export const STATUS_PAGE_POLL_INTERVAL = 60 * 1000 | ||
| export const STATUS_PAGE_STALE_TIME = 30 * 1000 | ||
|
|
||
| export const statusPageKeys = { | ||
| all: ['status-page'] as const, | ||
| summaries: () => [...statusPageKeys.all, 'summary'] as const, | ||
| summary: () => [...statusPageKeys.summaries(), 'sim'] as const, | ||
| } | ||
|
|
||
| interface UseStatusPageOptions { | ||
| enabled?: boolean | ||
| } | ||
|
|
||
| /** Polls Sim's public status while a hosted workspace is open. */ | ||
| export function useStatusPage({ enabled = true }: UseStatusPageOptions = {}) { | ||
| return useQuery({ | ||
| queryKey: statusPageKeys.summary(), | ||
| queryFn: ({ signal }) => fetchStatusPageSummary(signal), | ||
| enabled, | ||
| staleTime: STATUS_PAGE_STALE_TIME, | ||
| refetchInterval: STATUS_PAGE_POLL_INTERVAL, | ||
| refetchOnWindowFocus: true, | ||
| retry: false, | ||
| }) | ||
| } |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
|
|
||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
| import { fetchStatusPageSummary } from '@/lib/status-page' | ||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllGlobals() | ||
| }) | ||
|
|
||
| describe('fetchStatusPageSummary', () => { | ||
| it('returns a validated public status summary and forwards cancellation', async () => { | ||
| const signal = new AbortController().signal | ||
| const fetchMock = vi.fn().mockResolvedValue( | ||
| new Response( | ||
| JSON.stringify({ | ||
| page: { name: 'Sim' }, | ||
| status: { description: 'Minor Service Outage', indicator: 'minor' }, | ||
| }), | ||
| { status: 200 } | ||
| ) | ||
| ) | ||
| vi.stubGlobal('fetch', fetchMock) | ||
|
|
||
| await expect(fetchStatusPageSummary(signal)).resolves.toEqual({ | ||
| status: { description: 'Minor Service Outage', indicator: 'minor' }, | ||
| }) | ||
| expect(fetchMock).toHaveBeenCalledWith( | ||
| 'https://status.sim.ai/api/v2/status.json', | ||
| expect.objectContaining({ signal }) | ||
| ) | ||
| }) | ||
|
|
||
| it('throws when the status endpoint fails', async () => { | ||
| vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response(null, { status: 503 }))) | ||
|
|
||
| await expect(fetchStatusPageSummary()).rejects.toThrow('Status page request failed with 503') | ||
| }) | ||
|
|
||
| it('throws when the provider returns an unknown indicator', async () => { | ||
| vi.stubGlobal( | ||
| 'fetch', | ||
| vi.fn().mockResolvedValue( | ||
| new Response( | ||
| JSON.stringify({ | ||
| status: { description: 'Unexpected status', indicator: 'unknown' }, | ||
| }), | ||
| { status: 200 } | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| await expect(fetchStatusPageSummary()).rejects.toThrow() | ||
| }) | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { z } from 'zod' | ||
|
|
||
| export const STATUS_PAGE_URL = 'https://status.sim.ai' as const | ||
| const STATUS_PAGE_API_URL = `${STATUS_PAGE_URL}/api/v2/status.json` as const | ||
|
|
||
| const statusPageIndicatorSchema = z.enum(['none', 'minor', 'major', 'critical']) | ||
|
|
||
| const statusPageSummarySchema = z.object({ | ||
| status: z.object({ | ||
| description: z | ||
| .string() | ||
| .min(1, 'Status description cannot be empty') | ||
| .max(200, 'Status description cannot exceed 200 characters'), | ||
| indicator: statusPageIndicatorSchema, | ||
| }), | ||
| }) | ||
|
|
||
| export type StatusPageIndicator = z.output<typeof statusPageIndicatorSchema> | ||
| export type StatusPageSummary = z.output<typeof statusPageSummarySchema> | ||
|
|
||
| /** Loads and validates Sim's public service status. */ | ||
| export async function fetchStatusPageSummary(signal?: AbortSignal): Promise<StatusPageSummary> { | ||
| // boundary-raw-fetch: external Incident.io status API, not a same-origin Sim API | ||
| const response = await fetch(STATUS_PAGE_API_URL, { | ||
| cache: 'no-store', | ||
| headers: { Accept: 'application/json' }, | ||
| signal, | ||
| }) | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error(`Status page request failed with ${response.status}`) | ||
| } | ||
|
|
||
| return statusPageSummarySchema.parse(await response.json()) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty status spacer always reserved
Low Severity
The hosted sidebar always mounts a
px-2 py-2wrapper aroundStatusNotice. When the notice returnsnullfor loading, operational, or minor status, that empty padded div still occupies vertical space above the footer on every expanded hosted session.Reviewed by Cursor Bugbot for commit 165db31. Configure here.