chatcn

Threads

Flat and nested threading for conversations. Use flat threads for simple reply chains and nested threads for Reddit-style indented discussions with voting.

5
Alice5:26 AM

Has anyone tried the new streaming API?

3
Bob5:28 AM

Yeah, it's great for real-time updates

1
Carol5:30 AM

Agreed, docs could be better though

2
Dan5:29 AM

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.

Alice5:31 AM

Should we migrate to the new API version?

You5:32 AM

I think so. The new endpoints are much cleaner.

Bob5:33 AM

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.

5
Alice5:26 AM

What's the best approach for caching?

3
You5:28 AM

Redis for hot data, CDN for static assets.

2
Bob5:30 AM

Don't forget to set TTLs!

1
Carol5:29 AM

We could also look into stale-while-revalidate.

ThreadedMessage Data Shape

The ThreadedMessage interface extends the base message fields with threading-specific properties:

2
Alice5:31 AM

Example root message (parentId: null, depth: 0)

1
Bob5:33 AM

First-level reply (depth: 1)

0
Carol5:35 AM

Nested reply (depth: 2)

FieldTypeDescription
parentIdstring | nullID of the parent message, null for root
childrenThreadedMessage[]Array of child replies
depthnumberNesting level (0 = root)
votesnumber?Optional net vote count for the message
userVote"up" | "down" | null?Current user's vote direction
isCollapsedboolean?Whether this thread branch is collapsed