From 4775497dc7cb40d8d37f208fd5fa183e35a77b17 Mon Sep 17 00:00:00 2001 From: colinislit Date: Mon, 1 Dec 2025 15:45:44 +0100 Subject: [PATCH] feat: add docs chat widget UI components (E3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add useDocsChat hook with message state, streaming, error handling - Add ChatMessages component with auto-scroll and streaming cursor - Add ChatInput component with Enter/Shift+Enter support - Add DocsChatWidget floating container with amber styling - Add AI integration specs (PRD, FO, bouwplan) Implements Epic 3 of AI Documentatie Assistent feature. πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- components/docs-chat/chat-input.tsx | 98 +++++ components/docs-chat/chat-messages.tsx | 150 +++++++ components/docs-chat/docs-chat-widget.tsx | 116 +++++ components/docs-chat/index.ts | 5 + components/docs-chat/use-docs-chat.ts | 208 +++++++++ .../bouwplan-ai-docs-assistent-v1.md | 321 ++++++++++++++ .../ai-integratie/fo-ai-docs-assistent-v1.md | 386 +++++++++++++++++ .../ai-integratie/prd-ai-docs-assistent-v1.md | 403 ++++++++++++++++++ .../prd-ai-prefill-behandelplan-v1.md | 349 +++++++++++++++ 9 files changed, 2036 insertions(+) create mode 100644 components/docs-chat/chat-input.tsx create mode 100644 components/docs-chat/chat-messages.tsx create mode 100644 components/docs-chat/docs-chat-widget.tsx create mode 100644 components/docs-chat/index.ts create mode 100644 components/docs-chat/use-docs-chat.ts create mode 100644 docs/specs/ai-integratie/bouwplan-ai-docs-assistent-v1.md create mode 100644 docs/specs/ai-integratie/fo-ai-docs-assistent-v1.md create mode 100644 docs/specs/ai-integratie/prd-ai-docs-assistent-v1.md create mode 100644 docs/specs/ai-integratie/prd-ai-prefill-behandelplan-v1.md diff --git a/components/docs-chat/chat-input.tsx b/components/docs-chat/chat-input.tsx new file mode 100644 index 0000000..013d37f --- /dev/null +++ b/components/docs-chat/chat-input.tsx @@ -0,0 +1,98 @@ +'use client' + +import { useRef, useState } from 'react' +import { Send } from 'lucide-react' + +import { cn } from '@/lib/utils' + +interface ChatInputProps { + onSend: (message: string) => void + disabled?: boolean + placeholder?: string +} + +/** + * Chat input component with textarea, send button, Enter/Shift+Enter support + * + * - Enter: send message + * - Shift+Enter: new line + * - Auto-resize textarea + */ +export function ChatInput({ + onSend, + disabled = false, + placeholder = 'Stel een vraag...', +}: ChatInputProps) { + const [value, setValue] = useState('') + const textareaRef = useRef(null) + + const handleSubmit = () => { + const trimmed = value.trim() + if (!trimmed || disabled) return + + onSend(trimmed) + setValue('') + + // Reset textarea height + if (textareaRef.current) { + textareaRef.current.style.height = 'auto' + } + } + + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault() + handleSubmit() + } + } + + const handleChange = (e: React.ChangeEvent) => { + setValue(e.target.value) + + // Auto-resize + const textarea = e.target + textarea.style.height = 'auto' + textarea.style.height = `${Math.min(textarea.scrollHeight, 120)}px` + } + + const canSend = value.trim().length > 0 && !disabled + + return ( +
+
+