# Task 009: Prompt Input Basic - Text Input with Send Functionality ## Status: TODO ## Objective Implement a basic prompt input component that allows users to type messages and send them to the OpenCode server. This enables testing of the SSE integration and completes the core chat interface loop. ## Prerequisites - Task 007 (Message display) complete - Task 008 (SSE integration) complete - Active session available - SDK client configured ## Context The prompt input is the primary way users interact with OpenCode. For the MVP, we need: - Simple text input (multi-line textarea) - Send button - Basic keyboard shortcuts (Enter to send, Shift+Enter for new line) - Loading state while assistant is responding - Basic validation (empty message prevention) Advanced features (slash commands, file attachments, @ mentions) will come in Task 021-024. ## Implementation Steps ### Step 1: Create Prompt Input Component Create `src/components/prompt-input.tsx`: ```typescript import { createSignal, Show } from "solid-js" interface PromptInputProps { instanceId: string sessionId: string onSend: (prompt: string) => Promise disabled?: boolean } export default function PromptInput(props: PromptInputProps) { const [prompt, setPrompt] = createSignal("") const [sending, setSending] = createSignal(false) let textareaRef: HTMLTextAreaElement | undefined function handleKeyDown(e: KeyboardEvent) { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault() handleSend() } } async function handleSend() { const text = prompt().trim() if (!text || sending() || props.disabled) return setSending(true) try { await props.onSend(text) setPrompt("") // Auto-resize textarea back to initial size if (textareaRef) { textareaRef.style.height = "auto" } } catch (error) { console.error("Failed to send message:", error) alert("Failed to send message: " + (error instanceof Error ? error.message : String(error))) } finally { setSending(false) textareaRef?.focus() } } function handleInput(e: Event) { const target = e.target as HTMLTextAreaElement setPrompt(target.value) // Auto-resize textarea target.style.height = "auto" target.style.height = Math.min(target.scrollHeight, 200) + "px" } const canSend = () => prompt().trim().length > 0 && !sending() && !props.disabled return (