Files
CatoandClaude Opus 5.5 9dde8fbee9 feat(forms): prose fields on chatkit DictationField, with a working microphone (#330)
* wip: prose fields on chatkit DictationField (awaits chatkit 0.45)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuMRAXYWNkfowAXVfi

* feat(forms): prose fields on chatkit DictationField, with a working microphone

- Bump @bitbaum/chatkit to ^0.45.0.
- One app wrapper, components/forms/TextBox, around DictationField. Used by
  the bot builder (name, description, knowledge topic and content, system
  prompt), the custom-bot edit page (name, description, system prompt,
  greeting), the contact message, the demo intake questions, quick-create
  (name, relationship, memories) and the consultation form's
  react-hook-form message field ({...register('message')}).
- app/api/transcribe: dictation server leg on ai-kit's speechChain and
  transcribe(), rate limited, recordings and transcripts neither stored nor
  logged. Every field and every in-page chat points voice at it, so the
  microphone works where the browser has no recogniser of its own.
- Permissions-Policy allowed no microphone at all (microphone=()), which
  blocked every mic on the site; it now allows the site itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuMRAXYWNkfowAXVfi

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-19 14:23:42 +01:00

125 lines
3.6 KiB
TypeScript

'use client';
/**
* Step 1: Basic Information
* - Bot title
* - URL slug
* - Description
*/
import { useEffect } from 'react';
import { TextBox } from '@/components/forms/TextBox';
interface StepBasicInfoProps {
title: string;
slug: string;
description: string;
onChange: (data: { title?: string; slug?: string; description?: string }) => void;
errors: string[];
}
/**
* Convert title to URL-friendly slug
*/
function titleToSlug(title: string): string {
return title
.toLowerCase()
.trim()
.replace(/[^a-z0-9\s-]/g, '')
.replace(/\s+/g, '-')
.replace(/-+/g, '-')
.replace(/^-|-$/g, '');
}
export function StepBasicInfo({ title, slug, description, onChange, errors }: StepBasicInfoProps) {
// Auto-generate slug from title if slug is empty or matches previous auto-generated value
useEffect(() => {
if (title && !slug) {
onChange({ slug: titleToSlug(title) });
}
}, [title, slug, onChange]);
return (
<div className="space-y-6">
<div>
<h2 className="text-xl font-semibold text-gray-900">Basic Information</h2>
<p className="mt-1 text-sm text-gray-500">
Give your bot a name and identity. This is how users will find and recognize it.
</p>
</div>
{/* Error display */}
{errors.length > 0 && (
<div className="rounded-md bg-red-50 p-4">
<ul className="list-disc list-inside text-sm text-red-700">
{errors.map((error, i) => (
<li key={i}>{error}</li>
))}
</ul>
</div>
)}
{/* Title */}
<div>
<TextBox
label={
<>
Bot Name <span className="text-red-500">*</span>
</>
}
multiline={false}
id="title"
value={title}
onValueChange={(newTitle) => {
onChange({
title: newTitle,
// Auto-update slug if it was auto-generated
...(slug === titleToSlug(title) ? { slug: titleToSlug(newTitle) } : {}),
});
}}
placeholder="e.g., HR Strategy Advisor"
maxLength={100}
required
hint={`${title.length}/100 characters`}
/>
</div>
{/* Slug */}
<div>
<label htmlFor="slug" className="block text-sm font-medium text-gray-700">
URL Slug <span className="text-red-500">*</span>
</label>
<div className="mt-1 flex rounded-lg shadow-sm">
<span className="inline-flex items-center rounded-l-lg border border-r-0 border-gray-300 bg-gray-50 px-3 text-sm text-gray-500">
/bots/
</span>
<input
type="text"
id="slug"
value={slug}
onChange={(e) => onChange({ slug: e.target.value.toLowerCase() })}
placeholder="hr-strategy-advisor"
className="block w-full rounded-r-lg border border-gray-300 px-4 py-2 text-gray-900 placeholder-gray-400 focus:border-blue-500 focus:ring-blue-500"
maxLength={50}
/>
</div>
<p className="mt-1 text-xs text-gray-500">Lowercase letters, numbers, and hyphens only</p>
</div>
{/* Description */}
<div>
<TextBox
label="Description"
id="description"
value={description}
onValueChange={(next) => onChange({ description: next })}
placeholder="A brief description of what your bot does and who it's for..."
rows={3}
maxLength={500}
hint={`${description.length}/500 characters`}
/>
</div>
</div>
);
}