💡 User Story
As a developer, I want to consolidate the chat message flow into a single backend endpoint so that the frontend remains simple, consistent, and synced with the server-side source of truth.
📖 Description
We are refactoring the current message lifecycle to reduce complexity and improve maintainability. Currently, the frontend handles multiple responsibilities: generating IDs, managing log creation/updating, and calling multiple backend endpoints. This leads to redundant state management, increased surface area for bugs, and difficult onboarding for new contributors.
The new plan involves:
- Creating a single backend endpoint (
/chat-message) that handles:
- Generating IDs and timestamps
- Checking for new vs. existing chats
- Creating or updating the chat log
- Streaming the assistant response
- Sending a final JSON payload to the frontend
- Shifting all orchestration responsibility to the backend
- Simplifying the frontend to call only one Redux thunk
- Ensuring the Redux state is updated from the server's authoritative response
This change improves reliability, error handling, and developer clarity.
✅ Acceptance Criteria
📌 Technical Details
- Server will verify if a chat ID is new or existing and take appropriate action
- The final JSON response should include
chatId, messages, timestamp, and optional title
- Redux
logSlice and messageSlice remain separate but are updated together from server response
- Frontend no longer creates UUIDs or timestamps
- Streaming remains functional, with partial updates handled via SSE or chunked fetch
🖼️ UI/UX Mockups (If applicable)
N/A – No UI changes, backend-focused refactor
📎 Related Issues or Dependencies
🚀 Priority & Story Points
- Priority: High
- Story Points: 5
💡 User Story
As a developer, I want to consolidate the chat message flow into a single backend endpoint so that the frontend remains simple, consistent, and synced with the server-side source of truth.
📖 Description
We are refactoring the current message lifecycle to reduce complexity and improve maintainability. Currently, the frontend handles multiple responsibilities: generating IDs, managing log creation/updating, and calling multiple backend endpoints. This leads to redundant state management, increased surface area for bugs, and difficult onboarding for new contributors.
The new plan involves:
/chat-message) that handles:This change improves reliability, error handling, and developer clarity.
✅ Acceptance Criteria
sendMessageThunk) to send message and stream assistant response📌 Technical Details
chatId,messages,timestamp, and optionaltitlelogSliceandmessageSliceremain separate but are updated together from server response🖼️ UI/UX Mockups (If applicable)
N/A – No UI changes, backend-focused refactor
📎 Related Issues or Dependencies
🚀 Priority & Story Points