Repository navigation
Commit 1f114dd
authored
fix(mothership): re-read the transcript until the server has saved a finished turn (#8676)
* fix(mothership): re-read the transcript until the server has saved a finished turn
A tab finalizes a turn on the stream's `complete` event and reads the saved
transcript. The server sends that event before it persists the turn and clears
the chat's stream marker, so the read can land in the gap and return the
in-flight copy: the finished stream still listed as active and the answer under
its live id. That copy matches the optimistic one, so the history effect saw
nothing new, and the chat's `completed` event only marks a cached live stream
stale, so the tab kept it until a reload. On the local QA stack this happened
in roughly one turn in four: the finished answer had no Fork action, and the
cached stream marker kept a queued message from draining on a later return.
Finalize now re-reads with a short backoff while the server still lists the
stream it saw end. The first pass joins finalize's own read, so a turn saved in
time is still read once.
* fix(mothership): keep waiting for a slow save, and wait with a follow-up queued
- The re-read gave up after six reads (about 8s), so a slow save left the
finished turn on its in-flight copy. It now keeps reading on a capped
backoff for up to two minutes, and still stops as soon as the chat moves on
(another send or another chat).
- It skipped the wait when a follow-up was queued, but a queued follow-up that
does not go out at once (held for an edit) left the finished stream listed
as running in the cache. It now runs for every finished turn; a follow-up
that does go out ends it, since its send cancels the read and replaces the
stream.
* improvement(mothership): pace the saved-turn re-read with the shared jittered backoff1 parent c8ef18d commit 1f114dd
2 files changed
Lines changed: 176 additions & 2 deletions
Lines changed: 119 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2138 | 2138 | | |
2139 | 2139 | | |
2140 | 2140 | | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
2141 | 2260 | | |
2142 | 2261 | | |
2143 | 2262 | | |
| |||
Lines changed: 57 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
302 | 307 | | |
303 | 308 | | |
304 | 309 | | |
| |||
992 | 997 | | |
993 | 998 | | |
994 | 999 | | |
| 1000 | + | |
| 1001 | + | |
995 | 1002 | | |
996 | 1003 | | |
997 | 1004 | | |
| |||
1915 | 1922 | | |
1916 | 1923 | | |
1917 | 1924 | | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
1918 | 1966 | | |
1919 | 1967 | | |
1920 | 1968 | | |
| |||
3347 | 3395 | | |
3348 | 3396 | | |
3349 | 3397 | | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
3350 | 3402 | | |
3351 | | - | |
3352 | | - | |
| 3403 | + | |
3353 | 3404 | | |
3354 | 3405 | | |
3355 | 3406 | | |
| |||
3358 | 3409 | | |
3359 | 3410 | | |
3360 | 3411 | | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
3361 | 3415 | | |
3362 | 3416 | | |
3363 | 3417 | | |
| 3418 | + | |
3364 | 3419 | | |
3365 | 3420 | | |
3366 | 3421 | | |
| |||
0 commit comments