Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): r1-h1 refresh identity documents after save
Josué126d698847da
diff --git a/control-ui/components/HostIdentityTab/index.tsx b/control-ui/components/HostIdentityTab/index.tsxindex d8ac50462..e742cdd42 100644--- a/control-ui/components/HostIdentityTab/index.tsx+++ b/control-ui/components/HostIdentityTab/index.tsx@@ -109,37 +109,60 @@ export function HostIdentityTab({ hostName, onActionsChange }: HostIdentityTabPrconst nextFields = { ...current.fields, [currentConfig.key]: value }setState(prev => ({ ...prev, error: '', saving: true }))+ let result: { resourceVersion: string }try {- const result = await updateHostPersonalization(hostName, {+ result = await updateHostPersonalization(hostName, {agents: nextFields.agents,identity: nextFields.identity,resourceVersion: current.resourceVersion,soul: nextFields.soul,user: nextFields.user,})+ } catch (error) {+ const err = error as { message?: string; status?: number }+ const isConflict = err.status === 409 || /409/.test(err.message ?? '')+ const message = isConflict+ ? 'Someone else updated these identity files. Reload the latest version and reapply this draft.'+ : err.message || 'Save failed'+ setState(prev => ({+ ...prev,+ error: message,+ reloadHint: isConflict,+ saving: false,+ }))+ showToast(message, { tone: 'error' })+ return+ }++ try {+ const authoritative = await getHostPersonalization(hostName)+ const authoritativeFields = fieldsFromPayload(authoritative)setState(prev => ({...prev,error: '',- fields: nextFields,- initial: { ...nextFields },+ fields: authoritativeFields,+ initial: { ...authoritativeFields },reloadHint: false,- resourceVersion: result.resourceVersion,+ resourceVersion: authoritative.resourceVersion,saving: false,}))setEditing(false)showToast(`${currentConfig.fileName} saved.`, { tone: 'success' })} catch (error) {- const err = error as { message?: string; status?: number }- const isConflict = err.status === 409 || /409/.test(err.message ?? '')- const message = isConflict- ? 'Someone else updated these identity files. Reload the latest version and reapply this draft.'- : err.message || 'Save failed'+ const message =+ error instanceof Error+ ? `Document saved, but the latest identity files could not be reloaded: ${error.message}`+ : 'Document saved, but the latest identity files could not be reloaded.'setState(prev => ({...prev,error: message,- reloadHint: isConflict,+ fields: nextFields,+ initial: { ...nextFields },+ reloadHint: false,+ resourceVersion: result.resourceVersion,saving: false,}))+ setEditing(false)showToast(message, { tone: 'error' })}}diff --git a/control-ui/components/__tests__/HostIdentityTab.test.tsx b/control-ui/components/__tests__/HostIdentityTab.test.tsxindex fe698b9cd..911bc35cf 100644--- a/control-ui/components/__tests__/HostIdentityTab.test.tsx+++ b/control-ui/components/__tests__/HostIdentityTab.test.tsx@@ -75,8 +75,15 @@ describe('HostIdentityTab', () => {expect(api.updateHostPersonalization).not.toHaveBeenCalled()})- it('saves one document through the aggregate Host payload and current resourceVersion', async () => {+ it('saves one document and renders the authoritative refreshed content', async () => {vi.mocked(api.updateHostPersonalization).mockResolvedValue({ resourceVersion: '2' })+ vi.mocked(api.getHostPersonalization)+ .mockResolvedValueOnce(initialFiles)+ .mockResolvedValueOnce({+ ...initialFiles,+ identity: '## Canonical updated mission',+ resourceVersion: '2',+ })renderTab()const dialog = await openIdentityEditor()fireEvent.change(within(dialog).getByLabelText('Identity markdown'), {@@ -93,9 +100,10 @@ describe('HostIdentityTab', () => {user: initialFiles.user,}))+ await waitFor(() => expect(api.getHostPersonalization).toHaveBeenCalledTimes(2))await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())expect(screen.getByRole('article', { name: 'Rendered Identity document' })).toHaveTextContent(- 'Updated mission'+ 'Canonical updated mission')expect(screen.getByText('IDENTITY.md saved.')).toBeInTheDocument()})diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex ca895a276..8dc78587e 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.625",+ "version": "0.1.626","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.625",+ "version": "0.1.626","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex d09a223d1..318df15d4 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.625",+ "version": "0.1.626","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",