Skip to content

Build the portal conversation view (W6-03) #137 - #150

Merged
calebyhan merged 4 commits into
mainfrom
137/conversation-view
Nov 18, 2026
Merged

calebyhan merged 4 commits into
mainfrom
137/conversation-view

Conversation

@BrianRyu04

Copy link
Copy Markdown
Contributor

Motivation
This is where responders actually talk to students: the full history of the open conversation, live, with a composer and an "End conversation" button (TDD 4.3.2). The API is #114, and #121 already keeps ["conversation", id] up to date from the socket.

Changes:

  • Added ConversationView, shown in the inbox's right-hand slot for active and queued conversations.
    • Header: "Texter N", status, when it opened, the Guide panel button, and the escalate button (moved here from the inbox, resolving the TODO(#137)).
    • Messages render in order. Responder messages are on the right, texter messages on the left, and system messages (like the after-hours reply) are centered and styled apart.
    • Sending posts to /api/portal/conversations/{id}/messages. A message shows as pending until the request returns. A failed send shows "Not sent. Tap to retry." If the socket already delivered the saved message, it isn't added twice.
    • "End conversation" asks for confirmation, then calls /end.
    • Once the conversation is closed, the composer is replaced by "This conversation has ended" and the report form.
    • A 404 (for example, the conversation went back to the queue at shift end) shows "This conversation is no longer available" and clears the inbox selection.
    • Marks the conversation read when it opens, and again when a texter message arrives while the tab is visible. Afterwards it refreshes the inbox so unread counts update.
  • Added useConversation(id) to lib/portal/queries.ts, using the existing conversationQueryKey that the portal socket already keeps up to date.
  • Added self and labels props to MessageList so the portal reuses it instead of copying it. The student chat's defaults are unchanged.
  • Added an optional description prop to EndConversationDialog, because the default text is written for texters.
  • Closed and needs-report conversations still open straight to the report form without loading history, so the existing inbox tests still pass.
  • Tests cover message order and sides, pending then saved, retry after a failed send, confirming before ending, mark-as-read on open, the closed state, and the 404 state.

Not included: the typing indicator
Known limitation: if a send fails after the server already saved the message, retrying can post it twice. The send endpoint has no idempotency key.
No texter identifiers are shown or sent. The view only uses the label, status, timestamps, and message bodies from the existing DTOs.

Closes #137

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Backend Test Results

685 tests  ±0   685 ✅ ±0   20s ⏱️ -4s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit d615914. ± Comparison against base commit 9718c3b.

♻️ This comment has been updated with latest results.

@calebyhan calebyhan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

404 state is never visible in the inbox. Issue #137 asks for a 404 to show "This conversation is no longer available" and clear the selection. Right now ConversationView calls onUnavailable() in an effect as soon as the 404 arrives. Inbox passes clearSelection for that, so selectedId becomes null and the view is removed. The message shows for at most one frame before the pane switches to "Select a conversation from the inbox." The test only renders ConversationView on its own, so it doesn't catch this.

Suggested fix: keep the unavailable state on screen and clear the selection when the responder clicks "Back to inbox", or have Inbox show the message after it clears the selection. Please add an Inbox-level test that checks the message is still visible after a 404.

Note: when a shift ends, the inbox refetch also drops the conversation, which clears the selection too. So the message only stays visible if the view, not the inbox, is what shows it.

@calebyhan calebyhan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@calebyhan
calebyhan merged commit 3fac79e into main Nov 18, 2026
4 checks passed
@calebyhan
calebyhan deleted the 137/conversation-view branch November 18, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build the portal conversation view (W6-03)

2 participants