Files
supabase/apps/docs/components/ContentListings/ContentListings.client.tsx
Saxon Fletcher 36d2982af4 docs: add reusable monitoring agent setup components (#49506)
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Stack

Draft stack extracted from `docs/monitoring`. Merge bottom-up.
Troubleshooting / debugging-guide rewrite is out of scope.

1. #49503 move inspect and advisors
2. #49501 split Studio logs from ClickHouse queries
3. #49500 treat reports as signal dashboards
4. #49502 add Observe the data hub
5. **#49506** add agent setup components ← **this PR**
6. #49504 add hire-an-agent templates
7. #49505 restructure observability nav and overview

## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Docs app feature (MDX components + markdown export). Fifth layer in the
observability stack.

## What is the current behavior?

There is no shared way to render a monitoring agent prompt, schedule,
and Claude/Codex/Cursor setup instructions in both HTML and generated
markdown.

## What is the new behavior?

- `AgentSetup` and `AgentWatchSchedule` MDX components, registered for
HTML and markdown export
- Shared `monitoring-agents` data (cadence, prompt ids, harness steps)
- Opt-in `AiPrompt` markdown export (`includeInMarkdown`) so quickstarts
stay HTML-only
- Optional content-listing `subtitle` for schedule labels on cards

No agent guide pages yet — those land in #49504 so this PR stays a
reviewable code change.

## Additional context

Markdown schema handlers share the same data module as the React
components.
<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-a3cb5ece-925b-4046-b58a-5d69e9a9d794?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-a3cb5ece-925b-4046-b58a-5d69e9a9d794&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Saxon Fletcher <SaxonF@users.noreply.github.com>
2026-09-04 13:38:37 +10:00

144 lines
5.0 KiB
TypeScript

'use client'
import type { ContentListingGroup, ContentListingItem } from '~/lib/content-listings.schema'
import {
filterContentListingItems,
getContentListingById,
getContentListingGroupLabel,
isExternalContentListingHref,
} from '~/lib/content-listings.utils'
import { useSendTelemetryEvent } from '~/lib/telemetry'
import Link from 'next/link'
import { useCallback, useMemo } from 'react'
import ReactMarkdown from 'react-markdown'
import { Badge, Heading } from 'ui'
import { GlassPanel } from 'ui-patterns/GlassPanel'
import { resolveContentListingIcon } from './iconChip'
const GRID_ITEM_CLASS = {
// Stay 2-up until xl (~1280px) so cards aren't cramped beside the docs sidebar.
2: 'col-span-12 md:col-span-6',
3: 'col-span-12 md:col-span-6 xl:col-span-4',
4: 'col-span-12 md:col-span-6 xl:col-span-3',
} as const
function useContentListingClickHandler(group: ContentListingGroup) {
const sendTelemetryEvent = useSendTelemetryEvent()
const groupLabel = getContentListingGroupLabel(group)
const trackClick = useCallback(
(item: ContentListingItem) => {
sendTelemetryEvent({
action: 'docs_content_listing_clicked',
properties: {
targetPath: item.href,
linkTitle: item.title,
...(groupLabel ? { groupTitle: groupLabel } : {}),
listingId: group.id,
},
})
},
[sendTelemetryEvent, group.id, groupLabel]
)
return { trackClick }
}
function ContentListingGroupHeading({ group }: { group: ContentListingGroup }) {
if (!group.heading) return null
return <Heading tag={group.headingLevel ?? 'h2'}>{group.heading}</Heading>
}
function ContentListingsGroup({ group }: { group: ContentListingGroup }) {
const { trackClick } = useContentListingClickHandler(group)
const items = useMemo(() => filterContentListingItems(group.items), [group.items])
const isGrid = group.type === 'grid'
const listClassName = isGrid ? 'grid md:grid-cols-12 gap-4' : 'list-disc pl-6 space-y-2'
const gridItemClassName = isGrid ? GRID_ITEM_CLASS[group.columns ?? 3] : undefined
if (!items.length) return null
// Heading stays outside `not-prose` so it inherits the surrounding MDX prose
// typography. The list itself opts out so its explicit Tailwind layout wins.
return (
<section className="space-y-4">
<ContentListingGroupHeading group={group} />
<div className="not-prose space-y-4">
{group.description && (
<div className="text-foreground-light [&_a]:text-foreground [&_a]:underline [&_p]:m-0">
<ReactMarkdown>{group.description}</ReactMarkdown>
</div>
)}
<ul className={listClassName}>
{items.map((item) => {
const external = isExternalContentListingHref(item.href)
const key = `${group.id}-${item.href}`
if (isGrid) {
return (
<li key={key} className={gridItemClassName}>
<Link
href={item.href}
passHref
className="block h-full"
onClick={() => trackClick(item)}
target={external ? '_blank' : undefined}
rel={external ? 'noopener noreferrer' : undefined}
>
<GlassPanel
title={item.title}
icon={resolveContentListingIcon(item.icon)}
hasLightIcon={item.hasLightIcon ?? typeof item.icon === 'string'}
badge={
item.badge && item.badgePosition !== 'below' ? (
<Badge variant="success">{item.badge}</Badge>
) : undefined
}
>
{item.badge && item.badgePosition === 'below' && (
<Badge variant="success" className="mb-3 block w-fit">
{item.badge}
</Badge>
)}
{item.subtitle && (
<span className="mb-2 block text-tertiary-foreground">{item.subtitle}</span>
)}
{item.description}
</GlassPanel>
</Link>
</li>
)
}
return (
<li key={key}>
<Link
href={item.href}
onClick={() => trackClick(item)}
target={external ? '_blank' : undefined}
rel={external ? 'noopener noreferrer' : undefined}
>
<strong>{item.title}</strong>: {item.description}
</Link>
</li>
)
})}
</ul>
</div>
</section>
)
}
export function ContentListings({ id }: { id: string }) {
const group = getContentListingById(id)
if (!group || !filterContentListingItems(group.items).length) return null
return (
<div className="my-10 space-y-10">
<ContentListingsGroup group={group} />
</div>
)
}