Iron Law: Load this skill before building any chat interface; never hardcode streaming or message formats without verifying against the skill's patterns.
AI Chat Interface Skill
Tech Stack: Angular 21.x (signals, daisyUI, TailwindCSS) | Flutter 3.41.x (Riverpod, Dart 3.10.9)
When to Activate
Load this skill when the task involves any of:
- Streaming LLM response rendering (SSE / chunked HTTP)
- Chat message list with assistant/user bubbles
- Token context window indicators
- Regenerate / stop generation controls
- Thumbs up/down feedback collection
- Multi-modal input (file/image attachment in a chat box)
- AI-specific error states (refusal, rate limit, context exceeded)
- Tool call visualization in the message thread
Pre-Code Checklist
Before writing any component:
- Angular: Read
angular-spa skill — verify signal/OnPush/daisyUI baseline
- Flutter: Read
flutter-mobile skill — verify Riverpod/AppSpacing/colorScheme baseline
- Docs: Use
Context7 MCP for any library not confirmed in this session (e.g., marked, flutter_markdown)
Core Component Overview
| Component |
Angular |
Flutter |
| Message bubble list |
ChatMessageListComponent |
ChatMessageList widget |
| Streaming message display |
StreamingMessageComponent |
StreamedMessageWidget |
| Token context indicator |
TokenIndicatorComponent |
TokenIndicatorWidget |
| Chat input (multi-modal) |
ChatInputComponent |
ChatInputWidget |
| Feedback bar |
FeedbackComponent |
FeedbackBar widget |
| AI error display |
AiErrorComponent |
AiErrorWidget |
| Tool call visualization |
ToolCallCardComponent |
ToolCallCard widget |
Quick Start
See reference/quick-start.md for entry-point wiring (Angular ChatComponent + Flutter ChatScreen).
Key Patterns (brief — details in reference files)
Streaming (Angular)
- Use
AbortController to cancel in-flight SSE streams
- Auto-scroll: scroll only when user is within 100px of bottom
computed() signal to derive rendered markdown — prevents re-parsing on every chunk
aria-live="polite" wraps the message list
Streaming (Flutter)
AsyncNotifier with Stream.listen updates state incrementally
ScrollController + addPostFrameCallback for auto-scroll after frame
- Check
MediaQuery.of(context).disableAnimations before scroll animations
Token Context
- Angular:
TokenIndicatorComponent uses daisyUI progress + text-warning/text-error classes at 80%/100% thresholds
- Flutter:
LinearProgressIndicator with colorScheme.error / colorScheme.tertiary
- Always display "~N messages remaining" not raw token numbers
AI Errors
- Every AI error type has a distinct UI state — see
reference/ai-error-handling.md
- NEVER swallow AI errors silently — always show user-visible feedback with an action
Feedback
- Angular:
signal<'up'|'down'|null> tracks selected thumb; regenerate re-emits prompt
- Flutter:
HapticFeedback.lightImpact() on thumb press; colorScheme.primary for active state
Multi-Modal Input
- Angular: Angular CDK drag-drop for file zone;
Enter sends, Shift+Enter newlines
- Flutter:
image_picker for attachments; maxLines: null for auto-expanding TextField
Reference Files
| File |
Contents |
reference/quick-start.md |
Entry-point wiring for Angular ChatComponent and Flutter ChatScreen |
reference/streaming-patterns.md |
Streaming UX, auto-scroll, memoization, stop controls |
reference/context-management.md |
Token indicator, threshold logic, summarization trigger |
reference/ai-error-handling.md |
Refusal, rate limit, context exceeded, timeout, hallucination flag |
reference/feedback-loops.md |
Thumbs up/down, copy, regenerate — Angular & Flutter |
reference/multimodal-input.md |
File attach, preview chips, auto-expand textarea/field |
Anti-Patterns — Hard Prohibitions
- NEVER re-parse markdown on every streaming chunk — memoize with
computed() / derived state
- NEVER auto-scroll unconditionally — it steals user scroll position mid-read
- NEVER display raw token counts to end users — use human-readable approximations
- NEVER silently ignore AI error responses — every error must log + show user feedback
- NEVER hardcode colors for error/warning states — use daisyUI tokens or
colorScheme
- NEVER use constructor DI in Angular — use
inject()
- NEVER use
@Input()/@Output() decorators — use input(), output(), model() signals
- NEVER use raw
EdgeInsets numeric literals in Flutter — use AppSpacing tokens
- NEVER use
Color(0x...) literals in Flutter — use Theme.of(context).colorScheme
Post-Code Review
After implementation, dispatch these reviewer agents:
| Concern |
Agent |
| Angular code quality |
code-reviewer |
| Accessibility (ARIA, keyboard nav) |
accessibility-auditor |
| Flutter/Riverpod patterns |
riverpod-reviewer |
| Security (file uploads, content rendering) |
security-reviewer |
| UI/UX consistency |
ui-standards-expert |
1---2name: ai-chat3description: AI chat interface patterns for Angular 21.x and Flutter 3.41.x. Use when building streaming chat UI, conversational AI assistants, copilots, token context indicators, feedback loops, multi-modal inputs, tool visualization, or AI-specific error handling. Covers streaming markdown, auto-scroll heuristics, memoized rendering, token limit UI, regeneration controls, thumbs up/down feedback, and AI error states.4---56**Iron Law:** Load this skill before building any chat interface; never hardcode streaming or message formats without verifying against the skill's patterns.78# AI Chat Interface Skill910> **Tech Stack**: Angular 21.x (signals, daisyUI, TailwindCSS) | Flutter 3.41.x (Riverpod, Dart 3.10.9)1112## When to Activate1314Load this skill when the task involves any of:15- Streaming LLM response rendering (SSE / chunked HTTP)16- Chat message list with assistant/user bubbles17- Token context window indicators18- Regenerate / stop generation controls19- Thumbs up/down feedback collection20- Multi-modal input (file/image attachment in a chat box)21- AI-specific error states (refusal, rate limit, context exceeded)22- Tool call visualization in the message thread2324## Pre-Code Checklist2526Before writing any component:27281. **Angular**: Read `angular-spa` skill — verify signal/OnPush/daisyUI baseline292. **Flutter**: Read `flutter-mobile` skill — verify Riverpod/AppSpacing/colorScheme baseline303. **Docs**: Use `Context7` MCP for any library not confirmed in this session (e.g., `marked`, `flutter_markdown`)3132## Core Component Overview3334| Component | Angular | Flutter |35|-----------|---------|---------|36| Message bubble list | `ChatMessageListComponent` | `ChatMessageList` widget |37| Streaming message display | `StreamingMessageComponent` | `StreamedMessageWidget` |38| Token context indicator | `TokenIndicatorComponent` | `TokenIndicatorWidget` |39| Chat input (multi-modal) | `ChatInputComponent` | `ChatInputWidget` |40| Feedback bar | `FeedbackComponent` | `FeedbackBar` widget |41| AI error display | `AiErrorComponent` | `AiErrorWidget` |42| Tool call visualization | `ToolCallCardComponent` | `ToolCallCard` widget |4344## Quick Start4546See `reference/quick-start.md` for entry-point wiring (Angular `ChatComponent` + Flutter `ChatScreen`).4748## Key Patterns (brief — details in reference files)4950### Streaming (Angular)51- Use `AbortController` to cancel in-flight SSE streams52- Auto-scroll: scroll only when user is within 100px of bottom53- `computed()` signal to derive rendered markdown — prevents re-parsing on every chunk54- `aria-live="polite"` wraps the message list5556### Streaming (Flutter)57- `AsyncNotifier` with `Stream.listen` updates `state` incrementally58- `ScrollController` + `addPostFrameCallback` for auto-scroll after frame59- Check `MediaQuery.of(context).disableAnimations` before scroll animations6061### Token Context62- Angular: `TokenIndicatorComponent` uses daisyUI `progress` + `text-warning`/`text-error` classes at 80%/100% thresholds63- Flutter: `LinearProgressIndicator` with `colorScheme.error` / `colorScheme.tertiary`64- Always display "~N messages remaining" not raw token numbers6566### AI Errors67- Every AI error type has a distinct UI state — see `reference/ai-error-handling.md`68- NEVER swallow AI errors silently — always show user-visible feedback with an action6970### Feedback71- Angular: `signal<'up'|'down'|null>` tracks selected thumb; regenerate re-emits prompt72- Flutter: `HapticFeedback.lightImpact()` on thumb press; `colorScheme.primary` for active state7374### Multi-Modal Input75- Angular: Angular CDK drag-drop for file zone; `Enter` sends, `Shift+Enter` newlines76- Flutter: `image_picker` for attachments; `maxLines: null` for auto-expanding TextField7778## Reference Files7980| File | Contents |81|------|----------|82| `reference/quick-start.md` | Entry-point wiring for Angular ChatComponent and Flutter ChatScreen |83| `reference/streaming-patterns.md` | Streaming UX, auto-scroll, memoization, stop controls |84| `reference/context-management.md` | Token indicator, threshold logic, summarization trigger |85| `reference/ai-error-handling.md` | Refusal, rate limit, context exceeded, timeout, hallucination flag |86| `reference/feedback-loops.md` | Thumbs up/down, copy, regenerate — Angular & Flutter |87| `reference/multimodal-input.md` | File attach, preview chips, auto-expand textarea/field |8889## Anti-Patterns — Hard Prohibitions9091- **NEVER** re-parse markdown on every streaming chunk — memoize with `computed()` / derived state92- **NEVER** auto-scroll unconditionally — it steals user scroll position mid-read93- **NEVER** display raw token counts to end users — use human-readable approximations94- **NEVER** silently ignore AI error responses — every error must log + show user feedback95- **NEVER** hardcode colors for error/warning states — use daisyUI tokens or `colorScheme`96- **NEVER** use constructor DI in Angular — use `inject()`97- **NEVER** use `@Input()`/`@Output()` decorators — use `input()`, `output()`, `model()` signals98- **NEVER** use raw `EdgeInsets` numeric literals in Flutter — use `AppSpacing` tokens99- **NEVER** use `Color(0x...)` literals in Flutter — use `Theme.of(context).colorScheme`100101## Post-Code Review102103After implementation, dispatch these reviewer agents:104105| Concern | Agent |106|---------|-------|107| Angular code quality | `code-reviewer` |108| Accessibility (ARIA, keyboard nav) | `accessibility-auditor` |109| Flutter/Riverpod patterns | `riverpod-reviewer` |110| Security (file uploads, content rendering) | `security-reviewer` |111| UI/UX consistency | `ui-standards-expert` |