Skip to content

fix(headless): correct chat room model, message body format, and auth flow#1

Merged
boiyelove merged 2 commits intomainfrom
fix/headless-chat-api
Apr 25, 2026
Merged

fix(headless): correct chat room model, message body format, and auth flow#1
boiyelove merged 2 commits intomainfrom
fix/headless-chat-api

Conversation

@boiyelove
Copy link
Copy Markdown
Owner

Changes

  • ChatRoomList model fix: PaginatedResponse[ChatRoomDetail] instead of PaginatedResponse[ChatRoom]. The ChatRoom wrapper always returned None for all fields because the API returns flat records, not nested under chat_room.

  • create_chat_message body helper: Accepts body="plain text" and auto-converts to Circle's tiptap rich_text_body format. Previously, passing body="text" silently sent but displayed as empty/undefined in Circle.

  • headless_as_user convenience method: Simplifies the two-step headless auth flow into one call: client.headless_as_user(email="...") returns a ready-to-use headless namespace.

  • Return type fixes: create_chat_room, get_chat_room, update_chat_participant now return ChatRoomDetail instead of ChatRoom (both sync and async).

Before/After

# Before (broken)
room.chat_room.uuid  # AttributeError: None
create_chat_message(uuid, body="hi")  # shows empty in Circle

# After (works)
room.uuid  # "abc-123"
create_chat_message(uuid, body="hi")  # displays correctly
headless = client.headless_as_user(email="user@example.com")

Testing

Tested against live Circle.so community with 10K+ members.

… flow

- ChatRoomList now paginates ChatRoomDetail directly instead of the
  ChatRoom wrapper that always returned None for all fields
- create_chat_message accepts body=string and auto-converts to the
  tiptap rich_text_body format Circle requires (fixes messages
  appearing as empty/undefined)
- Added _text_to_tiptap helper for plain text to tiptap conversion
- Updated create_chat_room, get_chat_room, update_chat_participant
  return types from ChatRoom to ChatRoomDetail (sync and async)
- Added headless_as_user convenience method to CircleClient for the
  two-step headless auth flow (auth token -> user access token)
@boiyelove boiyelove merged commit 69557ec into main Apr 25, 2026
5 checks passed
@boiyelove boiyelove deleted the fix/headless-chat-api branch April 25, 2026 13:20
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.

1 participant