feat(team): add real-time team chat - #106
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59b7e4172a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return apiRequest<ChatMessagePage>( | ||
| `/project-groups/${projectGroupId}/chat/messages?${params.toString()}`, |
There was a problem hiding this comment.
Add chat endpoints to the OpenAPI contract
In real API mode this new request calls /project-groups/{projectGroupId}/chat/messages, but openapi/openapi.yaml is the repo's source of truth and it contains no chat paths at all (I checked the spec for chat//project-groups/{projectGroupId}/chat). That leaves the real-mode chat UI depending on undocumented endpoints/response shapes, so it can drift from or fail against the backend contract until the REST chat history/read endpoints are added to the OpenAPI spec.
Useful? React with 👍 / 👎.
| queryClient.setQueryData<ChatMessagePage>( | ||
| chatQueryKeys.messages(projectGroupId), | ||
| (current) => appendChatMessagePage(current, chatMessage), | ||
| ); |
There was a problem hiding this comment.
Preserve live messages while history is loading
When a STOMP message arrives before the initial useChatMessagesQuery request has resolved, this writes the live message into the same query key, but the in-flight REST history response can then overwrite the cache with an older page that does not include that just-delivered message. In that race the message disappears from the chat until a later refetch/remount, so the subscription should wait for history or merge the REST result with any cache entries that arrived meanwhile.
Useful? React with 👍 / 👎.
| const client = new Client({ | ||
| brokerURL: getChatWebSocketUrl(), | ||
| connectHeaders: { | ||
| Authorization: `Bearer ${session.accessToken}`, | ||
| }, |
There was a problem hiding this comment.
Reconnect chat with a refreshed access token
This captures the current access token once when creating the STOMP client, unlike apiRequest, which refreshes tokens on 401 and stores the new access token. If a user opens /team with an expired access token but a valid refresh token, the REST chat history/project-group calls can recover while the WebSocket handshake keeps using the stale token (and future STOMP auto-reconnects reuse it too), leaving chat stuck in a connection error until a full remount/reload. Fetch the latest session token before each connect/reconnect or trigger the same refresh path before activating the client.
Useful? React with 👍 / 👎.
|
LGTM Detected! Ready to merge |
Summary
Validation
Closes #105