Skip to content

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

TypeScript

fix(control-ui): address PR 634 review follow-ups

Josué8a517b67bc1b
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.css
index bd1dc6ca7..14db8e894 100644
--- a/control-ui/app/globals.css
+++ b/control-ui/app/globals.css
@@ -8862,19 +8862,12 @@ td.cu-registry-description {
text-transform: uppercase;
}
-.cu-identity-dirty[data-hidden='true'],
-.cu-identity-dirty-actions[data-hidden='true'] {
+.cu-identity-dirty[data-hidden='true'] {
opacity: 0;
pointer-events: none;
visibility: hidden;
}
-.cu-identity-dirty-actions {
- display: inline-flex;
- align-items: center;
- gap: var(--cu-space-2);
-}
-
.cu-identity-panel__local-actions {
display: inline-flex;
justify-content: flex-end;
diff --git a/control-ui/components/ConfirmDialog/index.tsx b/control-ui/components/ConfirmDialog/index.tsx
index 45c9f461c..a39f57e49 100644
--- a/control-ui/components/ConfirmDialog/index.tsx
+++ b/control-ui/components/ConfirmDialog/index.tsx
@@ -1,7 +1,12 @@
'use client'
import { useCallback, useEffect, useId, useRef, useState } from 'react'
-import type { ConfirmDialogOptions, ConfirmDialogProps, ConfirmDialogRequest } from './types'
+import type {
+ ConfirmDialogOptions,
+ ConfirmDialogOutcome,
+ ConfirmDialogProps,
+ ConfirmDialogRequest,
+} from './types'
function ConfirmDialog({ request, onResolve }: ConfirmDialogProps) {
const titleId = useId()
@@ -16,7 +21,7 @@ function ConfirmDialog({ request, onResolve }: ConfirmDialogProps) {
cancelButtonRef.current?.focus()
function onKeyDown(event: KeyboardEvent) {
- if (event.key === 'Escape') onResolve(false)
+ if (event.key === 'Escape') onResolve('dismiss')
}
window.addEventListener('keydown', onKeyDown)
@@ -31,6 +36,7 @@ function ConfirmDialog({ request, onResolve }: ConfirmDialogProps) {
const {
cancelLabel = 'Cancel',
confirmLabel = 'OK',
+ discardLabel,
details,
message,
title = 'Confirm action',
@@ -43,7 +49,7 @@ function ConfirmDialog({ request, onResolve }: ConfirmDialogProps) {
className="cu-modal-backdrop"
role="presentation"
onMouseDown={event => {
- if (event.target === event.currentTarget) onResolve(false)
+ if (event.target === event.currentTarget) onResolve('dismiss')
}}
>
<section
@@ -72,11 +78,20 @@ function ConfirmDialog({ request, onResolve }: ConfirmDialogProps) {
ref={cancelButtonRef}
type="button"
className="cu-btn cu-btn--ghost"
- onClick={() => onResolve(false)}
+ onClick={() => onResolve('cancel')}
>
{cancelLabel}
</button>
- <button type="button" className={confirmButtonClass} onClick={() => onResolve(true)}>
+ {discardLabel ? (
+ <button
+ type="button"
+ className="cu-btn cu-btn--danger"
+ onClick={() => onResolve('discard')}
+ >
+ {discardLabel}
+ </button>
+ ) : null}
+ <button type="button" className={confirmButtonClass} onClick={() => onResolve('confirm')}>
{confirmLabel}
</button>
</div>
@@ -90,9 +105,9 @@ export function useConfirmDialog() {
const nextIdRef = useRef(0)
const resolveRequest = useCallback(
- (confirmed: boolean) => {
+ (outcome: ConfirmDialogOutcome) => {
setRequest(current => {
- if (current) current.resolve(confirmed)
+ if (current) current.resolve(outcome)
return null
})
},
@@ -101,6 +116,17 @@ export function useConfirmDialog() {
const confirm = useCallback((options: ConfirmDialogOptions) => {
return new Promise<boolean>(resolve => {
+ nextIdRef.current += 1
+ setRequest({
+ id: nextIdRef.current,
+ options,
+ resolve: outcome => resolve(outcome === 'confirm'),
+ })
+ })
+ }, [])
+
+ const choose = useCallback((options: ConfirmDialogOptions) => {
+ return new Promise<ConfirmDialogOutcome>(resolve => {
nextIdRef.current += 1
setRequest({ id: nextIdRef.current, options, resolve })
})
@@ -108,6 +134,7 @@ export function useConfirmDialog() {
return {
confirm,
+ choose,
confirmDialog: <ConfirmDialog request={request} onResolve={resolveRequest} />,
}
}
diff --git a/control-ui/components/ConfirmDialog/types.ts b/control-ui/components/ConfirmDialog/types.ts
index bf0bec60a..fe18c88b9 100644
--- a/control-ui/components/ConfirmDialog/types.ts
+++ b/control-ui/components/ConfirmDialog/types.ts
@@ -1,6 +1,7 @@
import type { ReactNode } from 'react'
export type ConfirmDialogTone = 'default' | 'danger'
+export type ConfirmDialogOutcome = 'confirm' | 'cancel' | 'discard' | 'dismiss'
export interface ConfirmDialogOptions {
title?: string
@@ -13,16 +14,17 @@ export interface ConfirmDialogOptions {
details?: ReactNode
confirmLabel?: string
cancelLabel?: string
+ discardLabel?: string
tone?: ConfirmDialogTone
}
export interface ConfirmDialogRequest {
id: number
options: ConfirmDialogOptions
- resolve: (confirmed: boolean) => void
+ resolve: (outcome: ConfirmDialogOutcome) => void
}
export interface ConfirmDialogProps {
request: ConfirmDialogRequest | null
- onResolve: (confirmed: boolean) => void
+ onResolve: (outcome: ConfirmDialogOutcome) => void
}
diff --git a/control-ui/components/HostAdvancedTab/index.tsx b/control-ui/components/HostAdvancedTab/index.tsx
index ab09022f0..15b8e3ed1 100644
--- a/control-ui/components/HostAdvancedTab/index.tsx
+++ b/control-ui/components/HostAdvancedTab/index.tsx
@@ -6,9 +6,8 @@ import { DataTable, TableViewport } from '@clerum/frontend-components'
import { HostApprovalSection } from '@components/HostApprovalSection'
import { HostEnvTable } from '@components/HostEnvTable'
import { HostGuardrailsSection } from '@components/HostGuardrailsSection'
+import { GUARDRAIL_MARKETPLACE_ROUTE } from '@components/HostGuardrailsSection/constants'
import { TabBar } from '@components/TabBar'
-import { GUARDRAIL_ENTRY_TYPE } from '@constants/marketplaceEntryTypes'
-import { CONTROL_ROUTES } from '@constants/routes'
import type { AdvancedSubTab, HostAdvancedTabProps } from './types'
const ADVANCED_SUB_TABS: { key: AdvancedSubTab; label: string }[] = [
@@ -35,23 +34,19 @@ export function HostAdvancedTab({
const [subTab, setSubTab] = useState<AdvancedSubTab>(DEFAULT_SUB_TAB)
useEffect(() => {
- if (!onActionsChange || subTab !== 'hooks') return
+ if (!onActionsChange || initialLoading || subTab !== 'hooks') return
onActionsChange(
<button
type="button"
className="cu-btn cu-btn--primary cu-btn--sm"
- onClick={() =>
- routerRef.current.push(
- CONTROL_ROUTES.marketplace.orgEntriesFiltered({ type: GUARDRAIL_ENTRY_TYPE })
- )
- }
+ onClick={() => routerRef.current.push(GUARDRAIL_MARKETPLACE_ROUTE)}
disabled={busy}
>
Add hook
</button>
)
return () => onActionsChange(null)
- }, [busy, onActionsChange, subTab])
+ }, [busy, initialLoading, onActionsChange, subTab])
return (
<section className="cu-advanced-tab" aria-label="Advanced">
diff --git a/control-ui/components/HostGuardrailsSection/constants.ts b/control-ui/components/HostGuardrailsSection/constants.ts
index 47c22b7f8..c02dcd47b 100644
--- a/control-ui/components/HostGuardrailsSection/constants.ts
+++ b/control-ui/components/HostGuardrailsSection/constants.ts
@@ -1,5 +1,13 @@
+import { GUARDRAIL_ENTRY_TYPE } from '@constants/marketplaceEntryTypes'
+import { CONTROL_ROUTES } from '@constants/routes'
import type { GuardrailPhase } from './types'
+// Guardrail hooks are Marketplace entries; keep the chooser scoped to that
+// type so regular connectors and plugins do not appear as install candidates.
+export const GUARDRAIL_MARKETPLACE_ROUTE = CONTROL_ROUTES.marketplace.orgEntriesFiltered({
+ type: GUARDRAIL_ENTRY_TYPE,
+})
+
// Render/iteration order for the hook phases.
export const GUARDRAIL_PHASES: readonly GuardrailPhase[] = [
'preToolUse',
diff --git a/control-ui/components/HostGuardrailsSection/index.tsx b/control-ui/components/HostGuardrailsSection/index.tsx
index 6c80c646a..8a846351f 100644
--- a/control-ui/components/HostGuardrailsSection/index.tsx
+++ b/control-ui/components/HostGuardrailsSection/index.tsx
@@ -6,9 +6,8 @@ import { DataTable, TableViewport } from '@clerum/frontend-components'
import { useConfirmDialog } from '@components/ConfirmDialog'
import { RowActionsMenu } from '@components/RowActionsMenu'
import { useToast } from '@components/Toast'
-import { GUARDRAIL_ENTRY_TYPE } from '@constants/marketplaceEntryTypes'
import { CONTROL_ROUTES } from '@constants/routes'
-import { GUARDRAIL_PHASES, GUARDRAIL_PHASE_LABELS } from './constants'
+import { GUARDRAIL_MARKETPLACE_ROUTE, GUARDRAIL_PHASES, GUARDRAIL_PHASE_LABELS } from './constants'
import type { GuardrailHookRow, HostGuardrails, HostGuardrailsSectionProps } from './types'
// Every field this section does not edit rides along untouched — dropping
@@ -20,8 +19,6 @@ function withHooks(
return { ...source, hooks }
}
-const ADD_HOOK_ROUTE = CONTROL_ROUTES.marketplace.orgEntriesFiltered({ type: GUARDRAIL_ENTRY_TYPE })
-
export function HostGuardrailsSection({
initialGuardrails,
onSave,
@@ -94,7 +91,7 @@ export function HostGuardrailsSection({
<button
type="button"
className="cu-btn cu-btn--primary cu-btn--sm"
- onClick={() => router.push(ADD_HOOK_ROUTE)}
+ onClick={() => router.push(GUARDRAIL_MARKETPLACE_ROUTE)}
disabled={disabled}
>
Add hook
diff --git a/control-ui/components/HostIdentityTab/index.tsx b/control-ui/components/HostIdentityTab/index.tsx
index bd5f68670..b4d73b3aa 100644
--- a/control-ui/components/HostIdentityTab/index.tsx
+++ b/control-ui/components/HostIdentityTab/index.tsx
@@ -36,7 +36,7 @@ function fieldsFromPayload(payload: IdentityFields): IdentityFields {
export function HostIdentityTab({ hostName, onActionsChange }: HostIdentityTabProps) {
const { showToast } = useToast()
- const { confirm, confirmDialog } = useConfirmDialog()
+ const { choose, confirmDialog } = useConfirmDialog()
const loadRequestId = useRef(0)
const [state, setState] = useState<HostIdentityTabState>({
activeField: 'identity',
@@ -48,6 +48,8 @@ export function HostIdentityTab({ hostName, onActionsChange }: HostIdentityTabPr
resourceVersion: '',
saving: false,
})
+ const stateRef = useRef(state)
+ stateRef.current = state
const activeConfig =
IDENTITY_FIELDS.find(field => field.key === state.activeField) ?? IDENTITY_FIELDS[0]
@@ -105,16 +107,26 @@ export function HostIdentityTab({ hostName, onActionsChange }: HostIdentityTabPr
}, [])
const saveActiveField = useCallback(async (): Promise<boolean> => {
- if (!activeDirty || activeTooLarge || state.reloadHint) return false
+ const current = stateRef.current
+ const currentConfig =
+ IDENTITY_FIELDS.find(field => field.key === current.activeField) ?? IDENTITY_FIELDS[0]
+ const currentValue = current.fields[currentConfig.key]
+ if (
+ currentValue === current.initial[currentConfig.key] ||
+ fieldBytes(currentValue) > FIELD_MAX_BYTES ||
+ current.reloadHint
+ ) {
+ return false
+ }
setState(prev => ({ ...prev, error: '', saving: true }))
try {
const result = await updateHostPersonalization(hostName, {
- agents: state.fields.agents,
- identity: state.fields.identity,
- resourceVersion: state.resourceVersion,
- soul: state.fields.soul,
- user: state.fields.user,
+ agents: current.fields.agents,
+ identity: current.fields.identity,
+ resourceVersion: current.resourceVersion,
+ soul: current.fields.soul,
+ user: current.fields.user,
})
setState(prev => ({
...prev,
@@ -139,7 +151,7 @@ export function HostIdentityTab({ hostName, onActionsChange }: HostIdentityTabPr
showToast(message, { tone: 'error' })
return false
}
- }, [activeDirty, activeTooLarge, hostName, showToast, state])
+ }, [hostName, showToast])
const setActiveField = useCallback(
async (key: IdentityFieldKey) => {
@@ -149,16 +161,19 @@ export function HostIdentityTab({ hostName, onActionsChange }: HostIdentityTabPr
return
}
- const shouldSave = await confirm({
- cancelLabel: 'Discard all',
+ const outcome = await choose({
+ cancelLabel: 'Cancel',
confirmLabel: 'Save',
+ discardLabel: 'Discard all',
message: 'Save or discard your identity edits before changing files.',
title: 'Unsaved identity edits',
})
- if (shouldSave) {
+ if (outcome === 'confirm') {
if (!(await saveActiveField())) return
- } else {
+ } else if (outcome === 'discard') {
discardEdits()
+ } else {
+ return
}
setState(prev => ({ ...prev, activeField: key }))
},
@@ -218,6 +233,9 @@ export function HostIdentityTab({ hostName, onActionsChange }: HostIdentityTabPr
return (
<section className="cu-identity-panel" aria-label="Admin-managed identity files">
+ <p className="cu-identity-panel__intro">
+ Admin-managed identity files are readable by the agent but blocked from agent writes.
+ </p>
{!onActionsChange && anyDirty ? (
<div className="cu-identity-panel__local-actions">
<Button
diff --git a/control-ui/components/TablePanelHeader/ClampedDescription.tsx b/control-ui/components/TablePanelHeader/ClampedDescription.tsx
index 93c3153cd..5e7696004 100644
--- a/control-ui/components/TablePanelHeader/ClampedDescription.tsx
+++ b/control-ui/components/TablePanelHeader/ClampedDescription.tsx
@@ -1,13 +1,20 @@
'use client'
-import { useId, useLayoutEffect, useRef, useState } from 'react'
+import { Children, isValidElement, useLayoutEffect, useRef, useState } from 'react'
import type { ReactNode } from 'react'
+function getDescriptionText(node: ReactNode): string {
+ if (typeof node === 'string' || typeof node === 'number') return String(node)
+ if (!isValidElement<{ children?: ReactNode }>(node)) return ''
+ return Children.toArray(node.props.children).map(getDescriptionText).join('')
+}
+
export function ClampedDescription({ children }: { children: ReactNode }) {
const contentRef = useRef<HTMLSpanElement>(null)
- const tooltipId = useId()
const [isTruncated, setIsTruncated] = useState(false)
+ const tooltipText = Children.toArray(children).map(getDescriptionText).join('')
+
useLayoutEffect(() => {
const content = contentRef.current
if (!content) return
@@ -23,20 +30,16 @@ export function ClampedDescription({ children }: { children: ReactNode }) {
observer?.disconnect()
window.removeEventListener('resize', measure)
}
- }, [])
+ }, [children])
return (
- <span
- aria-describedby={isTruncated ? tooltipId : undefined}
- className="cu-table-panel__description"
- tabIndex={isTruncated ? 0 : undefined}
- >
+ <span className="cu-table-panel__description" tabIndex={isTruncated ? 0 : undefined}>
<span ref={contentRef} className="cu-table-panel__description-value">
{children}
</span>
{isTruncated ? (
- <span className="cu-table-panel__description-tooltip" id={tooltipId} role="tooltip">
- {children}
+ <span aria-hidden="true" className="cu-table-panel__description-tooltip" role="tooltip">
+ {tooltipText}
</span>
) : null}
</span>
diff --git a/control-ui/components/TablePanelHeader/index.tsx b/control-ui/components/TablePanelHeader/index.tsx
index 109e291e6..3f447d5f1 100644
--- a/control-ui/components/TablePanelHeader/index.tsx
+++ b/control-ui/components/TablePanelHeader/index.tsx
@@ -28,7 +28,10 @@ export function TablePanelHeader({
}: TablePanelHeaderProps) {
const titleNodes = flattenTitleNodes(title)
const [firstTitleNode, ...remainingTitleNodes] = titleNodes
- const titleIcon = isValidElement(firstTitleNode) ? firstTitleNode : undefined
+ const titleIcon =
+ isValidElement(firstTitleNode) && typeof firstTitleNode.type !== 'string'
+ ? firstTitleNode
+ : undefined
const titleText = titleIcon ? remainingTitleNodes : titleNodes
return (
diff --git a/control-ui/components/__tests__/HostAdvancedTab.test.tsx b/control-ui/components/__tests__/HostAdvancedTab.test.tsx
new file mode 100644
index 000000000..cea9b0393
--- /dev/null
+++ b/control-ui/components/__tests__/HostAdvancedTab.test.tsx
@@ -0,0 +1,51 @@
+import React from 'react'
+import { describe, expect, it, vi } from 'vitest'
+import { fireEvent, render, screen } from '@testing-library/react'
+import { HostAdvancedTab } from '../HostAdvancedTab'
+
+vi.mock('next/navigation', () => ({ useRouter: () => ({ push: vi.fn() }) }))
+vi.mock('../HostApprovalSection', () => ({ HostApprovalSection: () => <div>Approvals</div> }))
+vi.mock('../HostEnvTable', () => ({ HostEnvTable: () => <div>Environment variables</div> }))
+vi.mock('../HostGuardrailsSection', () => ({ HostGuardrailsSection: () => <div>Hooks</div> }))
+
+function renderHeaderMode(initialLoading = false) {
+ function HeaderMode() {
+ const [actions, setActions] = React.useState<React.ReactNode>(null)
+ return (
+ <>
+ <div aria-label="Header actions">{actions}</div>
+ <HostAdvancedTab
+ busy={false}
+ hostName="foo"
+ initialGuardrails={undefined}
+ initialLoading={initialLoading}
+ initialTools={{}}
+ onActionsChange={setActions}
+ onSaveApprovalTools={vi.fn()}
+ onSaveGuardrails={vi.fn()}
+ />
+ </>
+ )
+ }
+
+ return render(<HeaderMode />)
+}
+
+describe('HostAdvancedTab title actions', () => {
+ it('registers Add hook only for the loaded Hooks subtab', () => {
+ renderHeaderMode()
+
+ expect(screen.getByRole('button', { name: 'Add hook' })).toBeInTheDocument()
+ fireEvent.click(screen.getByRole('tab', { name: 'Per-tool approval' }))
+ expect(screen.queryByRole('button', { name: 'Add hook' })).toBeNull()
+ fireEvent.click(screen.getByRole('tab', { name: 'Hooks' }))
+ expect(screen.getByRole('button', { name: 'Add hook' })).toBeInTheDocument()
+ })
+
+ it('does not register Add hook while hooks are initially loading', () => {
+ renderHeaderMode(true)
+
+ expect(screen.queryByRole('button', { name: 'Add hook' })).toBeNull()
+ expect(screen.getByRole('status', { name: 'Loading guardrail hooks' })).toBeInTheDocument()
+ })
+})
diff --git a/control-ui/components/__tests__/HostIdentityTab.test.tsx b/control-ui/components/__tests__/HostIdentityTab.test.tsx
index 7c1f8ab86..cc6a15c33 100644
--- a/control-ui/components/__tests__/HostIdentityTab.test.tsx
+++ b/control-ui/components/__tests__/HostIdentityTab.test.tsx
@@ -28,14 +28,28 @@ describe('HostIdentityTab', () => {
return editor
}
- function renderTab() {
+ function renderTab(onActionsChange?: (actions: React.ReactNode | null) => void) {
return render(
<ToastProvider>
- <HostIdentityTab hostName="foo" />
+ <HostIdentityTab hostName="foo" onActionsChange={onActionsChange} />
</ToastProvider>
)
}
+ function renderHeaderTab() {
+ function HeaderMode() {
+ const [actions, setActions] = React.useState<React.ReactNode>(null)
+ return (
+ <ToastProvider>
+ <div aria-label="Header actions">{actions}</div>
+ <HostIdentityTab hostName="foo" onActionsChange={setActions} />
+ </ToastProvider>
+ )
+ }
+
+ return render(<HeaderMode />)
+ }
+
it('renders the four section tabs and displays the editor for each section', async () => {
;(api.getHostPersonalization as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({
agents: 'a',
@@ -150,6 +164,104 @@ describe('HostIdentityTab', () => {
expect(screen.queryByRole('button', { name: /save/i })).not.toBeInTheDocument()
})
+ it('keeps edits and the active file when the unsaved-edits prompt is dismissed', async () => {
+ ;(api.getHostPersonalization as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({
+ agents: '',
+ identity: 'identity old',
+ resourceVersion: '1',
+ soul: 'soul old',
+ user: '',
+ })
+ renderTab()
+ const identityEditor = await findMarkdownEditor(/Identity markdown/i)
+ fireEvent.change(identityEditor, { target: { value: 'identity new' } })
+ fireEvent.click(screen.getByRole('tab', { name: 'Soul' }))
+ expect(screen.getByRole('alertdialog')).toBeInTheDocument()
+
+ fireEvent.keyDown(window, { key: 'Escape' })
+
+ await waitFor(() => expect(screen.queryByRole('alertdialog')).toBeNull())
+ expect(screen.getByLabelText(/Identity markdown/i)).toHaveValue('identity new')
+ expect(screen.queryByLabelText(/Soul markdown/i)).toBeNull()
+ })
+
+ it('saves edited content before switching identity files', async () => {
+ ;(api.getHostPersonalization as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({
+ agents: '',
+ identity: 'identity old',
+ resourceVersion: '1',
+ soul: 'soul old',
+ user: '',
+ })
+ ;(api.updateHostPersonalization as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({
+ resourceVersion: '2',
+ })
+ renderTab()
+ fireEvent.change(await findMarkdownEditor(/Identity markdown/i), {
+ target: { value: 'identity new' },
+ })
+ fireEvent.click(screen.getByRole('tab', { name: 'Soul' }))
+ fireEvent.click(within(screen.getByRole('alertdialog')).getByRole('button', { name: 'Save' }))
+
+ await waitFor(() =>
+ expect(api.updateHostPersonalization).toHaveBeenCalledWith(
+ 'foo',
+ expect.objectContaining({ identity: 'identity new' })
+ )
+ )
+ await expectMarkdownEditorValue(/Soul markdown/i, 'soul old')
+ })
+
+ it('keeps the current file selected when saving before a switch fails', async () => {
+ ;(api.getHostPersonalization as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({
+ agents: '',
+ identity: 'identity old',
+ resourceVersion: '1',
+ soul: 'soul old',
+ user: '',
+ })
+ ;(api.updateHostPersonalization as unknown as ReturnType<typeof vi.fn>).mockRejectedValue(
+ Object.assign(new Error('HTTP 409'), { status: 409 })
+ )
+ renderTab()
+ fireEvent.change(await findMarkdownEditor(/Identity markdown/i), {
+ target: { value: 'identity new' },
+ })
+ fireEvent.click(screen.getByRole('tab', { name: 'Soul' }))
+ fireEvent.click(within(screen.getByRole('alertdialog')).getByRole('button', { name: 'Save' }))
+
+ await waitFor(() =>
+ expect(screen.getAllByText(/someone else updated/i).length).toBeGreaterThan(0)
+ )
+ expect(screen.getByLabelText(/Identity markdown/i)).toHaveValue('identity new')
+ expect(screen.queryByLabelText(/Soul markdown/i)).toBeNull()
+ })
+
+ it('registers dirty-file actions in header mode without re-registering per keystroke', async () => {
+ const onActionsChange = vi.fn()
+ ;(api.getHostPersonalization as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({
+ agents: '',
+ identity: 'identity old',
+ resourceVersion: '1',
+ soul: '',
+ user: '',
+ })
+ renderTab(onActionsChange)
+ const editor = await findMarkdownEditor(/Identity markdown/i)
+ fireEvent.change(editor, { target: { value: 'identity one' } })
+ await waitFor(() => expect(onActionsChange).toHaveBeenCalled())
+ const callsAfterFirstEdit = onActionsChange.mock.calls.length
+
+ fireEvent.change(editor, { target: { value: 'identity two' } })
+ expect(onActionsChange).toHaveBeenCalledTimes(callsAfterFirstEdit)
+
+ cleanup()
+ renderHeaderTab()
+ const headerEditor = await screen.findByLabelText(/Identity markdown/i)
+ fireEvent.change(headerEditor, { target: { value: 'identity header edit' } })
+ await waitFor(() => expect(screen.getByRole('button', { name: /save/i })).toBeInTheDocument())
+ })
+
it('disables Save and marks the textarea invalid when the active field exceeds 64 KiB', async () => {
;(api.getHostPersonalization as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({
agents: '',
diff --git a/control-ui/components/__tests__/TablePanelHeader.test.tsx b/control-ui/components/__tests__/TablePanelHeader.test.tsx
index e6ed09699..c006a6544 100644
--- a/control-ui/components/__tests__/TablePanelHeader.test.tsx
+++ b/control-ui/components/__tests__/TablePanelHeader.test.tsx
@@ -6,6 +6,10 @@ import { TablePanelHeader } from '../TablePanelHeader'
const css = readFileSync(resolve(__dirname, '../../app/globals.css'), 'utf8')
+function AgentsIcon() {
+ return <svg aria-label="Agents icon" />
+}
+
describe('TablePanelHeader', () => {
it('applies the common action-toolbar layout to every header', () => {
render(
@@ -30,7 +34,7 @@ describe('TablePanelHeader', () => {
<TablePanelHeader
title={
<>
- <svg aria-label="Agents icon" />
+ <AgentsIcon />
Agents (8)
</>
}
@@ -43,6 +47,13 @@ describe('TablePanelHeader', () => {
expect(screen.getByText('Agents (8)')).toHaveClass('cu-table-panel__title-text')
})
+ it('does not treat an ordinary leading title element as an icon', () => {
+ render(<TablePanelHeader title={<span>Agents</span>} />)
+
+ expect(screen.getByText('Agents').closest('.cu-table-panel__title-text')).not.toBeNull()
+ expect(document.querySelector('.cu-table-panel__title-icon')).toBeNull()
+ })
+
it('renders secondary actions, search, refresh, and the primary action in focus order', () => {
render(
<TablePanelHeader
@@ -102,7 +113,7 @@ describe('TablePanelHeader', () => {
const description = document.querySelector('.cu-table-panel__description')
expect(description).toHaveAttribute('tabindex', '0')
- expect(screen.getByRole('tooltip')).toHaveTextContent(
+ expect(screen.getByRole('tooltip', { hidden: true })).toHaveTextContent(
'A longer description that cannot fit within two lines.'
)
} finally {
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index c0df12b81..388568a25 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.587",
+ "version": "0.1.588",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.587",
+ "version": "0.1.588",
"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 9990e37e6..c852dbe31 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.587",
+ "version": "0.1.588",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",