From f8e88c00b2a6f5bbe30c3bb8616b88368066802a Mon Sep 17 00:00:00 2001 From: siddhant-galileo Date: Sun, 1 Feb 2026 12:05:56 +0530 Subject: [PATCH 01/11] feat: inital set of ui fixes --- ui/AGENTS.md | 12 +- ui/src/core/components/label-with-tooltip.tsx | 30 + ui/src/core/evaluators/json/form.tsx | 323 +++++---- ui/src/core/evaluators/list/form.tsx | 168 ++--- ui/src/core/evaluators/luna2/form.tsx | 436 ++++++------ ui/src/core/evaluators/regex/form.tsx | 35 +- ui/src/core/evaluators/sql/form.tsx | 672 +++++++++--------- .../agent-detail/agent-detail.tsx | 62 +- .../modals/add-new-control/index.tsx | 242 ++----- .../modals/control-store/index.tsx | 209 +++--- .../edit-control/control-definition-form.tsx | 289 ++++---- .../edit-control/edit-control-content.tsx | 159 +++-- .../modals/edit-control/step-name-input.tsx | 69 ++ .../agent-detail/modals/edit-control/types.ts | 1 + .../agent-detail/modals/edit-control/utils.ts | 13 + ui/src/pages/_app.tsx | 5 +- ui/src/styles/globals.css | 9 + ui/tests/agent-detail.spec.ts | 20 +- ui/tests/control-store.spec.ts | 58 +- ui/tests/evaluators/helpers.ts | 6 +- ui/tests/evaluators/regex.spec.ts | 5 - ui/tests/step-name-input.spec.ts | 90 +++ 22 files changed, 1495 insertions(+), 1418 deletions(-) create mode 100644 ui/src/core/components/label-with-tooltip.tsx create mode 100644 ui/src/core/page-components/agent-detail/modals/edit-control/step-name-input.tsx create mode 100644 ui/tests/step-name-input.spec.ts diff --git a/ui/AGENTS.md b/ui/AGENTS.md index 4170abd9..de3dc038 100644 --- a/ui/AGENTS.md +++ b/ui/AGENTS.md @@ -49,11 +49,17 @@ pnpm fetch-api-types # regenerate API types from server (must be running on :80 - `core/page-components/` — actual page UI logic lives here - `core/layouts/` — app shell, sidebar navigation -### Evaluator forms (`core/page-components/agent-detail/edit-control/evaluators/`) +### Evaluator forms (`core/evaluators/`) - Each evaluator type has its own folder: `json/`, `sql/`, `regex/`, `list/`, `luna2/` - Each folder exports: `form.tsx` (React component), `types.ts` (form types), `index.ts` (re-exports) - Registry in `evaluators/index.ts` maps evaluator names to form components +### Form guidelines (control definition + evaluator forms) +- **Always use the input's `label` prop** — never render a separate `` above the input as the label. Use Mantine's built-in `label` so required asterisks and layout are consistent. +- **Label with tooltip**: Use `LabelWithTooltip` from `@/core/components/label-with-tooltip` when a field needs an (i) icon that shows help text on hover. Pass `label={}` and, for inputs that support it, `labelProps={labelPropsInline}` so the label renders inline. +- **Required fields**: Use the input's `required` prop (e.g. Select, TextInput) so Mantine renders the red asterisk. Use `labelPropsInline` from the same module when you need the label inline. +- Applies to: control definition form (`edit-control/control-definition-form.tsx`) and all evaluator forms (`core/evaluators/*/form.tsx`). + ### Reusable components (`core/components/`) - Create reusable components that encapsulate common patterns and logic - **Best practice**: When creating wrapper components around Mantine components, extend the underlying component's props using `Omit` to exclude overridden props, then spread `...rest` to forward all other props @@ -96,9 +102,9 @@ export function SearchInput({ ## Common changes ### Add a new evaluator form -1. Create folder in `core/page-components/agent-detail/edit-control/evaluators//` +1. Create folder in `core/evaluators//` 2. Add `types.ts` with form field types -3. Add `form.tsx` with the form component (use Mantine form components) +3. Add `form.tsx` with the form component — use Mantine form components with `label` prop and `LabelWithTooltip` from `@/core/components/label-with-tooltip` for fields that need a tooltip (see Form guidelines above) 4. Add `index.ts` re-exporting form and types 5. Register in `evaluators/index.ts` diff --git a/ui/src/core/components/label-with-tooltip.tsx b/ui/src/core/components/label-with-tooltip.tsx new file mode 100644 index 00000000..a7f8cd8d --- /dev/null +++ b/ui/src/core/components/label-with-tooltip.tsx @@ -0,0 +1,30 @@ +import { Group, Text, Tooltip } from "@mantine/core"; +import { IconInfoCircle } from "@tabler/icons-react"; + +export interface LabelWithTooltipProps { + label: string; + tooltip: string; +} + +/** + * Label with (i) icon that shows tooltip on hover. + * Use as the `label` prop of Mantine form inputs (Select, TextInput, etc.) + * so the input always uses the label prop and optional tooltip is consistent. + */ +export function LabelWithTooltip({ label, tooltip }: LabelWithTooltipProps) { + return ( + + + {label} + + + + + + ); +} + +/** Pass to labelProps on inputs so the label renders inline. */ +export const labelPropsInline = { + style: { display: "inline-block" as const }, +}; diff --git a/ui/src/core/evaluators/json/form.tsx b/ui/src/core/evaluators/json/form.tsx index ec2fbf31..ae7c9e92 100644 --- a/ui/src/core/evaluators/json/form.tsx +++ b/ui/src/core/evaluators/json/form.tsx @@ -1,180 +1,177 @@ import { - Box, Checkbox, Divider, Select, Stack, - Text, Textarea, TextInput, } from "@mantine/core"; +import { + labelPropsInline, + LabelWithTooltip, +} from "@/core/components/label-with-tooltip"; + import type { EvaluatorFormProps } from "../types"; import type { JsonFormValues } from "./types"; export const JsonForm = ({ form }: EvaluatorFormProps) => { return ( - - - - - - JSON Schema - -