The open-source agent harness - the runtime layer that turns an LLM into a working agent.
Chore: show only name and description in save agent in drawer instead modal (#636)
harshil-20967e25f68084fe
diff --git a/.changeset/simplify-save-agent.md b/.changeset/simplify-save-agent.mdnew file mode 100644index 000000000..1ec8a377b--- /dev/null+++ b/.changeset/simplify-save-agent.md@@ -0,0 +1,5 @@+---+"@truefoundry/trueforge-ui": minor+---++Open Save Agent in a right-side drawer with only the agent name while preserving configuration from Agent Config.diff --git a/packages/trueforge-ui/README.md b/packages/trueforge-ui/README.mdindex 9ac44523c..93c36a15d 100644--- a/packages/trueforge-ui/README.md+++ b/packages/trueforge-ui/README.md@@ -407,7 +407,7 @@ show the title text (see [Custom layouts](#custom-layouts)).In library modes, picking an agent from Agents switches to a named chat for that agent **and remounts the runtime** so the new agent starts from a clean conversation. Draft chats can be promoted via **Save agent** (`server.saveAgent` on the resolved `AgentUIServer`). **Clear Chat** (thread header) resets the current named or draft session.-Mutable composers expose **Agent Config** for live model parameters, instructions, runtime behavior, per-connector MCP tools, and skills. Runtime Config opens in a second right-side drawer. The compact Tools picker contains only Connectors and Skills. The Save Agent dialog keeps a local editable copy of the same configuration and shares the same selector dialogs; cancelling it leaves the active draft unchanged. Model context and output limits render when the server supplies that optional catalog metadata.+Mutable composers expose **Agent Config** for live model parameters, instructions, runtime behavior, per-connector MCP tools, and skills. Runtime Config opens in a second right-side drawer. The compact Tools picker contains only Connectors and Skills. The Save Agent drawer only edits the agent name while preserving the active draft configuration; cancelling it discards that local edit. Model context and output limits render when the server supplies that optional catalog metadata.```tsx{diff --git a/packages/trueforge-ui/src/atoms/SaveAgentButton.tsx b/packages/trueforge-ui/src/atoms/SaveAgentButton.tsxindex 0f212ef29..90cf84bc2 100644--- a/packages/trueforge-ui/src/atoms/SaveAgentButton.tsx+++ b/packages/trueforge-ui/src/atoms/SaveAgentButton.tsx@@ -5,21 +5,18 @@ import {useTrueFoundryAgentSpec,useTrueFoundryFlushAgentSpec,} from '@truefoundry/assistant-ui-runtime';-import { useMemo, useRef, useState } from 'react';+import { useRef, useState } from 'react';import { useSaveAgentVisible } from '../hooks/useChatChromeActionsVisible.js';import { Icon } from '../icons/Icon.js';-import { useOptionalServer, useServerCapabilities } from '../server/ServerContext.js';+import { useOptionalServer } from '../server/ServerContext.js';import { useOptionalShellMode } from '../server/ShellModeContext.js';-import type { AgentSpec, McpToolSelection } from '../server/types.js';+import type { AgentSpec } from '../server/types.js';import { useSlot } from '../theme/SlotsProvider.js';import { getErrorMessage } from '../utils/getErrorMessage.js';-import type { AgentConfigEditor } from './draft/AgentConfigEditors.js';import { useOptionalAgentConfigInstructions } from './draft/AgentConfigInstructionsContext.js';-import { DraftCatalogProvider, useDraftCatalog } from './draft/DraftCatalogProvider.js';-import { editableMountsFromSpec, withPreload } from './draft/agentConfigMounts.js';import { Button } from './primitives/Button.js';-import { CenteredModal } from './primitives/CenteredModal.js';+import { SideDrawer } from './primitives/SideDrawer.js';type SaveIntent = 'create' | 'update';@@ -51,11 +48,9 @@ export function SaveAgentButton({instructionsOverride,}: SaveAgentButtonProps) {return (- <DraftCatalogProvider>- <SaveAgentButtonContent disabled={disabled} className={className} instructionsOverride={instructionsOverride}>- {children}- </SaveAgentButtonContent>- </DraftCatalogProvider>+ <SaveAgentButtonContent disabled={disabled} className={className} instructionsOverride={instructionsOverride}>+ {children}+ </SaveAgentButtonContent>);}@@ -78,29 +73,17 @@ function SaveAgentButtonContent({const builder = useOptionalServer();const shell = useOptionalShellMode();const configInstructions = useOptionalAgentConfigInstructions();- const catalog = useDraftCatalog();- const serverCapabilities = useServerCapabilities();- const AgentConfigEditors = useSlot('AgentConfigEditors');const SaveAgentForm = useSlot('SaveAgentForm');const visible = useSaveAgentVisible();const [open, setOpen] = useState(false);- const [editor, setEditor] = useState<AgentConfigEditor | null>(null);const [intent, setIntent] = useState<SaveIntent>('create');const [name, setName] = useState('');const [draftSpec, setDraftSpec] = useState<AgentSpec | null>(null);const [saving, setSaving] = useState(false);const [error, setError] = useState<string | null>(null);- const mcpMounts = useMemo(() => editableMountsFromSpec(draftSpec?.mcpServers), [draftSpec?.mcpServers]);- const skillMounts = useMemo(() => editableMountsFromSpec(draftSpec?.skills), [draftSpec?.skills]);- const modelEntry = useMemo(- () => catalog.models.find(model => model.name === draftSpec?.model.name),- [catalog.models, draftSpec?.model.name],- );-const close = () => {if (saving) return;- setEditor(null);setOpen(false);setDraftSpec(null);setError(null);@@ -109,7 +92,6 @@ function SaveAgentButtonContent({const show = async () => {if (agentSpecRef.current === null || builder === null) return;setError(null);- catalog.ensureLoaded();configInstructions?.flush();await flushAgentSpec();const flushedAgentSpec = agentSpecRef.current;@@ -146,7 +128,6 @@ function SaveAgentButtonContent({shell?.invalidateAgentsList();setOpen(false);setDraftSpec(null);- setEditor(null);} catch (caught) {setError(getErrorMessage(caught, 'Could not save agent'));} finally {@@ -154,35 +135,11 @@ function SaveAgentButtonContent({}};- const toggleMcpPreload = (id: string) => {- if (draftSpec === null) return;- const next = mcpMounts.map(item =>- item.id === id ? withPreload(item.value, Reflect.get(item.value, 'preload') !== true) : item.value,- );- setDraftSpec({ ...draftSpec, mcpServers: next });- };-- const removeMcp = (id: string) => {- if (draftSpec === null) return;- setDraftSpec({- ...draftSpec,- mcpServers: mcpMounts.filter(item => item.id !== id).map(item => item.value),- });- };-const isUpdateMode =shell?.mode.status === 'active' &&shell.mode.isMutable &&(shell.mode.agentName !== undefined || shell.mode.agentId !== undefined);const triggerLabel = isUpdateMode && children === 'Save Agent' ? 'Update Agent' : children;- const getMcpTools = builder === null ? undefined : Reflect.get(builder, 'getMcpTools');- const loadMcpTools =- typeof getMcpTools === 'function'- ? async (connectorId: string): Promise<McpToolSelection[]> => {- const result: unknown = await getMcpTools.call(builder, { connectorId });- return Array.isArray(result) ? result : [];- }- : undefined;if (!visible) return null;@@ -199,11 +156,12 @@ function SaveAgentButtonContent({{triggerLabel}</Button.Primary>- <CenteredModal+ <SideDraweropen={open}onOpenChange={next => !next && close()}title={intent === 'create' ? 'Save agent' : 'Update agent'}- className="md:h-auto md:max-h-[85dvh] md:max-w-2xl"+ anchor="right"+ size="md"aria-label={intent === 'create' ? 'Save agent' : 'Update agent'}>{draftSpec ? (@@ -211,39 +169,15 @@ function SaveAgentButtonContent({intent={intent}name={name}spec={draftSpec}- modelEntry={modelEntry}- mcpMounts={mcpMounts}- skillMounts={skillMounts}saving={saving}error={error}onNameChange={setName}onChange={setDraftSpec}- onEdit={setEditor}- onToggleMcpPreload={toggleMcpPreload}- onRemoveMcp={removeMcp}onCancel={close}onSave={() => void save()}/>) : null}- </CenteredModal>-- {draftSpec ? (- <AgentConfigEditors- editor={editor}- spec={draftSpec}- models={catalog.models}- connectors={catalog.connectors}- skills={catalog.skills}- loading={catalog.loading}- error={catalog.error}- skillsDisabled={serverCapabilities?.skill.enabled !== true}- sandboxAvailable={serverCapabilities?.sandbox.enabled === true}- loadMcpTools={loadMcpTools}- onRefreshConnectors={catalog.refreshConnectors}- onChange={setDraftSpec}- onClose={() => setEditor(null)}- />- ) : null}+ </SideDrawer></>);}diff --git a/packages/trueforge-ui/src/atoms/SaveAgentForm.tsx b/packages/trueforge-ui/src/atoms/SaveAgentForm.tsxindex 8b572e1bd..8c6d0f236 100644--- a/packages/trueforge-ui/src/atoms/SaveAgentForm.tsx+++ b/packages/trueforge-ui/src/atoms/SaveAgentForm.tsx@@ -2,10 +2,7 @@import { useEffect, useRef } from 'react';-import type { AgentSpec, ModelSelection } from '../server/types.js';-import { useSlot } from '../theme/SlotsProvider.js';-import type { AgentConfigEditor } from './draft/AgentConfigEditors.js';-import type { EditableMount } from './draft/agentConfigMounts.js';+import type { AgentSpec } from '../server/types.js';import { auiInputClass } from './lib/inputClasses.js';import { Button } from './primitives/Button.js';@@ -13,16 +10,10 @@ export type SaveAgentFormProps = {intent: 'create' | 'update';name: string;spec: AgentSpec;- modelEntry?: ModelSelection;- mcpMounts: EditableMount[];- skillMounts: EditableMount[];saving: boolean;error: string | null;onNameChange: (name: string) => void;onChange: (spec: AgentSpec) => void;- onEdit: (editor: AgentConfigEditor) => void;- onToggleMcpPreload: (id: string) => void;- onRemoveMcp?: (id: string) => void;onCancel: () => void;onSave: () => void;};@@ -31,20 +22,12 @@ export function SaveAgentForm({intent,name,spec,- modelEntry,- mcpMounts,- skillMounts,saving,error,onNameChange,- onChange,- onEdit,- onToggleMcpPreload,- onRemoveMcp,onCancel,onSave,}: SaveAgentFormProps) {- const SaveAgentFormFields = useSlot('SaveAgentFormFields');const errorRef = useRef<HTMLParagraphElement>(null);useEffect(() => {@@ -67,28 +50,18 @@ export function SaveAgentForm({/></label>- <label className="mb-3 block">- <span className="mb-1.5 block text-sm font-medium">Instructions</span>- <textarea- value={spec.instructions ?? ''}- disabled={saving}- onChange={event => onChange({ ...spec, instructions: event.target.value })}- rows={5}- placeholder="You are a release notes writer for a platform team."- className={auiInputClass('resize-y py-2 disabled:opacity-60')}- />- </label>-- <SaveAgentFormFields- spec={spec}- modelEntry={modelEntry}- mcpMounts={mcpMounts}- skillMounts={skillMounts}- disabled={saving}- onEdit={onEdit}- onToggleMcpPreload={onToggleMcpPreload}- onRemoveMcp={onRemoveMcp}- />+ {/* TODO: Uncomment the description field when the backend supports description */}+ {/* <label className="mb-3 block">+ <span className="mb-1.5 block text-sm font-medium">Description</span>+ <textarea+ value={spec.description ?? ''}+ disabled={saving}+ onChange={event => onChange({ ...spec, description: event.target.value })}+ rows={4}+ placeholder="Describe what this agent does."+ className={auiInputClass('resize-y py-2 disabled:opacity-60')}+ />+ </label> */}{error ? (<pdiff --git a/packages/trueforge-ui/src/atoms/SaveAgentFormFields.tsx b/packages/trueforge-ui/src/atoms/SaveAgentFormFields.tsxdeleted file mode 100644index 58a441772..000000000--- a/packages/trueforge-ui/src/atoms/SaveAgentFormFields.tsx+++ /dev/null@@ -1,248 +0,0 @@-'use client';--import { Icon } from '../icons/Icon.js';-import type { AgentSpec, ModelSelection } from '../server/types.js';-import type { AgentConfigEditor } from './draft/AgentConfigEditors.js';-import { enabledToolsFromMount, type EditableMount } from './draft/agentConfigMounts.js';-import { displayModelLabel, ProviderMark } from './draft/DraftModelCatalogPanel.js';-import { modelParamSummary } from './draft/modelParamsSummary.js';-import { runtimeConfigSummary, runtimeConfigValueClassName } from './draft/runtimeConfigSummary.js';-import { auiButtonClass } from './lib/buttonClasses.js';-import { cn } from './lib/cn.js';-import { Tooltip } from './primitives/Tooltip.js';--export type SaveAgentFormFieldsProps = {- spec: AgentSpec;- modelEntry?: ModelSelection;- mcpMounts: EditableMount[];- skillMounts: EditableMount[];- disabled: boolean;- onEdit: (editor: AgentConfigEditor) => void;- onToggleMcpPreload: (id: string) => void;- onRemoveMcp?: (id: string) => void;-};--const PRELOAD_TOOLS_COPY = {- header: 'Preload tools',- on: 'Tool definitions load into context upfront. No discovery step, but uses more context.',- off: 'The agent discovers tools on demand. Lighter context upfront, but a discovery step the first time it needs a tool.',-} as const;--function formatTokens(value: number): string {- return Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 1 }).format(value);-}--export function SaveAgentFormFields({- spec,- modelEntry,- mcpMounts,- skillMounts,- disabled,- onEdit,- onToggleMcpPreload,- onRemoveMcp,-}: SaveAgentFormFieldsProps) {- const contextLength = Reflect.get(modelEntry?.properties ?? {}, 'contextLength');- const maxOutputTokens = Reflect.get(modelEntry?.properties ?? {}, 'maxOutputTokens');- const modelParams = modelParamSummary(spec.model.params);- const runtimeConfig = runtimeConfigSummary(spec.config);-- return (- <>- <div className="mb-3">- <div className="mb-1.5 flex items-center justify-between">- <span className="text-text-secondary text-xs font-semibold tracking-wide uppercase">Model</span>- <button- type="button"- aria-label="Edit Model"- disabled={disabled}- className={auiButtonClass({ variant: 'ghost', size: 'icon', className: 'size-7' })}- onClick={() => onEdit('model')}- >- <Icon name="pencil" className="size-3.5" />- </button>- </div>- {spec.model.name ? (- <div className="flex flex-wrap items-center gap-2">- <span className="border-border inline-flex items-center gap-2 rounded-lg border py-1 pr-2.5 pl-2">- <ProviderMark- logo={modelEntry?.provider.logo}- label={modelEntry?.provider.name ?? spec.model.name}- className="size-4 text-[8px]"- />- <span className="text-text-primary text-sm">{displayModelLabel(spec.model.name)}</span>- </span>- {typeof contextLength === 'number' && contextLength ? (- <span className="text-text-secondary text-xs">{formatTokens(contextLength)} context</span>- ) : null}- {typeof maxOutputTokens === 'number' && maxOutputTokens ? (- <span className="text-text-secondary text-xs">{formatTokens(maxOutputTokens)} max output</span>- ) : null}- </div>- ) : (- <p className="text-text-secondary text-xs">No model selected.</p>- )}- <div className="mt-2 flex items-center gap-2">- <dl className=" text-text-secondary flex min-w-0 flex-1 flex-wrap gap-x-3 gap-y-1 text-xs">- {modelParams.length ? (- modelParams.map(entry => (- <div key={entry.label} className="flex gap-1">- <dt>{entry.label}:</dt>- <dd className="text-text-primary font-medium">{entry.value}</dd>- </div>- ))- ) : (- <div>model settings: defaults</div>- )}- </dl>- <button- type="button"- aria-label="Model settings"- title="Model settings"- disabled={disabled}- className={auiButtonClass({ variant: 'ghost', size: 'icon', className: 'size-7 shrink-0' })}- onClick={() => onEdit('model-settings')}- >- <Icon name="sliders" className="size-3.5" />- </button>- </div>- </div>-- <div className="mb-3">- <div className="mb-1.5 flex items-center justify-between">- <span className="text-text-secondary text-xs font-semibold tracking-wide uppercase">Runtime Config</span>- <button- type="button"- aria-label="Edit Runtime Config"- disabled={disabled}- className={auiButtonClass({ variant: 'ghost', size: 'icon', className: 'size-7' })}- onClick={() => onEdit('runtime')}- >- <Icon name="pencil" className="size-3.5" />- </button>- </div>- <dl className="text-text-secondary flex flex-wrap gap-x-3 gap-y-1 text-xs">- {runtimeConfig.map(entry => (- <div key={entry.label} className="flex gap-1">- <dt>{entry.label}:</dt>- <dd className={runtimeConfigValueClassName(entry.value)}>{entry.value}</dd>- </div>- ))}- </dl>- </div>-- <div className="mb-3">- <div className="mb-1.5 flex items-center justify-between">- <span className="text-text-secondary text-xs font-semibold tracking-wide uppercase">Connectors</span>- <button- type="button"- aria-label="Edit Connectors"- disabled={disabled}- className={auiButtonClass({ variant: 'ghost', size: 'icon', className: 'size-7' })}- onClick={() => onEdit('mcp')}- >- <Icon name="pencil" className="size-3.5" />- </button>- </div>- {mcpMounts.length === 0 ? (- <p className="text-text-secondary text-xs">No connectors added.</p>- ) : (- <div className="flex flex-wrap gap-2">- {mcpMounts.map(mount => {- const preload = Reflect.get(mount.value, 'preload') === true;- const enabledTools = enabledToolsFromMount(mount.value);- const label = `${PRELOAD_TOOLS_COPY.header} · ${preload ? 'ON' : 'OFF'}`;- return (- <span- key={mount.id}- className="border-border flex items-center gap-2 rounded-lg border py-1 pr-2.5 pl-1.5"- >- <Tooltip- className="max-w-68 whitespace-normal"- content={- <div className="text-left">- <p className="mb-1 text-[11px] font-semibold tracking-wide uppercase">{label}</p>- <p className="text-xs leading-snug">- {preload ? PRELOAD_TOOLS_COPY.on : PRELOAD_TOOLS_COPY.off}- </p>- </div>- }- >- <button- type="button"- aria-label={label}- aria-pressed={preload}- disabled={disabled}- onClick={() => onToggleMcpPreload(mount.id)}- className={cn(- 'flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md border',- 'transition-[color,background-color,border-color,transform] active:scale-90',- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40',- 'disabled:cursor-not-allowed disabled:opacity-50 disabled:active:scale-100',- preload- ? 'border-primary-button-bg/40 bg-primary-button-bg/10 text-primary-button-bg hover:border-primary-button-bg/70 hover:bg-primary-button-bg/20'- : 'border-border text-text-secondary hover:border-text-secondary/50 hover:bg-text-secondary/10 hover:text-text-primary',- )}- >- <Icon name="book-open" className="size-3.5" />- </button>- </Tooltip>- <span className="text-text-primary text-sm">{mount.name}</span>- <span className="text-text-secondary text-xs">- {enabledTools === 'all' ? 'All tools' : `${enabledTools.length} tools`}- </span>- {onRemoveMcp ? (- <button- type="button"- aria-label={`Remove ${mount.name}`}- disabled={disabled}- className={auiButtonClass({ variant: 'ghost', size: 'icon', className: 'size-5' })}- onClick={() => onRemoveMcp(mount.id)}- >- <Icon name="xmark" className="size-3" />- </button>- ) : null}- </span>- );- })}- </div>- )}- </div>-- <div className="mb-3">- <div className="mb-1.5 flex items-center justify-between">- <span className="text-text-secondary text-xs font-semibold tracking-wide uppercase">Skills</span>- <button- type="button"- aria-label="Edit Skills"- disabled={disabled}- className={auiButtonClass({ variant: 'ghost', size: 'icon', className: 'size-7' })}- onClick={() => onEdit('skills')}- >- <Icon name="pencil" className="size-3.5" />- </button>- </div>- {skillMounts.length === 0 ? (- <p className="text-text-secondary text-xs">No skills added.</p>- ) : (- <div className="flex flex-wrap gap-2">- {skillMounts.map(mount => (- <span- key={mount.id}- className="border-border flex items-center gap-2 rounded-lg border py-1 pr-2.5 pl-2.5"- >- <span className="text-text-primary text-sm">{mount.name}</span>- </span>- ))}- </div>- )}- </div>- </>- );-}--declare module '../theme/SlotsProvider.js' {- interface AtomSlots {- SaveAgentFormFields: typeof SaveAgentFormFields;- }-}diff --git a/packages/trueforge-ui/src/index.ts b/packages/trueforge-ui/src/index.tsindex b119b4e57..f55cc5014 100644--- a/packages/trueforge-ui/src/index.ts+++ b/packages/trueforge-ui/src/index.ts@@ -502,7 +502,5 @@ export { SaveAgentButton } from './atoms/SaveAgentButton.js';export type { SaveAgentButtonProps } from './atoms/SaveAgentButton.js';export { SaveAgentForm } from './atoms/SaveAgentForm.js';export type { SaveAgentFormProps } from './atoms/SaveAgentForm.js';-export { SaveAgentFormFields } from './atoms/SaveAgentFormFields.js';-export type { SaveAgentFormFieldsProps } from './atoms/SaveAgentFormFields.js';export { SessionsBrowserButton } from './atoms/SessionsBrowserButton.js';export type { SessionsBrowserButtonProps } from './atoms/SessionsBrowserButton.js';diff --git a/packages/trueforge-ui/src/plugins/trueforge-agent-server-adapter/builderServer.ts b/packages/trueforge-ui/src/plugins/trueforge-agent-server-adapter/builderServer.tsindex aeaf02f84..722baada3 100644--- a/packages/trueforge-ui/src/plugins/trueforge-agent-server-adapter/builderServer.ts+++ b/packages/trueforge-ui/src/plugins/trueforge-agent-server-adapter/builderServer.ts@@ -119,6 +119,7 @@ export function createHarnessBuilderServer(},async saveAgent({ agentName, agentSpec, intent }) {+ // TODO: TrueForge currently drops AgentSpec.description until its schema supports it.const manifest = toHarnessAgentSpec(agentSpec);if (intent === 'update') {const { data } = await client.agents.list();diff --git a/packages/trueforge-ui/src/theme/defaultSlots.ts b/packages/trueforge-ui/src/theme/defaultSlots.tsindex abd96b428..b089a1be9 100644--- a/packages/trueforge-ui/src/theme/defaultSlots.ts+++ b/packages/trueforge-ui/src/theme/defaultSlots.ts@@ -72,7 +72,6 @@ import { SandboxArtifactDownload } from '../atoms/SandboxArtifactDownload.js';import { SandboxToolCallCard } from '../atoms/SandboxToolCallCard.js';import { SaveAgentButton } from '../atoms/SaveAgentButton.js';import { SaveAgentForm } from '../atoms/SaveAgentForm.js';-import { SaveAgentFormFields } from '../atoms/SaveAgentFormFields.js';import { SchedulesButton } from '../atoms/SchedulesButton.js';import { ScrollToBottomButton } from '../atoms/ScrollToBottomButton.js';import { SelectAgentEmptyState } from '../atoms/SelectAgentEmptyState.js';@@ -228,7 +227,6 @@ export const defaultSlots = {SchedulesButton,SaveAgentButton,SaveAgentForm,- SaveAgentFormFields,SelectAgentEmptyState,ClearChatButton,ThreadListRowSkeleton,diff --git a/packages/trueforge-ui/test/atoms/SaveAgentButton.test.tsx b/packages/trueforge-ui/test/atoms/SaveAgentButton.test.tsxindex 667c6ce66..720d032fa 100644--- a/packages/trueforge-ui/test/atoms/SaveAgentButton.test.tsx+++ b/packages/trueforge-ui/test/atoms/SaveAgentButton.test.tsx@@ -142,13 +142,6 @@ function deferred<T>() {};}-async function findStackedDialog(label: string): Promise<HTMLDialogElement> {- await waitFor(() => expect(document.querySelectorAll('dialog')[1]).toHaveAttribute('aria-label', label));- const dialog = document.querySelectorAll('dialog')[1];- if (!(dialog instanceof HTMLDialogElement)) throw new Error(`Expected stacked dialog: ${label}`);- return dialog;-}-describe('SaveAgentButton', () => {beforeEach(() => {agentSpec = {@@ -205,36 +198,38 @@ describe('SaveAgentButton', () => {fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));const dialog = await screen.findByRole('dialog', { name: 'Save agent' });- expect(dialog).toHaveClass('bg-card-bg', 'text-text-primary');+ expect(dialog).toHaveClass('bg-card-bg', 'text-text-primary', 'md:ml-auto', 'md:mr-0', 'md:h-dvh');expect(within(dialog).getByLabelText('Agent name')).toHaveClass('border-input-border','bg-input-box-bg','text-text-primary','focus-visible:ring-focus-ring/40',);- expect(within(dialog).getByLabelText('Instructions')).toHaveClass(- 'border-input-border',- 'bg-input-box-bg',- 'text-text-primary',- 'focus-visible:ring-focus-ring/40',- );- expect(within(dialog).queryByText('file downloads:')).not.toBeInTheDocument();- expect(within(dialog).queryByText('compaction threshold:')).not.toBeInTheDocument();+ expect(within(dialog).queryByLabelText('Description')).not.toBeInTheDocument();+ expect(within(dialog).queryByRole('button', { name: 'Edit Model' })).not.toBeInTheDocument();+ expect(within(dialog).queryByRole('button', { name: 'Edit Runtime Config' })).not.toBeInTheDocument();+ expect(within(dialog).queryByRole('button', { name: 'Edit Connectors' })).not.toBeInTheDocument();+ expect(within(dialog).queryByRole('button', { name: 'Edit Skills' })).not.toBeInTheDocument();});- it('removes an MCP server directly from the save modal', async () => {+ it('preserves configuration without exposing unsupported fields', async () => {const saveAgent = vi.fn(async (): Promise<SaveAgentResult> => ({ agentId: 'agent-1' }));renderButton({ saveAgent });fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));const dialog = await screen.findByRole('dialog', { name: 'Save agent' });fireEvent.change(within(dialog).getByLabelText('Agent name'), { target: { value: 'writer' } });- fireEvent.click(within(dialog).getByRole('button', { name: 'Remove GitHub' }));fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));await waitFor(() =>expect(saveAgent).toHaveBeenCalledWith(- expect.objectContaining({ agentSpec: expect.objectContaining({ mcpServers: [] }) }),+ expect.objectContaining({+ agentSpec: expect.objectContaining({+ instructions: 'Be helpful.',+ mcpServers: [{ id: 'github', name: 'GitHub' }],+ skills: [{ id: 'research', name: 'Research' }],+ }),+ }),),);});@@ -242,7 +237,8 @@ describe('SaveAgentButton', () => {it('opens with the latest runtime spec after flushing pending picker edits', async () => {const pendingFlush = deferred<undefined>();flushAgentSpec.mockReturnValueOnce(pendingFlush.promise);- const rendered = renderButton();+ const saveAgent = vi.fn(async (): Promise<SaveAgentResult> => ({ agentId: 'agent-1' }));+ const rendered = renderButton({ saveAgent });fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));await waitFor(() => expect(flushAgentSpec).toHaveBeenCalledOnce());@@ -258,28 +254,48 @@ describe('SaveAgentButton', () => {pendingFlush.resolve(undefined);const dialog = await screen.findByRole('dialog', { name: 'Save agent' });- expect(within(dialog).getByLabelText('Instructions')).toHaveValue('Latest flushed instructions.');- expect(within(dialog).getByText('generative UI:').parentElement).toHaveTextContent('off');+ fireEvent.change(within(dialog).getByLabelText('Agent name'), { target: { value: 'latest-agent' } });+ fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));- fireEvent.click(within(dialog).getByRole('button', { name: 'Edit Connectors' }));- const mcpDialog = await findStackedDialog('Select MCP Tools');- expect(await within(mcpDialog).findByLabelText('Slack selected')).toBeInTheDocument();+ await waitFor(() =>+ expect(saveAgent).toHaveBeenCalledWith(+ expect.objectContaining({+ agentSpec: expect.objectContaining({+ instructions: 'Latest flushed instructions.',+ mcpServers: [{ id: 'slack', name: 'Slack' }],+ skills: [{ id: 'writing', name: 'Writing' }],+ config: { generativeUi: { enabled: false } },+ }),+ }),+ ),+ );});it('uses the drawer instruction draft when opening before debounce sync completes', async () => {+ const saveAgent = vi.fn(async (): Promise<SaveAgentResult> => ({ agentId: 'agent-1' }));renderButton({+ saveAgent,children: <SaveAgentButton instructionsOverride="Instructions currently visible in the drawer." />,});fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));const dialog = await screen.findByRole('dialog', { name: 'Save agent' });+ fireEvent.change(within(dialog).getByLabelText('Agent name'), { target: { value: 'writer' } });+ fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));- expect(within(dialog).getByLabelText('Instructions')).toHaveValue('Instructions currently visible in the drawer.');- expect(within(dialog).getByText('gpt-4.1')).toBeInTheDocument();+ await waitFor(() =>+ expect(saveAgent).toHaveBeenCalledWith(+ expect.objectContaining({+ agentSpec: expect.objectContaining({ instructions: 'Instructions currently visible in the drawer.' }),+ }),+ ),+ );});it('flushes the shared instruction draft when opening Save Agent', async () => {+ const saveAgent = vi.fn(async (): Promise<SaveAgentResult> => ({ agentId: 'agent-1' }));renderButton({+ saveAgent,children: (<AgentConfigInstructionsProvider><SaveWithInstructionDraft />@@ -290,11 +306,19 @@ describe('SaveAgentButton', () => {fireEvent.click(screen.getByRole('button', { name: 'Edit instructions' }));fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));const dialog = await screen.findByRole('dialog', { name: 'Save agent' });+ fireEvent.change(within(dialog).getByLabelText('Agent name'), { target: { value: 'writer' } });+ fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));expect(updateAgentSpec).toHaveBeenCalledWith({instructions: 'Instructions currently visible in the drawer.',});- expect(within(dialog).getByLabelText('Instructions')).toHaveValue('Instructions currently visible in the drawer.');+ await waitFor(() =>+ expect(saveAgent).toHaveBeenCalledWith(+ expect.objectContaining({+ agentSpec: expect.objectContaining({ instructions: 'Instructions currently visible in the drawer.' }),+ }),+ ),+ );});it('labels an existing mutable binding as Update Agent and submits an update', async () => {@@ -316,35 +340,16 @@ describe('SaveAgentButton', () => {);});- it('discards modal-only changes when closed', async () => {+ it('discards drawer-only changes when closed', async () => {renderButton();fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));const dialog = await screen.findByRole('dialog', { name: 'Save agent' });fireEvent.change(within(dialog).getByLabelText('Agent name'), { target: { value: 'discard-me' } });- fireEvent.change(within(dialog).getByLabelText('Instructions'), { target: { value: 'Discarded instructions' } });fireEvent.click(within(dialog).getByRole('button', { name: 'Close' }));fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));const reopened = await screen.findByRole('dialog', { name: 'Save agent' });expect(within(reopened).getByLabelText('Agent name')).toHaveValue('');- expect(within(reopened).getByLabelText('Instructions')).toHaveValue('Be helpful.');- });-- it('opens model editing as a stacked dialog', async () => {- renderButton();- fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));- const saveDialog = await screen.findByRole('dialog', { name: 'Save agent' });- fireEvent.click(within(saveDialog).getByRole('button', { name: 'Edit Model' }));-- const modelDialog = document.querySelectorAll('dialog')[1];- expect(modelDialog).toBeInstanceOf(HTMLDialogElement);- if (!(modelDialog instanceof HTMLDialogElement)) throw new Error('expected stacked model dialog');- expect(modelDialog).toHaveAttribute('aria-label', 'Edit model');- expect(saveDialog).toHaveAttribute('open');- expect(modelDialog).toHaveAttribute('open');- fireEvent.click(within(modelDialog).getByRole('button', { name: 'Anthropic' }));- fireEvent.click(await within(modelDialog).findByRole('option', { name: /claude-sonnet-4-6/ }));- expect(within(saveDialog).getByText('claude-sonnet-4-6')).toBeInTheDocument();});it('submits one explicit create request and adopts the persisted session spec', async () => {@@ -356,10 +361,6 @@ describe('SaveAgentButton', () => {fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));const dialog = await screen.findByRole('dialog', { name: 'Save agent' });fireEvent.change(within(dialog).getByLabelText('Agent name'), { target: { value: 'my-agent' } });- fireEvent.click(within(dialog).getByRole('button', { name: 'Edit Runtime Config' }));- const runtimeDialog = await findStackedDialog('Edit Runtime Config');- fireEvent.click(within(runtimeDialog).getByRole('switch', { name: 'Generative UI' }));- fireEvent.click(within(runtimeDialog).getByRole('button', { name: 'Close' }));fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));await waitFor(() => expect(saveAgent).toHaveBeenCalledOnce());@@ -370,9 +371,7 @@ describe('SaveAgentButton', () => {instructions: 'Be helpful.',mcpServers: [{ id: 'github', name: 'GitHub' }],skills: [{ id: 'research', name: 'Research' }],- config: {- generativeUi: { enabled: false },- },+ config: undefined,},intent: 'create',sessionId: 'draft-1',@@ -385,7 +384,7 @@ describe('SaveAgentButton', () => {);});- it('preserves opaque mount fields while adding catalog selections', async () => {+ it('preserves opaque mount fields without exposing resource editors', async () => {agentSpec = {model: { name: 'openai/gpt-4.1' },mcpServers: [{ id: 'github', name: 'GitHub', enableTools: ['@read-only'], config: { project: 'sdk' } }],@@ -396,66 +395,15 @@ describe('SaveAgentButton', () => {fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));const saveDialog = await screen.findByRole('dialog', { name: 'Save agent' });fireEvent.change(within(saveDialog).getByLabelText('Agent name'), { target: { value: 'preserved-agent' } });-- fireEvent.click(within(saveDialog).getByRole('button', { name: 'Edit Connectors' }));- const mcpDialog = await findStackedDialog('Select MCP Tools');- fireEvent.click(within(mcpDialog).getByRole('button', { name: 'Slack' }));- fireEvent.click(within(mcpDialog).getByRole('switch', { name: 'Enable all tools' }));- fireEvent.click(within(mcpDialog).getByRole('button', { name: 'Save' }));-- fireEvent.click(within(saveDialog).getByRole('button', { name: 'Edit Skills' }));- const skillsDialog = await findStackedDialog('Edit skills');- fireEvent.click(await within(skillsDialog).findByRole('menuitemcheckbox', { name: /Writing/ }));- fireEvent.click(within(skillsDialog).getByRole('button', { name: 'Close' }));fireEvent.click(within(saveDialog).getByRole('button', { name: 'Save changes' }));await waitFor(() => expect(saveAgent).toHaveBeenCalledOnce());expect(saveAgent).toHaveBeenCalledWith(expect.objectContaining({agentSpec: expect.objectContaining({- mcpServers: [- { id: 'github', name: 'GitHub', enableTools: ['@read-only'], config: { project: 'sdk' } },- { id: 'slack', name: 'Slack', enableTools: ['@all'] },- ],- skills: [- { id: 'research', name: 'Research', fqn: 'skills/research:1', config: { depth: 2 } },- { id: 'writing', name: 'Writing' },- ],- }),- }),- );- });-- it('allows unavailable selected connectors and skills to be removed', async () => {- const saveAgent = vi.fn(async (): Promise<SaveAgentResult> => ({ agentId: 'agent-1' }));- renderButton({- saveAgent,- serverOverrides: {- getCapabilities: async () => ({- data: {- sandbox: { enabled: true },- skill: { enabled: false, reason: 'Configure a sandbox provider' },- },+ mcpServers: [{ id: 'github', name: 'GitHub', enableTools: ['@read-only'], config: { project: 'sdk' } }],+ skills: [{ id: 'research', name: 'Research', fqn: 'skills/research:1', config: { depth: 2 } }],}),- getMcp: async () => [{ id: 'github', name: 'GitHub', authenticated: false }],- },- });- fireEvent.click(screen.getByRole('button', { name: 'Save Agent' }));- const saveDialog = await screen.findByRole('dialog', { name: 'Save agent' });- fireEvent.change(within(saveDialog).getByLabelText('Agent name'), { target: { value: 'trimmed-agent' } });-- fireEvent.click(within(saveDialog).getByRole('button', { name: 'Remove GitHub' }));-- fireEvent.click(within(saveDialog).getByRole('button', { name: 'Edit Skills' }));- const skillsDialog = await findStackedDialog('Edit skills');- fireEvent.click(await within(skillsDialog).findByRole('menuitemcheckbox', { name: /Research/ }));- fireEvent.click(within(skillsDialog).getByRole('button', { name: 'Close' }));- fireEvent.click(within(saveDialog).getByRole('button', { name: 'Save changes' }));-- await waitFor(() => expect(saveAgent).toHaveBeenCalledOnce());- expect(saveAgent).toHaveBeenCalledWith(- expect.objectContaining({- agentSpec: expect.objectContaining({ mcpServers: [], skills: [] }),}),);});@@ -469,9 +417,6 @@ describe('SaveAgentButton', () => {fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));expect(within(dialog).getByLabelText('Agent name')).toBeDisabled();- expect(within(dialog).getByLabelText('Instructions')).toBeDisabled();- expect(within(dialog).getByRole('button', { name: 'Edit Model' })).toBeDisabled();- expect(within(dialog).getByRole('button', { name: 'Edit Runtime Config' })).toBeDisabled();expect(within(dialog).getByRole('button', { name: 'Cancel' })).toBeDisabled();pending.resolve({ agentId: 'agent-1' });diff --git a/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx b/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsxindex 9aaed083b..35e7cf5b3 100644--- a/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx+++ b/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx@@ -218,7 +218,7 @@ describe('TrueForgeUI', () => {expect(await screen.findByRole('status')).toHaveTextContent('Select Sandbox first');});- it('shares catalog data with the Save Agent stacked editors', async () => {+ it('keeps configuration editors out of Save Agent', async () => {const getModels = vi.fn(async () => [{id: 'openai-main/gpt-4.1',@@ -241,17 +241,10 @@ describe('TrueForgeUI', () => {fireEvent.click(await screen.findByRole('button', { name: 'Start new agent' }));fireEvent.click(await screen.findByRole('button', { name: 'Save Agent' }));const saveDialog = await screen.findByRole('dialog', { name: 'Save agent' });- fireEvent.click(within(saveDialog).getByRole('button', { name: 'Edit Model' }));-- const modelDialog = document.querySelector('dialog[aria-label="Edit model"]');- if (!(modelDialog instanceof HTMLDialogElement)) throw new Error('expected stacked model dialog');- expect(await within(modelDialog).findByRole('option', { name: /gpt-4.1/ })).toBeInTheDocument();- fireEvent.click(within(modelDialog).getByRole('button', { name: 'Close' }));-- fireEvent.click(within(saveDialog).getByRole('button', { name: 'Edit Connectors' }));- const mcpDialog = document.querySelector('dialog[aria-label="Select MCP Tools"]');- if (!(mcpDialog instanceof HTMLDialogElement)) throw new Error('expected stacked MCP dialog');- expect(await within(mcpDialog).findByText('GitHub')).toBeInTheDocument();+ expect(within(saveDialog).getByLabelText('Agent name')).toBeInTheDocument();+ expect(within(saveDialog).queryByLabelText('Description')).not.toBeInTheDocument();+ expect(within(saveDialog).queryByRole('button', { name: 'Edit Model' })).not.toBeInTheDocument();+ expect(within(saveDialog).queryByRole('button', { name: 'Edit Connectors' })).not.toBeInTheDocument();expect(getModels).toHaveBeenCalled();expect(getMcp).toHaveBeenCalled();expect(getSkills).toHaveBeenCalled();diff --git a/packages/trueforge-ui/test/publicUiExports.test.ts b/packages/trueforge-ui/test/publicUiExports.test.tsindex 5f4560117..4b5c2b884 100644--- a/packages/trueforge-ui/test/publicUiExports.test.ts+++ b/packages/trueforge-ui/test/publicUiExports.test.ts@@ -105,7 +105,6 @@ const expectedRuntimeExports: Array<keyof typeof sdk> = ['SandboxToolCallCard','SaveAgentButton','SaveAgentForm',- 'SaveAgentFormFields','ScrollToBottomButton','SelectAgentEmptyState','ServerProvider',