diff --git a/apps/studio/components/interfaces/Workers/WorkerPromptPanel.tsx b/apps/studio/components/interfaces/Workers/WorkerPromptPanel.tsx index f48ad2918ad..f2ded1f25bb 100644 --- a/apps/studio/components/interfaces/Workers/WorkerPromptPanel.tsx +++ b/apps/studio/components/interfaces/Workers/WorkerPromptPanel.tsx @@ -39,7 +39,7 @@ export const WorkerPromptPanel = ({ input, className }: WorkerPromptPanelProps) }) return ( - + }>AI Prompt {snippets.aiPrompt} diff --git a/packages/ui-patterns/src/PromptPanel/index.tsx b/packages/ui-patterns/src/PromptPanel/index.tsx index 3d037c91f82..c1439efa2ee 100644 --- a/packages/ui-patterns/src/PromptPanel/index.tsx +++ b/packages/ui-patterns/src/PromptPanel/index.tsx @@ -39,6 +39,13 @@ type PromptProps = { type PromptPanelProps = { children: ReactNode className?: string + /** + * When true, the panel resizes to fit the active tab's content — inactive + * panes are unmounted. Default false: all panes stay mounted stacked in one + * grid cell so the panel keeps the tallest tab's height (used by the docs + * homepage, where a stable frame across tabs matters more than tight fit). + */ + adaptiveHeight?: boolean } type CollectedPrompt = { @@ -236,7 +243,7 @@ const tabTriggerClassName = 'h-full px-0 py-0 text-xs shadow-none data-[state=ac * * ``` */ -function PromptPanel({ children, className }: PromptPanelProps) { +function PromptPanel({ children, className, adaptiveHeight = false }: PromptPanelProps) { const fallbackId = useId() const titleId = useId() const prompts = collectPrompts(children) @@ -307,31 +314,44 @@ function PromptPanel({ children, className }: PromptPanelProps) { className={cn('w-full overflow-hidden rounded-lg border bg-background shadow-sm', className)} > {header} - {/* - Stack panes in one grid cell so the panel keeps the tallest tab's - height. `grid-cols-1` pins the single track to `minmax(0, 1fr)` — without - it the track sizes to the widest pane (e.g. a long cURL line), pushing - the whole panel past its column. `min-w-0` on each pane then lets its - content wrap (text) or scroll (code) instead of overflowing. - */} -
- {prompts.map((prompt) => { - const isActive = prompt.value === activeTab - - return ( - + {adaptiveHeight ? ( + // Only the active pane renders, so the panel height tracks its content. + // `min-w-0` on the grid track keeps long code lines from pushing the + // whole panel past its column (they wrap or scroll inside instead). +
+ {prompts.map((prompt) => ( + - ) - })} -
+ ))} +
+ ) : ( + /* + Stack panes in one grid cell so the panel keeps the tallest tab's + height. `grid-cols-1` pins the single track to `minmax(0, 1fr)` — without + it the track sizes to the widest pane (e.g. a long cURL line), pushing + the whole panel past its column. `min-w-0` on each pane then lets its + content wrap (text) or scroll (code) instead of overflowing. + */ +
+ {prompts.map((prompt) => { + const isActive = prompt.value === activeTab + + return ( + + + + ) + })} +
+ )} ) }