()
| 634 | // server-factory.test.ts call this directly so the idle-shutdown path can be |
| 635 | // exercised without waiting 60s for the interval to fire. |
| 636 | function idleCheckTick() { |
| 637 | // Headed mode: the user is looking at the browser. Never auto-die. |
| 638 | // Only shut down when the user explicitly disconnects or closes the window. |
| 639 | // Reads via the activeBrowserManager indirection so embedders that pass |
| 640 | // their own BrowserManager into buildFetchHandler hit the right instance. |
| 641 | if (activeBrowserManager.getConnectionMode() === 'headed') return; |
| 642 | // Tunnel mode: remote agents may send commands sporadically. Never auto-die. |
| 643 | if (tunnelActive) return; |
| 644 | if (Date.now() - lastActivity > IDLE_TIMEOUT_MS) { |
| 645 | console.log(`[browse] Idle for ${IDLE_TIMEOUT_MS / 1000}s, shutting down`); |
| 646 | activeShutdown?.(); |
| 647 | } |
| 648 | } |
| 649 | const idleCheckInterval = setInterval(idleCheckTick, 60_000); |
| 650 | |
| 651 | // Test-only surface for server-factory.test.ts. Lets the dual-instance |
nothing calls this directly
no test coverage detected