updated chat interface#399
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a real-time chat interface by wiring up new chat service modules (models, API, queries) and integrating WebSocket connectivity and React Query.
- Introduces Zod models, API client, and query helpers for chat
- Implements
ChatInterfacecomponent usingreact-use-websocketand TanStack Query - Updates dependencies (
react-use-websocket,@testing-library/dom)
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| clients/web/react/src/services/chat/models.ts | Defines Zod shape for chat entity |
| clients/web/react/src/services/chat/api.ts | Configures chatApi with REST client |
| clients/web/react/src/services/chat/queries.ts | Creates reusable React Query option builders |
| clients/web/react/src/services/chat/index.ts | Re-exports chat modules |
| clients/web/react/src/components/chat-interface.tsx | Builds chat UI with WebSocket handlers and query |
| clients/web/react/package.json | Adds new runtime and testing dependencies |
Files not reviewed (1)
- {{cookiecutter.project_slug}}/clients/web/react/package-lock.json: Language not supported
Comments suppressed due to low confidence (4)
clients/web/react/src/components/chat-interface.tsx:128
- Accessing
chats.results[0].idwithout confirming thatresultsis defined and non-empty can lead to runtime errors. Guard this access or provide a fallback if no chats are returned.
chat_id: chats?.results?.[0]?.id, // Use the first chat ID for now
clients/web/react/src/components/chat-interface.tsx:15
- Consider handling loading and error states from this query (e.g.
isLoading,isError) in the UI to improve user feedback when fetching chat list fails or is pending.
const { data: chats } = useQuery(chatQueries.list())
clients/web/react/src/services/chat/queries.ts:1
- The new query helpers (
chatQueries.all,retrieve,list) currently lack associated tests. Adding unit tests for these functions will ensure correct query key generation and option configuration.
import { queryOptions } from '@tanstack/react-query'
clients/web/react/src/services/chat/models.ts:3
- Currently
chatShapeis an object of Zod types, not a Zod schema itself. Wrap it inz.object(...)(e.g.export const chatSchema = z.object({ id: z.string(), ... })) so downstream code receives a proper schema.
export const chatShape = {
|
I think this will be replaced with Dami's PR |
584ac4a to
9f3cb1f
Compare
Are you referring to #397? Both PRs are getting stale. Do we still want to make these changes or close the PRs? |
|
Focused risk findings after rebase/push:
Current CI status after rebase push:
Recommendation from this pass: needs fixes before approval. |
Summary
Refactors the chat interface to use
react-use-websocketand adds a new chat service layer (api/models/queries) wired through TanStack Query.What Changed
WebSocketlifecycle handling inchat-interface.tsxwithreact-use-websocketsrc/services/chat/api.tssrc/services/chat/models.tssrc/services/chat/queries.tssrc/services/chat/index.tsreact-use-websocket@testing-library/domCurrent Notes / Follow-ups
/api/chatand useschats?.results?.[0]?.idforchat_id.CI / Merge State
mainSetupcheck is currently failing due to Heroku app setup environment, while lint/tests are passing