The open-source agent harness - the runtime layer that turns an LLM into a working agent.
improvement: updated UX for agent config (#608)
Vinit8296c52e91d0
diff --git a/.changeset/pre/agent-config-clickable-sections.md b/.changeset/pre/agent-config-clickable-sections.mdnew file mode 100644index 000000000..272b986ec--- /dev/null+++ b/.changeset/pre/agent-config-clickable-sections.md@@ -0,0 +1,5 @@+---+'@truefoundry/trueforge-ui': patch+---++Make Runtime Config, MCP Servers, and Skills blocks clickable with a hover action icon, explain disabled sandbox and large-tool-response toggles in tooltips, and replace boxed capability cards with divider-separated columns.diff --git a/packages/trueforge-ui/src/atoms/draft/AgentConfigPanel.tsx b/packages/trueforge-ui/src/atoms/draft/AgentConfigPanel.tsxindex 3da112c58..cecc2850c 100644--- a/packages/trueforge-ui/src/atoms/draft/AgentConfigPanel.tsx+++ b/packages/trueforge-ui/src/atoms/draft/AgentConfigPanel.tsx@@ -81,7 +81,10 @@ function McpServerChip({? 'bg-primary-button-bg text-primary-button-text': 'text-text-secondary hover:bg-ghost-button-hover',)}- onClick={onTogglePreload}+ onClick={event => {+ event.stopPropagation();+ onTogglePreload();+ }}><Icon name="book-open" className="size-3.5" /></button>@@ -98,7 +101,10 @@ function McpServerChip({size: 'icon',className: 'mx-1 size-5',})}- onClick={onRemove}+ onClick={event => {+ event.stopPropagation();+ onRemove();+ }}><Icon name="xmark" className="size-3" /></button>@@ -112,32 +118,70 @@ function McpServerChip({export function AgentConfigSection({title,description,+ icon,+ actionIcon = 'pencil',+ actionLabel,onEdit,children,}: {- title: string;+ title?: string;description?: string;+ icon?: string;+ actionIcon?: string;+ actionLabel?: string;onEdit?: () => void;- children: ReactNode;+ children?: ReactNode;}) {+ const action = actionLabel ?? `Edit ${title}`;+return (- <section className="border-b border-border px-4 py-4">- <div className="mb-3 flex items-start justify-between gap-3">- <div>- <h3 className="text-text-primary text-sm font-semibold">{title}</h3>- {description ? <p className="text-text-secondary mt-0.5 text-xs">{description}</p> : null}+ <section+ className={cn('group border-b border-border px-4 py-4', onEdit ? 'cursor-pointer' : null)}+ role={onEdit ? 'button' : undefined}+ tabIndex={onEdit ? 0 : undefined}+ onClick={onEdit}+ // Enter/Space activate the block like a native button. Keys aimed at nested+ // controls must pass through, or preventDefault here cancels their activation.+ onKeyDown={+ onEdit+ ? event => {+ if (event.target !== event.currentTarget) return;+ if (event.key !== 'Enter' && event.key !== ' ') return;+ event.preventDefault();+ onEdit();+ }+ : undefined+ }+ >+ {title && (+ <div className={cn('flex items-start justify-between gap-3', children ? 'mb-3' : null)}>+ <div className="flex min-w-0 items-start gap-2">+ {icon ? <Icon name={icon} className="text-text-secondary mt-0.5 size-4 shrink-0" /> : null}+ <div className="min-w-0">+ <h3 className="text-text-primary text-sm font-semibold">{title}</h3>+ {description ? <p className="text-text-secondary mt-0.5 text-xs">{description}</p> : null}+ </div>+ </div>+ {onEdit ? (+ <button+ type="button"+ aria-label={action}+ title={action}+ className={auiButtonClass({+ variant: 'ghost',+ size: 'icon',+ className: 'size-7 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100',+ })}+ onClick={event => {+ event.stopPropagation();+ onEdit();+ }}+ >+ <Icon name={actionIcon} className="size-3.5" />+ </button>+ ) : null}</div>- {onEdit ? (- <button- type="button"- aria-label={`Edit ${title}`}- className={auiButtonClass({ variant: 'ghost', size: 'icon', className: 'size-7' })}- onClick={onEdit}- >- <Icon name="pencil" className="size-3.5" />- </button>- ) : null}- </div>+ )}{children}</section>);@@ -191,7 +235,7 @@ export function AgentConfigPanel({) : null}</header><div className="min-h-0 flex-1 overflow-y-auto">- <Section title="Model">+ <Section><div className="flex items-center gap-2"><ProviderMarklogo={model?.provider.logo}@@ -270,6 +314,7 @@ export function AgentConfigPanel({<Sectiontitle="Runtime Config"description="Control execution and context behavior."+ actionIcon="sliders"onEdit={() => onOpenEditor('runtime')}><dl className="text-text-secondary flex flex-wrap gap-x-3 gap-y-1 text-xs leading-relaxed">@@ -282,25 +327,13 @@ export function AgentConfigPanel({</dl></Section>- <section className="group border-b border-border px-4 py-4">- <div className={cn('flex items-center justify-between gap-3', mcp.length ? 'mb-3' : null)}>- <div className="flex min-w-0 items-center gap-2">- <Icon name="mcp-server" className="text-text-secondary size-4 shrink-0" />- <h3 className="text-text-primary text-sm font-semibold">MCP Servers</h3>- </div>- <button- type="button"- aria-label="Add MCP server"- className={auiButtonClass({- variant: 'ghost',- size: 'icon',- className: 'size-7 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100',- })}- onClick={() => onOpenEditor('mcp')}- >- <Icon name="plus" className="size-3.5" />- </button>- </div>+ <Section+ title="MCP Servers"+ icon="mcp-server"+ actionIcon="plus"+ actionLabel="Add MCP server"+ onEdit={() => onOpenEditor('mcp')}+ >{mcp.length ? (<div className="flex flex-wrap gap-1.5">{mcp.map(item => (@@ -333,9 +366,9 @@ export function AgentConfigPanel({))}</div>) : null}- </section>+ </Section>- <Section title="Skills" onEdit={() => onOpenEditor('skills')}>+ <Section title="Skills" actionIcon="plus" actionLabel="Add skill" onEdit={() => onOpenEditor('skills')}>{!skillsAvailable ? (<p className="text-text-secondary text-xs">Skills require an available sandbox.</p>) : skills.length ? (diff --git a/packages/trueforge-ui/src/atoms/draft/AgentRuntimeConfigFields.tsx b/packages/trueforge-ui/src/atoms/draft/AgentRuntimeConfigFields.tsxindex 0008b2616..355a43928 100644--- a/packages/trueforge-ui/src/atoms/draft/AgentRuntimeConfigFields.tsx+++ b/packages/trueforge-ui/src/atoms/draft/AgentRuntimeConfigFields.tsx@@ -1,8 +1,10 @@'use client';import type { AgentRuntimeConfig } from '../../server/types.js';+import { cn } from '../lib/cn.js';import { auiInputClass } from '../lib/inputClasses.js';import { Switch } from '../primitives/Switch.js';+import { Tooltip } from '../primitives/Tooltip.js';export type AgentRuntimeConfigFieldsProps = {value: AgentRuntimeConfig;@@ -26,11 +28,14 @@ function parsePositiveInteger(raw: string): number | null {return Number.isInteger(parsed) && parsed > 0 ? parsed : null;}+const NO_SANDBOX_PROVIDER_HINT = 'No sandbox provider yet, add one in Settings → Sandbox';+type RuntimeSwitchField = {label: string;description: string;checked: boolean;disabled?: boolean;+ disabledTooltip?: string;update: (enabled: boolean) => AgentRuntimeConfig;};@@ -70,6 +75,11 @@ export function AgentRuntimeConfigFields({description: 'Provide an isolated environment for code, files, and skills.',checked: sandboxEnabled,disabled: !sandboxAvailable || hasSkills,+ disabledTooltip: !sandboxAvailable+ ? NO_SANDBOX_PROVIDER_HINT+ : hasSkills+ ? 'Always on while skills are attached — remove them to turn it off'+ : undefined,update: enabled => ({ ...value, sandbox: { ...value.sandbox, enabled } }),};const fileDownloadsField: RuntimeSwitchField = {@@ -100,6 +110,7 @@ export function AgentRuntimeConfigFields({description: 'Move large tool output to the sandbox and retain a preview.',checked: value.contextManagement?.largeToolResponse?.enabled ?? true,disabled: !sandboxAvailable,+ disabledTooltip: !sandboxAvailable ? `Offloading needs a sandbox. ${NO_SANDBOX_PROVIDER_HINT}` : undefined,update: enabled => ({...value,contextManagement: {@@ -111,30 +122,56 @@ export function AgentRuntimeConfigFields({};const runtimeFields = [sandboxField, fileDownloadsField, compactionField, largeToolResponseField];const compactionThreshold = value.contextManagement?.compaction?.trigger?.value ?? 50_000;- const switchField = (field: (typeof runtimeFields)[number], className = '') => (- <label key={field.label} className={className || 'flex items-center justify-between gap-3 py-1.5'}>- <span className="min-w-0">- <span className="text-text-primary block text-xs font-medium">{field.label}</span>- {layout === 'detailed' ? (- <span className="text-text-secondary mt-0.5 block text-xs leading-snug">{field.description}</span>- ) : null}- </span>- <Switch- checked={field.checked}- disabled={disabled || field.disabled}- onCheckedChange={enabled => onChange(field.update(enabled))}- aria-label={field.label}- />- </label>++ const switchField = ({+ field,+ className,+ wrapperClassName,+ }: {+ field: RuntimeSwitchField;+ className?: string;+ wrapperClassName?: string;+ }) => (+ <Tooltip+ key={field.label}+ content={field.disabledTooltip ?? ''}+ triggerClassName={cn('flex w-full min-w-0', wrapperClassName)}+ >+ <label className={cn('flex w-full', className ?? 'items-center justify-between gap-3 py-1.5')}>+ <span className="min-w-0">+ <span className={cn('text-text-primary text-xs', layout === 'detailed' && 'block font-medium')}>+ {field.label}+ </span>+ {layout === 'detailed' ? (+ <span className="text-text-secondary mt-0.5 block text-xs leading-snug">{field.description}</span>+ ) : null}+ </span>+ <Switch+ checked={field.checked}+ disabled={disabled || field.disabled}+ onCheckedChange={enabled => onChange(field.update(enabled))}+ aria-label={field.label}+ />+ </label>+ </Tooltip>);if (layout === 'detailed') {return (<div className="space-y-5">{showCapabilities ? (- <div className="grid gap-3 md:grid-cols-3">- {capabilityFields.map(field =>- switchField(field, 'flex min-h-24 items-start justify-between gap-3 rounded-lg border border-border p-3'),+ // Stacked below `md` so the bottom-sheet modal does not cram three labeled switches into one row.+ <div className="flex flex-col gap-3 md:flex-row">+ {capabilityFields.map((field, index) =>+ switchField({+ field,+ className: 'items-start justify-between gap-3',+ wrapperClassName: cn(+ 'flex-1',+ index < capabilityFields.length - 1 &&+ 'border-b border-border pb-3 md:border-b-0 md:border-r md:pb-0 md:pr-3',+ ),+ }),)}</div>) : null}@@ -160,13 +197,13 @@ export function AgentRuntimeConfigFields({</label><div className="divide-y divide-border"><section className="py-3">- {switchField(sandboxField, 'flex items-center justify-between gap-4')}+ {switchField({ field: sandboxField, className: 'items-center justify-between gap-4' })}<div className={`mt-3 border-l-2 border-primary-button-bg/50 pl-3 ${sandboxEnabled ? '' : 'opacity-50'}`}>- {switchField(fileDownloadsField, 'flex items-center justify-between gap-4')}+ {switchField({ field: fileDownloadsField, className: 'items-center justify-between gap-4' })}</div></section><section className="py-3">- {switchField(compactionField, 'flex items-center justify-between gap-4')}+ {switchField({ field: compactionField, className: 'items-center justify-between gap-4' })}<labelclassName={`mt-3 flex items-center justify-between gap-4 border-l-2 border-primary-button-bg/50 pl-3 ${compactionEnabled ? '' : 'opacity-50'@@ -203,7 +240,7 @@ export function AgentRuntimeConfigFields({/></label></section>- {switchField(largeToolResponseField, 'flex items-center justify-between gap-4 py-3')}+ {switchField({ field: largeToolResponseField, className: 'items-center justify-between gap-4 py-3' })}</div></div>);@@ -226,17 +263,7 @@ export function AgentRuntimeConfigFields({}}/></label>- {[...runtimeFields, ...(showCapabilities ? capabilityFields : [])].map(field => (- <label key={field.label} className="flex items-center justify-between gap-3 py-1.5">- <span className="text-text-primary text-xs">{field.label}</span>- <Switch- checked={field.checked}- disabled={disabled || field.disabled}- onCheckedChange={enabled => onChange(field.update(enabled))}- aria-label={field.label}- />- </label>- ))}+ {[...runtimeFields, ...(showCapabilities ? capabilityFields : [])].map(field => switchField({ field }))}</div>);}diff --git a/packages/trueforge-ui/test/atoms/draft/AgentConfigPanel.test.tsx b/packages/trueforge-ui/test/atoms/draft/AgentConfigPanel.test.tsxindex 8e5223113..e13e72e2a 100644--- a/packages/trueforge-ui/test/atoms/draft/AgentConfigPanel.test.tsx+++ b/packages/trueforge-ui/test/atoms/draft/AgentConfigPanel.test.tsx@@ -167,6 +167,27 @@ describe('AgentConfigPanel', () => {});});+ it('leaves keyboard activation of chip controls to the chip', () => {+ const onOpenEditor = vi.fn();+ render(+ <SlotsProvider>+ <AgentConfigPanel+ spec={spec}+ model={model}+ skillsAvailable+ instructions={spec.instructions ?? ''}+ onOpenEditor={onOpenEditor}+ onChange={vi.fn()}+ />+ </SlotsProvider>,+ );++ fireEvent.keyDown(screen.getByRole('button', { name: 'Remove GitHub' }), { key: 'Enter' });+ fireEvent.keyDown(screen.getByRole('button', { name: 'Preload tools for GitHub' }), { key: ' ' });++ expect(onOpenEditor).not.toHaveBeenCalled();+ });+it('opens the MCP editor from the section add action', () => {const onOpenEditor = vi.fn();render(