Repository navigation
Commit f0e5700
authored
fix(mothership): send a late queue write to the chat a new-chat queue moved to (#8741)
* fix(mothership): send a late queue write to the chat a new-chat queue moved to
On the new-chat surface, a Send-now whose Stop saw the first message admitted
moved the queue to that chat, but the follow-up's busy refusal was re-queued
under the dead new-chat key it was dispatched from: gone from the chat, never
retried there, and liable to be adopted into a new chat later. migrate now
records where a key moved, and every write that captured a key before an
await (the dispatch's removal and restore, the direct send's re-queue, the
history check's defer and drop) resolves it at write time (liveQueueKey).
Every re-queue on a chatless surface also carries the surface, so one that
lands after the surface unmounted can still be adopted.
* fix(mothership): keep a late write behind what the chat's queue already held
When the new-chat queue moved into a chat queue that already had messages,
migrate put those first, but a late write still used its index in the
new-chat queue and could land ahead of them. The move now records how many
messages it went behind, and late writes resolve their position, not just
their key (liveQueuePosition).
* fix(mothership): anchor a late re-queue on the messages ahead of it, not an index
A restored message went back at an index captured at dispatch, offset by
how many messages a chat's queue held when the new-chat queue moved into it.
Removing any of those while the POST was out shifted it behind a newer
message. It now goes right after the last message still queued that was
ahead of it (at dispatch, or in the chat's queue before the move), else at
the head.1 parent af5501b commit f0e5700
8 files changed
Lines changed: 208 additions & 23 deletions
File tree
- apps/sim
- app/workspace/[workspaceId]/home/hooks
- lib/mothership
- stores/mothership-queue
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2829 | 2829 | | |
2830 | 2830 | | |
2831 | 2831 | | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
2832 | 2883 | | |
2833 | 2884 | | |
2834 | 2885 | | |
| |||
Lines changed: 27 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
138 | 143 | | |
139 | 144 | | |
140 | 145 | | |
| |||
336 | 341 | | |
337 | 342 | | |
338 | 343 | | |
339 | | - | |
| 344 | + | |
340 | 345 | | |
341 | 346 | | |
342 | 347 | | |
| |||
4359 | 4364 | | |
4360 | 4365 | | |
4361 | 4366 | | |
4362 | | - | |
| 4367 | + | |
| 4368 | + | |
| 4369 | + | |
4363 | 4370 | | |
4364 | 4371 | | |
4365 | 4372 | | |
| |||
4368 | 4375 | | |
4369 | 4376 | | |
4370 | 4377 | | |
4371 | | - | |
| 4378 | + | |
4372 | 4379 | | |
4373 | 4380 | | |
4374 | 4381 | | |
| |||
4899 | 4906 | | |
4900 | 4907 | | |
4901 | 4908 | | |
4902 | | - | |
4903 | | - | |
| 4909 | + | |
| 4910 | + | |
| 4911 | + | |
| 4912 | + | |
4904 | 4913 | | |
4905 | 4914 | | |
4906 | 4915 | | |
| |||
4913 | 4922 | | |
4914 | 4923 | | |
4915 | 4924 | | |
4916 | | - | |
| 4925 | + | |
4917 | 4926 | | |
4918 | 4927 | | |
4919 | 4928 | | |
| |||
4925 | 4934 | | |
4926 | 4935 | | |
4927 | 4936 | | |
4928 | | - | |
| 4937 | + | |
| 4938 | + | |
| 4939 | + | |
| 4940 | + | |
| 4941 | + | |
| 4942 | + | |
| 4943 | + | |
4929 | 4944 | | |
4930 | 4945 | | |
4931 | 4946 | | |
| |||
4972 | 4987 | | |
4973 | 4988 | | |
4974 | 4989 | | |
4975 | | - | |
| 4990 | + | |
4976 | 4991 | | |
4977 | 4992 | | |
4978 | 4993 | | |
| |||
4996 | 5011 | | |
4997 | 5012 | | |
4998 | 5013 | | |
4999 | | - | |
| 5014 | + | |
5000 | 5015 | | |
5001 | 5016 | | |
5002 | 5017 | | |
| |||
5057 | 5072 | | |
5058 | 5073 | | |
5059 | 5074 | | |
5060 | | - | |
| 5075 | + | |
5061 | 5076 | | |
5062 | 5077 | | |
5063 | 5078 | | |
5064 | 5079 | | |
5065 | | - | |
| 5080 | + | |
5066 | 5081 | | |
5067 | 5082 | | |
5068 | 5083 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| |||
181 | 185 | | |
182 | 186 | | |
183 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
184 | 232 | | |
185 | 233 | | |
186 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| 56 | + | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
| |||
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
109 | 153 | | |
110 | 154 | | |
111 | 155 | | |
| |||
191 | 235 | | |
192 | 236 | | |
193 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
194 | 245 | | |
195 | 246 | | |
196 | | - | |
| 247 | + | |
197 | 248 | | |
198 | 249 | | |
199 | 250 | | |
| |||
211 | 262 | | |
212 | 263 | | |
213 | 264 | | |
214 | | - | |
| 265 | + | |
215 | 266 | | |
216 | 267 | | |
217 | 268 | | |
| |||
0 commit comments