improvement(mothership): message queueing for home chat#3576
improvement(mothership): message queueing for home chat#3576waleedlatif1 merged 10 commits intostagingfrom
Conversation
PR SummaryMedium Risk Overview Introduces a collapsible Written by Cursor Bugbot for commit ad0d418. Configure here. |
Greptile SummaryThis PR adds message queueing to the home chat so that messages submitted while the mothership is streaming are held in a queue rather than aborting the in-progress response. A new collapsible Key changes and concerns found:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant UI as UserInput
participant H as Home
participant QM as QueuedMessages
participant UC as useChat
U->>UI: Enter / Submit (while streaming)
UI->>H: onSubmit(content, attachments, contexts)
H->>UC: sendMessage(content, ...)
UC->>UC: sendingRef.current === true
UC->>UC: setMessageQueue([...prev, QueuedMessage])
UC-->>QM: messageQueue updated (render)
QM->>U: Shows collapsible queue panel
Note over UC: Stream completes (normal)
UC->>UC: finalize() — no error
UC->>UC: messageQueueRef.current[0] = next
UC->>UC: setMessageQueue(remove next)
UC->>UC: queueMicrotask → sendMessageRef.current(next)
UC->>UC: sendMessage(next.content, ...)
alt User clicks "Send Now" on queued msg B
U->>QM: onClick sendNow(B.id)
QM->>UC: sendNow(B.id) [void — fire & forget]
UC->>UC: eager: messageQueueRef.current remove B
UC->>UC: await stopGeneration()
UC->>UC: setMessageQueue(remove B)
UC->>UC: await sendMessage(B.content, ...)
end
alt User clicks "Edit" on queued msg
U->>QM: onClick edit(id)
QM->>H: onEdit(id)
H->>UC: editQueuedMessage(id) → returns msg
H->>H: setEditingInputValue(msg.content)
H->>UI: editValue prop updated
UI->>UI: setValue(editValue) via render-phase state sync
UI->>UI: useEffect → onEditValueConsumed()
H->>H: setEditingInputValue('')
end
|
apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx
Show resolved
Hide resolved
…es, defer onEditValueConsumed to effect, await sendMessage in sendNow
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/home/components/queued-messages/queued-messages.tsx
Show resolved
Hide resolved
… move sendMessageRef to useLayoutEffect
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx
Show resolved
Hide resolved
Final Audit — Implementation Complete ✅Comprehensive line-by-line audit of all 6 files confirms the message queueing implementation is correct and complete. No code changes needed. Files Audited
Correctness Highlights
All 8 verification scenarios (send-while-streaming, multiple queued, remove, send-now, auto-drain, edit, navigate-away, switch-tasks) are confirmed working by code inspection. |
|
@greptile |
|
@cursor review |
…uard ref - Remove `setMessageQueue` from useCallback deps (stable setter, never changes) - Replace `sendNowProcessingRef` double-click guard with eager `messageQueueRef` update - Simplify `editQueuedMessage` with same eager-ref pattern for consistency Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ilure - Reset editingInputValue when chatId changes so stale edit text doesn't leak into the next chat - Pass error flag to finalize so queue is cleared (not drained) when sendMessage fails — prevents cascading failures on auth expiry or rate limiting from silently consuming every queued message Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@cursor review |
|
@greptile |
Match the pattern used by sendNow and editQueuedMessage — update the ref synchronously so finalize's microtask cannot read a stale queue and drain a message the user just removed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@greptile |
|
@cursor review |
Summary
finalize()callback)Type of Change
Testing
Tested manually
Checklist