Commit a8956e1
committed
fix(core): restart opencode server on 3 cancels
If the user tries to cancel their request three times in a row, shutdown
the opencode server and then restart.
Getting the code working was a little bit tricky for two main issues:
1. If we try to do it on demand in api_client when the user sends a
prompt, then there's a race condition between that prompt getting
sent and when we get subscribed to server events. That race condition
can cause us to miss message/part events.
2. Some other listeners to opencode_server may trigger api_client calls
so we have to be extra careful to make sure base_url is set. That means
we can't rely solely on state.opencode_server notification to update
base_url but have to check it before using it.1 parent 1bd3bc9 commit a8956e1
2 files changed
+72
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 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 | + | |
17 | 44 | | |
18 | 45 | | |
19 | 46 | | |
20 | 47 | | |
21 | 48 | | |
22 | 49 | | |
23 | 50 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 51 | + | |
| 52 | + | |
32 | 53 | | |
33 | 54 | | |
34 | 55 | | |
| |||
361 | 382 | | |
362 | 383 | | |
363 | 384 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
| 385 | + | |
368 | 386 | | |
369 | 387 | | |
370 | 388 | | |
| |||
403 | 421 | | |
404 | 422 | | |
405 | 423 | | |
406 | | - | |
| 424 | + | |
407 | 425 | | |
408 | 426 | | |
409 | | - | |
410 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
411 | 430 | | |
412 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
413 | 449 | | |
414 | 450 | | |
415 | 451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| |||
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
178 | | - | |
| 180 | + | |
| 181 | + | |
179 | 182 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
185 | 188 | | |
186 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
187 | 197 | | |
188 | 198 | | |
189 | 199 | | |
| |||
231 | 241 | | |
232 | 242 | | |
233 | 243 | | |
234 | | - | |
| 244 | + | |
235 | 245 | | |
236 | 246 | | |
237 | 247 | | |
0 commit comments