Skip to content

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

TypeScript

feat(control-ui): widen Button and add a shared RowActions primitive

Jose Ramirez35c89c08c7f4
diff --git a/control-ui/app/communication-channels/[name]/edit/page.tsx b/control-ui/app/communication-channels/[name]/edit/page.tsx
index fe8a13174..8e2590f3e 100644
--- a/control-ui/app/communication-channels/[name]/edit/page.tsx
+++ b/control-ui/app/communication-channels/[name]/edit/page.tsx
@@ -647,7 +647,7 @@ export default function EditCommunicationChannelPage() {
</div>
<button
type="button"
- className="cu-btn cu-btn--secondary"
+ className="cu-btn"
onClick={copySlackRequestUrl}
disabled={!slackRequestUrl || saving}
>
@@ -784,7 +784,7 @@ export default function EditCommunicationChannelPage() {
</div>
<button
type="button"
- className="cu-btn cu-btn--secondary"
+ className="cu-btn"
onClick={copyTeamsRequestUrl}
disabled={!teamsRequestUrl || saving}
>
diff --git a/control-ui/app/communication-channels/new/page.tsx b/control-ui/app/communication-channels/new/page.tsx
index 739ae65f5..5259d3ad7 100644
--- a/control-ui/app/communication-channels/new/page.tsx
+++ b/control-ui/app/communication-channels/new/page.tsx
@@ -864,7 +864,7 @@ export default function CreateCommunicationChannelPage() {
{teamsInstallLink ? (
<>
<a
- className="cu-btn cu-btn--secondary cu-btn--sm cu-teams-setup__install"
+ className="cu-btn cu-btn--sm cu-teams-setup__install"
href={teamsInstallLink}
target="_blank"
rel="noopener noreferrer"
diff --git a/control-ui/app/profile-admin/teams/[teamId]/page.tsx b/control-ui/app/profile-admin/teams/[teamId]/page.tsx
index 812092999..d8cb5e4e5 100644
--- a/control-ui/app/profile-admin/teams/[teamId]/page.tsx
+++ b/control-ui/app/profile-admin/teams/[teamId]/page.tsx
@@ -831,7 +831,7 @@ export default function TeamDetailsPage() {
>
<button
type="button"
- className="cu-btn cu-btn--secondary cu-btn--sm"
+ className="cu-btn cu-btn--sm"
onClick={() => void resendPendingInvitation(inv)}
disabled={
busy ||
diff --git a/control-ui/components/McpServerTable.tsx b/control-ui/components/McpServerTable.tsx
index 93627290b..b94d296bd 100644
--- a/control-ui/components/McpServerTable.tsx
+++ b/control-ui/components/McpServerTable.tsx
@@ -194,7 +194,7 @@ function ConnectorContexts({
{onAdd ? (
<button
type="button"
- className="cu-btn cu-btn--secondary cu-btn--sm cu-connector-context-access__add"
+ className="cu-btn cu-btn--sm cu-connector-context-access__add"
disabled={busy}
onClick={onAdd}
>
diff --git a/control-ui/components/ProfileAdminHome.tsx b/control-ui/components/ProfileAdminHome.tsx
index b338a4948..5bdeb0981 100644
--- a/control-ui/components/ProfileAdminHome.tsx
+++ b/control-ui/components/ProfileAdminHome.tsx
@@ -772,7 +772,7 @@ export function ProfileAdminHome({ activeTab, highlightedAdminId = '' }: Profile
<div className="cu-row-actions cu-row-actions--wrap">
<button
type="button"
- className="cu-btn cu-btn--secondary cu-btn--sm"
+ className="cu-btn cu-btn--sm"
onClick={() => void resendPendingInvitation(invitation)}
disabled={
(busy && !loaded) || resendingInvitationId === invitation.id
@@ -902,7 +902,7 @@ export function ProfileAdminHome({ activeTab, highlightedAdminId = '' }: Profile
{user.passwordPendingFromAcceptedInvitation ? (
<button
type="button"
- className="cu-btn cu-btn--secondary cu-btn--sm cu-nowrap"
+ className="cu-btn cu-btn--sm cu-nowrap"
onClick={event => {
event.stopPropagation()
void resendPasswordSetupInvitation(user)
diff --git a/control-ui/components/PublisherView/OwnedEntries.tsx b/control-ui/components/PublisherView/OwnedEntries.tsx
index d374741d3..55e918a48 100644
--- a/control-ui/components/PublisherView/OwnedEntries.tsx
+++ b/control-ui/components/PublisherView/OwnedEntries.tsx
@@ -12,7 +12,7 @@ import {
getRegistryCatalog,
} from '../../lib/api'
import { useConfirmDialog } from '../ConfirmDialog'
-import { type RowAction, RowActionsMenu } from '../RowActionsMenu'
+import { type RowActionMenuItem, RowActionsMenu } from '../RowActionsMenu'
import { SectionLoadingSkeleton } from '../SectionLoadingSkeleton'
import { TableHeaderRow } from '../TableHeaderRow'
import type { TableHeaderColumn } from '../TableHeaderRow/types'
@@ -278,7 +278,7 @@ export function OwnedEntries({
const isGranting = grantTarget?.entryName === e.name
const expanded = expandedNames.has(e.name)
const hasPrevious = versions.length > 1
- const rowActions: RowAction[] = [
+ const rowActions: RowActionMenuItem[] = [
{
key: 'edit',
label: 'Edit',
diff --git a/control-ui/components/RegistryCatalog.tsx b/control-ui/components/RegistryCatalog.tsx
index cd15ebdfa..3ad540d68 100644
--- a/control-ui/components/RegistryCatalog.tsx
+++ b/control-ui/components/RegistryCatalog.tsx
@@ -5,7 +5,7 @@ import Link from 'next/link'
import { useRouter } from 'next/navigation'
import { FilterSelect } from '@components/FilterSelect'
import { MarketplaceTabs } from '@components/MarketplaceTabs'
-import { type RowAction, RowActionsMenu } from '@components/RowActionsMenu'
+import { type RowActionMenuItem, RowActionsMenu } from '@components/RowActionsMenu'
import { SectionSearchInput } from '@components/SectionSearchInput'
import { IconStore } from '@components/Sidebar/icons'
import { SkeletonTableRows } from '@components/SkeletonTableRows'
@@ -434,7 +434,7 @@ export default function RegistryCatalog() {
setRemoveTarget(entry)
},
},
- ] satisfies RowAction[]
+ ] satisfies RowActionMenuItem[]
}
/>
</td>
diff --git a/control-ui/components/RowActions/index.tsx b/control-ui/components/RowActions/index.tsx
new file mode 100644
index 000000000..ebd98c32d
--- /dev/null
+++ b/control-ui/components/RowActions/index.tsx
@@ -0,0 +1,62 @@
+'use client'
+
+import { IconChevronRight } from '@components/icons'
+import { Button } from '@components/ui'
+import { cn } from '@lib/cn'
+import { RowActionsMenu } from '../RowActionsMenu'
+import type { RowAction, RowActionKind, RowActionsProps } from './types'
+
+const KIND_ORDER: RowActionKind[] = ['utility', 'edit', 'destructive', 'inspect']
+
+/** Kinds that stay one click away even when the row overflows. */
+const ALWAYS_INLINE: RowActionKind[] = ['destructive', 'inspect']
+
+function byKind(a: RowAction, b: RowAction) {
+ return KIND_ORDER.indexOf(a.kind) - KIND_ORDER.indexOf(b.kind)
+}
+
+/**
+ * The single row-action surface for route tables. It fixes the order and the
+ * affordance vocabulary and leaves the set of actions to the caller, because
+ * rows legitimately differ: a file row has more operations than a plugin row,
+ * and an unpriced model row cannot be deleted at all.
+ */
+export function RowActions({ actions, className, overflowAfter = 3 }: RowActionsProps) {
+ const ordered = actions.filter(action => !action.hidden).sort(byKind)
+ const overflows = ordered.length > overflowAfter
+
+ const collapsed = overflows ? ordered.filter(action => !ALWAYS_INLINE.includes(action.kind)) : []
+ const inline = overflows ? ordered.filter(action => ALWAYS_INLINE.includes(action.kind)) : ordered
+
+ return (
+ <div className={cn('cu-row-actions', className)}>
+ {collapsed.length > 0 ? (
+ <RowActionsMenu
+ ariaLabel="More actions"
+ actions={collapsed.map(action => ({
+ key: action.key,
+ label: action.label,
+ onClick: action.onSelect,
+ disabled: action.disabled,
+ }))}
+ />
+ ) : null}
+ {inline.map(action => {
+ const destructive = action.kind === 'destructive'
+ return (
+ <Button
+ key={action.key}
+ aria-label={action.label}
+ disabled={action.disabled}
+ icon
+ onClick={action.onSelect}
+ toolbar={!destructive}
+ variant={destructive ? 'ghost-danger' : 'secondary'}
+ >
+ {action.kind === 'inspect' ? <IconChevronRight width={16} height={16} /> : action.icon}
+ </Button>
+ )
+ })}
+ </div>
+ )
+}
diff --git a/control-ui/components/RowActions/types.ts b/control-ui/components/RowActions/types.ts
new file mode 100644
index 000000000..0185d034f
--- /dev/null
+++ b/control-ui/components/RowActions/types.ts
@@ -0,0 +1,32 @@
+import type { ReactNode } from 'react'
+
+/**
+ * Row actions are ordered by kind, never by array position, so every route
+ * table presents the same vocabulary in the same place:
+ *
+ * - `utility` non-mutating helpers (copy, download)
+ * - `edit` opens an editor for the row
+ * - `destructive` removes the row
+ * - `inspect` opens the row's detail view; always the right-edge chevron
+ */
+export type RowActionKind = 'utility' | 'edit' | 'destructive' | 'inspect'
+
+export type RowAction = {
+ key: string
+ kind: RowActionKind
+ /** Required. Becomes the button's `aria-label`, and its text once overflowed. */
+ label: string
+ /** Omit for `inspect`: the chevron is supplied so every table opens details alike. */
+ icon?: ReactNode
+ onSelect: () => void
+ disabled?: boolean
+ /** Lets a row drop an affordance it cannot support in its current state. */
+ hidden?: boolean
+}
+
+export type RowActionsProps = {
+ actions: RowAction[]
+ /** Beyond this many buttons, non-destructive/non-inspect actions collapse into a kebab. */
+ overflowAfter?: number
+ className?: string
+}
diff --git a/control-ui/components/RowActionsMenu/index.tsx b/control-ui/components/RowActionsMenu/index.tsx
index 4c768ec19..b5490689f 100644
--- a/control-ui/components/RowActionsMenu/index.tsx
+++ b/control-ui/components/RowActionsMenu/index.tsx
@@ -5,7 +5,7 @@ import { createPortal } from 'react-dom'
import { IconDotsVertical, IconMoreHorizontal } from '@components/icons'
import type { RowActionsMenuProps } from './types'
-export type { RowAction } from './types'
+export type { RowActionMenuItem } from './types'
function getEnabledMenuItems(menu: HTMLDivElement | null): HTMLButtonElement[] {
if (!menu) return []
diff --git a/control-ui/components/RowActionsMenu/types.ts b/control-ui/components/RowActionsMenu/types.ts
index 51449f717..b2482527b 100644
--- a/control-ui/components/RowActionsMenu/types.ts
+++ b/control-ui/components/RowActionsMenu/types.ts
@@ -1,4 +1,9 @@
-export type RowAction = {
+/**
+ * One entry inside the kebab menu. This is the menu's own item shape, distinct
+ * from `RowActions`' `RowAction` descriptor: the menu renders text entries and
+ * knows nothing about kind ordering or inline affordances.
+ */
+export type RowActionMenuItem = {
key: string
label: string
onClick: () => void
@@ -8,6 +13,6 @@ export type RowAction = {
export type RowActionsMenuProps = {
ariaLabel: string
- actions: RowAction[]
+ actions: RowActionMenuItem[]
horizontalTrigger?: boolean
}
diff --git a/control-ui/components/__tests__/Button.test.tsx b/control-ui/components/__tests__/Button.test.tsx
new file mode 100644
index 000000000..db9a359de
--- /dev/null
+++ b/control-ui/components/__tests__/Button.test.tsx
@@ -0,0 +1,48 @@
+import { afterEach, describe, expect, it } from 'vitest'
+import { cleanup, render, screen } from '@testing-library/react'
+import { Button } from '../ui'
+
+afterEach(cleanup)
+
+describe('Button', () => {
+ it('maps the icon and toolbar props onto their modifier classes', () => {
+ render(
+ <Button icon toolbar>
+ <span aria-hidden="true" />
+ </Button>
+ )
+
+ const button = screen.getByRole('button')
+ expect(button).toHaveClass('cu-btn', 'cu-btn--icon', 'cu-btn--toolbar')
+ })
+
+ it('renders ghost-danger as a ghost button tinted danger', () => {
+ render(<Button variant="ghost-danger">Remove</Button>)
+
+ expect(screen.getByRole('button')).toHaveClass('cu-btn--ghost', 'cu-btn--ghost-danger')
+ })
+
+ it('reuses the danger-icon treatment for a ghost-danger icon button', () => {
+ render(
+ <Button icon variant="ghost-danger" aria-label="Delete">
+ <span aria-hidden="true" />
+ </Button>
+ )
+
+ // cu-btn--icon.cu-btn--toolbar would win the colour cascade over
+ // cu-btn--ghost-danger, so the combination maps onto the class that
+ // already renders a transparent, danger-tinted glyph.
+ const button = screen.getByRole('button', { name: 'Delete' })
+ expect(button).toHaveClass('cu-btn--icon', 'cu-btn--danger-icon')
+ expect(button).not.toHaveClass('cu-btn--ghost-danger')
+ })
+
+ it('shows a spinner and blocks interaction while loading', () => {
+ const view = render(<Button loading>Save</Button>)
+
+ const button = screen.getByRole('button')
+ expect(button).toBeDisabled()
+ expect(button).toHaveAttribute('aria-busy', 'true')
+ expect(view.container.querySelector('.cu-btn__spinner')).toBeInTheDocument()
+ })
+})
diff --git a/control-ui/components/__tests__/RowActions.test.tsx b/control-ui/components/__tests__/RowActions.test.tsx
new file mode 100644
index 000000000..f36cd98ab
--- /dev/null
+++ b/control-ui/components/__tests__/RowActions.test.tsx
@@ -0,0 +1,90 @@
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, render, screen } from '@testing-library/react'
+import { RowActions } from '../RowActions'
+import type { RowAction, RowActionKind } from '../RowActions/types'
+
+afterEach(cleanup)
+
+function action(key: string, kind: RowActionKind, label: string): RowAction {
+ return { key, kind, label, icon: <span aria-hidden="true" />, onSelect: vi.fn() }
+}
+
+function labels() {
+ return screen.getAllByRole('button').map(button => button.getAttribute('aria-label'))
+}
+
+describe('RowActions', () => {
+ it('orders actions by kind, not by array order', () => {
+ render(
+ <RowActions
+ overflowAfter={4}
+ actions={[
+ action('open', 'inspect', 'Open'),
+ action('delete', 'destructive', 'Delete'),
+ action('copy', 'utility', 'Copy'),
+ action('edit', 'edit', 'Edit'),
+ ]}
+ />
+ )
+
+ expect(labels()).toEqual(['Copy', 'Edit', 'Delete', 'Open'])
+ })
+
+ it('omits hidden actions so a row can drop an affordance it cannot support', () => {
+ render(
+ <RowActions
+ actions={[
+ action('edit', 'edit', 'Edit'),
+ { ...action('delete', 'destructive', 'Delete'), hidden: true },
+ ]}
+ />
+ )
+
+ expect(labels()).toEqual(['Edit'])
+ })
+
+ it('collapses all but destructive and inspect once past the overflow threshold', () => {
+ render(
+ <RowActions
+ overflowAfter={3}
+ actions={[
+ action('copy', 'utility', 'Copy'),
+ action('download', 'utility', 'Download'),
+ action('edit', 'edit', 'Edit'),
+ action('delete', 'destructive', 'Delete'),
+ action('open', 'inspect', 'Open'),
+ ]}
+ />
+ )
+
+ // Delete stays reachable in one click; the rest move behind the kebab.
+ expect(labels()).toEqual(['More actions', 'Delete', 'Open'])
+ expect(screen.getByRole('button', { name: 'More actions' })).toHaveAttribute(
+ 'aria-haspopup',
+ 'menu'
+ )
+ })
+
+ it('keeps every action inline when it fits within the threshold', () => {
+ render(
+ <RowActions
+ overflowAfter={3}
+ actions={[
+ action('copy', 'utility', 'Copy'),
+ action('edit', 'edit', 'Edit'),
+ action('delete', 'destructive', 'Delete'),
+ ]}
+ />
+ )
+
+ expect(labels()).toEqual(['Copy', 'Edit', 'Delete'])
+ })
+
+ it('supplies the chevron for inspect so every table opens details the same way', () => {
+ render(
+ <RowActions actions={[{ key: 'open', kind: 'inspect', label: 'Open', onSelect: vi.fn() }]} />
+ )
+
+ expect(screen.getByRole('button', { name: 'Open' }).querySelector('svg')).toBeInTheDocument()
+ })
+})
diff --git a/control-ui/components/ui/index.tsx b/control-ui/components/ui/index.tsx
index 5df4561cf..bd21540ad 100644
--- a/control-ui/components/ui/index.tsx
+++ b/control-ui/components/ui/index.tsx
@@ -15,26 +15,50 @@ import type {
export function Button({
block = false,
+ children,
className,
+ disabled = false,
+ icon = false,
+ loading = false,
size = 'md',
+ toolbar = false,
type = 'button',
variant = 'secondary',
...props
}: ButtonProps) {
return (
<button
+ aria-busy={loading || undefined}
className={cn(
'cu-btn',
variant === 'primary' && 'cu-btn--primary',
- variant === 'ghost' && 'cu-btn--ghost',
+ (variant === 'ghost' || variant === 'ghost-danger') && 'cu-btn--ghost',
+ variant === 'ghost-danger' && !icon && 'cu-btn--ghost-danger',
+ // `cu-btn--icon.cu-btn--toolbar` sets `color` at specificity 0,2,0, which
+ // would beat `cu-btn--ghost-danger` at 0,1,0 and render a delete glyph
+ // grey. `cu-btn--danger-icon` is the existing class that already gets
+ // this combination right, so reuse it rather than recomposing.
+ variant === 'ghost-danger' && icon && 'cu-btn--danger-icon',
variant === 'danger' && 'cu-btn--danger',
size === 'sm' && 'cu-btn--sm',
block && 'cu-btn--block',
+ icon && 'cu-btn--icon',
+ toolbar && 'cu-btn--toolbar',
className
)}
+ disabled={disabled || loading}
type={type}
{...props}
- />
+ >
+ {loading ? (
+ <span className="cu-btn__content">
+ <span aria-hidden="true" className="cu-btn__spinner" />
+ {children}
+ </span>
+ ) : (
+ children
+ )}
+ </button>
)
}
diff --git a/control-ui/components/ui/types.ts b/control-ui/components/ui/types.ts
index 195a8fa0a..aa263b896 100644
--- a/control-ui/components/ui/types.ts
+++ b/control-ui/components/ui/types.ts
@@ -6,12 +6,18 @@ import type {
TextareaHTMLAttributes,
} from 'react'
-export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger'
+export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'ghost-danger' | 'danger'
export type ButtonSize = 'md' | 'sm'
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
block?: boolean
+ /** Square, padding-free button sized for a single glyph. */
+ icon?: boolean
size?: ButtonSize
+ /** Disables the button and swaps its content for a spinner. */
+ loading?: boolean
+ /** Borderless treatment for buttons sitting in a table or panel toolbar. */
+ toolbar?: boolean
variant?: ButtonVariant
}
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 9371562e4..c7cda9813 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.458",
+ "version": "0.1.459",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.458",
+ "version": "0.1.459",
"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.json
index 6feb28a82..29e399255 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.458",
+ "version": "0.1.459",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/docs/agents/control-ui-rules.md b/docs/agents/control-ui-rules.md
index 162d8f965..fc54ed8e2 100644
--- a/docs/agents/control-ui-rules.md
+++ b/docs/agents/control-ui-rules.md
@@ -75,9 +75,13 @@ leaning on either behaviour.
- Keep the table element and its header row mounted through loading, empty, and
error states. Only the body changes. An empty result renders a full-width row,
not an unmounted table.
-- Row actions run in a fixed order: utility, then edit, then destructive, then
- the detail-open chevron. The chevron sits at the right edge and is the only
- affordance for opening a detail view.
+- Render row actions with `RowActions`. It fixes the order by `kind` (utility,
+ then edit, then destructive, then inspect) regardless of array order, supplies
+ the right-edge chevron for `inspect`, and collapses everything except
+ destructive and inspect into a kebab past `overflowAfter`. Set `hidden` to drop
+ an affordance a row cannot support rather than rendering a disabled one.
+- The chevron is the only affordance for opening a detail view. Do not add a
+ name link, a left-edge chevron, or a row click as a second route.
- `app/cost-and-usage/llm-prices` is the reference implementation for a route
table, including state-dependent row affordances.