Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): clarify agent grant conflicts
Alfredo Lopezb609712a28ee
diff --git a/control-ui/lib/__tests__/agentGrantApi.test.ts b/control-ui/lib/__tests__/agentGrantApi.test.tsindex b55eeece9..52a580ca6 100644--- a/control-ui/lib/__tests__/agentGrantApi.test.ts+++ b/control-ui/lib/__tests__/agentGrantApi.test.ts@@ -1,9 +1,9 @@import { afterEach, describe, expect, it, vi } from 'vitest'import { updateAdminTeamAgents, updateAdminUserAgents } from '../api'-function jsonResponse(body: unknown): Response {+function jsonResponse(body: unknown, status = 200): Response {return new Response(JSON.stringify(body), {- status: 200,+ status,headers: { 'content-type': 'application/json' },})}@@ -54,4 +54,18 @@ describe('agent grant replacement API helpers', () => {expectedCurrentAgentNames: [],})})++ it.each([+ [412, 'precondition_failed', 'This item changed since it was loaded.'],+ [409, 'deleted_agent_history_limit_exceeded', 'No existing history was removed.'],+ [428, 'agent_grant_precondition_required', 'Reload the page and try again.'],+ ])('keeps agent-grant conflicts actionable for status %i', async (status, code, message) => {+ vi.spyOn(globalThis, 'fetch').mockResolvedValue(jsonResponse({ error: code }, status))++ await expect(updateAdminUserAgents('user-1', ['active-agent'], ['active-agent'])).rejects.toMatchObject({+ status,+ code,+ message: expect.stringContaining(message),+ })+ })})diff --git a/control-ui/lib/api.ts b/control-ui/lib/api.tsindex 36e2edda7..c1fc75391 100644--- a/control-ui/lib/api.ts+++ b/control-ui/lib/api.ts@@ -100,9 +100,15 @@ function formatApiError(res: Response, text: string): Error {? 'This admin invitation is invalid or expired.': detail === 'member password must be between 8 and 256 characters'? 'Desktop App password must be between 8 and 256 characters.'- : detail === 'password must be between 8 and 256 characters'- ? 'Password must be between 8 and 256 characters.'- : // Exact match is correct HERE: control-ui calls control-api directly,+ : detail === 'password must be between 8 and 256 characters'+ ? 'Password must be between 8 and 256 characters.'+ : detail === 'precondition_failed'+ ? 'This item changed since it was loaded. Reload the page, review the latest state, and try again.'+ : detail === 'agent_grant_precondition_required'+ ? 'Agent access could not be updated because the page did not include its current access state. Reload the page and try again.'+ : detail === 'deleted_agent_history_limit_exceeded'+ ? 'Agent access was not updated because the deleted-agent history limit was reached. No existing history was removed. Reload the page, review the current access, and try again.'+ : // Exact match is correct HERE: control-ui calls control-api directly,// so a member-registration 503 arrives as the bare { error: '<code>' }// body. profile-ui reaches these same codes through external-rest-api,// whose error middleware wraps any 5xx into { message: '...: <code>' },