()
| 298 | }; |
| 299 | |
| 300 | const armSupervisedMonitor = () => { |
| 301 | stopSupervisedMonitor(); |
| 302 | supervisedMonitorTimer = setInterval(() => { |
| 303 | void (async () => { |
| 304 | const live = await attachToSupervisedDaemon(); |
| 305 | const window = liveMainWindow(); |
| 306 | if (!live) { |
| 307 | supervisedMonitorMisses += 1; |
| 308 | if (supervisedMonitorMisses < SUPERVISED_MONITOR_MISSES_BEFORE_DOWN) return; |
| 309 | if (!supervisedDaemonDown && window) { |
| 310 | supervisedDaemonDown = true; |
| 311 | const html = sidecarCrashHtml({ reported: errorReportingEnabled }); |
| 312 | void window.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`); |
| 313 | } |
| 314 | return; |
| 315 | } |
| 316 | supervisedMonitorMisses = 0; |
| 317 | if (supervisedDaemonDown) { |
| 318 | supervisedDaemonDown = false; |
| 319 | connection = live; |
| 320 | installBearerAuthHeader(live.baseUrl, live.authToken); |
| 321 | if (window) void window.loadURL(webUrlForConnection(live)); |
| 322 | } |
| 323 | })(); |
| 324 | }, 10_000); |
| 325 | }; |
| 326 | |
| 327 | const installBearerAuthHeader = (origin: string, token: string | null) => { |
| 328 | authHeaderUnsubscribe?.(); |
no test coverage detected