Skip to content

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

TypeScript

feat: standardize relationship chooser pilots

Josué5d7ad5332be3
diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsx
index dcaf7799e..a0a6b3821 100644
--- a/control-ui/app/hosts/[name]/page.tsx
+++ b/control-ui/app/hosts/[name]/page.tsx
@@ -2,7 +2,7 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useParams, useRouter } from 'next/navigation'
-import { DataTable, TableViewport } from '@clerum/frontend-components'
+import { DataTable, MultiSelectActionDialog, TableViewport } from '@clerum/frontend-components'
import { useConfirmDialog } from '@components/ConfirmDialog'
import { DetailPageShell } from '@components/DetailPageShell'
import { SelectionDropdown } from '@components/SelectionDropdown'
@@ -1554,104 +1554,36 @@ export default function HostDetailsPage() {
</>
)}
- {showAddConnector && (
- <div
- className="cu-modal-backdrop"
- role="presentation"
- onMouseDown={event => {
- if (event.target === event.currentTarget && !busy) {
- setShowAddConnector(false)
- setSelectedConnectorNames([])
- }
- }}
- >
- <section
- className="cu-modal-panel cu-modal-panel--selection"
- role="dialog"
- aria-modal="true"
- aria-labelledby="add-agent-connector-title"
- onMouseDown={event => event.stopPropagation()}
- >
- <div className="cu-modal-panel__head">
- <h3 id="add-agent-connector-title" className="cu-modal-panel__title">
- Add connectors
- </h3>
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--ghost"
- onClick={() => {
- setShowAddConnector(false)
- setSelectedConnectorNames([])
- }}
- disabled={busy}
- aria-label="Close"
- >
- <IconX width={18} height={18} />
- </button>
- </div>
-
- <p className="cu-modal-copy">
- Select the connectors this agent can use. You can change this later.
- </p>
-
- {connectorCatalogLoading ? (
- <div className="cu-empty">Loading available connectors…</div>
- ) : (
- <div className="cu-field">
- <label htmlFor="agent-connector-picker">Connectors</label>
- <SelectionDropdown
- id="agent-connector-picker"
- inline
- value={selectedConnectorNames}
- onChange={setSelectedConnectorNames}
- options={connectorOptions}
- placeholder="Select connectors"
- searchPlaceholder="Search connectors..."
- selectionLabel="Selected connectors"
- emptyLabel="No additional connectors available."
- disabled={busy}
- />
- </div>
- )}
-
- <div className="cu-modal-panel__foot">
- <button
- type="button"
- className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={() => {
- setShowAddConnector(false)
- setSelectedConnectorNames([])
- }}
- disabled={busy}
- >
- Cancel
- </button>
- <button
- type="button"
- className="cu-btn cu-btn--primary"
- onClick={async () => {
- const saved = await saveAgentConnectors([
- ...contextMcpServers,
- ...selectedConnectorNames,
- ])
- if (saved) {
- setShowAddConnector(false)
- setSelectedConnectorNames([])
- }
- }}
- disabled={
- busy ||
- connectorCatalogLoading ||
- selectedConnectorNames.length === 0 ||
- !agentContext
- }
- >
- {selectedConnectorNames.length > 1 ? 'Add connectors' : 'Add connector'}
- </button>
- </div>
- </section>
- </div>
- )}
+ <MultiSelectActionDialog
+ open={showAddConnector}
+ title="Add connectors"
+ description="Select the connectors this agent can use. You can change this later."
+ items={connectorOptions.map(option => ({
+ id: option.value,
+ label: option.label,
+ searchText: option.label,
+ }))}
+ selectedIds={selectedConnectorNames}
+ onSelectedIdsChange={setSelectedConnectorNames}
+ onDismiss={() => {
+ setShowAddConnector(false)
+ setSelectedConnectorNames([])
+ }}
+ onAction={async selectedIds => {
+ const saved = await saveAgentConnectors([...contextMcpServers, ...selectedIds])
+ if (saved) {
+ setShowAddConnector(false)
+ setSelectedConnectorNames([])
+ }
+ }}
+ actionLabel={selectedConnectorNames.length > 1 ? 'Add connectors' : 'Add connector'}
+ searchLabel="Search connectors"
+ searchPlaceholder="Search connectors..."
+ emptyMessage="No additional connectors available."
+ loading={connectorCatalogLoading}
+ pending={busy}
+ error={error}
+ />
{activeTab === 'identity' && (
<HostIdentityTab hostName={routeName} onActionsChange={handleSectionActionsChange} />
diff --git a/control-ui/components/HostAccessTab/index.tsx b/control-ui/components/HostAccessTab/index.tsx
index cfd9ec990..0466b0fec 100644
--- a/control-ui/components/HostAccessTab/index.tsx
+++ b/control-ui/components/HostAccessTab/index.tsx
@@ -2,10 +2,9 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useRouter } from 'next/navigation'
-import { DataTable, TableViewport } from '@clerum/frontend-components'
+import { DataTable, MultiSelectActionDialog, TableViewport } from '@clerum/frontend-components'
import { useConfirmDialog } from '@components/ConfirmDialog'
import { RowActionsMenu } from '@components/RowActionsMenu'
-import { SelectionModal } from '@components/SelectionModal'
import { TabBar } from '@components/TabBar'
import { useToast } from '@components/Toast'
import { CONTROL_ROUTES } from '@constants/routes'
@@ -480,51 +479,55 @@ export function HostAccessTab({ hostName, onActionsChange }: HostAccessTabProps)
</TableViewport>
</div>
- {showAddUser ? (
- <SelectionModal
- busy={busy}
- emptyLabel="No available members."
- id="agent-member-picker"
- label="Members"
- onClose={() => setShowAddUser(false)}
- onConfirm={async () => {
- await grantUserAccess()
- setShowAddUser(false)
- }}
- options={memberGrantOptions}
- placeholder="Select members"
- searchPlaceholder="Search members..."
- selectionLabel="Selected members"
- submitLabel={selectedUserIdsToGrant.length > 1 ? 'Add members' : 'Add member'}
- title="Add member"
- titleId="add-user-title"
- value={selectedUserIdsToGrant}
- onChange={setSelectedUserIdsToGrant}
- />
- ) : null}
+ <MultiSelectActionDialog
+ open={showAddUser}
+ title="Add members"
+ description="Select the members who can use this agent."
+ items={memberGrantOptions.map(option => ({
+ id: option.value,
+ label: option.label,
+ description: option.description,
+ searchText: `${option.label} ${option.description}`,
+ }))}
+ selectedIds={selectedUserIdsToGrant}
+ onSelectedIdsChange={setSelectedUserIdsToGrant}
+ onDismiss={() => {
+ setShowAddUser(false)
+ setSelectedUserIdsToGrant([])
+ }}
+ onAction={() => void grantUserAccess().then(() => setShowAddUser(false))}
+ actionLabel={selectedUserIdsToGrant.length > 1 ? 'Add members' : 'Add member'}
+ searchLabel="Search members"
+ searchPlaceholder="Search members..."
+ emptyMessage="No available members."
+ pending={busy}
+ error={error}
+ />
- {showAddTeam ? (
- <SelectionModal
- busy={busy}
- emptyLabel="No available teams."
- id="agent-team-picker"
- label="Teams"
- onClose={() => setShowAddTeam(false)}
- onConfirm={async () => {
- await grantTeamAccess()
- setShowAddTeam(false)
- }}
- options={teamGrantOptions}
- placeholder="Select teams"
- searchPlaceholder="Search teams..."
- selectionLabel="Selected teams"
- submitLabel={selectedTeamIdsToGrant.length > 1 ? 'Add teams' : 'Add team'}
- title="Add team"
- titleId="add-team-title"
- value={selectedTeamIdsToGrant}
- onChange={setSelectedTeamIdsToGrant}
- />
- ) : null}
+ <MultiSelectActionDialog
+ open={showAddTeam}
+ title="Add teams"
+ description="Select the teams that can use this agent."
+ items={teamGrantOptions.map(option => ({
+ id: option.value,
+ label: option.label,
+ description: option.badge,
+ searchText: `${option.label} ${option.badge}`,
+ }))}
+ selectedIds={selectedTeamIdsToGrant}
+ onSelectedIdsChange={setSelectedTeamIdsToGrant}
+ onDismiss={() => {
+ setShowAddTeam(false)
+ setSelectedTeamIdsToGrant([])
+ }}
+ onAction={() => void grantTeamAccess().then(() => setShowAddTeam(false))}
+ actionLabel={selectedTeamIdsToGrant.length > 1 ? 'Add teams' : 'Add team'}
+ searchLabel="Search teams"
+ searchPlaceholder="Search teams..."
+ emptyMessage="No available teams."
+ pending={busy}
+ error={error}
+ />
{confirmDialog}
</section>
diff --git a/control-ui/components/__tests__/HostAccessTab.test.tsx b/control-ui/components/__tests__/HostAccessTab.test.tsx
index 1ec595a24..3e9bc113b 100644
--- a/control-ui/components/__tests__/HostAccessTab.test.tsx
+++ b/control-ui/components/__tests__/HostAccessTab.test.tsx
@@ -1,6 +1,13 @@
import React from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import { cleanup, fireEvent, render as rtlRender, screen, waitFor } from '@testing-library/react'
+import {
+ cleanup,
+ fireEvent,
+ render as rtlRender,
+ screen,
+ waitFor,
+ within,
+} from '@testing-library/react'
import * as api from '@lib/api'
import { HostAccessTab } from '../HostAccessTab'
import { ToastProvider } from '../Toast'
@@ -160,11 +167,11 @@ describe('HostAccessTab — extracted access behavior', () => {
// Pick Bob from the modal.
const dialog = await waitFor(() => screen.getByRole('dialog', { name: /Add member/i }))
- fireEvent.click(screen.getByRole('option', { name: 'Bob' }))
+ fireEvent.click(screen.getByRole('checkbox', { name: '[email protected]' }))
// The submit "Add member" lives inside the dialog; the section also has
// a button of the same name, so scope the click to the dialog.
- fireEvent.click(dialog.querySelector('button.cu-btn--primary') as HTMLButtonElement)
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Add member' }))
await waitFor(() => {
expect(api.updateAdminUserAgents).toHaveBeenCalledWith('u2', ['foo'], expect.any(Array))
@@ -217,8 +224,8 @@ describe('HostAccessTab — extracted access behavior', () => {
fireEvent.click(screen.getByRole('button', { name: /Add team/i }))
const dialog = await waitFor(() => screen.getByRole('dialog', { name: /Add team/i }))
- fireEvent.click(screen.getByRole('option', { name: 'Platform' }))
- fireEvent.click(dialog.querySelector('button.cu-btn--primary') as HTMLButtonElement)
+ fireEvent.click(screen.getByRole('checkbox', { name: 'Platform3 members' }))
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Add team' }))
await waitFor(() => {
expect(api.updateAdminTeamAgents).toHaveBeenCalledWith('t1', ['foo'], expect.any(Array))
diff --git a/control-ui/components/__tests__/HostDetailsPage.connectors.test.tsx b/control-ui/components/__tests__/HostDetailsPage.connectors.test.tsx
index e74cc394d..a87c734ed 100644
--- a/control-ui/components/__tests__/HostDetailsPage.connectors.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.connectors.test.tsx
@@ -128,7 +128,7 @@ describe('HostDetailsPage connectors', () => {
fireEvent.click(screen.getByRole('button', { name: 'Add connector' }))
await waitFor(() => expect(api.getMcpServers).toHaveBeenCalledTimes(1))
- fireEvent.click(await screen.findByRole('option', { name: 'mcp-new' }))
+ fireEvent.click(await screen.findByRole('checkbox', { name: 'mcp-new' }))
fireEvent.click(
within(screen.getByRole('dialog')).getByRole('button', { name: 'Add connector' })
)
@@ -305,7 +305,7 @@ describe('HostDetailsPage connectors', () => {
expect(await screen.findByText('mcp-existing')).toBeInTheDocument()
fireEvent.click(screen.getByRole('button', { name: 'Add connector' }))
await waitFor(() => expect(api.getMcpServers).toHaveBeenCalledTimes(1))
- fireEvent.click(await screen.findByRole('option', { name: 'mcp-new' }))
+ fireEvent.click(await screen.findByRole('checkbox', { name: 'mcp-new' }))
fireEvent.click(
within(screen.getByRole('dialog')).getByRole('button', { name: 'Add connector' })
)
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index d6f52cf37..cf27ff65c 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.612",
+ "version": "0.1.614",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.612",
+ "version": "0.1.614",
"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.json
index 554a7f1c1..df7dcf033 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.612",
+ "version": "0.1.614",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",