Commit b2d146c
improvement(mothership): message queueing for home chat (#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>1 parent d06aa1d commit b2d146c
File tree
7 files changed
+437
-62
lines changed- apps/sim/app/workspace/[workspaceId]/home
- components
- queued-messages
- user-input
- hooks
7 files changed
+437
-62
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 113 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
Lines changed: 50 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| |||
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
128 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
129 | 136 | | |
130 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
131 | 142 | | |
132 | 143 | | |
133 | 144 | | |
| |||
137 | 148 | | |
138 | 149 | | |
139 | 150 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 151 | + | |
147 | 152 | | |
148 | 153 | | |
149 | 154 | | |
| 155 | + | |
| 156 | + | |
150 | 157 | | |
151 | 158 | | |
152 | 159 | | |
| |||
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
| 171 | + | |
| 172 | + | |
164 | 173 | | |
165 | 174 | | |
166 | 175 | | |
| |||
176 | 185 | | |
177 | 186 | | |
178 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
179 | 204 | | |
180 | | - | |
181 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
182 | 209 | | |
183 | 210 | | |
184 | 211 | | |
| |||
393 | 420 | | |
394 | 421 | | |
395 | 422 | | |
396 | | - | |
397 | | - | |
398 | | - | |
| 423 | + | |
399 | 424 | | |
400 | 425 | | |
401 | 426 | | |
| |||
461 | 486 | | |
462 | 487 | | |
463 | 488 | | |
464 | | - | |
| 489 | + | |
465 | 490 | | |
466 | 491 | | |
467 | 492 | | |
| |||
637 | 662 | | |
638 | 663 | | |
639 | 664 | | |
640 | | - | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
641 | 668 | | |
642 | 669 | | |
643 | 670 | | |
| |||
662 | 689 | | |
663 | 690 | | |
664 | 691 | | |
665 | | - | |
| 692 | + | |
666 | 693 | | |
667 | 694 | | |
668 | 695 | | |
| |||
818 | 845 | | |
819 | 846 | | |
820 | 847 | | |
821 | | - | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
822 | 853 | | |
823 | 854 | | |
824 | 855 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
186 | 190 | | |
187 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
188 | 209 | | |
189 | 210 | | |
190 | 211 | | |
| |||
419 | 440 | | |
420 | 441 | | |
421 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
422 | 449 | | |
423 | 450 | | |
424 | 451 | | |
425 | 452 | | |
426 | 453 | | |
427 | 454 | | |
428 | 455 | | |
| 456 | + | |
| 457 | + | |
429 | 458 | | |
430 | 459 | | |
431 | 460 | | |
| |||
0 commit comments