Threads
Flat and nested threading for conversations. Use flat threads for simple reply chains and nested threads for Reddit-style indented discussions with voting.
Has anyone tried the new streaming API?
Yeah, it's great for real-time updates
Agreed, docs could be better though
I found a bug with token counting
Flat Thread
The ChatNestedThread component can render a flat thread by using a single nesting level. This is the simplest threading model, similar to Slack-style threads.
Should we migrate to the new API version?
I think so. The new endpoints are much cleaner.
Agreed. Let's plan the migration for next sprint.
Nested Thread
The ChatNestedThread component supports indented sub-threads, collapsible branches, and vote counts. Each reply level is indented further, and threads can be collapsed to focus on top-level discussion.
What's the best approach for caching?
Redis for hot data, CDN for static assets.
Don't forget to set TTLs!
We could also look into stale-while-revalidate.
ThreadedMessage Data Shape
The ThreadedMessage interface extends the base message fields with threading-specific properties:
Example root message (parentId: null, depth: 0)
First-level reply (depth: 1)
Nested reply (depth: 2)
| Field | Type | Description |
|---|---|---|
parentId | string | null | ID of the parent message, null for root |
children | ThreadedMessage[] | Array of child replies |
depth | number | Nesting level (0 = root) |
votes | number? | Optional net vote count for the message |
userVote | "up" | "down" | null? | Current user's vote direction |
isCollapsed | boolean? | Whether this thread branch is collapsed |