Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(control-ui): filter the org marketplace entries list by entry type

Andy Paviaf52ee95a817b
diff --git a/control-ui/app/constants/marketplaceEntryTypes.ts b/control-ui/app/constants/marketplaceEntryTypes.ts
new file mode 100644
index 000000000..26ee13466
--- /dev/null
+++ b/control-ui/app/constants/marketplaceEntryTypes.ts
@@ -0,0 +1,12 @@
+// Registry `entry_type` values, as sent on the wire. Shared by the surfaces
+// that link into a type-filtered entries list and the list that reads the
+// filter back off the URL, so the two never drift apart.
+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',
+}
diff --git a/control-ui/app/constants/routes.ts b/control-ui/app/constants/routes.ts
index 6c0920e00..21b26ed55 100644
--- a/control-ui/app/constants/routes.ts
+++ b/control-ui/app/constants/routes.ts
@@ -79,6 +79,10 @@ export const CONTROL_ROUTES = {
// The org-named tab (design spec §4): everything this deployment owns.
org: '/marketplace/org',
orgEntries: '/marketplace/org/entries',
+ // Same section, pre-filtered by entry type (`?type=llm-hook`). The type is
+ // a filter over one list, not a section of its own, so it stays a query
+ // param rather than becoming a route segment.
+ orgEntriesFiltered: (query?: ControlRouteQuery) => withQuery('/marketplace/org/entries', query),
orgImages: '/marketplace/org/images',
orgCredentials: '/marketplace/org/credentials',
orgConnection: '/marketplace/org/connection',
diff --git a/control-ui/components/PublisherView/OwnedEntries.tsx b/control-ui/components/PublisherView/OwnedEntries.tsx
index f27614388..42034b12e 100644
--- a/control-ui/components/PublisherView/OwnedEntries.tsx
+++ b/control-ui/components/PublisherView/OwnedEntries.tsx
@@ -1,8 +1,9 @@
'use client'
-import React, { Fragment, useCallback, useEffect, useState } from 'react'
-import { useRouter } from 'next/navigation'
+import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react'
+import { useRouter, useSearchParams } from 'next/navigation'
import { IconChevronRight } from '@components/icons'
+import { MARKETPLACE_ENTRY_TYPE_LABELS } from '@constants/marketplaceEntryTypes'
import { CONTROL_ROUTES } from '@constants/routes'
import {
type OwnedRegistryEntry,
@@ -108,6 +109,7 @@ export function OwnedEntries({
sharingUnavailable?: boolean
}) {
const router = useRouter()
+ const searchParams = useSearchParams()
const { showToast } = useToast()
const { confirm, confirmDialog } = useConfirmDialog()
const [entries, setEntries] = useState<OwnedRegistryEntry[]>([])
@@ -207,10 +209,21 @@ export function OwnedEntries({
)
}
- const hasPrivateEntries = entries.some(e => e.visibility === 'private')
+ // `?type=` narrows the list to a single entry kind — this is how "Add hook"
+ // on an agent lands here showing only guardrail hooks. An unrecognised value
+ // filters nothing, so a stale or hand-edited link degrades to the full list
+ // instead of an empty one.
+ const typeFilter = searchParams?.get('type') ?? null
+ const activeTypeLabel = typeFilter ? MARKETPLACE_ENTRY_TYPE_LABELS[typeFilter] : undefined
+ const visibleEntries = useMemo(
+ () => (activeTypeLabel ? entries.filter(e => ownedEntryKind(e) === typeFilter) : entries),
+ [entries, typeFilter, activeTypeLabel]
+ )
+
+ const hasPrivateEntries = visibleEntries.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(entries)
+ const grouped = groupByName(visibleEntries)
return (
<section>
@@ -231,10 +244,25 @@ export function OwnedEntries({
onRetry={() => void load()}
/>
) : null}
+ {!loading && !error && activeTypeLabel ? (
+ <p className="cu-banner cu-banner--info">
+ Showing {activeTypeLabel.toLowerCase()} only.{' '}
+ <button
+ type="button"
+ className="cu-link"
+ onClick={() => router.replace(CONTROL_ROUTES.marketplace.orgEntries)}
+ >
+ Show all entries
+ </button>
+ </p>
+ ) : null}
{!loading && !error && entries.length === 0 ? (
<p>You haven’t published any registry entries yet.</p>
) : null}
- {!loading && !error && entries.length > 0 ? (
+ {!loading && !error && entries.length > 0 && visibleEntries.length === 0 ? (
+ <p>No {activeTypeLabel?.toLowerCase() ?? 'entries'} published yet.</p>
+ ) : null}
+ {!loading && !error && visibleEntries.length > 0 ? (
<>
<div className="cu-table-wrap">
<table className="cu-table">
diff --git a/control-ui/components/__tests__/OwnedEntries.test.tsx b/control-ui/components/__tests__/OwnedEntries.test.tsx
index 491a86967..ca564313d 100644
--- a/control-ui/components/__tests__/OwnedEntries.test.tsx
+++ b/control-ui/components/__tests__/OwnedEntries.test.tsx
@@ -25,9 +25,11 @@ vi.mock('../ConfirmDialog', () => ({
useConfirmDialog: () => ({ confirm: confirmMock, confirmDialog: null }),
}))
-const navigation = vi.hoisted(() => ({ push: vi.fn() }))
+const navigation = vi.hoisted(() => ({ push: vi.fn(), replace: vi.fn() }))
+let mockSearchParams = new URLSearchParams()
vi.mock('next/navigation', () => ({
- useRouter: () => ({ push: navigation.push }),
+ useRouter: () => ({ push: navigation.push, replace: navigation.replace }),
+ useSearchParams: () => mockSearchParams,
}))
function render(ui: React.ReactNode) {
@@ -36,6 +38,7 @@ function render(ui: React.ReactNode) {
afterEach(cleanup)
beforeEach(() => {
vi.clearAllMocks()
+ mockSearchParams = new URLSearchParams()
confirmMock.mockResolvedValue(false)
// Default: nothing installed, so entries show the Install CTA.
vi.mocked(api.getRegistryCatalog).mockResolvedValue(EMPTY_INSTALLED as never)
@@ -167,6 +170,45 @@ describe('OwnedEntries', () => {
expect(await screen.findByText(/haven’t published/i)).toBeInTheDocument()
})
+ it('?type=llm-hook narrows the list to guardrail hooks and offers Show all', async () => {
+ mockSearchParams = new URLSearchParams('type=llm-hook')
+ vi.mocked(api.getOwnedRegistryEntries).mockResolvedValue({
+ data: [
+ { name: '@acme/redactor', version: '1.0.0', entryType: 'llm-hook', status: 'published' },
+ { name: '@acme/db', version: '2.0.0', serverMode: 'http', status: 'published' },
+ ],
+ } as never)
+ render(<OwnedEntries orgScope="acme" />)
+
+ expect(await screen.findByText('@acme/redactor')).toBeInTheDocument()
+ expect(screen.queryByText('@acme/db')).toBeNull()
+
+ fireEvent.click(screen.getByRole('button', { name: /show all entries/i }))
+ expect(navigation.replace).toHaveBeenCalledWith('/marketplace/org/entries')
+ })
+
+ it('a type filter that matches nothing says so without claiming the org has published nothing', async () => {
+ mockSearchParams = new URLSearchParams('type=llm-hook')
+ 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(/no guardrail hooks published yet/i)).toBeInTheDocument()
+ expect(screen.queryByText(/haven’t published/i)).toBeNull()
+ })
+
+ it('an unrecognised type filter falls back to the full list', async () => {
+ mockSearchParams = new URLSearchParams('type=not-a-type')
+ 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('error + Retry re-fetches', async () => {
vi.mocked(api.getOwnedRegistryEntries)
.mockRejectedValueOnce(Object.assign(new Error('boom'), { status: 500 }))