Skip to Content
HomeLink Hub

Messages

The chat screen for agents and landlords, how rooms load, how messages are sent in real time over socket.io, and what is not built yet.

Where it lives

RouteView fileAccess
/messagessrc/views/app/messages/messages.tsxagent, landlord
/messages?room=:idsame file, opens that conversation (used by global search results)agent, landlord

Supporting code: src/hooks/use-chat.ts (socket lifecycle), src/services/chat/socket.service.ts (one shared socket), src/services/chat/chat-slice.ts (Redux state), src/services/chat/chat-api.ts (REST, base path /api/v1/chat).

Before you start

  • Signed in as an agent or landlord. The socket authenticates with the access token from the session.
  • A conversation must already exist. Rooms are started by a client from the consumer app, or by Send Message on an inspection request, see Inspection requests. This screen has no "new conversation" button.

Flow

Connect and load rooms

  1. Opening /messages connects a socket.io client to the API host with auth: { token }. It retries up to five times, two seconds apart.
  2. On connect the app emits chat:get_rooms. The server answers with chat:rooms, and the list is stored in Redux.
  3. The left panel is headed "Messages" with three tabs: All Chats, Unread, Active Leads.
  4. Each row shows the other participant's name and avatar, the last message (or "No messages yet") and a relative time: "just now", "5m ago", "3h ago", or a date after 24 hours.
  5. On a desktop the middle panel reads "Select a conversation to start messaging" until a row is clicked. On a phone the list fills the screen.

The first room is joined in the background

Before any row is clicked, the app already joins the first room in the list and loads its messages. The chat panel still stays on the placeholder until the user picks a conversation.

Open a conversation

  1. Click a row, or arrive with ?room={id}. Picking another row drops the room parameter from the URL.
  2. The app emits chat:join with { roomId }. The server replies with chat:history.
  3. In parallel it calls GET /api/v1/chat/rooms/{roomId}/messages?limit=50&offset=0.
  4. Both results are merged in Redux, de-duplicated by message id and sorted oldest first. The view scrolls to the newest message.
  5. Switching rooms emits chat:leave for the old room and chat:join for the new one.
  6. The header shows the other person's name, Active Now or Offline, Call and Video icons, and a Schedule Tour button. On a phone a back arrow returns to the list.
  7. On wide screens a right-hand column shows Referenced Property (photo, title, price, or "No property linked"), Client Insights and Quick Replies.

Send a message

  1. Type into "Type your message here...". The send button is disabled while the text is empty or only spaces.
  2. Press Enter or the send button.
  3. The message appears at once as an optimistic bubble with a temporary id.
  4. The app emits chat:message with { roomId, content, messageType: "TEXT", replyToId }. No REST call is made.
  5. The server broadcasts chat:message to the room. The echo replaces the optimistic bubble, matched by its text.
  6. The server also sends chat:room_updated to each participant, which updates the last-message preview in the list.

Only text can be sent. The message types IMAGE, FILE and AUDIO exist in the type definitions but have no upload control.

Reply, typing and read ticks

  • Reply: hover a bubble and click the reply arrow. A bar reading "Replying to (name)" or "Replying to yourself" appears above the input with the quoted text. The X cancels it. The sent bubble carries the quote.
  • Typing: every keystroke emits chat:typing with { roomId, isTyping }. It is switched off automatically after two seconds. When the other person types, three bouncing dots show at the bottom of the thread.
  • Read ticks: your own messages show one grey tick, or two coloured ticks once readBy holds more than one user.
  • Quick Replies: "Confirm Viewing" and "Inquiry Response" drop a starter sentence into the input. Nothing is sent until you press Enter.

Schedule Tour

The Schedule Tour dialog is a mock-up

The "Schedule Inspection" dialog shows a calendar preset to 12 September 2024, four fixed time slots (one marked Booked) and the caption "Available slots for Thursday, Sept 12". Confirm Booking only closes the dialog. No request is sent and no inspection is created.

Delete and report

No delete or report control

The screen has no way to delete a message or report a conversation. DELETE /api/v1/chat/messages/{messageId} is defined in chat-api.ts but no component calls it. The API also has POST /api/v1/chat/rooms/{roomId}/report, which this app never references.

States and edge cases

SituationWhat the user sees
Socket not yet connected, no rooms"Connecting…" in the list and in the chat panel, plus a no-signal icon in the header
Connected, no rooms"No conversations yet" and "Messages from clients will appear here"
Socket drops mid-chatThe header status changes to Offline. Messages typed now are shown optimistically and only reach the server if the socket reconnects
Server rejects a messageNothing. The server emits chat:error, which the app does not listen for
Leaving the pageThe app emits chat:leave and disconnects the socket

Things on this screen that are placeholders:

ElementActual behaviour
Active Now / OfflineReflects your own socket connection, not the other person's presence
Unread tabShows every room that has a last message. There is no unread count
Active Leads tabShows every room
"Today" dividerFixed text, shown above every thread
Call, Video, attach (+) and emoji buttonsNo action
Client InsightsFixed sample text ("ID Verified", "12 Bookings", a budget range)
Referenced Property pricePrinted with a dollar sign regardless of currency. Details has no action

Leaving Messages stops live notifications

The chat and the notification bell share one socket. When the Messages page unmounts it disconnects and discards that socket, so the listener for new notifications is lost until the next full page load. This looks unintended.

What happens next

  • The other participant receives the message live if they are in the room, and their room list preview updates.
  • A message sent from an inspection request lands in the same rooms and appears here, see Inspection requests.

On this page