Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): preserve unmodeled context spec fields in connector/filesystem saves (R5-M3)
Diego Zacarias9ce1b4baad39
diff --git a/control-ui/app/contexts/[name]/page.tsx b/control-ui/app/contexts/[name]/page.tsxindex fe11a6926..6608d126a 100644--- a/control-ui/app/contexts/[name]/page.tsx+++ b/control-ui/app/contexts/[name]/page.tsx@@ -464,16 +464,21 @@ export default function ContextDetailsPage() {setBusy(true)setError('')try {- await updateContext(routeName, {- spec: {- contextId: resolvedContextId,- // Echo the persisted display name so a connector edit never drops it.- ...(savedDisplayName.trim() ? { displayName: savedDisplayName.trim() } : {}),- description: descriptionDraft.trim(),- mcpServers: nextServers,- sharedFileSystems: sharedFileSystemsDraft,- },- })+ // Full-replace PUT: spread the loaded spec so additive fields the form+ // doesn't model (e.g. spec.gfs) survive a connector edit, then overwrite+ // only the fields this handler owns (all re-echoed from current state).+ const nextSpec: Record<string, unknown> = {+ ...loadedSpec,+ contextId: resolvedContextId,+ description: descriptionDraft.trim(),+ mcpServers: nextServers,+ sharedFileSystems: sharedFileSystemsDraft,+ }+ // Echo the persisted display name; a cleared name must REMOVE it, not leave+ // the spread's stale value — so a delete is required (mirrors save()).+ if (savedDisplayName.trim()) nextSpec.displayName = savedDisplayName.trim()+ else delete nextSpec.displayName+ await updateContext(routeName, { spec: nextSpec as unknown as ContextSpec })setMcpServersDraft(nextServers)showToast('Connectors updated.', { tone: 'success' })} catch (e) {@@ -487,16 +492,21 @@ export default function ContextDetailsPage() {setBusy(true)setError('')try {- await updateContext(routeName, {- spec: {- contextId: resolvedContextId,- // Echo the persisted display name so an SFS edit never drops it.- ...(savedDisplayName.trim() ? { displayName: savedDisplayName.trim() } : {}),- description: descriptionDraft.trim(),- mcpServers: mcpServersDraft,- sharedFileSystems: nextRefs,- },- })+ // Full-replace PUT: spread the loaded spec so additive fields the form+ // doesn't model (e.g. spec.gfs) survive an SFS edit, then overwrite only+ // the fields this handler owns (all re-echoed from current state).+ const nextSpec: Record<string, unknown> = {+ ...loadedSpec,+ contextId: resolvedContextId,+ description: descriptionDraft.trim(),+ mcpServers: mcpServersDraft,+ sharedFileSystems: nextRefs,+ }+ // Echo the persisted display name; a cleared name must REMOVE it, not leave+ // the spread's stale value — so a delete is required (mirrors save()).+ if (savedDisplayName.trim()) nextSpec.displayName = savedDisplayName.trim()+ else delete nextSpec.displayName+ await updateContext(routeName, { spec: nextSpec as unknown as ContextSpec })setSharedFileSystemsDraft(nextRefs)showToast('Shared filesystems updated.', { tone: 'success' })} catch (e) {diff --git a/control-ui/app/contexts/__tests__/ContextDetail.spec-preserve.test.tsx b/control-ui/app/contexts/__tests__/ContextDetail.spec-preserve.test.tsxindex dcc8c023e..6ce8882c4 100644--- a/control-ui/app/contexts/__tests__/ContextDetail.spec-preserve.test.tsx+++ b/control-ui/app/contexts/__tests__/ContextDetail.spec-preserve.test.tsx@@ -163,3 +163,75 @@ describe('ContextDetailsPage spec preservation on update (R5-M2)', () => {expect(spec.displayName).toBe('Prod Ctx')})})++describe('ContextDetailsPage spec preservation on connector/SFS edits (R5-M3)', () => {+ // spec.gfs — modeled on the real context CRD (charts/clerum-crds/crds/context.yaml,+ // spec.gfs.mounts[].{drive,target,scopes}) — is an additive field the form has no+ // input for. saveMcpServers / saveSharedFileSystems build a full-replace PUT, so+ // without a spread of the loaded spec they silently drop it.+ const gfs = {+ mounts: [{ drive: 'main', target: '/data/shared', scopes: ['gfs.read'] }],+ }++ beforeEach(() => {+ vi.clearAllMocks()+ mockParams = { name: 'prod-ctx' }+ })++ it('saveMcpServers preserves an unmodeled spec field (gfs) while applying the connector change', async () => {+ mockContext({+ metadata: { name: 'prod-ctx' },+ spec: {+ contextId: 'prod-ctx',+ description: 'Original description',+ mcpServers: ['srv-a', 'srv-b'],+ displayName: 'Prod Ctx',+ gfs,+ },+ })++ render(<ContextDetailsPage />)+ // Connectors is the default tab — remove one connector to trigger saveMcpServers.+ fireEvent.click(await screen.findByRole('button', { name: 'Remove connector srv-b' }))++ await waitFor(() => expect(api.updateContext).toHaveBeenCalled())+ const spec = lastPutSpec()+ // The unmodeled field survives the connector edit.+ expect(spec.gfs).toEqual(gfs)+ // The change the handler owns is applied…+ expect(spec.mcpServers).toEqual(['srv-a'])+ // …and the echoed fields are intact.+ expect(spec.displayName).toBe('Prod Ctx')+ expect(spec.contextId).toBe('prod-ctx')+ })++ it('saveSharedFileSystems preserves an unmodeled spec field (gfs) while applying the SFS change', async () => {+ // Land directly on the agent-files tab, where the detach control lives.+ mockParams = { name: 'prod-ctx', tab: 'agent-files' }+ mockContext({+ metadata: { name: 'prod-ctx' },+ spec: {+ contextId: 'prod-ctx',+ description: 'Original description',+ mcpServers: ['srv-a'],+ sharedFileSystems: [{ name: 'sfs-a', mountPath: '/workspace/sfs-a' }],+ displayName: 'Prod Ctx',+ gfs,+ },+ })++ render(<ContextDetailsPage />)+ fireEvent.click(await screen.findByRole('button', { name: 'Detach shared filesystem sfs-a' }))++ await waitFor(() => expect(api.updateContext).toHaveBeenCalled())+ const spec = lastPutSpec()+ // The unmodeled field survives the SFS edit.+ expect(spec.gfs).toEqual(gfs)+ // The change the handler owns is applied…+ expect(spec.sharedFileSystems).toEqual([])+ // …and the echoed fields are intact.+ expect(spec.mcpServers).toEqual(['srv-a'])+ expect(spec.displayName).toBe('Prod Ctx')+ expect(spec.contextId).toBe('prod-ctx')+ })+})diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex f7fab9862..6d08b519c 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.395",+ "version": "0.1.396","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.395",+ "version": "0.1.396","dependencies": {"@clerum/llm-providers": "file:../packages/llm-providers","@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",diff --git a/control-ui/package.json b/control-ui/package.jsonindex c056b04f4..0e21fe746 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.395",+ "version": "0.1.396","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",