mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
## What kind of change does this PR introduce? docs ui polish for the prompt panel on the docs homepage and in the quickstarts ## What is the current behavior? agent prompt renders as one run on paragraph steps read as "1. ... 2. ... 3. ..." inline making it hard to read ## What is the new behavior? - sets prompt bodies as markdown for easier readability - adds long prompts collapse - removes panel tab icons - uses panel code block ui - makes active tab has an underline on first paint `home` | state | preview | | -------|------| | before | <img width="709" height="344" alt="image" src="https://github.com/user-attachments/assets/ba3a0948-efff-4144-8eba-9065e1f140d9" /> | | after | <img width="709" height="344" alt="image" src="https://github.com/user-attachments/assets/e63e71e9-86d2-4d9a-ac2d-925e197d69f9" /> | `quickstart` | state | preview | | -------|------| | before | <img width="862" height="344" alt="image" src="https://github.com/user-attachments/assets/96faf012-a9f1-4ee9-8a98-3ec6de24d2de" /> | | after | <img width="862" height="344" alt="image" src="https://github.com/user-attachments/assets/7a41a259-e181-4a32-949f-de095d8bb66c" /> | <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Prompts now support Markdown formatting, inline code chips, expandable content, and improved hover-reveal behavior. * Code-copy controls support customizable labels and clearer screen-reader announcements. * Prompt tabs and panels have updated styling, spacing, and active-content handling. * **UI Improvements** * Setup and agent prompts now use consistent Markdown-rendered presentation. * Prompt headings now display “Agent Prompt.” * Home page setup code blocks use a more compact layout. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
109 lines
2.7 KiB
TypeScript
109 lines
2.7 KiB
TypeScript
'use client'
|
|
|
|
import {
|
|
getMonitoringAgent,
|
|
getMonitoringAgentHarnesses,
|
|
type MonitoringAgentHarnessSetup,
|
|
} from '~/data/monitoring-agents.utils'
|
|
import { Sparkles } from 'lucide-react'
|
|
import { useTheme } from 'next-themes'
|
|
import { type ReactNode } from 'react'
|
|
import ReactMarkdown from 'react-markdown'
|
|
import { ConnectionIcon } from 'ui-patterns/McpUrlBuilder'
|
|
|
|
import { AiPrompt } from './AiPrompt'
|
|
import { PromptCode } from './PromptPanel'
|
|
import { TabPanel, Tabs } from './Tabs'
|
|
|
|
type AgentSetupProps = {
|
|
id: string
|
|
}
|
|
|
|
const markdownComponents = {
|
|
p: ({ children }: { children?: ReactNode }) => <>{children}</>,
|
|
a: ({ href, children }: { href?: string; children?: ReactNode }) => {
|
|
if (!href) return <>{children}</>
|
|
const external = /^(?:[a-z][a-z0-9+\-.]*:|\/\/)/i.test(href)
|
|
return (
|
|
<a
|
|
href={href}
|
|
className="text-brand-link hover:underline"
|
|
{...(external ? { target: '_blank', rel: 'noreferrer noopener' } : {})}
|
|
>
|
|
{children}
|
|
</a>
|
|
)
|
|
},
|
|
code: PromptCode,
|
|
}
|
|
|
|
function HarnessBody({ harness }: { harness: MonitoringAgentHarnessSetup }) {
|
|
return (
|
|
<>
|
|
<p>{harness.intro}</p>
|
|
<ol>
|
|
{harness.steps.map((step) => (
|
|
<li key={step}>
|
|
<ReactMarkdown components={markdownComponents}>{step}</ReactMarkdown>
|
|
</li>
|
|
))}
|
|
</ol>
|
|
{harness.note && (
|
|
<p>
|
|
<ReactMarkdown components={markdownComponents}>{harness.note}</ReactMarkdown>
|
|
</p>
|
|
)}
|
|
<p>
|
|
<a
|
|
href={harness.docsUrl}
|
|
className="text-brand-link hover:underline"
|
|
target="_blank"
|
|
rel="noreferrer noopener"
|
|
>
|
|
{harness.label} docs
|
|
</a>
|
|
</p>
|
|
</>
|
|
)
|
|
}
|
|
|
|
function AgentSetup({ id }: AgentSetupProps) {
|
|
const agent = getMonitoringAgent(id)
|
|
const harnesses = getMonitoringAgentHarnesses(agent)
|
|
const { resolvedTheme } = useTheme()
|
|
const theme = resolvedTheme?.includes('dark') ? 'dark' : 'light'
|
|
|
|
return (
|
|
<Tabs
|
|
defaultActiveId="prompt"
|
|
type="underlined"
|
|
size="small"
|
|
wrappable
|
|
queryGroup="agent-setup"
|
|
>
|
|
<TabPanel id="prompt" label="Prompt" icon={<Sparkles size={14} />}>
|
|
<AiPrompt id={agent.promptId} />
|
|
</TabPanel>
|
|
{harnesses.map((harness) => (
|
|
<TabPanel
|
|
key={harness.key}
|
|
id={harness.key}
|
|
label={harness.label}
|
|
icon={
|
|
<ConnectionIcon
|
|
theme={theme}
|
|
connection={harness.icon}
|
|
hasDistinctDarkIcon={harness.hasDistinctDarkIcon}
|
|
/>
|
|
}
|
|
>
|
|
<HarnessBody harness={harness} />
|
|
</TabPanel>
|
|
))}
|
|
</Tabs>
|
|
)
|
|
}
|
|
|
|
export { AgentSetup }
|
|
export type { AgentSetupProps }
|