Conversation
Add optional expenseId field to Message with relation to Expense. Add reverse messages[] relation on Expense. Enables expense-to-chat-message linking for rich expense cards in chat.
ExpensesService.create() now creates a Message with expenseId set and broadcasts it via RealtimeGateway to the group room. ExpensesModule imports RealtimeModule; RealtimeModule exports gateway. This makes expenses appear as rich cards in the chat in real-time.
MessagesService.list() and create() now include expense with id, title, totalAmount, currency fields. GroupsService.findAll() includes expense on lastMessage so the trip list preview shows 'X paid ' instead of raw JSON.
ApiMessage type now includes expenseId and expense fields. ChatView renders rich expense card (title, payer, amount) for messages with expense data. Clicking 'View expense →' navigates to the Expenses tab with the expense selected. AppShell passes onOpenExpense callback that switches tab and selects the expense.
previewOf() now handles expense messages showing 'X paid ' instead of raw JSON. add-expense.tsx invalidates groups cache on success so the trip list refreshes after adding an expense.
There was a problem hiding this comment.
Pull request overview
This PR wires expenses into the chat timeline by linking Message ↔ Expense in Prisma, selecting the related expense in message/group queries, and rendering expense “cards” in the Tripshare chat + trip list previews. It also adds realtime updates so the groups list preview stays current when new messages arrive.
Changes:
- Add an optional
expenseId+expenserelation to messages (DB + backend selects + frontend types). - Emit a realtime
message:newevent when an expense is created, and keep the groups list cache updated from socket events. - Render expense previews in the trips list and an expense “View expense” card in chat messages.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/features/whatsapp/api.ts | Extends ApiMessage to support linked expenses returned by the API. |
| frontend/src/features/tripshare/my-trips.tsx | Adds expense-aware preview rendering for the trip list. |
| frontend/src/features/tripshare/chat-view.tsx | Renders expense-linked messages as a clickable “expense card”. |
| frontend/src/features/tripshare/app-shell.tsx | Adds a global socket listener to keep the cached groups list (lastMessage/updatedAt) fresh. |
| frontend/src/features/tripshare/add-expense.tsx | Invalidates ["groups"] after creating an expense to refresh previews. |
| backend/src/realtime/realtime.module.ts | Exports RealtimeGateway for injection into other modules/services. |
| backend/src/messages/messages.service.ts | Includes expense in message create/list responses. |
| backend/src/groups/groups.service.ts | Includes expense in each group’s newest message (lastMessage). |
| backend/src/expenses/expenses.service.ts | Creates and emits a message linked to a newly created expense. |
| backend/src/expenses/expenses.module.ts | Imports RealtimeModule so ExpensesService can emit realtime events. |
| backend/prisma/schema.prisma | Adds Message.expenseId relation and Expense.messages backrelation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.