Skip to content

feat(ai-partner): streaming chat UI with citation pills (#1455)#1485

Merged
CraigBuckmaster merged 2 commits into
masterfrom
claude/issue-1455-streaming-chat-ui
Apr 17, 2026
Merged

feat(ai-partner): streaming chat UI with citation pills (#1455)#1485
CraigBuckmaster merged 2 commits into
masterfrom
claude/issue-1455-streaming-chat-ui

Conversation

@CraigBuckmaster
Copy link
Copy Markdown
Owner

Closes #1455. Phase 2 of epic #1446. Depends on #1454 + #1457 (both merged) + #1450 (merged).

Summary

Real-time streaming Amicus chat: token-by-token deltas, inline citation pills, follow-up chips, Stop button, typed error banners.

New modules

  • services/amicus/streamParser.ts — pure helpers for SSE + structured envelopes
  • services/amicus/chat.ts — end-to-end orchestrator (retrieve/ai/chat SSE)
  • hooks/useAmicusThread — per-thread state, optimistic send, abort, persistence
  • components/amicus/* — MessageList, UserMessageBubble, AssistantMessageBubble, CitationPill, StreamingDot, FollowUpChips, InputBar
  • screens/AmicusThreadScreen — wired to the full stack

Key behaviors

  • Stream deltas append to an optimistic assistant bubble in real time.
  • [CITE:type:id] or [type:id] markers become tappable pills inline.
  • Trailing {"follow_ups": [...]} and {"gap": true/false} envelopes are parsed off the end and removed from prose.
  • Stop button aborts via AbortController and preserves partial text.
  • 401/402/429/5xx → typed AmicusError rendered as a dismissable banner above the input.
  • User messages persist immediately; assistant messages persist on onComplete.

Test plan

  • npx tsc --noEmit clean
  • 14 new streamParser tests: CITE/plain forms, dedup, unknown types, interleaved nodes, gap envelope, follow-ups envelope, non-JSON brace preservation, prose normalization
  • Full suite 3,272 / 3,272 passing
  • Reviewer: end-to-end smoke on dev build against staging proxy.

Out of scope

https://claude.ai/code/session_01Pht3kzgdvkn81DDfL9SnFe

Wires the live Amicus conversation experience onto the shell from #1454.

New service module:
- services/amicus/streamParser.ts — pure helpers: extractDeltaText (SSE
  content_block_delta parser), parseAssistantMessage (interleaves text
  and citation pill nodes, strips trailing gap + follow_ups envelopes,
  preserves unknown source types as literal text, dedupes citations).
- services/amicus/chat.ts — streamChat orchestrator: profile → retrieve
  → POST /ai/chat SSE → onDelta/onCitation/onGapSignal/onComplete/onError
  with typed AmicusError.

New hook:
- hooks/useAmicusThread — message history, optimistic send, AbortController
  for stop, typed error state, persistence on complete.

New components under src/components/amicus/:
- MessageList (inverted FlatList, "New message ↓" jump pill, follow-up
  chips slot)
- UserMessageBubble (gold)
- AssistantMessageBubble (renders parsed nodes with inline CitationPill,
  StreamingDot while streaming)
- CitationPill (compact gold pill, tappable; navigation in #1456)
- StreamingDot (pulsing Animated.Value)
- FollowUpChips (3 tappable chips under final assistant message)
- InputBar (multi-line, Send ↔ Stop button)

Screen wiring:
- screens/AmicusThreadScreen — swaps the shell for MessageList + InputBar
  and renders an ErrorBanner above the input for typed errors.

Tests:
- 14 new parser tests — CITE / [chunk_id] forms, dedup, unknown source
  type fallback, interleaved nodes, gap + follow_ups envelopes, non-JSON
  trailing brace preservation, cite→[chunk_id] normalization.

Full suite (3,272 tests) passes; tsc clean.

https://claude.ai/code/session_01Pht3kzgdvkn81DDfL9SnFe
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2026

Test Results

✅ All tests passed

Passed Failed Total
Tests ✅ 3295 ❌ 0 3295
Suites ✅ 444 ❌ 0 444

Coverage

Statements Branches Functions Lines

⏱️ Duration: 78.9s

Fixes the post-merge coverage drop flagged by CI on #1485.

- 7 new component tests (CitationPill, InputBar, UserMessageBubble,
  AssistantMessageBubble, FollowUpChips, MessageList, StreamingDot)
- 5 new chat.ts orchestrator tests covering happy path, 401/402
  (PROXY_UNAUTHORIZED), 429 (rate limit), offline, and gap-envelope
  delivery
- jest.config.js excludes dev-only smoke harness (screens/dev/ and
  services/amicus/__smoke__/) from coverage collection

Global thresholds now pass: statements 80.39, lines 82.2, functions
72.7, branches 66.1.

https://claude.ai/code/session_01Pht3kzgdvkn81DDfL9SnFe
@CraigBuckmaster CraigBuckmaster merged commit be05c29 into master Apr 17, 2026
6 checks passed
@CraigBuckmaster CraigBuckmaster deleted the claude/issue-1455-streaming-chat-ui branch April 17, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ai-partner: streaming chat UI with citation pills

2 participants