Files
temetro/.agents/skills/coss/references/rules/forms.md
T
Khalid Abdi 929bec8f31 feat: AI-added records save with placeholders + "Added by AI" provenance
Stop blocking AI imports/proposals on missing non-critical fields. Records
the chat agent drafts now save with safe placeholders, auto-generated file
numbers, and a source="ai" marker that surfaces an "Added by AI" badge so a
clinician can review/edit them later.

Backend:
- add `source` (manual|ai) column to patients/appointments/prescriptions
  (migration 0014) + canonical types, services, validation schemas
- relax patient/appointment validation: empty file number allowed, demographic
  + type/provider/initials fall back to placeholders (initials derived from name)
- patients.generateFileNumber() auto-assigns an MRN when one is missing
- proposeAppointment accepts a name when no file number resolves; AI commits +
  /api/ai/import stamp source="ai"

Frontend:
- `source` on Appointment/Patient/Prescription types; AI commits send source="ai"
- reusable <AiBadge> shown on the Patients table/detail and prescriptions list

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 19:27:17 +03:00

1.7 KiB

Forms and Inputs Rules (coss)

Use this when implementing fields, input groups, validation states, and form examples.

Core Rules

  • For form-bound controls, default to Field composition (Field, FieldLabel, FieldDescription, FieldError) instead of standalone inputs.
  • Always specify type on input-like controls where relevant (type="text", type="email", etc.).
  • Always specify type on buttons (button, submit, or reset) instead of relying on browser defaults.
  • Preserve accessible labelling:
    • visible label association (Label, htmlFor, id)
    • aria-label when there is no visible label.
  • Keep validation signaling aligned between container and control (aria-invalid, related field semantics).

Input Group Rule

  • In InputGroup, place InputGroupAddon after InputGroupInput or InputGroupTextarea in DOM order to preserve focus behavior.

Input OTP Rule

  • Keep length on the root synchronized with the number of rendered OTPFieldInput slots.

Textarea Rule

  • coss Textarea already uses Base UI field control semantics internally; in normal form flows, use Textarea directly inside Field and avoid manual FieldControl render wiring unless a custom control implementation is truly needed.

Do / Don't

// Do
<Field>
  <FieldLabel>Email</FieldLabel>
  <Input type="email" />
</Field>

<InputGroup>
  <InputGroupInput type="text" />
  <InputGroupAddon>{/* ... */}</InputGroupAddon>
</InputGroup>

// Don't
<Input placeholder="Email" />

<InputGroup>
  <InputGroupAddon>{/* ... */}</InputGroupAddon>
  <InputGroupInput type="text" />
</InputGroup>

Further reading

  • Base UI Forms handbook: https://base-ui.com/react/handbook/forms.md