Uh oh!
There was an error while loading. Please reload this page.
improvement(mothership): message queueing for home chat - #3576
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
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…es, defer onEditValueConsumed to effect, await sendMessage in sendNow
The latest updates on your projects. Learn more about Vercel for GitHub. |
waleedlatif1
commented
Mar 14, 2026
waleedlatif1
commented
Mar 14, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
… move sendMessageRef to useLayoutEffect
waleedlatif1
commented
Mar 14, 2026
waleedlatif1
commented
Mar 14, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Mar 14, 2026
waleedlatif1
commented
Mar 14, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Mar 14, 2026
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. |
waleedlatif1
commented
Mar 14, 2026
waleedlatif1
commented
Mar 14, 2026
@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>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…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>
waleedlatif1
commented
Mar 14, 2026
@cursor review |
waleedlatif1
commented
Mar 14, 2026
Uh oh!
There was an error while loading. Please reload this page.
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>
waleedlatif1
commented
Mar 14, 2026
waleedlatif1
commented
Mar 14, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
…3576) * improvement(mothership): message queueing for home chat * fix(mothership): address PR review — move FileAttachmentForApi to types, defer onEditValueConsumed to effect, await sendMessage in sendNow * fix(mothership): replace updater side-effect with useEffect ref sync, move sendMessageRef to useLayoutEffect * fix(mothership): clear message queue on chat switch while sending * fix(mothership): remove stale isSending from handleKeyDown deps * fix(mothership): guard sendNow against double-click duplicate sends * fix(mothership): simplify queue callbacks — drop redundant deps and guard 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> * fix(mothership): clear edit value on nav, stop queue drain on send failure - 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> * fix(mothership): eagerly update messageQueueRef in removeFromQueue 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> * fix(mothership): mark onSendNow as explicit fire-and-forget Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
finalize()callback)Type of Change
Testing
Tested manually
Checklist