<!-- source-hash: 6d459e335b05378d1756f274a61128f0 -->
A controlled chat input component with slash-command autocomplete, send/stop functionality, and an imperative ref API for programmatic control.

## Key Components

### `ChatInput` (default export)
A `forwardRef` component that renders a textarea-based chat input with:
- **Slash command autocomplete** — triggers on `/` prefix, debounced 150ms, keyboard-navigable dropdown
- **Send/Stop modes** — toggles between send and stop-stream actions based on `sending`/`onStop` props
- **Awaiting response indicator** — replaces input with `ChatTypingIndicator` while waiting for a reply
- **Auto-refocus** — restores focus after send completes or streaming stops

### `ChatInputRef` (imperative handle)
Exposed methods for parent components:

| Method | Description |
|---|---|
| `focus()` / `blur()` | Programmatic focus control |
| `clear()` | Resets input value |
| `setValue(next)` | Prefills input, places caret at end |
| `setValueAndCursor(next, offset)` | Prefills input with clamped caret position |
| `submit(next)` | Fires `onSend` and clears, bypassing user interaction |
| `getValue()` | Returns current value via stable ref |

### `SLASH_INPUT_TRIGGER`
Regex `/^\/([a-z][a-z0-9-]*)?$/` — kept in sync with server-side slash command registration to prevent suggesting commands the API would reject.

## Usage Example

```typescript
import { useRef } from "react"
import { ChatInput } from "./chat-input"
import type { ChatInputRef } from "./types"

function ChatPanel() {
  const inputRef = useRef<ChatInputRef>(null)

  const prefillSlashCommand = () => {
    inputRef.current?.setValue("/reboot ")
  }

  return (
    <ChatInput
      ref={inputRef}
      sending={false}
      awaitingResponse={false}
      onSend={(message) => console.log("Sending:", message)}
      onStop={() => abortStream()}
      slashCommands={{
        fetchCommands: async (prefix, signal) => fetchSlashCommands(prefix, signal),
      }}
      autoFocus
    />
  )
}
```