Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: associate config form labels with inputs via shared FormField (#2027)

Adam Eivyd7d80546d248
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 8f5e63a12a..71bac5ba93 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -4,6 +4,10 @@
- **Destructive actions now show a clear "Delete? / Cancel" prompt instead of a hidden second click.** Deleting a round, universe, series, share bucket, issue/episode, or a Writers Room work/folder — and removing an Ask conversation or deleting a world in the Universe Builder — used to silently re-arm the same button on the first click, with nothing on screen telling you a second click was needed. Each of these now pops an explicit inline confirm/cancel affordance right where you clicked, so it's obvious what will happen and easy to back out. The pipeline's "replace existing scenes / pages / audio lines" extract buttons got the same treatment (an inline "Replace? / Cancel" row) instead of arming via a fleeting toast. Delete/confirm controls in the Writers Room library were also enlarged to a comfortable 44px touch target for mobile.
+## Accessibility
+
+- **Config form labels now focus their field when clicked and read correctly to screen readers.** Many settings/config forms (AI Providers, DataDog, feature-agent config, message & calendar account setup, scheduled-task provider/model pickers, the agent world/schedule tabs, MeatSpace nicotine + POST drills, and more) rendered the label as a plain sibling of its input with no association, so clicking the label did nothing and assistive tech couldn't announce the pairing. These fields now flow through a shared `FormField` wrapper that generates a stable id and wires `htmlFor`/`id` automatically, keeping the exact same styling (#2027). Remaining forms are tracked for a follow-up sweep (#2051).
+
## Internal
- Migration 155 heals `data/prompts/stages/cd-treatment.md` installs that #1808's anchor-based migration 148 left stranded (#2042). Installs seeded before the `imageStrength` scene knob (older pre-#1808 template) got the `## Cast & ingredients` list but missed the per-scene `"cast": [{ "ingredientId": … }]` field, so the Creative Director cast-threading regression test stayed red on the runtime template and migration 148 (already applied) never re-ran. The new hash-driven prompt-replace upgrades those copies (and both pristine pre-#1808 shipped versions) to the current shipped reference, leaving hand-customized copies untouched. Also folds `cd-treatment.md` into `buildPromptDriftTables` so setup-data.js's drift warning classifies a stranded copy correctly.
diff --git a/client/src/components/agents/tabs/SchedulesTab.jsx b/client/src/components/agents/tabs/SchedulesTab.jsx
index c68cac88f0..f5fa39db76 100644
--- a/client/src/components/agents/tabs/SchedulesTab.jsx
+++ b/client/src/components/agents/tabs/SchedulesTab.jsx
@@ -1,6 +1,7 @@
import { useState, useEffect, useCallback } from 'react';
import * as api from '../../../services/api';
import BrailleSpinner from '../../BrailleSpinner';
+import { FormField } from '../../ui/FormField';
import { ACTION_TYPES, SCHEDULE_TYPES, CRON_PRESETS, INTERVAL_PRESETS } from '../constants';
import { formatDateTime } from '../../../utils/formatters';
@@ -150,8 +151,7 @@ export default function SchedulesTab({ agentId }) {
<h3 className="text-md font-semibold text-white mb-4">Create Schedule</h3>
<div className="grid grid-cols-2 gap-4 mb-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Account</label>
+ <FormField label="Account">
<select
value={formData.accountId}
onChange={(e) => {
@@ -170,9 +170,8 @@ export default function SchedulesTab({ agentId }) {
</option>
))}
</select>
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Action Type</label>
+ </FormField>
+ <FormField label="Action Type">
<select
value={formData.action.type}
onChange={(e) => setFormData({ ...formData, action: { type: e.target.value, params: {} } })}
@@ -187,11 +186,10 @@ export default function SchedulesTab({ agentId }) {
<p className="text-xs text-gray-500 mt-1">
{ACTION_TYPES.find(a => a.value === formData.action.type)?.description}
</p>
- </div>
+ </FormField>
</div>
- <div className="mb-4">
- <label className="block text-sm text-gray-400 mb-1">Schedule Type</label>
+ <FormField label="Schedule Type" className="mb-4">
<select
value={formData.schedule.type}
onChange={(e) => handleScheduleTypeChange(e.target.value)}
@@ -203,11 +201,10 @@ export default function SchedulesTab({ agentId }) {
</option>
))}
</select>
- </div>
+ </FormField>
{formData.schedule.type === 'cron' && (
- <div className="mb-4">
- <label className="block text-sm text-gray-400 mb-1">Cron Expression</label>
+ <FormField label="Cron Expression" className="mb-4">
<select
value={formData.schedule.cron}
onChange={(e) => setFormData({ ...formData, schedule: { ...formData.schedule, cron: e.target.value } })}
@@ -219,12 +216,11 @@ export default function SchedulesTab({ agentId }) {
</option>
))}
</select>
- </div>
+ </FormField>
)}
{formData.schedule.type === 'interval' && (
- <div className="mb-4">
- <label className="block text-sm text-gray-400 mb-1">Interval</label>
+ <FormField label="Interval" className="mb-4">
<select
value={formData.schedule.intervalMs}
onChange={(e) => setFormData({ ...formData, schedule: { ...formData.schedule, intervalMs: parseInt(e.target.value, 10) } })}
@@ -236,13 +232,12 @@ export default function SchedulesTab({ agentId }) {
</option>
))}
</select>
- </div>
+ </FormField>
)}
{formData.schedule.type === 'random' && (
<div className="grid grid-cols-2 gap-4 mb-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Min Interval</label>
+ <FormField label="Min Interval">
<select
value={formData.schedule.randomWindow?.minMs}
onChange={(e) => setFormData({
@@ -260,9 +255,8 @@ export default function SchedulesTab({ agentId }) {
</option>
))}
</select>
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Max Interval</label>
+ </FormField>
+ <FormField label="Max Interval">
<select
value={formData.schedule.randomWindow?.maxMs}
onChange={(e) => setFormData({
@@ -280,12 +274,11 @@ export default function SchedulesTab({ agentId }) {
</option>
))}
</select>
- </div>
+ </FormField>
</div>
)}
- <div className="mb-4">
- <label className="block text-sm text-gray-400 mb-1">Max Per Day (rate limit)</label>
+ <FormField label="Max Per Day (rate limit)" className="mb-4">
<input
type="number"
value={formData.rateLimit.maxPerDay || 50}
@@ -294,7 +287,7 @@ export default function SchedulesTab({ agentId }) {
min="1"
max="1000"
/>
- </div>
+ </FormField>
<div className="flex gap-2">
<button
diff --git a/client/src/components/agents/tabs/WorldTab.jsx b/client/src/components/agents/tabs/WorldTab.jsx
index 506553763e..9e55a37372 100644
--- a/client/src/components/agents/tabs/WorldTab.jsx
+++ b/client/src/components/agents/tabs/WorldTab.jsx
@@ -1,5 +1,6 @@
import { useState, useEffect, useCallback } from 'react';
import toast from '../../ui/Toast';
+import { FormField } from '../../ui/FormField';
import * as api from '../../../services/api';
import BrailleSpinner from '../../BrailleSpinner';
import socket from '../../../services/socket';
@@ -804,8 +805,7 @@ export default function WorldTab({ agentId }) {
{wsConnected && <span className="text-xs text-port-success">(via WS)</span>}
</div>
<div className="grid grid-cols-2 gap-2 mb-2">
- <div>
- <label className="block text-xs text-gray-500 mb-1">X (-240 to 240)</label>
+ <FormField label="X (-240 to 240)" labelClassName="block text-xs text-gray-500 mb-1">
<input
type="number"
value={moveX}
@@ -815,9 +815,8 @@ export default function WorldTab({ agentId }) {
placeholder="X"
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"
/>
- </div>
- <div>
- <label className="block text-xs text-gray-500 mb-1">Y (-240 to 240)</label>
+ </FormField>
+ <FormField label="Y (-240 to 240)" labelClassName="block text-xs text-gray-500 mb-1">
<input
type="number"
value={moveY}
@@ -827,7 +826,7 @@ export default function WorldTab({ agentId }) {
placeholder="Y"
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"
/>
- </div>
+ </FormField>
</div>
<input
type="text"
@@ -882,8 +881,7 @@ export default function WorldTab({ agentId }) {
<div className="bg-port-card border border-port-border rounded-lg p-4">
<h3 className="font-semibold text-white mb-3">Build</h3>
<div className="grid grid-cols-3 gap-2 mb-2">
- <div>
- <label className="block text-xs text-gray-500 mb-1">X</label>
+ <FormField label="X" labelClassName="block text-xs text-gray-500 mb-1">
<input
type="number"
value={buildX}
@@ -893,9 +891,8 @@ export default function WorldTab({ agentId }) {
placeholder="X"
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"
/>
- </div>
- <div>
- <label className="block text-xs text-gray-500 mb-1">Y</label>
+ </FormField>
+ <FormField label="Y" labelClassName="block text-xs text-gray-500 mb-1">
<input
type="number"
value={buildY}
@@ -905,9 +902,8 @@ export default function WorldTab({ agentId }) {
placeholder="Y"
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"
/>
- </div>
- <div>
- <label className="block text-xs text-gray-500 mb-1">Z (height)</label>
+ </FormField>
+ <FormField label="Z (height)" labelClassName="block text-xs text-gray-500 mb-1">
<input
type="number"
value={buildZ}
@@ -917,7 +913,7 @@ export default function WorldTab({ agentId }) {
placeholder="Z"
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"
/>
- </div>
+ </FormField>
</div>
<div className="grid grid-cols-2 gap-2 mb-3">
<select
diff --git a/client/src/components/calendar/ConfigTab.jsx b/client/src/components/calendar/ConfigTab.jsx
index 7fc638729a..5cffdbcc1d 100644
--- a/client/src/components/calendar/ConfigTab.jsx
+++ b/client/src/components/calendar/ConfigTab.jsx
@@ -6,6 +6,7 @@ import * as api from '../../services/api';
import { formatDateTime } from '../../utils/formatters';
import FeatureProviderPicker from '../FeatureProviderPicker';
import InlineConfirmRow from '../ui/InlineConfirmRow';
+import { FormField } from '../ui/FormField';
import { useConfirmDelete } from '../../hooks/useConfirmDelete';
const TYPE_ICONS = { 'outlook-calendar': Globe, 'google-calendar': Calendar };
@@ -217,8 +218,7 @@ export default function ConfigTab({ accounts, setAccounts }) {
{showForm && (
<div className="p-4 bg-port-card rounded-lg border border-port-border space-y-3 mb-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Name</label>
+ <FormField label="Name">
<input
type="text"
value={form.name}
@@ -226,9 +226,8 @@ export default function ConfigTab({ accounts, setAccounts }) {
placeholder="e.g. Work Calendar"
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-sm text-white placeholder-gray-500 focus:outline-none focus:border-port-accent"
/>
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Type</label>
+ </FormField>
+ <FormField label="Type">
<select
value={form.type}
onChange={(e) => setForm(f => ({ ...f, type: e.target.value }))}
@@ -237,9 +236,8 @@ export default function ConfigTab({ accounts, setAccounts }) {
<option value="outlook-calendar">Outlook Calendar (API)</option>
<option value="google-calendar">Google Calendar (MCP Push)</option>
</select>
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Email{form.type === 'google-calendar' ? ' (used as OAuth test user)' : ''}</label>
+ </FormField>
+ <FormField label={`Email${form.type === 'google-calendar' ? ' (used as OAuth test user)' : ''}`}>
<input
type="email"
value={form.email}
@@ -247,7 +245,7 @@ export default function ConfigTab({ accounts, setAccounts }) {
placeholder="[email protected]"
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-sm text-white placeholder-gray-500 focus:outline-none focus:border-port-accent"
/>
- </div>
+ </FormField>
<div className="flex gap-2">
<button
onClick={handleCreate}
diff --git a/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx b/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
index 0a2bd3450f..93b4d362f2 100644
--- a/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
+++ b/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
@@ -4,6 +4,7 @@ import CronInput from '../../../CronInput';
import { AGENT_OPTIONS, DEFAULT_REVIEW_STOP_MODE, PR_AUTHOR_FILTER_OPTIONS, ISSUE_AUTHOR_FILTER_OPTIONS, ISSUE_AUTHOR_FILTER_TASK_TYPES, SWARM_COUNT_OPTIONS, SWARM_TASK_TYPES } from '../../constants';
import ReviewerPicker from '../../ReviewerPicker';
import Banner from '../../../ui/Banner';
+import { FormField } from '../../../ui/FormField';
import { formatDateTime } from '../../../../utils/formatters';
import { useCodeReviewDefaults } from '../../../../hooks/useCodeReviewDefaults';
import ToggleSwitch from '../../../ToggleSwitch';
@@ -177,8 +178,7 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
</Banner>
)}
- <div>
- <label className="text-sm text-gray-400 block mb-2">Interval Type</label>
+ <FormField label="Interval Type" labelClassName="text-sm text-gray-400 block mb-2">
<select
value={selectedType}
onChange={(e) => handleTypeChange(e.target.value)}
@@ -203,7 +203,7 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
) : (
<p className="text-xs text-gray-500 mt-1">{INTERVAL_DESCRIPTIONS[selectedType]}</p>
)}
- </div>
+ </FormField>
{selectedType === 'perpetual' && (
<div>
@@ -265,8 +265,7 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
{!config.taskMetadata?.pipeline?.stages?.length && (
<>
- <div>
- <label className="text-sm text-gray-400 block mb-2">Provider (optional)</label>
+ <FormField label="Provider (optional)" labelClassName="text-sm text-gray-400 block mb-2">
<select
value={selectedProviderId}
onChange={(e) => handleProviderChange(e.target.value)}
@@ -279,10 +278,9 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
))}
</select>
<p className="text-xs text-gray-500 mt-1">Leave as default to use the currently active provider</p>
- </div>
+ </FormField>
- <div>
- <label className="text-sm text-gray-400 block mb-2">Model (optional)</label>
+ <FormField label="Model (optional)" labelClassName="text-sm text-gray-400 block mb-2">
<select
value={selectedModel}
onChange={(e) => handleModelChange(e.target.value)}
@@ -298,7 +296,7 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
))}
</select>
<p className="text-xs text-gray-500 mt-1">Leave as default to use the provider's default model</p>
- </div>
+ </FormField>
</>
)}
diff --git a/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx b/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx
index c3ed10e2f6..c5ce68da82 100644
--- a/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx
+++ b/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx
@@ -1,4 +1,5 @@
import { filterSelectableModels } from '../../../../utils/providers';
+import { FormField } from '../../../ui/FormField';
export default function PipelineStageConfig({ taskType, config, providers, onUpdate, updating, setUpdating }) {
const stages = config.taskMetadata?.pipeline?.stages || [];
@@ -47,8 +48,7 @@ export default function PipelineStageConfig({ taskType, config, providers, onUpd
)}
</div>
<div className="grid grid-cols-2 gap-3">
- <div>
- <label className="text-xs text-gray-500 block mb-1">Provider</label>
+ <FormField label="Provider" labelClassName="text-xs text-gray-500 block mb-1">
<select
value={stage.providerId || ''}
onChange={(e) => handleStageUpdate(i, 'providerId', e.target.value || null)}
@@ -60,9 +60,8 @@ export default function PipelineStageConfig({ taskType, config, providers, onUpd
<option key={provider.id} value={provider.id}>{provider.name}</option>
))}
</select>
- </div>
- <div>
- <label className="text-xs text-gray-500 block mb-1">Model</label>
+ </FormField>
+ <FormField label="Model" labelClassName="text-xs text-gray-500 block mb-1">
<select
value={stage.model || ''}
onChange={(e) => handleStageUpdate(i, 'model', e.target.value || null)}
@@ -77,7 +76,7 @@ export default function PipelineStageConfig({ taskType, config, providers, onUpd
<option key={model} value={model}>{model}</option>
))}
</select>
- </div>
+ </FormField>
</div>
</div>
);
diff --git a/client/src/components/feature-agents/ConfigTab.jsx b/client/src/components/feature-agents/ConfigTab.jsx
index acfe4cc774..0ca4ae1140 100644
--- a/client/src/components/feature-agents/ConfigTab.jsx
+++ b/client/src/components/feature-agents/ConfigTab.jsx
@@ -1,6 +1,7 @@
import { useState, useEffect, useCallback } from 'react';
import { Save } from 'lucide-react';
import toast from '../ui/Toast';
+import { FormField } from '../ui/FormField';
import * as api from '../../services/api';
function ArrayInput({ label, value, onChange, placeholder }) {
@@ -16,8 +17,7 @@ function ArrayInput({ label, value, onChange, placeholder }) {
};
return (
- <div>
- <label className="block text-sm text-gray-400 mb-1">{label}</label>
+ <FormField label={label}>
<textarea
value={text}
onChange={e => setText(e.target.value)}
@@ -27,7 +27,7 @@ function ArrayInput({ label, value, onChange, placeholder }) {
className="w-full bg-port-bg border border-port-border rounded px-3 py-2 text-sm text-white placeholder-gray-600 focus:outline-hidden focus:border-port-accent resize-y"
/>
<p className="text-xs text-gray-600 mt-0.5">One per line</p>
- </div>
+ </FormField>
);
}
@@ -109,71 +109,62 @@ export default function ConfigTab({ agent, isCreate, apps, onSave }) {
{/* Basic Info */}
<div className="bg-port-card border border-port-border rounded-xl p-5 space-y-4">
<h3 className="text-sm font-medium text-gray-400 uppercase tracking-wider">Basic Info</h3>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Name</label>
+ <FormField label="Name">
<input value={form.name} onChange={e => set('name', e.target.value)} className={inputCls} placeholder="Audio Generator Guardian" required />
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Description</label>
+ </FormField>
+ <FormField label="Description">
<textarea value={form.description} onChange={e => set('description', e.target.value)} className={`${inputCls} resize-y`} rows={2} placeholder="What this agent owns and iterates on" required />
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Persona (system prompt)</label>
+ </FormField>
+ <FormField label="Persona (system prompt)">
<textarea value={form.persona} onChange={e => set('persona', e.target.value)} className={`${inputCls} resize-y`} rows={4} placeholder="You are a meticulous developer who..." />
- </div>
+ </FormField>
<div className="grid grid-cols-2 gap-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">App</label>
+ <FormField label="App">
<select value={form.appId} onChange={e => set('appId', e.target.value)} className={selectCls} required>
<option value="">Select app...</option>
{(apps || []).map(app => (
<option key={app.id} value={app.id}>{app.name}</option>
))}
</select>
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Priority</label>
+ </FormField>
+ <FormField label="Priority">
<select value={form.priority} onChange={e => set('priority', e.target.value)} className={selectCls}>
<option value="LOW">Low</option>
<option value="MEDIUM">Medium</option>
<option value="HIGH">High</option>
<option value="CRITICAL">Critical</option>
</select>
- </div>
+ </FormField>
</div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Autonomy Level</label>
+ <FormField label="Autonomy Level">
<select value={form.autonomyLevel} onChange={e => set('autonomyLevel', e.target.value)} className={selectCls}>
<option value="standby">Standby - Only when triggered</option>
<option value="assistant">Assistant - Follows instructions closely</option>
<option value="manager">Manager - Makes independent decisions</option>
<option value="yolo">YOLO - Full autonomy</option>
</select>
- </div>
+ </FormField>
</div>
{/* Schedule */}
<div className="bg-port-card border border-port-border rounded-xl p-5 space-y-4">
<h3 className="text-sm font-medium text-gray-400 uppercase tracking-wider">Schedule</h3>
<div className="grid grid-cols-2 gap-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Mode</label>
+ <FormField label="Mode">
<select value={form.schedule.mode} onChange={e => set('schedule', { ...form.schedule, mode: e.target.value })} className={selectCls}>
<option value="continuous">Continuous</option>
<option value="interval">Interval</option>
</select>
- </div>
+ </FormField>
{form.schedule.mode === 'interval' && (
- <div>
- <label className="block text-sm text-gray-400 mb-1">Interval (minutes)</label>
+ <FormField label="Interval (minutes)">
<input type="number" value={Math.round((form.schedule.intervalMs || 3600000) / 60000)} onChange={e => { const v = parseInt(e.target.value); if (!Number.isNaN(v) && v > 0) set('schedule', { ...form.schedule, intervalMs: v * 60000 }); }} className={inputCls} min={1} />
- </div>
+ </FormField>
)}
{form.schedule.mode === 'continuous' && (
- <div>
- <label className="block text-sm text-gray-400 mb-1">Pause Between Runs (seconds)</label>
+ <FormField label="Pause Between Runs (seconds)">
<input type="number" value={Math.round((form.schedule.pauseBetweenRunsMs || 60000) / 1000)} onChange={e => { const v = parseInt(e.target.value); if (!Number.isNaN(v) && v >= 0) set('schedule', { ...form.schedule, pauseBetweenRunsMs: v * 1000 }); }} className={inputCls} min={0} />
- </div>
+ </FormField>
)}
</div>
</div>
@@ -189,14 +180,12 @@ export default function ConfigTab({ agent, isCreate, apps, onSave }) {
<div className="bg-port-card border border-port-border rounded-xl p-5 space-y-4">
<h3 className="text-sm font-medium text-gray-400 uppercase tracking-wider">AI Provider (optional override)</h3>
<div className="grid grid-cols-2 gap-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Provider ID</label>
+ <FormField label="Provider ID">
<input value={form.providerId || ''} onChange={e => set('providerId', e.target.value)} className={inputCls} placeholder="Leave empty for default" />
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Model</label>
+ </FormField>
+ <FormField label="Model">
<input value={form.model || ''} onChange={e => set('model', e.target.value)} className={inputCls} placeholder="Leave empty for default" />
- </div>
+ </FormField>
</div>
</div>
diff --git a/client/src/components/meatspace/post/PostDrillConfig.jsx b/client/src/components/meatspace/post/PostDrillConfig.jsx
index fac1df0a56..0df2807cc1 100644
--- a/client/src/components/meatspace/post/PostDrillConfig.jsx
+++ b/client/src/components/meatspace/post/PostDrillConfig.jsx
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
import { ArrowLeft, Save, Brain, Bell, TrendingUp, TrendingDown, Minus } from 'lucide-react';
import { updatePostConfig, getProviders, getPostAdaptivePreview } from '../../../services/api';
import toast from '../../ui/Toast';
+import { FormField } from '../../ui/FormField';
import { filterSelectableModels, enabledApiProviderFilter } from '../../../utils/providers';
// Human labels for the adaptive difficulty knob each math drill tunes.
@@ -283,8 +284,7 @@ function DrillCard({ meta, drillConfig, enabled, accent, onToggle, onUpdateField
{enabled && (
<div className="grid grid-cols-2 gap-3">
{meta.fields.map(field => (
- <div key={field.key}>
- <label className="text-xs text-gray-500 mb-1 block">{field.label}</label>
+ <FormField key={field.key} label={field.label} labelClassName="text-xs text-gray-500 mb-1 block">
{field.type === 'select' ? (
<select
value={drillConfig[field.key] ?? field.options?.[0]?.value ?? ''}
@@ -305,7 +305,7 @@ function DrillCard({ meta, drillConfig, enabled, accent, onToggle, onUpdateField
className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm text-white focus:border-port-accent focus:outline-none"
/>
)}
- </div>
+ </FormField>
))}
</div>
)}
@@ -627,8 +627,7 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
<div className="bg-port-card border border-port-accent-2/30 rounded-lg p-4">
<h4 className="text-sm font-medium text-gray-400 mb-3">AI Provider</h4>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
- <div>
- <label className="text-xs text-gray-500 mb-1 block">Provider</label>
+ <FormField label="Provider" labelClassName="text-xs text-gray-500 mb-1 block">
<select
value={llmProviderId}
onChange={e => { setLlmProviderId(e.target.value); setLlmModel(''); }}
@@ -639,9 +638,8 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
<option key={p.id} value={p.id}>{p.name}</option>
))}
</select>
- </div>
- <div>
- <label className="text-xs text-gray-500 mb-1 block">Model</label>
+ </FormField>
+ <FormField label="Model" labelClassName="text-xs text-gray-500 mb-1 block">
<select
value={llmModel}
onChange={e => setLlmModel(e.target.value)}
@@ -652,7 +650,7 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
<option key={m} value={m}>{m}</option>
))}
</select>
- </div>
+ </FormField>
</div>
</div>
diff --git a/client/src/components/meatspace/tabs/NicotineTab.jsx b/client/src/components/meatspace/tabs/NicotineTab.jsx
index 3101d8bf76..c3e8a767e3 100644
--- a/client/src/components/meatspace/tabs/NicotineTab.jsx
+++ b/client/src/components/meatspace/tabs/NicotineTab.jsx
@@ -4,6 +4,7 @@ import toast from '../../ui/Toast';
import * as api from '../../../services/api';
import BrailleSpinner from '../../BrailleSpinner';
import ConfirmButtonPair from '../../ui/ConfirmButtonPair';
+import { FormField } from '../../ui/FormField';
import { useConfirmDelete } from '../../../hooks/useConfirmDelete';
import NicotineChart from '../NicotineChart';
import NicotineHealthCorrelation from '../NicotineHealthCorrelation';
@@ -331,8 +332,7 @@ export default function NicotineTab() {
{/* Custom entry + date — single row */}
<form onSubmit={handleCustomAdd} className="flex flex-wrap items-end gap-2 pt-2 border-t border-port-border/50">
- <div className="flex-1 min-w-[100px]">
- <label className="block text-xs text-gray-500 mb-1">Product</label>
+ <FormField label="Product" className="flex-1 min-w-[100px]" labelClassName="block text-xs text-gray-500 mb-1">
<input
type="text"
value={product}
@@ -340,9 +340,8 @@ export default function NicotineTab() {
className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-xs text-white placeholder-gray-600"
placeholder="e.g. Stokes Pick"
/>
- </div>
- <div className="w-16">
- <label className="block text-xs text-gray-500 mb-1">mg</label>
+ </FormField>
+ <FormField label="mg" className="w-16" labelClassName="block text-xs text-gray-500 mb-1">
<input
type="number"
value={mgPerUnit}
@@ -353,9 +352,8 @@ export default function NicotineTab() {
min="0.1"
required
/>
- </div>
- <div className="w-14">
- <label className="block text-xs text-gray-500 mb-1">Qty</label>
+ </FormField>
+ <FormField label="Qty" className="w-14" labelClassName="block text-xs text-gray-500 mb-1">
<input
type="number"
value={count}
@@ -363,16 +361,15 @@ export default function NicotineTab() {
className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-xs text-white"
min="1"
/>
- </div>
- <div>
- <label className="block text-xs text-gray-500 mb-1">Date</label>
+ </FormField>
+ <FormField label="Date" labelClassName="block text-xs text-gray-500 mb-1">
<input
type="date"
value={date}
onChange={e => setDate(e.target.value)}
className="bg-port-bg border border-port-border rounded px-2 py-1.5 text-xs text-white"
/>
- </div>
+ </FormField>
{date !== today && (
<button
type="button"
diff --git a/client/src/components/messages/ConfigTab.jsx b/client/src/components/messages/ConfigTab.jsx
index 59eaa89654..3411c63850 100644
--- a/client/src/components/messages/ConfigTab.jsx
+++ b/client/src/components/messages/ConfigTab.jsx
@@ -6,6 +6,7 @@ import * as api from '../../services/api';
import ProviderModelSelector from '../ProviderModelSelector';
import useProviderModels from '../../hooks/useProviderModels';
import InlineConfirmRow from '../ui/InlineConfirmRow';
+import { FormField } from '../ui/FormField';
import { useConfirmDelete } from '../../hooks/useConfirmDelete';
const TYPE_ICONS = { gmail: Mail, outlook: Globe, teams: MessageSquare };
@@ -275,8 +276,7 @@ export default function ConfigTab({ accounts, setAccounts }) {
{showForm && (
<div className="p-4 bg-port-card rounded-lg border border-port-border space-y-3 mb-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Name</label>
+ <FormField label="Name">
<input
type="text"
value={form.name}
@@ -284,9 +284,8 @@ export default function ConfigTab({ accounts, setAccounts }) {
placeholder="e.g. Work Gmail"
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-sm text-white placeholder-gray-500 focus:outline-none focus:border-port-accent"
/>
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Type</label>
+ </FormField>
+ <FormField label="Type">
<select
value={form.type}
onChange={(e) => setForm(f => ({ ...f, type: e.target.value }))}
@@ -296,9 +295,8 @@ export default function ConfigTab({ accounts, setAccounts }) {
<option value="outlook">Outlook (Playwright)</option>
<option value="teams">Teams (Playwright)</option>
</select>
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Email</label>
+ </FormField>
+ <FormField label="Email">
<input
type="email"
value={form.email}
@@ -306,7 +304,7 @@ export default function ConfigTab({ accounts, setAccounts }) {
placeholder="[email protected]"
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-sm text-white placeholder-gray-500 focus:outline-none focus:border-port-accent"
/>
- </div>
+ </FormField>
<div className="flex gap-2">
<button
onClick={handleCreate}
@@ -469,24 +467,30 @@ export default function ConfigTab({ accounts, setAccounts }) {
<RefreshCw size={16} className="text-port-accent animate-spin" />
) : (
<div className="space-y-4">
- <div className="p-4 bg-port-card rounded-lg border border-port-border">
- <label className="block text-sm font-medium text-gray-300 mb-2">Reply Template</label>
+ <FormField
+ label="Reply Template"
+ className="p-4 bg-port-card rounded-lg border border-port-border"
+ labelClassName="block text-sm font-medium text-gray-300 mb-2"
+ >
<textarea
value={config.replyTemplate}
onChange={(e) => updateTemplate('replyTemplate', e.target.value)}
rows={8}
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-sm text-white font-mono placeholder-gray-500 focus:outline-none focus:border-port-accent resize-y"
/>
- </div>
- <div className="p-4 bg-port-card rounded-lg border border-port-border">
- <label className="block text-sm font-medium text-gray-300 mb-2">Forward Template</label>
+ </FormField>
+ <FormField
+ label="Forward Template"
+ className="p-4 bg-port-card rounded-lg border border-port-border"
+ labelClassName="block text-sm font-medium text-gray-300 mb-2"
+ >
<textarea
value={config.forwardTemplate}
onChange={(e) => updateTemplate('forwardTemplate', e.target.value)}
rows={6}
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-sm text-white font-mono placeholder-gray-500 focus:outline-none focus:border-port-accent resize-y"
/>
- </div>
+ </FormField>
<div className="flex items-center gap-3">
<button
onClick={handleSaveConfig}
diff --git a/client/src/components/ui/FormField.jsx b/client/src/components/ui/FormField.jsx
new file mode 100644
index 0000000000..37afa012de
--- /dev/null
+++ b/client/src/components/ui/FormField.jsx
@@ -0,0 +1,44 @@
+import { useId, Children, cloneElement, isValidElement } from 'react';
+
+/**
+ * Accessible config-form field wrapper.
+ *
+ * Generates a stable id via `useId()` and wires the `<label htmlFor>` to the
+ * first child input/select/textarea's `id`, so clicking the label focuses the
+ * field and screen readers announce the association (the repo's
+ * "form labels need htmlFor/id pairing" convention).
+ *
+ * Styling is caller-owned so migrating an existing field is a lossless swap:
+ * pass `className` for the wrapper and `labelClassName` to match the field's
+ * current label classes. The `id` is injected only when the first child has no
+ * `id` of its own, so an explicit id still wins.
+ *
+ * @param {string} label - Visible label text.
+ * @param {import('react').ReactNode} [hint] - Optional hint rendered between label and field.
+ * @param {import('react').ReactNode} children - The field control(s); the first element receives the generated id.
+ * @param {string} [className] - Wrapper div className.
+ * @param {string} [labelClassName] - Label className (defaults to the common config-form label style).
+ */
+export function FormField({
+ label,
+ hint,
+ children,
+ className = '',
+ labelClassName = 'block text-sm text-gray-400 mb-1',
+}) {
+ const id = useId();
+ const augmented = Children.map(children, (child, i) =>
+ i === 0 && isValidElement(child) && !child.props.id
+ ? cloneElement(child, { id })
+ : child
+ );
+ return (
+ <div className={className}>
+ {label != null && <label htmlFor={id} className={labelClassName}>{label}</label>}
+ {hint != null && <p className="text-xs text-gray-500 mb-1">{hint}</p>}
+ {augmented}
+ </div>
+ );
+}
+
+export default FormField;
diff --git a/client/src/components/ui/FormField.test.jsx b/client/src/components/ui/FormField.test.jsx
new file mode 100644
index 0000000000..966ea5ceda
--- /dev/null
+++ b/client/src/components/ui/FormField.test.jsx
@@ -0,0 +1,85 @@
+import { describe, it, expect } from 'vitest';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+
+import { FormField } from './FormField';
+
+describe('FormField', () => {
+ it('associates the label with the first control via generated id', () => {
+ render(
+ <FormField label="Display Name">
+ <input defaultValue="" />
+ </FormField>
+ );
+ // getByLabelText resolves only when htmlFor/id are correctly paired.
+ const input = screen.getByLabelText('Display Name');
+ expect(input.tagName).toBe('INPUT');
+ expect(input.id).toBeTruthy();
+ });
+
+ it('focuses the field when its label is clicked', async () => {
+ const user = userEvent.setup();
+ render(
+ <FormField label="Email">
+ <input defaultValue="" />
+ </FormField>
+ );
+ await user.click(screen.getByText('Email'));
+ expect(screen.getByLabelText('Email')).toHaveFocus();
+ });
+
+ it('works with a select control', () => {
+ render(
+ <FormField label="Type">
+ <select defaultValue="a">
+ <option value="a">A</option>
+ <option value="b">B</option>
+ </select>
+ </FormField>
+ );
+ expect(screen.getByLabelText('Type').tagName).toBe('SELECT');
+ });
+
+ it('injects the id into the first child only, leaving siblings untouched', () => {
+ render(
+ <FormField label="Notes">
+ <textarea defaultValue="" />
+ <p>One per line</p>
+ </FormField>
+ );
+ const field = screen.getByLabelText('Notes');
+ expect(field.tagName).toBe('TEXTAREA');
+ expect(screen.getByText('One per line').id).toBe('');
+ });
+
+ it('does not override an explicit id on the child', () => {
+ render(
+ <FormField label="Custom">
+ <input id="my-fixed-id" defaultValue="" />
+ </FormField>
+ );
+ // With a fixed child id but a generated label htmlFor, the association
+ // is not made — but the caller-provided id must be preserved.
+ expect(document.getElementById('my-fixed-id')).toBeTruthy();
+ });
+
+ it('applies caller-provided wrapper and label classes', () => {
+ render(
+ <FormField label="Styled" className="wrap-x" labelClassName="lbl-x">
+ <input defaultValue="" />
+ </FormField>
+ );
+ const label = screen.getByText('Styled');
+ expect(label).toHaveClass('lbl-x');
+ expect(label.parentElement).toHaveClass('wrap-x');
+ });
+
+ it('renders a ReactNode label (e.g. badge + text)', () => {
+ render(
+ <FormField label={<><span>●</span>Light</>}>
+ <input defaultValue="" />
+ </FormField>
+ );
+ expect(screen.getByLabelText('●Light')).toBeTruthy();
+ });
+});
diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsx
index edec158ce7..d0f3a0434c 100644
--- a/client/src/pages/AIProviders.jsx
+++ b/client/src/pages/AIProviders.jsx
@@ -17,6 +17,7 @@ import {
import SettingsTabsHeader from '../components/settings/SettingsTabsHeader';
import CodeReviewDefaultsPanel from '../components/providers/CodeReviewDefaultsPanel';
import Modal from '../components/ui/Modal';
+import { FormField } from '../components/ui/FormField';
export default function AIProviders() {
const [providers, setProviders] = useState([]);
@@ -829,8 +830,7 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
</h2>
<form onSubmit={handleSubmit} className="space-y-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Name *</label>
+ <FormField label="Name *">
<input
type="text"
value={formData.name}
@@ -838,10 +838,9 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
required
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
/>
- </div>
+ </FormField>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Type *</label>
+ <FormField label="Type *">
<select
value={formData.type}
onChange={(e) => setFormData(prev => ({ ...prev, type: e.target.value }))}
@@ -851,12 +850,11 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
<option value="tui">TUI</option>
<option value="api">API</option>
</select>
- </div>
+ </FormField>
{(formData.type === 'cli' || formData.type === 'tui') && (
<>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Command *</label>
+ <FormField label="Command *">
<input
type="text"
value={formData.command}
@@ -865,10 +863,9 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
required={formData.type === 'cli' || formData.type === 'tui'}
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
/>
- </div>
+ </FormField>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Arguments (space-separated)</label>
+ <FormField label="Arguments (space-separated)">
<input
type="text"
value={formData.args}
@@ -876,11 +873,10 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
placeholder={formData.type === 'tui' ? '--dangerously-skip-permissions' : '--print -p'}
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
/>
- </div>
+ </FormField>
{formData.type === 'cli' && (
- <div>
- <label className="block text-sm text-gray-400 mb-1">Headless Args (for simple prompt tasks)</label>
+ <FormField label="Headless Args (for simple prompt tasks)">
<input
type="text"
value={formData.headlessArgs}
@@ -891,13 +887,12 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
<p className="text-xs text-gray-500 mt-1">
Extra CLI flags for lightweight prompt-in/text-out mode (brain classifier, etc.)
</p>
- </div>
+ </FormField>
)}
{formData.type === 'tui' && (
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Prompt Paste Delay (ms)</label>
+ <FormField label="Prompt Paste Delay (ms)">
<input
type="number"
min="250"
@@ -906,9 +901,8 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
onChange={(e) => setFormData(prev => ({ ...prev, tuiPromptDelayMs: e.target.value }))}
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
/>
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Idle Complete (ms)</label>
+ </FormField>
+ <FormField label="Idle Complete (ms)">
<input
type="number"
min="10000"
@@ -917,7 +911,7 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
onChange={(e) => setFormData(prev => ({ ...prev, tuiIdleTimeoutMs: e.target.value }))}
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
/>
- </div>
+ </FormField>
<p className="sm:col-span-2 text-xs text-gray-500">
TUI providers open an attachable shell session, paste the agent prompt, parse terminal output, and complete after the terminal is idle.
</p>
@@ -928,8 +922,7 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
{formData.type === 'api' && (
<>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Endpoint *</label>
+ <FormField label="Endpoint *">
<input
type="url"
value={formData.endpoint}
@@ -938,10 +931,9 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
required={formData.type === 'api'}
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
/>
- </div>
+ </FormField>
- <div>
- <label className="block text-sm text-gray-400 mb-1">API Key</label>
+ <FormField label="API Key">
<input
type="password"
value={formData.apiKey}
@@ -949,15 +941,14 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
placeholder={provider?.hasApiKey ? 'Key set — leave blank to keep' : 'Optional'}
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
/>
- </div>
+ </FormField>
</>
)}
- <div>
- <label className="block text-sm text-gray-400 mb-1">
+ <FormField label={<>
Available Models
{formData.type === 'api' && <span className="text-xs text-gray-500 ml-2">(Use Refresh button after saving)</span>}
- </label>
+ </>}>
<textarea
value={(formData.models || []).join(', ')}
onChange={(e) => {
@@ -974,10 +965,9 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
<p className="text-xs text-gray-500 mt-1">
Comma-separated list of available models. For API providers, use Refresh to auto-populate.
</p>
- </div>
+ </FormField>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Default Model</label>
+ <FormField label="Default Model">
{availableModels.length > 0 ? (
<select
value={formData.defaultModel}
@@ -1003,17 +993,16 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
? 'Model to use when no tier is specified'
: 'Save and test provider to fetch available models'}
</p>
- </div>
+ </FormField>
{/* Model Tiers */}
<div className="border-t border-port-border pt-4 mt-4">
<h4 className="text-sm font-medium text-gray-300 mb-3">Model Tiers</h4>
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
- <div>
- <label className="block text-xs text-gray-400 mb-1">
+ <FormField labelClassName="block text-xs text-gray-400 mb-1" label={<>
<span className="inline-block w-2 h-2 rounded-full bg-port-success mr-1"></span>
Light (fast)
- </label>
+ </>}>
{availableModels.length > 0 ? (
<select
value={formData.lightModel}
@@ -1034,12 +1023,11 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
className="w-full px-2 py-1.5 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:border-port-accent focus:outline-hidden"
/>
)}
- </div>
- <div>
- <label className="block text-xs text-gray-400 mb-1">
+ </FormField>
+ <FormField labelClassName="block text-xs text-gray-400 mb-1" label={<>
<span className="inline-block w-2 h-2 rounded-full bg-port-warning mr-1"></span>
Medium (balanced)
- </label>
+ </>}>
{availableModels.length > 0 ? (
<select
value={formData.mediumModel}
@@ -1060,12 +1048,11 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
className="w-full px-2 py-1.5 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:border-port-accent focus:outline-hidden"
/>
)}
- </div>
- <div>
- <label className="block text-xs text-gray-400 mb-1">
+ </FormField>
+ <FormField labelClassName="block text-xs text-gray-400 mb-1" label={<>
<span className="inline-block w-2 h-2 rounded-full bg-port-error mr-1"></span>
Heavy (powerful)
- </label>
+ </>}>
{availableModels.length > 0 ? (
<select
value={formData.heavyModel}
@@ -1086,7 +1073,7 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
className="w-full px-2 py-1.5 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:border-port-accent focus:outline-hidden"
/>
)}
- </div>
+ </FormField>
</div>
<p className="text-xs text-gray-500 mt-2">
{availableModels.length > 0
@@ -1095,8 +1082,7 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
</p>
</div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Timeout (ms)</label>
+ <FormField label="Timeout (ms)">
<input
type="number"
inputMode="numeric"
@@ -1119,13 +1105,12 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
: `Per-call cap. Server max: ${TIMEOUT_INPUT_MAX_MS.toLocaleString()} ms (${formatDurationMs(TIMEOUT_INPUT_MAX_MS)}).`;
})()}
</p>
- </div>
+ </FormField>
<div className="border-t border-port-border pt-4 mt-4">
<h4 className="text-sm font-medium text-gray-300 mb-3">Context Window</h4>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Planning Window</label>
+ <FormField label="Planning Window">
<input
type="number"
inputMode="numeric"
@@ -1139,11 +1124,10 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
<p className="text-xs text-gray-500 mt-1">
{plannedContextLabel ? `Budgeter uses ${plannedContextLabel}` : 'Leave blank to use model/provider defaults'}
</p>
- </div>
+ </FormField>
{formData.type === 'api' && (
- <div>
- <label className="block text-sm text-gray-400 mb-1">Local num_ctx</label>
+ <FormField label="Local num_ctx">
<input
type="number"
inputMode="numeric"
@@ -1157,14 +1141,14 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
<p className="text-xs text-gray-500 mt-1">
Sent to compatible local backends; used for planning when no model window is known.
</p>
- </div>
+ </FormField>
)}
</div>
</div>
{/* Fallback Provider */}
<div className="border-t border-port-border pt-4 mt-4">
- <label className="block text-sm text-gray-400 mb-1">Fallback Provider</label>
+ <FormField label="Fallback Provider">
<select
value={formData.fallbackProvider}
onChange={(e) => setFormData(prev => ({
@@ -1185,10 +1169,10 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
<p className="text-xs text-gray-500 mt-1">
If this provider hits a usage limit or becomes unavailable, tasks will automatically use the fallback provider.
</p>
+ </FormField>
{formData.fallbackProvider && (
- <div className="mt-3">
- <label className="block text-sm text-gray-400 mb-1">Fallback Model</label>
+ <FormField label="Fallback Model" className="mt-3">
{fallbackModelOptions.length > 0 ? (
<select
value={formData.fallbackModel}
@@ -1212,7 +1196,7 @@ function ProviderForm({ provider, onClose, onSave, allProviders = [] }) {
<p className="text-xs text-gray-500 mt-1">
Model to run on the fallback provider. Leave blank to use that provider's default model.
</p>
- </div>
+ </FormField>
)}
</div>
diff --git a/client/src/pages/DataDog.jsx b/client/src/pages/DataDog.jsx
index 26517ba3bf..d1e5d34c0b 100644
--- a/client/src/pages/DataDog.jsx
+++ b/client/src/pages/DataDog.jsx
@@ -1,5 +1,6 @@
import { useState, useEffect } from 'react';
import toast from '../components/ui/Toast';
+import { FormField } from '../components/ui/FormField';
import api from '../services/api';
const SITE_OPTIONS = [
@@ -243,10 +244,7 @@ export default function DataDog() {
)}
<div className="space-y-4">
- <div>
- <label className="block text-sm font-medium text-gray-300 mb-1">
- Instance ID
- </label>
+ <FormField label="Instance ID" labelClassName="block text-sm font-medium text-gray-300 mb-1">
<input
type="text"
name="id"
@@ -259,12 +257,9 @@ export default function DataDog() {
<p className="text-xs text-gray-400 mt-1">
Unique identifier (cannot be changed after creation)
</p>
- </div>
+ </FormField>
- <div>
- <label className="block text-sm font-medium text-gray-300 mb-1">
- Display Name
- </label>
+ <FormField label="Display Name" labelClassName="block text-sm font-medium text-gray-300 mb-1">
<input
type="text"
name="name"
@@ -273,12 +268,9 @@ export default function DataDog() {
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white"
placeholder="e.g., Company DataDog"
/>
- </div>
+ </FormField>
- <div>
- <label className="block text-sm font-medium text-gray-300 mb-1">
- Site
- </label>
+ <FormField label="Site" labelClassName="block text-sm font-medium text-gray-300 mb-1">
<select
value={customSite ? 'custom' : formData.site}
onChange={handleSiteChange}
@@ -298,12 +290,9 @@ export default function DataDog() {
placeholder="e.g., api.custom-datadog.com"
/>
)}
- </div>
+ </FormField>
- <div>
- <label className="block text-sm font-medium text-gray-300 mb-1">
- API Key
- </label>
+ <FormField label="API Key" labelClassName="block text-sm font-medium text-gray-300 mb-1">
<input
type="password"
name="apiKey"
@@ -315,12 +304,9 @@ export default function DataDog() {
<p className="text-xs text-gray-400 mt-1">
Found in DataDog Organization Settings &rarr; API Keys
</p>
- </div>
+ </FormField>
- <div>
- <label className="block text-sm font-medium text-gray-300 mb-1">
- Application Key
- </label>
+ <FormField label="Application Key" labelClassName="block text-sm font-medium text-gray-300 mb-1">
<input
type="password"
name="appKey"
@@ -332,7 +318,7 @@ export default function DataDog() {
<p className="text-xs text-gray-400 mt-1">
Found in DataDog Organization Settings &rarr; Application Keys
</p>
- </div>
+ </FormField>
<div className="flex flex-col sm:flex-row gap-2">
<button