Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(settings): allow host components to control AI panel tabs

Steven Enamakel462cd095f1a2
diff --git a/app/src/components/layout/PanelPage.tsx b/app/src/components/layout/PanelPage.tsx
index e932d8b8f5..95572ae773 100644
--- a/app/src/components/layout/PanelPage.tsx
+++ b/app/src/components/layout/PanelPage.tsx
@@ -52,6 +52,11 @@ interface PanelPageBaseProps<T extends string = string> {
tabsAriaLabel?: string;
/** Prefix for each chip's `data-testid` (`${prefix}-${id}`). */
tabsTestIdPrefix?: string;
+ /**
+ * Render only the active tab body. The host supplies the tab controls when
+ * they belong in page-level chrome rather than this panel's surface.
+ */
+ hideTabChrome?: boolean;
/** Body spacing for the single-body case. Defaults to `p-4 space-y-5`. */
contentClassName?: string;
@@ -118,6 +123,7 @@ export default function PanelPage<T extends string = string>({
onChange,
tabsAriaLabel,
tabsTestIdPrefix,
+ hideTabChrome = false,
children,
contentClassName = DEFAULT_CONTENT_CLASS,
width = 'full',
@@ -155,22 +161,24 @@ export default function PanelPage<T extends string = string>({
return (
<div className={cn('relative flex h-full min-h-0 flex-col', className)} data-testid={testId}>
{/* Fixed page chrome: optional title + description, then the chip row. */}
- <PanelHeader
- title={title}
- description={description}
- leading={leading}
- action={action}
- className="flex-shrink-0">
- {headerExtra}
- <ChipTabs
- className="flex flex-wrap gap-1.5 pt-2"
- ariaLabel={tabsAriaLabel}
- testIdPrefix={tabsTestIdPrefix}
- items={chipItems}
- value={active.id}
- onChange={id => onChange?.(id)}
- />
- </PanelHeader>
+ {!hideTabChrome && (
+ <PanelHeader
+ title={title}
+ description={description}
+ leading={leading}
+ action={action}
+ className="flex-shrink-0">
+ {headerExtra}
+ <ChipTabs
+ className="flex flex-wrap gap-1.5 pt-2"
+ ariaLabel={tabsAriaLabel}
+ testIdPrefix={tabsTestIdPrefix}
+ items={chipItems}
+ value={active.id}
+ onChange={id => onChange?.(id)}
+ />
+ </PanelHeader>
+ )}
{/* Active tab body — its own scaffold owns the scroll. The border marks the
seam below the chips. */}
@@ -179,7 +187,7 @@ export default function PanelPage<T extends string = string>({
description={active.description}
contentClassName={active.contentClassName ?? ''}
width={width}
- bodyBorder>
+ bodyBorder={!hideTabChrome}>
{active.content}
</PanelScaffold>
</div>
diff --git a/app/src/components/settings/panels/AIPanel.tsx b/app/src/components/settings/panels/AIPanel.tsx
index 980fbb8520..2bd5d68389 100644
--- a/app/src/components/settings/panels/AIPanel.tsx
+++ b/app/src/components/settings/panels/AIPanel.tsx
@@ -55,16 +55,27 @@ import { useReembedBackfillModal } from './useReembedBackfillModal';
export type { CloudProvider, ProviderRef, RoutingMap } from './ai/aiPanelTypes';
export { buildRoutingDiffSummary, BackgroundLoopControls };
-type AiTab = 'providers' | 'routing';
+export type AIPanelTab = 'providers' | 'routing';
interface AIPanelProps {
/** When true, the panel is rendered embedded inside another flow (e.g. the
* onboarding custom wizard) and skips its own SettingsHeader chrome so the
* host frame's title/back controls aren't duplicated. */
embedded?: boolean;
+ /** Selected section when the host owns the page-level chip tabs. */
+ tab?: AIPanelTab;
+ /** Called when the selected section changes. */
+ onTabChange?: (tab: AIPanelTab) => void;
+ /** Suppress PanelPage's internal tab chrome for a host-rendered chip row. */
+ hideTabChrome?: boolean;
}
-const AIPanel = ({ embedded = false }: AIPanelProps = {}) => {
+const AIPanel = ({
+ embedded = false,
+ tab: controlledTab,
+ onTabChange,
+ hideTabChrome = false,
+}: AIPanelProps = {}) => {
const { t } = useT();
const { navigateBack } = useSettingsNavigation();
const { saved, draft, isDirty, save, persist, discard, loading, error, reload } = useAISettings();
@@ -87,7 +98,12 @@ const AIPanel = ({ embedded = false }: AIPanelProps = {}) => {
// each workload uses. They were stacked, so the routing controls sat below
// a provider list whose length varies with the user's setup. Tabs give each
// the full pane and a stable position.
- const [tab, setTab] = useState<AiTab>('providers');
+ const [uncontrolledTab, setUncontrolledTab] = useState<AIPanelTab>('providers');
+ const tab = controlledTab ?? uncontrolledTab;
+ const handleTabChange = (nextTab: AIPanelTab) => {
+ if (controlledTab === undefined) setUncontrolledTab(nextTab);
+ onTabChange?.(nextTab);
+ };
const {
busyAction,
@@ -152,7 +168,8 @@ const AIPanel = ({ embedded = false }: AIPanelProps = {}) => {
tabsAriaLabel={t('pages.settings.ai.llm')}
tabsTestIdPrefix="ai-tab"
value={tab}
- onChange={setTab}
+ onChange={handleTabChange}
+ hideTabChrome={hideTabChrome}
tabs={[
{
id: 'providers',
diff --git a/app/src/components/settings/panels/LlmConnectionsPanel.tsx b/app/src/components/settings/panels/LlmConnectionsPanel.tsx
index 258658f14b..ed5f95470b 100644
--- a/app/src/components/settings/panels/LlmConnectionsPanel.tsx
+++ b/app/src/components/settings/panels/LlmConnectionsPanel.tsx
@@ -1,5 +1,8 @@
+import { useState } from 'react';
+
import { useT } from '../../../lib/i18n/I18nContext';
-import AIPanel from './AIPanel';
+import ChipTabs from '../../layout/ChipTabs';
+import AIPanel, { type AIPanelTab } from './AIPanel';
/**
* The Connections → LLM surface: provider credentials and workload routing.
@@ -17,6 +20,7 @@ import AIPanel from './AIPanel';
*/
const LlmConnectionsPanel = () => {
const { t } = useT();
+ const [tab, setTab] = useState<AIPanelTab>('providers');
return (
<div className="flex h-full flex-col gap-4">
@@ -26,8 +30,19 @@ const LlmConnectionsPanel = () => {
</h1>
<p className="text-sm text-content-muted">{t('connections.header.llm')}</p>
</div>
+ <ChipTabs
+ className="flex flex-wrap gap-1.5"
+ ariaLabel={t('pages.settings.ai.llm')}
+ testIdPrefix="ai-tab"
+ items={[
+ { id: 'providers', label: t('settings.ai.llmProviders') },
+ { id: 'routing', label: t('settings.ai.routing') },
+ ]}
+ value={tab}
+ onChange={setTab}
+ />
<div className="min-h-0 flex-1 overflow-hidden rounded-2xl border border-line bg-surface shadow-subtle">
- <AIPanel />
+ <AIPanel tab={tab} onTabChange={setTab} hideTabChrome />
</div>
</div>
);