Commit 22e09bf
fix(frontend): keep a local generation streaming while the machine is offline (#258)
Turning off Wi-Fi could cost the rest of a running generation.
`waitForReconnect` treated `navigator.onLine === false` as "cannot reach the
backend": it set "Connection paused while offline. Waiting for network..."
and returned a promise that settled only on an `online` event. No timer, no
retry. On a machine that stays offline -- a plane, a dead router, an adapter
switched off -- the stream never reconnected, and the answer being generated
one process away was lost to the UI.
`navigator.onLine` reports whether the machine has network connectivity. The
Cortex backend is not on the network: `normalizeApiBaseUrl` refuses anything
but a same-origin path or a loopback host in production, and throws otherwise.
So the flag says nothing about whether the backend is reachable, and offline
is the ordinary operating condition for a local-first desktop app rather than
a fault to wait out.
The branch is gone. A dropped stream now always retries on the existing
backoff, which is what a loopback connection needs, and the status text says
what is actually happening.
The test that covered the old behaviour asserted the pause and the resume, so
it was pinning the defect; it now asserts the opposite -- with the machine
offline for the whole test and no `online` event ever dispatched, the retry
still has to happen.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent ebc6661 commit 22e09bf
2 files changed
Lines changed: 22 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
524 | | - | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
525 | 530 | | |
526 | 531 | | |
527 | 532 | | |
| |||
535 | 540 | | |
536 | 541 | | |
537 | 542 | | |
538 | | - | |
539 | | - | |
540 | 543 | | |
541 | | - | |
542 | | - | |
| 544 | + | |
| 545 | + | |
543 | 546 | | |
| 547 | + | |
| 548 | + | |
544 | 549 | | |
545 | 550 | | |
546 | 551 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
103 | 115 | | |
104 | 116 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | 117 | | |
130 | 118 | | |
131 | 119 | | |
| |||
0 commit comments