packages/chat-next-ui/README.md

@portfolio/chat-next-ui

React state and stream parsing utilities for the portfolio chat UI.

Overview

This package provides the frontend chat experience:

  • Chat state management through ChatProvider
  • Server-Sent Events parsing
  • Retry handling and message assembly
  • UI hint routing for generic cards and links

Dependencies

  • eventsource-parser - SSE stream parsing
  • @portfolio/chat-contract - Type definitions

Peer Dependencies

  • react (^18.0.0 || ^19.2.6)
  • react-dom (^18.0.0 || ^19.2.6)

Integration

ChatProvider defaults to /api/chat, the current vault-backed agent loop endpoint.

The UI state package keeps hints generic:

type ChatSurfaceState = {
  anchorId: string;
  visibleCards: Array<{ type: string; slug: string; label?: string }>;
  visibleLinks: Array<{ id: string; label?: string; url?: string; blurb?: string }>;
};

The consuming app is responsible for mapping card types to components.

Related Packages