Skip to content

feat(queue): enqueue user message to agent_messages immediately#250

Merged
jlia0 merged 2 commits intomainfrom
jlia0/msg-enqueue-graceful
Mar 24, 2026
Merged

feat(queue): enqueue user message to agent_messages immediately#250
jlia0 merged 2 commits intomainfrom
jlia0/msg-enqueue-graceful

Conversation

@jlia0
Copy link
Copy Markdown
Collaborator

@jlia0 jlia0 commented Mar 23, 2026

Summary

Persist user messages to agent_messages at enqueue time so they appear on the next poll instead of waiting for agent processing. This eliminates the gap between sending a message and it showing up in chat history, and allows the web UI's optimistic update to gracefully merge with polled data via message_id deduplication.

Changes

  • Add hasAgentMessage() helper to detect duplicates in the database
  • Insert user message in the messages API route when an agent is specified
  • Guard insertAgentMessage in the queue processor to prevent double-inserts
  • Pass agent ID from chat-view to the sendMessage API call

Testing

Tested locally that messages sent from the web UI now appear immediately in polled data without duplicates, and the optimistic UI update gracefully merges with real data on poll.

🤖 Generated with Claude Code

Persist user messages to agent_messages table at enqueue time so they appear on the next poll instead of waiting for agent processing. This allows the web UI's optimistic message update to gracefully merge with polled data via message_id deduplication.

Changes:
- Add hasAgentMessage() helper to check for duplicates
- Insert user message in messages route when agent is specified
- Guard insertAgentMessage in processMessage to prevent double-insert
- Pass agent ID from chat-view to sendMessage API

This eliminates the gap between sending a message and it appearing in the chat history.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jlia0 jlia0 merged commit 94df8c7 into main Mar 24, 2026
@jlia0 jlia0 deleted the jlia0/msg-enqueue-graceful branch March 24, 2026 02:18
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.

1 participant