Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): keep table header actions on one line
Josué2c76f8366a5c
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.cssindex 3b55fa072..2e5160677 100644--- a/control-ui/app/globals.css+++ b/control-ui/app/globals.css@@ -2440,7 +2440,7 @@ textarea.cu-input {display: flex;align-items: stretch;justify-content: space-between;- flex-wrap: wrap;+ position: relative;gap: 0.65rem;padding: 0.85rem 1rem;background:@@ -2461,6 +2461,14 @@ textarea.cu-input {display: flex;align-items: center;gap: var(--cu-space-1);+ min-width: 0;+}++.cu-table-panel__title-text {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;}.cu-table-panel__subtitle {@@ -2471,28 +2479,77 @@ textarea.cu-input {}.cu-table-panel__head > .eft-data-view-header__main {- flex-wrap: wrap;+ flex-wrap: nowrap;width: 100%;min-width: 0;}.cu-table-panel__head .eft-data-view-header__identity {- flex: 0 1 auto;+ flex: 1 1 auto;+ min-width: 0;+}++.cu-table-panel__head .eft-data-view-header__identity > div {+ flex: 1 1 auto;+ min-width: 0;}.cu-table-panel__head .eft-data-view-header__actions {- flex: 1 1 42rem;+ flex: 0 0 auto;min-width: 0;+ width: auto;}.cu-table-panel__actions {display: flex;align-items: center;justify-content: flex-end;- flex-wrap: wrap;+ flex-wrap: nowrap;gap: 0.4rem;align-self: flex-start;- width: 100%;+ width: auto;+}++.cu-table-panel__description {+ display: block;+ min-width: 0;+}++.cu-table-panel__description-value {+ display: -webkit-box;+ overflow: hidden;+ text-overflow: ellipsis;+ -webkit-box-orient: vertical;+ -webkit-line-clamp: 2;+ line-clamp: 2;+}++.cu-table-panel__description[tabindex='0'] {+ cursor: help;+}++.cu-table-panel__description-tooltip {+ display: none;+ position: absolute;+ inset-inline: 0;+ top: calc(100% + var(--cu-space-05));+ z-index: 8;+ box-sizing: border-box;+ padding: var(--cu-space-3);+ border: 1px solid var(--cu-border-subtle);+ border-radius: var(--cu-radius-sm);+ background: var(--cu-surface);+ box-shadow: var(--cu-shadow);+ color: var(--cu-text);+ font-size: var(--cu-font-size-sm);+ font-weight: var(--cu-font-weight-regular);+ line-height: var(--cu-line-height-normal);+ overflow-wrap: normal;+}++.cu-table-panel__description:hover .cu-table-panel__description-tooltip,+.cu-table-panel__description:focus-within .cu-table-panel__description-tooltip {+ display: block;}.cu-table-panel__actions > select.cu-input {@@ -11161,9 +11218,9 @@ td.cu-registry-description {}.cu-table-panel__actions {- justify-content: flex-start;- flex-wrap: wrap;- width: 100%;+ justify-content: flex-end;+ flex-wrap: nowrap;+ width: auto;}.cu-table-panel__actions > .cu-section-search {@@ -11172,8 +11229,8 @@ td.cu-registry-description {}.cu-table-panel__head .eft-data-view-header__actions {- flex: none;- width: 100%;+ flex: 0 0 auto;+ width: auto;}.cu-registry-toolbar .cu-section-search {diff --git a/control-ui/components/TablePanelHeader/ClampedDescription.tsx b/control-ui/components/TablePanelHeader/ClampedDescription.tsxnew file mode 100644index 000000000..93c3153cd--- /dev/null+++ b/control-ui/components/TablePanelHeader/ClampedDescription.tsx@@ -0,0 +1,44 @@+'use client'++import { useId, useLayoutEffect, useRef, useState } from 'react'+import type { ReactNode } from 'react'++export function ClampedDescription({ children }: { children: ReactNode }) {+ const contentRef = useRef<HTMLSpanElement>(null)+ const tooltipId = useId()+ const [isTruncated, setIsTruncated] = useState(false)++ useLayoutEffect(() => {+ const content = contentRef.current+ if (!content) return++ const measure = () => setIsTruncated(content.scrollHeight > content.clientHeight + 1)+ measure()++ const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(measure)+ observer?.observe(content)+ window.addEventListener('resize', measure)++ return () => {+ observer?.disconnect()+ window.removeEventListener('resize', measure)+ }+ }, [])++ return (+ <span+ aria-describedby={isTruncated ? tooltipId : undefined}+ 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>+ ) : null}+ </span>+ )+}diff --git a/control-ui/components/TablePanelHeader/index.tsx b/control-ui/components/TablePanelHeader/index.tsxindex 3160acdae..90eff8896 100644--- a/control-ui/components/TablePanelHeader/index.tsx+++ b/control-ui/components/TablePanelHeader/index.tsx@@ -2,6 +2,7 @@import { DataViewHeader } from '@clerum/frontend-components'import { cn } from '@lib/cn'+import { ClampedDescription } from './ClampedDescription'import type { TablePanelHeaderProps } from './types'/** Control UI compatibility adapter for the shared list header. */@@ -28,10 +29,10 @@ export function TablePanelHeader({) : undefined}className="cu-table-panel__head"- description={subtitle}+ description={subtitle ? <ClampedDescription>{subtitle}</ClampedDescription> : undefined}title={<span className="cu-panel-title cu-table-panel__title-row">- {title}+ <span className="cu-table-panel__title-text">{title}</span>{titleActions}</span>}diff --git a/control-ui/components/__tests__/TablePanelHeader.test.tsx b/control-ui/components/__tests__/TablePanelHeader.test.tsxindex e90ddef66..24b2d919f 100644--- a/control-ui/components/__tests__/TablePanelHeader.test.tsx+++ b/control-ui/components/__tests__/TablePanelHeader.test.tsx@@ -1,4 +1,4 @@-import { describe, expect, it } from 'vitest'+import { describe, expect, it, vi } from 'vitest'import { render, screen } from '@testing-library/react'import { readFileSync } from 'node:fs'import { resolve } from 'node:path'@@ -44,29 +44,51 @@ describe('TablePanelHeader', () => {)).toEqual(['Import agents', 'Search agents', 'Refresh agents', 'Create agent'])expect(css).not.toMatch(/\.cu-table-panel__actions[^{}]*\{[^}]*\border\s*:/)- expect(css).toMatch(/\.cu-table-panel__actions\s*\{[^}]*flex-wrap:\s*wrap/)- expect(css).toMatch(/\.cu-table-panel__actions\s*\{[^}]*width:\s*100%/)+ expect(css).toMatch(/\.cu-table-panel__actions\s*\{[^}]*flex-wrap:\s*nowrap/)+ expect(css).toMatch(/\.cu-table-panel__actions\s*\{[^}]*width:\s*auto/)expect(css).toMatch(- /\.cu-table-panel__head\s*>\s*\.eft-data-view-header__main\s*\{[^}]*flex-wrap:\s*wrap/+ /\.cu-table-panel__head\s*>\s*\.eft-data-view-header__main\s*\{[^}]*flex-wrap:\s*nowrap/)expect(css).toMatch(- /\.cu-table-panel__head\s+\.eft-data-view-header__actions\s*\{[^}]*flex:\s*1\s+1\s+42rem/- )- expect(css).toMatch(- /@media\s*\(max-width:\s*768px\)[\s\S]*\.cu-table-panel__head\s+\.eft-data-view-header__actions\s*\{[^}]*flex:\s*none/+ /\.cu-table-panel__head\s+\.eft-data-view-header__actions\s*\{[^}]*flex:\s*0\s+0\s+auto/)+ expect(css).toMatch(/\.cu-table-panel__title-text\s*\{[^}]*text-overflow:\s*ellipsis/)+ expect(css).toMatch(/\.cu-table-panel__description-value\s*\{[^}]*-webkit-line-clamp:\s*2/)+ expect(css).toMatch(/\.cu-table-panel__description-tooltip\s*\{[^}]*inset-inline:\s*0/)expect(css).not.toMatch(/\.cu-table-panel__actions\s*>\s*\.cu-section-search\s*\{[^}]*flex:\s*1\s+1\s+100%/)- const narrowLayoutStart = css.lastIndexOf('@media (max-width: 768px)')- const narrowSearchStart = css.indexOf(- '.cu-table-panel__actions > .cu-section-search {',- narrowLayoutStart- )- expect(narrowSearchStart).toBeGreaterThan(narrowLayoutStart)- const narrowSearchBlock = css.slice(narrowSearchStart, css.indexOf('}', narrowSearchStart) + 1)- expect(narrowSearchBlock).toMatch(/flex:\s*0\s+1\s+13rem/)- expect(narrowSearchBlock).toMatch(/width:\s*min\(13rem,\s*100%\)/)expect(css).toMatch(/\.cu-table-panel__actions\s*>\s*select\.cu-input\s*\{[^}]*width:\s*auto/)})++ it('makes a two-line-clamped description available in a full-width tooltip', () => {+ const scrollHeight = vi+ .spyOn(HTMLElement.prototype, 'scrollHeight', 'get')+ .mockImplementation(function () {+ return this.classList.contains('cu-table-panel__description-value') ? 48 : 0+ })+ const clientHeight = vi+ .spyOn(HTMLElement.prototype, 'clientHeight', 'get')+ .mockImplementation(function () {+ return this.classList.contains('cu-table-panel__description-value') ? 32 : 0+ })++ try {+ render(+ <TablePanelHeader+ subtitle="A longer description that cannot fit within two lines."+ title="Agents"+ />+ )++ const description = document.querySelector('.cu-table-panel__description')+ expect(description).toHaveAttribute('tabindex', '0')+ expect(screen.getByRole('tooltip')).toHaveTextContent(+ 'A longer description that cannot fit within two lines.'+ )+ } finally {+ scrollHeight.mockRestore()+ clientHeight.mockRestore()+ }+ })})diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex e13cd85d9..6e19a7ac7 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.575",+ "version": "0.1.576","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.575",+ "version": "0.1.576","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.jsonindex 80993b694..3d70dd5e1 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.575",+ "version": "0.1.576","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",