Skip to content

Port Thread.getParticipants() method #54

@patrick-chinchill

Description

@patrick-chinchill

Missing upstream method.

What's missing

Upstream TS `Thread` exposes `async getParticipants(): Promise<Author[]>` — returns the unique non-bot authors who've posted in the thread. Iterates `messages()` and dedupes.

  • `vercel-chat/packages/chat/src/thread.ts:359`
  • `chat.test.ts` has 4 tests under `[getParticipants]`: unique authors, exclude bots, empty array for bot-only threads, include `currentMessage` author.

Python `ThreadImpl` has no equivalent. Fidelity check flags all 4 tests as missing.

Impact

Consumers building:

  • "@-mention all participants in this thread"
  • "show thread member list in a card"
  • "notify everyone involved in this discussion"

… have to manually iterate `thread.messages()` and dedupe. Works, but adds boilerplate across every consumer.

Fix

Port the method to `src/chat_sdk/thread.py`:
```python
async def get_participants(self) -> list[Author]:
seen: set[str] = set()
result: list[Author] = []
async for msg in self.messages():
if msg.author.is_bot or msg.author.user_id in seen:
continue
seen.add(msg.author.user_id)
result.append(msg.author)
# Include currentMessage author (may not be in fetched history yet)
if self._current_message and not self._current_message.author.is_bot:
if self._current_message.author.user_id not in seen:
result.append(self._current_message.author)
return result
```

Add the 4 faithful tests from `chat.test.ts`.

Acceptance

  • `ThreadImpl.get_participants()` returns non-bot unique authors
  • Includes `_current_message.author` when not in iterated history
  • 4 faithful tests ported from `chat.test.ts`
  • `verify_test_fidelity.py` shows 0 missing under `[getParticipants]`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions