Skip to content

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

TypeScript

feat(control-ui): polish LLM Models + Connectors headers

Miguelon Peluchon5fb2182c7cb3
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.css
index 3c89539b2..2d69ded9f 100644
--- a/control-ui/app/globals.css
+++ b/control-ui/app/globals.css
@@ -2375,7 +2375,7 @@ textarea.cu-input {
}
.cu-marketplace-table {
- min-width: 60rem;
+ min-width: 52rem;
--cu-expandable-inset-left: calc(3rem + 0.85rem);
--cu-expandable-inset-right: 4.75rem;
}
@@ -2392,16 +2392,11 @@ textarea.cu-input {
.cu-marketplace-table th:nth-child(4),
.cu-marketplace-table td:nth-child(4) {
- width: 8rem;
+ width: 7rem;
}
.cu-marketplace-table th:nth-child(5),
.cu-marketplace-table td:nth-child(5) {
- width: 7rem;
-}
-
-.cu-marketplace-table th:nth-child(6),
-.cu-marketplace-table td:nth-child(6) {
width: 4.75rem;
}
@@ -2423,16 +2418,16 @@ textarea.cu-input {
padding-left: 0.15rem;
}
-.cu-marketplace-table td:nth-child(5) {
+.cu-marketplace-table td:nth-child(4) {
text-align: center;
}
-.cu-marketplace-table td:nth-child(5) .cu-btn {
+.cu-marketplace-table td:nth-child(4) .cu-btn {
max-width: 100%;
padding-inline: var(--cu-space-1);
}
-.cu-marketplace-table td:nth-child(6) {
+.cu-marketplace-table td:nth-child(5) {
text-align: left;
}
@@ -8058,6 +8053,11 @@ textarea.cu-input {
white-space: nowrap;
}
+.cu-table__sort-link.is-active {
+ color: var(--cu-text);
+ font-weight: var(--font-weight-medium, 500);
+}
+
.cu-row-actions {
display: flex;
justify-content: flex-end;
@@ -9818,13 +9818,31 @@ textarea.cu-input {
}
/* Discovery: persistent "last synced" line under the panel header. */
+.cu-discovery-bar {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--cu-space-3);
+}
+
+.cu-discovery-bar > .cu-tabs {
+ flex: 0 1 auto;
+ margin: 1.25rem 0 1rem;
+}
+
+.cu-discovery-bar > .cu-discovery-status {
+ margin-top: 1.25rem;
+ margin-bottom: 1rem;
+}
+
.cu-discovery-status {
- flex: 0 0 auto;
+ flex: 1 1 auto;
display: flex;
align-items: center;
flex-wrap: wrap;
+ justify-content: flex-end;
gap: var(--cu-space-2);
- padding: var(--cu-space-3) 1rem 0;
+ padding: 0 1rem;
font-size: 0.8125rem;
color: var(--cu-text-muted);
}
diff --git a/control-ui/components/LlmDiscoveryPanel/index.tsx b/control-ui/components/LlmDiscoveryPanel/index.tsx
index 10b4a46b7..e8e64433e 100644
--- a/control-ui/components/LlmDiscoveryPanel/index.tsx
+++ b/control-ui/components/LlmDiscoveryPanel/index.tsx
@@ -24,13 +24,6 @@ import type { LlmDiscoveryPanelProps } from './types'
const CONFIGMAP_DEFERRED_WARNING =
'Propagation to the cluster is delayed and will reconcile shortly.'
-const REVIEW_COLUMNS: TableHeaderColumn[] = [
- { key: 'model', label: 'Model', minWidth: '12rem' },
- { key: 'vendor', label: 'Vendor', width: '10rem' },
- { key: 'contextWindow', label: 'Context window', align: 'right', width: '9rem' },
- { key: 'actions', width: '7rem', align: 'right', ariaLabel: 'Actions' },
-]
-
type ProviderModelGroup = [provider: string, models: LlmAllowedModel[]]
type ProviderGroupRowProps = {
@@ -41,6 +34,48 @@ type ProviderGroupRowProps = {
provider: string
}
+type ReviewSortKey = 'model' | 'vendor' | 'contextWindow'
+type SortDirection = 'asc' | 'desc'
+
+// Numeric columns lead descending (largest context window first); text columns
+// lead ascending (alphabetical). Picking a different column resets to that
+// column's natural default so the operator always sees the most useful order.
+const REVIEW_SORT_DEFAULT_DIR: Record<ReviewSortKey, SortDirection> = {
+ contextWindow: 'desc',
+ model: 'asc',
+ vendor: 'asc',
+}
+
+function compareReviewByKey(key: ReviewSortKey) {
+ return (a: LlmAllowedModel, b: LlmAllowedModel): number => {
+ switch (key) {
+ case 'model':
+ return a.model.localeCompare(b.model)
+ case 'vendor':
+ return (a.vendor ?? '').localeCompare(b.vendor ?? '')
+ case 'contextWindow':
+ return (a.context_window_tokens ?? 0) - (b.context_window_tokens ?? 0)
+ }
+ }
+}
+
+// Null / undefined values always trail known values regardless of sort
+// direction. They represent missing data, not a value at either extreme, so
+// flipping asc/desc must not move them.
+function compareNullsLast(
+ aValue: number | null | undefined,
+ bValue: number | null | undefined
+): number | null {
+ if (aValue == null && bValue == null) return 0
+ if (aValue == null) return 1
+ if (bValue == null) return -1
+ return null
+}
+
+function compareReviewModel(a: LlmAllowedModel, b: LlmAllowedModel): number {
+ return a.model.localeCompare(b.model)
+}
+
function modelLabel(model: LlmAllowedModel): string {
return `${getProviderDisplayLabel(model.provider)}/${model.model}`
}
@@ -51,13 +86,32 @@ function formatRunAt(value: string | null | undefined): string {
return Number.isNaN(date.getTime()) ? value : date.toLocaleString()
}
-function groupByProvider(models: LlmAllowedModel[]): ProviderModelGroup[] {
+function groupByProvider(
+ models: LlmAllowedModel[],
+ sortKey: ReviewSortKey | null,
+ sortDir: SortDirection
+): ProviderModelGroup[] {
const groups = new Map<string, LlmAllowedModel[]>()
for (const model of models) {
const group = groups.get(model.provider)
if (group) group.push(model)
else groups.set(model.provider, [model])
}
+ if (sortKey) {
+ const direction = sortDir === 'asc' ? 1 : -1
+ const byKey = compareReviewByKey(sortKey)
+ for (const group of groups.values()) {
+ group.sort((a, b) => {
+ if (sortKey === 'contextWindow') {
+ const nullOrder = compareNullsLast(a.context_window_tokens, b.context_window_tokens)
+ if (nullOrder !== null) return nullOrder
+ }
+ const diff = byKey(a, b) * direction
+ if (diff !== 0) return diff
+ return compareReviewModel(a, b)
+ })
+ }
+ }
return Array.from(groups.entries()).sort(([left], [right]) =>
getProviderDisplayLabel(left).localeCompare(getProviderDisplayLabel(right))
)
@@ -119,6 +173,8 @@ export function LlmDiscoveryPanel({
const [bulkEnabling, setBulkEnabling] = useState(false)
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set())
const [expandedProviders, setExpandedProviders] = useState<Set<string>>(new Set())
+ const [sortKey, setSortKey] = useState<ReviewSortKey | null>(null)
+ const [sortDir, setSortDir] = useState<SortDirection>('asc')
const statusRequestGeneration = useRef(0)
const isInitialLoad = loading && items.length === 0
@@ -126,7 +182,10 @@ export function LlmDiscoveryPanel({
() => items.filter(model => model.source === 'discovery' && !model.enabled && !model.stale),
[items]
)
- const reviewGroups = useMemo(() => groupByProvider(reviewQueue), [reviewQueue])
+ const reviewGroups = useMemo(
+ () => groupByProvider(reviewQueue, sortKey, sortDir),
+ [reviewQueue, sortDir, sortKey]
+ )
const selectedCount = useMemo(
() => reviewQueue.reduce((count, model) => (selectedIds.has(model.id) ? count + 1 : count), 0),
@@ -298,6 +357,40 @@ export function LlmDiscoveryPanel({
showToast(message, { tone: 'error' })
}
+ function toggleSort(key: ReviewSortKey) {
+ if (sortKey === key) {
+ setSortDir(prev => (prev === 'asc' ? 'desc' : 'asc'))
+ return
+ }
+ setSortKey(key)
+ setSortDir(REVIEW_SORT_DEFAULT_DIR[key])
+ }
+
+ function renderSortHeader(key: ReviewSortKey, label: string) {
+ const isActive = sortKey === key
+ const indicator = isActive ? (sortDir === 'asc' ? '↑' : '↓') : ''
+ const nextDirectionLabel = isActive
+ ? sortDir === 'asc'
+ ? 'descending'
+ : 'ascending'
+ : REVIEW_SORT_DEFAULT_DIR[key] === 'asc'
+ ? 'ascending'
+ : 'descending'
+ const buttonLabel = `${label}${indicator ? ` ${indicator}` : ''}`
+ const ariaLabel = `Sort by ${label.toLowerCase()} ${nextDirectionLabel}`
+ return (
+ <button
+ type="button"
+ className={`cu-link cu-link--sm cu-table__sort-link${isActive ? ' is-active' : ''}`}
+ onClick={() => toggleSort(key)}
+ aria-label={ariaLabel}
+ aria-pressed={isActive}
+ >
+ {buttonLabel}
+ </button>
+ )
+ }
+
const reviewColumns: TableHeaderColumn[] = [
{
key: 'select',
@@ -315,7 +408,15 @@ export function LlmDiscoveryPanel({
/>
),
},
- ...REVIEW_COLUMNS,
+ { key: 'model', label: renderSortHeader('model', 'Model'), minWidth: '12rem' },
+ { key: 'vendor', label: renderSortHeader('vendor', 'Vendor'), width: '10rem' },
+ {
+ key: 'contextWindow',
+ label: renderSortHeader('contextWindow', 'Context window'),
+ align: 'right',
+ width: '9rem',
+ },
+ { key: 'actions', width: '7rem', align: 'right', ariaLabel: 'Actions' },
]
return (
@@ -331,7 +432,7 @@ export function LlmDiscoveryPanel({
title={
<>
<IconModels />
- {isInitialLoad ? 'Discovery review' : `Discovery review (${reviewQueue.length})`}
+ LLM Models
</>
}
subtitle="Newly synced models land here disabled. Enable only the models you want available to agents and runtime."
@@ -361,28 +462,29 @@ export function LlmDiscoveryPanel({
</>
}
/>
- {navigation}
-
- <div className="cu-discovery-status" role="status">
- <span>
- {status
- ? `Last synced ${formatRunAt(status.ranAt)}`
- : 'Not synced yet. Run a sync to pull the latest catalog.'}
- </span>
- {status ? (
- <span className="cu-discovery-status__facts">
- <span
- className={`cu-px-badge ${
- status.source === 'live' ? 'cu-px-badge--info' : 'cu-px-badge--warn'
- }`}
- >
- {status.source === 'live' ? 'Live catalog' : 'Vendored fallback'}
- </span>
- <span>+{status.added} new</span>
- <span>{status.updated} refreshed</span>
- <span>{status.staled} stale</span>
+ <div className="cu-discovery-bar">
+ {navigation}
+ <div className="cu-discovery-status" role="status">
+ <span>
+ {status
+ ? `Last synced ${formatRunAt(status.ranAt)}`
+ : 'Not synced yet. Run a sync to pull the latest catalog.'}
</span>
- ) : null}
+ {status ? (
+ <span className="cu-discovery-status__facts">
+ <span
+ className={`cu-px-badge ${
+ status.source === 'live' ? 'cu-px-badge--info' : 'cu-px-badge--warn'
+ }`}
+ >
+ {status.source === 'live' ? 'Live catalog' : 'Vendored fallback'}
+ </span>
+ <span>+{status.added} new</span>
+ <span>{status.updated} refreshed</span>
+ <span>{status.staled} stale</span>
+ </span>
+ ) : null}
+ </div>
</div>
{selectedCount > 0 ? (
diff --git a/control-ui/components/LlmModelTable.tsx b/control-ui/components/LlmModelTable.tsx
index 6b0e49ff5..34b8cd0a6 100644
--- a/control-ui/components/LlmModelTable.tsx
+++ b/control-ui/components/LlmModelTable.tsx
@@ -17,16 +17,49 @@ import { TablePanelHeader } from './TablePanelHeader'
import { IconChevronRight, IconPencil, IconRefresh, IconX } from './icons'
import { SelectInput } from './ui'
-const MODEL_COLUMNS: TableHeaderColumn[] = [
- { key: 'model', label: 'Model', minWidth: '15rem' },
- { key: 'vendor', label: 'Vendor', width: '10rem' },
- { key: 'displayName', label: 'Display name', minWidth: '10rem' },
- { key: 'contextWindow', label: 'Context window', align: 'right', width: '9rem' },
- { key: 'enabled', label: 'Enabled', width: '6rem' },
- { key: 'source', label: 'Source', width: '7rem' },
- { key: 'catalogStatus', label: 'Catalog status', width: '8rem' },
- { key: 'actions', width: '5rem', align: 'right', ariaLabel: 'Actions' },
-]
+type ModelSortKey = 'model' | 'vendor' | 'displayName' | 'contextWindow'
+type SortDirection = 'asc' | 'desc'
+
+// Natural default direction per column: numeric columns read best descending
+// (largest context window first); text columns read best ascending.
+const MODEL_SORT_DEFAULT_DIR: Record<ModelSortKey, SortDirection> = {
+ contextWindow: 'desc',
+ displayName: 'asc',
+ model: 'asc',
+ vendor: 'asc',
+}
+
+function compareModelByKey(key: ModelSortKey) {
+ return (a: LlmAllowedModel, b: LlmAllowedModel): number => {
+ switch (key) {
+ case 'model':
+ return a.model.localeCompare(b.model)
+ case 'vendor':
+ return (a.vendor ?? '').localeCompare(b.vendor ?? '')
+ case 'displayName':
+ return (a.display_name ?? '').localeCompare(b.display_name ?? '')
+ case 'contextWindow':
+ return (a.context_window_tokens ?? 0) - (b.context_window_tokens ?? 0)
+ }
+ }
+}
+
+// Null / undefined values always trail known values regardless of sort
+// direction. They represent missing data, not a value at either extreme, so
+// flipping asc/desc must not move them.
+function compareNullsLast(
+ aValue: number | null | undefined,
+ bValue: number | null | undefined
+): number | null {
+ if (aValue == null && bValue == null) return 0
+ if (aValue == null) return 1
+ if (bValue == null) return -1
+ return null
+}
+
+function compareModel(a: LlmAllowedModel, b: LlmAllowedModel): number {
+ return a.model.localeCompare(b.model)
+}
const ALL_PROVIDERS = '__all__'
@@ -50,6 +83,8 @@ export function LlmModelTable({
const [enabledFilter, setEnabledFilter] = useState<EnabledFilter>('all')
const [sourceFilter, setSourceFilter] = useState<SourceFilter>('all')
const [expandedProviders, setExpandedProviders] = useState<Set<string>>(new Set())
+ const [sortKey, setSortKey] = useState<ModelSortKey | null>(null)
+ const [sortDir, setSortDir] = useState<SortDirection>('asc')
const normalizedSearch = searchQuery.trim().toLowerCase()
const providerOptions = useMemo(() => {
@@ -125,10 +160,24 @@ export function LlmModelTable({
if (group) group.push(model)
else groups.set(model.provider, [model])
}
+ for (const group of groups.values()) {
+ if (!sortKey) continue
+ const direction = sortDir === 'asc' ? 1 : -1
+ const byKey = compareModelByKey(sortKey)
+ group.sort((a, b) => {
+ if (sortKey === 'contextWindow') {
+ const nullOrder = compareNullsLast(a.context_window_tokens, b.context_window_tokens)
+ if (nullOrder !== null) return nullOrder
+ }
+ const diff = byKey(a, b) * direction
+ if (diff !== 0) return diff
+ return compareModel(a, b)
+ })
+ }
return Array.from(groups.entries()).sort(([left], [right]) =>
getProviderDisplayLabel(left).localeCompare(getProviderDisplayLabel(right))
)
- }, [filteredItems])
+ }, [filteredItems, sortDir, sortKey])
// Search should reveal results without forcing the operator to open every
// matching provider first. Keep those groups open after search is cleared so
@@ -165,13 +214,67 @@ export function LlmModelTable({
})
}
+ function toggleSort(key: ModelSortKey) {
+ if (sortKey === key) {
+ setSortDir(prev => (prev === 'asc' ? 'desc' : 'asc'))
+ return
+ }
+ setSortKey(key)
+ setSortDir(MODEL_SORT_DEFAULT_DIR[key])
+ }
+
+ function renderSortHeader(key: ModelSortKey, label: string) {
+ const isActive = sortKey === key
+ const indicator = isActive ? (sortDir === 'asc' ? '↑' : '↓') : ''
+ const nextDirectionLabel = isActive
+ ? sortDir === 'asc'
+ ? 'descending'
+ : 'ascending'
+ : MODEL_SORT_DEFAULT_DIR[key] === 'asc'
+ ? 'ascending'
+ : 'descending'
+ const buttonLabel = `${label}${indicator ? ` ${indicator}` : ''}`
+ const ariaLabel = `Sort by ${label.toLowerCase()} ${nextDirectionLabel}`
+ return (
+ <button
+ type="button"
+ className={`cu-link cu-link--sm cu-table__sort-link${isActive ? ' is-active' : ''}`}
+ onClick={() => toggleSort(key)}
+ aria-label={ariaLabel}
+ aria-pressed={isActive}
+ >
+ {buttonLabel}
+ </button>
+ )
+ }
+
+ const modelColumns: TableHeaderColumn[] = [
+ { key: 'model', label: renderSortHeader('model', 'Model'), minWidth: '15rem' },
+ { key: 'vendor', label: renderSortHeader('vendor', 'Vendor'), width: '10rem' },
+ {
+ key: 'displayName',
+ label: renderSortHeader('displayName', 'Display name'),
+ minWidth: '10rem',
+ },
+ {
+ key: 'contextWindow',
+ label: renderSortHeader('contextWindow', 'Context window'),
+ align: 'right',
+ width: '9rem',
+ },
+ { key: 'enabled', label: 'Enabled', width: '6rem' },
+ { key: 'source', label: 'Source', width: '7rem' },
+ { key: 'catalogStatus', label: 'Catalog status', width: '8rem' },
+ { key: 'actions', width: '5rem', align: 'right', ariaLabel: 'Actions' },
+ ]
+
return (
<div className="cu-card cu-card--viewport-fill cu-section-card">
<TablePanelHeader
title={
<>
<IconModels />
- {isInitialLoad ? 'Model catalog' : `Model catalog (${filteredItems.length})`}
+ LLM Models
</>
}
subtitle="The authoritative allowlist of manual and discovered models. Only enabled rows can be selected for agents and runtime."
@@ -243,10 +346,10 @@ export function LlmModelTable({
<div className="cu-table-wrap cu-table-wrap--sticky-header">
<table className="cu-table cu-table--header-band cu-llm-model-table">
<thead>
- <TableHeaderRow columns={MODEL_COLUMNS} />
+ <TableHeaderRow columns={modelColumns} />
</thead>
<tbody>
- <SkeletonTableRows columns={MODEL_COLUMNS.length} rows={4} />
+ <SkeletonTableRows columns={modelColumns.length} rows={4} />
</tbody>
</table>
</div>
@@ -260,7 +363,7 @@ export function LlmModelTable({
<div className="cu-table-wrap cu-table-wrap--sticky-header">
<table className="cu-table cu-table--header-band cu-llm-model-table">
<thead>
- <TableHeaderRow columns={MODEL_COLUMNS} />
+ <TableHeaderRow columns={modelColumns} />
</thead>
{groupedItems.map(([provider, models]) => {
const providerLabel = getProviderDisplayLabel(provider)
@@ -273,7 +376,7 @@ export function LlmModelTable({
return (
<tbody key={provider} className="cu-llm-model-group">
<tr className="cu-llm-model-group__row">
- <td colSpan={MODEL_COLUMNS.length}>
+ <td colSpan={modelColumns.length}>
<button
type="button"
className="cu-llm-model-group__toggle"
diff --git a/control-ui/components/LlmModelsSurface/index.tsx b/control-ui/components/LlmModelsSurface/index.tsx
index ff30cf897..90d874b62 100644
--- a/control-ui/components/LlmModelsSurface/index.tsx
+++ b/control-ui/components/LlmModelsSurface/index.tsx
@@ -108,25 +108,29 @@ function LlmModelsContent({ activeTab }: LlmModelsSurfaceProps) {
}
}, [activeTab, authState.isLoggedIn, authState.isLoading])
+ const discoveryReviewCount = useMemo(
+ () =>
+ models.filter(model => model.source === 'discovery' && !model.enabled && !model.stale).length,
+ [models]
+ )
+
const tabs = [
{
value: 'catalog' as const,
href: CONTROL_ROUTES.llmModels.root,
- label: 'Catalog',
+ label: models.length > 0 ? `Catalog (${models.length})` : 'Catalog',
},
{
value: 'discovery' as const,
href: CONTROL_ROUTES.llmModels.discovery,
- label: 'Discovery review',
+ label:
+ discoveryReviewCount > 0
+ ? `Discovery review (${discoveryReviewCount})`
+ : 'Discovery review',
},
]
const navigation = (
- <TabBar<LlmModelsTab>
- activeValue={activeTab}
- ariaLabel="LLM model management"
- className="cu-tabs--flush-top"
- options={tabs}
- />
+ <TabBar<LlmModelsTab> activeValue={activeTab} ariaLabel="LLM model management" options={tabs} />
)
return (
diff --git a/control-ui/components/McpServerTable.tsx b/control-ui/components/McpServerTable.tsx
index 172d99675..ad780932b 100644
--- a/control-ui/components/McpServerTable.tsx
+++ b/control-ui/components/McpServerTable.tsx
@@ -7,6 +7,7 @@ import type {
McpServerStatus,
McpServerTableProps,
} from './McpServerTable.types'
+import { type RowAction, RowActionsMenu } from './RowActionsMenu'
import { SectionSearchInput } from './SectionSearchInput'
import { SelectionDropdown } from './SelectionDropdown'
import { IconCable } from './Sidebar/icons'
@@ -17,6 +18,8 @@ import { TablePanelHeader } from './TablePanelHeader'
import { IconChevronRight, IconPencil, IconRefresh, IconX } from './icons'
const ENABLED_TOOLTIP = 'Enabled controls whether this server is available to contexts and agents.'
+type ConnectorSortKey = 'name' | 'enabled' | 'status'
+type SortDirection = 'asc' | 'desc'
const CONNECTOR_COLUMNS: TableHeaderColumn[] = [
{ key: 'expand', ariaLabel: 'Expand connector' },
@@ -51,25 +54,29 @@ function BoolBadge({
)
}
-function StatusBadge({ status }: { status?: McpServerStatus }) {
+function getStatusState(status?: McpServerStatus) {
const conditions = status?.conditions
const missingSecret = conditions?.find(c => c.type === 'SecretResolved' && c.status === 'False')
const ready = conditions?.find(c => c.type === 'Ready' && c.status === 'True')
- const state = missingSecret
- ? 'error'
- : ready
- ? 'ready'
- : conditions?.length
- ? 'pending'
- : 'unknown'
- const label =
- state === 'error'
- ? 'Missing Secret'
- : state === 'ready'
- ? 'Ready'
- : state === 'pending'
- ? 'Pending'
- : 'Unknown'
+ return missingSecret ? 'error' : ready ? 'ready' : conditions?.length ? 'pending' : 'unknown'
+}
+
+function getStatusLabel(status?: McpServerStatus) {
+ const state = getStatusState(status)
+ return state === 'error'
+ ? 'Missing Secret'
+ : state === 'ready'
+ ? 'Ready'
+ : state === 'pending'
+ ? 'Pending'
+ : 'Unknown'
+}
+
+function StatusBadge({ status }: { status?: McpServerStatus }) {
+ const conditions = status?.conditions
+ const missingSecret = conditions?.find(c => c.type === 'SecretResolved' && c.status === 'False')
+ const state = getStatusState(status)
+ const label = getStatusLabel(status)
return (
<span
className={`cu-connector-badge cu-connector-badge--status-${state}`}
@@ -126,6 +133,8 @@ export function McpServerTable({
loading,
}: McpServerTableProps) {
const [searchQuery, setSearchQuery] = useState('')
+ const [sortKey, setSortKey] = useState<ConnectorSortKey | null>(null)
+ const [sortDirection, setSortDirection] = useState<SortDirection>('asc')
const [expandedKeys, setExpandedKeys] = useState<Set<string>>(new Set())
const [serverKeyAddingContexts, setServerKeyAddingContexts] = useState<string | null>(null)
const [selectedContextNamesToAdd, setSelectedContextNamesToAdd] = useState<string[]>([])
@@ -140,38 +149,52 @@ export function McpServerTable({
)
const normalizedSearch = searchQuery.trim().toLowerCase()
const filteredRows = useMemo(() => {
- if (!normalizedSearch) return rows
- return rows.filter(({ namespace, name, item, key }) => {
- const spec = item.spec || {}
- const access = accessByConnectorKey?.[key]
- const accessText = [
- ...(access?.agents ?? []),
- ...(access?.users ?? []),
- ...(access?.teams ?? []),
- ]
- .flatMap(principal => [principal.id, principal.label])
- .join(' ')
- const conditionText = (item.status?.conditions || [])
- .map(condition =>
- [condition.type, condition.status, condition.reason, condition.message].join(' ')
- )
- .join(' ')
- return [
- namespace,
- name,
- spec.image,
- spec.contextRef,
- spec.description,
- spec.transport?.type,
- spec.transport?.url,
- accessText,
- conditionText,
- ]
- .join(' ')
- .toLowerCase()
- .includes(normalizedSearch)
+ const matchingRows = !normalizedSearch
+ ? rows
+ : rows.filter(({ namespace, name, item, key }) => {
+ const spec = item.spec || {}
+ const access = accessByConnectorKey?.[key]
+ const accessText = [
+ ...(access?.agents ?? []),
+ ...(access?.users ?? []),
+ ...(access?.teams ?? []),
+ ]
+ .flatMap(principal => [principal.id, principal.label])
+ .join(' ')
+ const conditionText = (item.status?.conditions || [])
+ .map(condition =>
+ [condition.type, condition.status, condition.reason, condition.message].join(' ')
+ )
+ .join(' ')
+ return [
+ namespace,
+ name,
+ spec.image,
+ spec.contextRef,
+ spec.description,
+ spec.transport?.type,
+ spec.transport?.url,
+ accessText,
+ conditionText,
+ ]
+ .join(' ')
+ .toLowerCase()
+ .includes(normalizedSearch)
+ })
+ if (!sortKey) return matchingRows
+
+ const direction = sortDirection === 'asc' ? 1 : -1
+ return [...matchingRows].sort((left, right) => {
+ const comparison =
+ sortKey === 'name'
+ ? left.name.localeCompare(right.name, undefined, { sensitivity: 'base' })
+ : sortKey === 'enabled'
+ ? Number((left.item.spec?.enabled ?? true) === true) -
+ Number((right.item.spec?.enabled ?? true) === true)
+ : getStatusLabel(left.item.status).localeCompare(getStatusLabel(right.item.status))
+ return comparison * direction
})
- }, [accessByConnectorKey, normalizedSearch, rows])
+ }, [accessByConnectorKey, normalizedSearch, rows, sortDirection, sortKey])
React.useEffect(() => {
if (!onRefresh) return
@@ -188,6 +211,39 @@ export function McpServerTable({
})
}
+ function toggleSort(key: ConnectorSortKey) {
+ if (sortKey === key) {
+ setSortDirection(direction => (direction === 'asc' ? 'desc' : 'asc'))
+ return
+ }
+ setSortKey(key)
+ setSortDirection('asc')
+ }
+
+ function renderSortHeader(key: ConnectorSortKey, label: string) {
+ const isActive = sortKey === key
+ const indicator = isActive ? (sortDirection === 'asc' ? '↑' : '↓') : ''
+ const nextDirection = isActive && sortDirection === 'asc' ? 'descending' : 'ascending'
+ return (
+ <button
+ type="button"
+ className={`cu-link cu-link--sm cu-table__sort-link${isActive ? ' is-active' : ''}`}
+ onClick={() => toggleSort(key)}
+ aria-label={`Sort by ${label.toLowerCase()} ${nextDirection}`}
+ aria-pressed={isActive}
+ >
+ {label} {indicator}
+ </button>
+ )
+ }
+
+ const columns = CONNECTOR_COLUMNS.map(column => {
+ if (column.key === 'name' || column.key === 'enabled' || column.key === 'status') {
+ return { ...column, label: renderSortHeader(column.key, column.label as string) }
+ }
+ return column
+ })
+
function contextsForConnector(name: string): ConnectorContextBinding[] {
return contexts.filter(context => context.mcpServers.includes(name))
}
@@ -214,6 +270,21 @@ export function McpServerTable({
{isInitialLoad ? 'Connectors' : `Connectors (${filteredRows.length})`}
</>
}
+ titleActions={
+ onCreate ? (
+ <RowActionsMenu
+ ariaLabel="Connector actions"
+ actions={[
+ {
+ key: 'create',
+ label: 'Create connector',
+ onClick: onCreate,
+ disabled: isInitialLoad,
+ },
+ ]}
+ />
+ ) : null
+ }
subtitle="Browse connector deployments and context bindings."
actionsClassName="cu-table-panel__actions--mcp"
actions={
@@ -243,23 +314,13 @@ export function McpServerTable({
{onInstallFromRegistry ? (
<button
type="button"
- className="cu-btn cu-btn--secondary cu-btn--sm cu-btn--mcp-install"
+ className="cu-btn cu-btn--primary cu-btn--sm cu-btn--mcp-install"
onClick={onInstallFromRegistry}
disabled={isInitialLoad}
>
Install from Marketplace
</button>
) : null}
- {onCreate ? (
- <button
- type="button"
- className="cu-btn cu-btn--primary cu-btn--sm"
- onClick={onCreate}
- disabled={isInitialLoad}
- >
- Create Connector
- </button>
- ) : null}
</>
}
/>
@@ -268,10 +329,10 @@ export function McpServerTable({
<div className="cu-table-wrap cu-connectors-table-wrap">
<table className="cu-table cu-table--header-band cu-expandable-table cu-connectors-table">
<thead>
- <TableHeaderRow columns={CONNECTOR_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- <SkeletonTableRows columns={CONNECTOR_COLUMNS.length} rows={5} />
+ <SkeletonTableRows columns={columns.length} rows={5} />
</tbody>
</table>
</div>
@@ -283,7 +344,7 @@ export function McpServerTable({
<div className="cu-table-wrap cu-connectors-table-wrap">
<table className="cu-table cu-table--header-band cu-expandable-table cu-connectors-table">
<thead>
- <TableHeaderRow columns={CONNECTOR_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
{filteredRows.map(({ key, namespace, name, item }) => {
diff --git a/control-ui/components/__tests__/LlmDiscoveryPanel.test.tsx b/control-ui/components/__tests__/LlmDiscoveryPanel.test.tsx
index de6997951..cd5bd4298 100644
--- a/control-ui/components/__tests__/LlmDiscoveryPanel.test.tsx
+++ b/control-ui/components/__tests__/LlmDiscoveryPanel.test.tsx
@@ -81,7 +81,7 @@ describe('LlmDiscoveryPanel merged lifecycle workflow', () => {
/>
)
- expect(screen.getByText('Discovery review (1)')).toBeInTheDocument()
+ expect(screen.getByText('LLM Models')).toBeInTheDocument()
expect(screen.getByText(/Newly synced models land here disabled/)).toBeInTheDocument()
const reviewGroup = screen.getByRole('button', { name: 'Expand OpenAI review models' })
@@ -157,3 +157,73 @@ describe('LlmDiscoveryPanel merged lifecycle workflow', () => {
expect(screen.getByRole('button', { name: 'Reload discovery review' })).toBeEnabled()
})
})
+
+describe('LlmDiscoveryPanel sorting', () => {
+ function rowOrder(): string[] {
+ const rows = document.querySelectorAll('tr.cu-llm-model-row')
+ return Array.from(rows).map(row => {
+ const cell = row.querySelector('td.cu-px-model')
+ return cell?.textContent?.trim() ?? ''
+ })
+ }
+
+ function expandOpenAi() {
+ fireEvent.click(screen.getByRole('button', { name: 'Expand OpenAI review models' }))
+ }
+
+ const discoveryModel = (overrides: Partial<LlmAllowedModel>): LlmAllowedModel => ({
+ ...reviewModel,
+ id: overrides.id ?? reviewModel.id,
+ enabled: false,
+ source: 'discovery',
+ stale: false,
+ ...overrides,
+ })
+
+ it('keeps the static LLM Models title for the discovery panel', () => {
+ render(
+ <LlmDiscoveryPanel
+ items={[reviewModel]}
+ loading={false}
+ onRefresh={vi.fn().mockResolvedValue(undefined)}
+ />
+ )
+ expect(document.querySelector('.cu-panel-title')?.textContent).toContain('LLM Models')
+ })
+
+ it('sorts queued models by model name ascending when clicked', () => {
+ const alpha = discoveryModel({ id: 'a', model: 'alpha' })
+ const bravo = discoveryModel({ id: 'b', model: 'bravo' })
+ const charlie = discoveryModel({ id: 'c', model: 'charlie' })
+ render(
+ <LlmDiscoveryPanel
+ items={[charlie, alpha, bravo]}
+ loading={false}
+ onRefresh={vi.fn().mockResolvedValue(undefined)}
+ />
+ )
+ expandOpenAi()
+
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by model ascending' }))
+
+ expect(rowOrder()).toEqual(['alpha', 'bravo', 'charlie'])
+ })
+
+ it('sorts context window descending by default and pushes null values to the end', () => {
+ const small = discoveryModel({ id: 's', model: 'small', context_window_tokens: 8_000 })
+ const large = discoveryModel({ id: 'l', model: 'large', context_window_tokens: 1_000_000 })
+ const unknown = discoveryModel({ id: 'u', model: 'unknown', context_window_tokens: null })
+ render(
+ <LlmDiscoveryPanel
+ items={[small, large, unknown]}
+ loading={false}
+ onRefresh={vi.fn().mockResolvedValue(undefined)}
+ />
+ )
+ expandOpenAi()
+
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by context window descending' }))
+
+ expect(rowOrder()).toEqual(['large', 'small', 'unknown'])
+ })
+})
diff --git a/control-ui/components/__tests__/LlmModelTable.test.tsx b/control-ui/components/__tests__/LlmModelTable.test.tsx
index 9dbafa7c4..380591ec8 100644
--- a/control-ui/components/__tests__/LlmModelTable.test.tsx
+++ b/control-ui/components/__tests__/LlmModelTable.test.tsx
@@ -320,3 +320,78 @@ describe('LlmModelTable provider groups', () => {
expect(screen.queryByText(/allowed models? have no enabled price/i)).toBeNull()
})
})
+
+describe('LlmModelTable sorting', () => {
+ const newModel = (overrides: Partial<LlmAllowedModel>): LlmAllowedModel => ({
+ ...baseModel,
+ id: overrides.id ?? baseModel.id,
+ ...overrides,
+ })
+
+ function expandedRowOrder(): string[] {
+ const rows = document.querySelectorAll('tr.cu-llm-model-row')
+ return Array.from(rows).map(row => {
+ const cell = row.querySelector('td.cu-px-model')
+ return cell?.textContent?.trim() ?? ''
+ })
+ }
+
+ it('keeps the static LLM Models title regardless of filters', () => {
+ renderTable([baseModel])
+ expect(document.querySelector('.cu-panel-title')?.textContent).toContain('LLM Models')
+ })
+
+ it('sorts models inside a provider group by model name when ascending', () => {
+ const alpha = newModel({ id: 'a', model: 'alpha', display_name: 'Alpha' })
+ const bravo = newModel({ id: 'b', model: 'bravo', display_name: 'Bravo' })
+ const charlie = newModel({ id: 'c', model: 'charlie', display_name: 'Charlie' })
+ renderTable([charlie, alpha, bravo])
+ expandAnthropicModels()
+
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by model ascending' }))
+
+ expect(expandedRowOrder()).toEqual(['alpha', 'bravo', 'charlie'])
+ })
+
+ it('toggles a sort header to descending on the second click', () => {
+ const alpha = newModel({ id: 'a', model: 'alpha' })
+ const bravo = newModel({ id: 'b', model: 'bravo' })
+ renderTable([alpha, bravo])
+ expandAnthropicModels()
+
+ const modelSort = screen.getByRole('button', { name: 'Sort by model ascending' })
+ fireEvent.click(modelSort)
+ expect(expandedRowOrder()).toEqual(['alpha', 'bravo'])
+
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by model descending' }))
+ expect(expandedRowOrder()).toEqual(['bravo', 'alpha'])
+ })
+
+ it('sorts context window descending by default and pushes null values to the end', () => {
+ const small = newModel({ id: 's', model: 'small', context_window_tokens: 8_000 })
+ const large = newModel({ id: 'l', model: 'large', context_window_tokens: 1_000_000 })
+ const unknown = newModel({ id: 'u', model: 'unknown', context_window_tokens: null })
+ renderTable([small, large, unknown])
+ expandAnthropicModels()
+
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by context window descending' }))
+
+ expect(expandedRowOrder()).toEqual(['large', 'small', 'unknown'])
+ })
+
+ it('resets to the natural default direction when switching sort columns', () => {
+ const alpha = newModel({ id: 'a', model: 'alpha', context_window_tokens: 100 })
+ const bravo = newModel({ id: 'b', model: 'bravo', context_window_tokens: 200 })
+ renderTable([alpha, bravo])
+ expandAnthropicModels()
+
+ // Model asc (default for text columns).
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by model ascending' }))
+ expect(expandedRowOrder()).toEqual(['alpha', 'bravo'])
+
+ // Switching to context window uses its natural default (descending) — not
+ // the previous direction — so the operator gets the most useful ordering.
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by context window descending' }))
+ expect(expandedRowOrder()).toEqual(['bravo', 'alpha'])
+ })
+})
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index b30ac5619..ef871d768 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.383",
+ "version": "0.1.384",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.383",
+ "version": "0.1.384",
"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.json
index 4d2a3ffe8..ccdef272f 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.383",
+ "version": "0.1.384",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",