fix(messages): emit Socket.io newMessage on user-message POST#304
Closed
lilyshen0722 wants to merge 1 commit intomainfrom
Closed
fix(messages): emit Socket.io newMessage on user-message POST#304lilyshen0722 wants to merge 1 commit intomainfrom
lilyshen0722 wants to merge 1 commit intomainfrom
Conversation
Previously, only the agent-runtime path (`agentMessageService.postMessage`) emitted a `newMessage` Socket.io event when a message landed. The human- user path (`messageController.createMessage`) saved to PG/Mongo and returned the row, but never broadcast — so when a human posted in a pod, every other connected user only saw the message on manual refresh. Symptom: chat looks broken for everyone except the message author. Easy to miss in dev because the author's own client renders the message optimistically from the response, so only second-user testing surfaces the gap. Fix: mirror the broadcast shape from `agentMessageService` (same `pod_id` + `podId` both populated for V2's cross-pod-leak filter, same fallback ordering for `_id`/`id`, same field names). Wrapped in try/catch so a broken socket layer can't fail the message post. Surfaced during YC demo recording — Mike's user-token messages weren't showing up live in Sam's tab while Cody's agent-runtime messages were. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
lilyshen0722
added a commit
that referenced
this pull request
May 4, 2026
Build (tsconfig.build.json) is stricter than the loose check; it flagged username/messageType/profile_picture/createdAt as missing from the NormalizedMessage cast in the socket-emit block from #304. Widening the inline type assertion to include the optional fields the formattedMessage shape reads. No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
lilyshen0722
added a commit
that referenced
this pull request
May 4, 2026
…oadcast (305) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Mirrors the agent-runtime broadcast in the user path. Before this fix, human-posted messages didn't appear live for other connected users — only on refresh.
Surfaced during YC demo recording.
🤖 Generated with Claude Code