Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): close pr 441 review findings
Andy Pavia2491a06b19fc
diff --git a/control-ui/app/constants/marketplaceEntryTypes.ts b/control-ui/app/constants/marketplaceEntryTypes.tsindex 26ee13466..616e66ef1 100644--- a/control-ui/app/constants/marketplaceEntryTypes.ts+++ b/control-ui/app/constants/marketplaceEntryTypes.ts@@ -5,8 +5,15 @@ export const GUARDRAIL_ENTRY_TYPE = 'llm-hook'// Human labels for the active-filter notice on the entries list. Only types// that something links to with `?type=` need an entry here.-export const MARKETPLACE_ENTRY_TYPE_LABELS: Record<string, string> = {- 'llm-hook': 'Guardrail hooks',- 'mcp-server': 'Connectors',- recipe: 'Plugins',-}+//+// Null-prototype on purpose: the keys are indexed with an untrusted `?type=`+// value off the URL, so an inherited key (`toString`, `constructor`, …) would+// otherwise resolve to a function and be treated as a real label.+export const MARKETPLACE_ENTRY_TYPE_LABELS: Record<string, string> = Object.assign(+ Object.create(null) as Record<string, string>,+ {+ 'llm-hook': 'Guardrail hooks',+ 'mcp-server': 'Connectors',+ recipe: 'Plugins',+ }+)diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsxindex 541bddb42..3ddb5c442 100644--- a/control-ui/app/hosts/[name]/page.tsx+++ b/control-ui/app/hosts/[name]/page.tsx@@ -630,7 +630,9 @@ export default function HostDetailsPage() {// Reload guardrails/server state while preserving any drafts left open// in the Overview or Model tabs.await loadData('none')- showToast('Guardrails saved.', { tone: 'success' })+ // No toast here on purpose: HostGuardrailsSection names the hook it+ // just changed once this resolves, and a generic 'saved' alongside it+ // would stack two success toasts on a single remove.} catch (e) {const status = (e as { status?: number } | null)?.statusconst code = (e as { code?: string } | null)?.code@@ -641,8 +643,8 @@ export default function HostDetailsPage() {} else {setError(e instanceof Error ? e.message : 'Failed to save guardrails')}- // Re-throw so HostGuardrailsSection stays in edit mode and keeps the- // operator's draft alongside the error/conflict banner.+ // Re-throw so HostGuardrailsSection knows the save failed and skips+ // its success toast, leaving the error/conflict banner to explain.throw e} finally {setBusy(false)diff --git a/control-ui/components/HostGuardrailsSection/index.tsx b/control-ui/components/HostGuardrailsSection/index.tsxindex b3fe1c91a..92a43dcf6 100644--- a/control-ui/components/HostGuardrailsSection/index.tsx+++ b/control-ui/components/HostGuardrailsSection/index.tsx@@ -87,7 +87,7 @@ export function HostGuardrailsSection({const disabled = busy || savingreturn (- <section className="cu-guardrails-tab" aria-label="Hooks">+ <section aria-label="Hooks"><div className="cu-access-section"><div className="cu-access-section__header"><p className="cu-muted cu-access-section__description">diff --git a/control-ui/components/PublisherView/OwnedEntries.tsx b/control-ui/components/PublisherView/OwnedEntries.tsxindex 42034b12e..d374741d3 100644--- a/control-ui/components/PublisherView/OwnedEntries.tsx+++ b/control-ui/components/PublisherView/OwnedEntries.tsx@@ -220,7 +220,10 @@ export function OwnedEntries({[entries, typeFilter, activeTypeLabel])- const hasPrivateEntries = visibleEntries.some(e => e.visibility === 'private')+ // Deliberately org-wide, not `visibleEntries`: the notice describes what+ // cross-org sharing does to this org's private entries, so a `?type=` filter+ // that happens to hide them all must not make it disappear.+ const hasPrivateEntries = entries.some(e => e.visibility === 'private')// Collapse same-named entries into one row (latest leads); expanding a row// reveals the previous versions, each individually installable.const grouped = groupByName(visibleEntries)diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsxindex c6e9ba36a..726bdea78 100644--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx@@ -46,8 +46,6 @@ vi.mock('../../lib/api', () => ({getAgentUsers: vi.fn(),getHost: vi.fn(),getHostDetailBundle: vi.fn(),- // The Hooks sub-tab loads the installed LlmHooks to populate its picker.- getLlmHooks: vi.fn().mockResolvedValue({ items: [] }),updateAdminTeamAgents: vi.fn(),updateAdminUserAgents: vi.fn(),// The model picker loads the operator allowlist via useLlmAllowedModels.diff --git a/control-ui/components/__tests__/HostGuardrailsSection.test.tsx b/control-ui/components/__tests__/HostGuardrailsSection.test.tsxindex c10bc11c5..369f85b7f 100644--- a/control-ui/components/__tests__/HostGuardrailsSection.test.tsx+++ b/control-ui/components/__tests__/HostGuardrailsSection.test.tsx@@ -117,6 +117,7 @@ describe('HostGuardrailsSection', () => {const saved = onSave.mock.calls[0][0] as HostGuardrailsexpect(saved.hooks).toEqual({})expect(saved.builtins).toEqual(GUARDRAILS.builtins)+ expect(saved.limits).toEqual(GUARDRAILS.limits)})it('a declined confirm leaves the hook in place', async () => {diff --git a/control-ui/components/__tests__/OwnedEntries.test.tsx b/control-ui/components/__tests__/OwnedEntries.test.tsxindex ca564313d..4e79b10b8 100644--- a/control-ui/components/__tests__/OwnedEntries.test.tsx+++ b/control-ui/components/__tests__/OwnedEntries.test.tsx@@ -209,6 +209,42 @@ describe('OwnedEntries', () => {expect(screen.queryByText(/showing .* only/i)).toBeNull()})+ it('a type filter naming an inherited object key falls back to the full list', async () => {+ // `?type=toString` used to resolve to Object.prototype.toString off the+ // label map, which read as a real label and crashed the render.+ mockSearchParams = new URLSearchParams('type=toString')+ vi.mocked(api.getOwnedRegistryEntries).mockResolvedValue({+ data: [{ name: '@acme/db', version: '2.0.0', serverMode: 'http', status: 'published' }],+ } as never)+ render(<OwnedEntries orgScope="acme" />)++ expect(await screen.findByText('@acme/db')).toBeInTheDocument()+ expect(screen.queryByText(/showing .* only/i)).toBeNull()+ })++ it('keeps the sharing notice when a type filter hides every private entry', async () => {+ mockSearchParams = new URLSearchParams('type=llm-hook')+ vi.mocked(api.getOwnedRegistryEntries).mockResolvedValue({+ data: [+ {+ name: '@acme/redactor',+ version: '1.0.0',+ entryType: 'llm-hook',+ visibility: 'public',+ status: 'published',+ },+ { name: '@acme/db', version: '2.0.0', serverMode: 'http', visibility: 'private' },+ ],+ } as never)+ render(<OwnedEntries orgScope="acme" canShare={false} sharingUnavailable />)++ await screen.findByText('@acme/redactor')+ // The private entry is filtered out of the table, but the notice describes+ // org state, so it must still explain why sharing is unavailable.+ expect(screen.queryByText('@acme/db')).toBeNull()+ expect(screen.getByText(/Cross-org sharing/i)).toBeInTheDocument()+ })+it('error + Retry re-fetches', async () => {vi.mocked(api.getOwnedRegistryEntries).mockRejectedValueOnce(Object.assign(new Error('boom'), { status: 500 }))diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex cb12f538b..e1f64bb94 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.447",+ "version": "0.1.448","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.447",+ "version": "0.1.448","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/llm-providers": "file:../packages/llm-providers",diff --git a/control-ui/package.json b/control-ui/package.jsonindex a389c6693..b9acd05fc 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.447",+ "version": "0.1.448","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",