From a7b2fd7fbefd60e5bb60f5a7d7c6b5973c759407 Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Tue, 7 Apr 2026 07:49:32 +0530 Subject: [PATCH] feat(onboarding/phase-4): telephony, AI, widget config CRUD pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the three remaining Pattern B placeholder routes (/settings/telephony, /settings/ai, /settings/widget) with real forms backed by the sidecar config endpoints introduced in Phase 1. Each page loads the current config on mount, round-trips edits via PUT, and supports reset-to-defaults. Changes take effect immediately since the TelephonyConfigService / AiConfigService / WidgetConfigService all keep in-memory caches that all consumers read through. - src/components/forms/telephony-form.tsx — Ozonetel + SIP + Exotel sections; honours the '***masked***' sentinel for secrets - src/components/forms/ai-form.tsx — provider/model/temperature/prompt with per-provider model suggestions - src/components/forms/widget-form.tsx — enabled/url/embed toggles plus an allowedOrigins chip list - src/pages/telephony-settings.tsx — loads masked config, marks the telephony wizard step complete when all required Ozonetel fields are filled - src/pages/ai-settings.tsx — clamps temperature to 0..2 on save, marks the ai wizard step complete on successful save - src/pages/widget-settings.tsx — uses the admin endpoint (/api/config/widget/admin), exposes rotate-key + copy-to-clipboard for the site key, and separates the read-only key card from the editable config card - src/main.tsx — swaps the three placeholder routes for the real pages - src/pages/settings-placeholder.tsx — removed; no longer referenced Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/forms/ai-form.tsx | 136 ++++++++++++++++ src/components/forms/telephony-form.tsx | 177 +++++++++++++++++++++ src/components/forms/widget-form.tsx | 167 ++++++++++++++++++++ src/main.tsx | 37 +---- src/pages/ai-settings.tsx | 159 +++++++++++++++++++ src/pages/settings-placeholder.tsx | 47 ------ src/pages/telephony-settings.tsx | 162 +++++++++++++++++++ src/pages/widget-settings.tsx | 199 ++++++++++++++++++++++++ 8 files changed, 1006 insertions(+), 78 deletions(-) create mode 100644 src/components/forms/ai-form.tsx create mode 100644 src/components/forms/telephony-form.tsx create mode 100644 src/components/forms/widget-form.tsx create mode 100644 src/pages/ai-settings.tsx delete mode 100644 src/pages/settings-placeholder.tsx create mode 100644 src/pages/telephony-settings.tsx create mode 100644 src/pages/widget-settings.tsx diff --git a/src/components/forms/ai-form.tsx b/src/components/forms/ai-form.tsx new file mode 100644 index 0000000..249fc5d --- /dev/null +++ b/src/components/forms/ai-form.tsx @@ -0,0 +1,136 @@ +import { Input } from '@/components/base/input/input'; +import { Select } from '@/components/base/select/select'; +import { TextArea } from '@/components/base/textarea/textarea'; + +// AI assistant form — mirrors AiConfig in +// helix-engage-server/src/config/ai.defaults.ts. API keys stay in env vars +// (true secrets, rotated at the infra level); everything the admin can safely +// adjust lives here: provider choice, model, temperature, and an optional +// system-prompt addendum appended to the hospital-specific prompts that the +// WidgetChatService generates. + +export type AiProvider = 'openai' | 'anthropic'; + +export type AiFormValues = { + provider: AiProvider; + model: string; + temperature: string; + systemPromptAddendum: string; +}; + +export const emptyAiFormValues = (): AiFormValues => ({ + provider: 'openai', + model: 'gpt-4o-mini', + temperature: '0.7', + systemPromptAddendum: '', +}); + +const PROVIDER_ITEMS = [ + { id: 'openai', label: 'OpenAI' }, + { id: 'anthropic', label: 'Anthropic' }, +]; + +// Recommended model presets per provider. Admin can still type any model +// string they want — these are suggestions, not the only options. +export const MODEL_SUGGESTIONS: Record = { + openai: ['gpt-4o-mini', 'gpt-4o', 'gpt-4-turbo', 'gpt-3.5-turbo'], + anthropic: ['claude-3-5-sonnet-latest', 'claude-3-5-haiku-latest', 'claude-3-opus-latest'], +}; + +type AiFormProps = { + value: AiFormValues; + onChange: (value: AiFormValues) => void; +}; + +export const AiForm = ({ value, onChange }: AiFormProps) => { + const patch = (updates: Partial) => onChange({ ...value, ...updates }); + + const suggestions = MODEL_SUGGESTIONS[value.provider]; + + return ( +
+
+
+

Provider & model

+

+ Choose the AI vendor powering the website widget chat and call-summary features. + Changing providers takes effect immediately. +

+
+ + + +
+ patch({ model: v })} + /> +
+ {suggestions.map((model) => ( + + ))} +
+
+ + patch({ temperature: v })} + /> +
+ +
+
+

System prompt addendum

+

+ Optional — gets appended to the hospital-specific prompts the widget generates + automatically from your doctors and clinics. Use this to add tone guidelines, + escalation rules, or topics the assistant should avoid. Leave blank for the default + behaviour. +

+
+