()
| 207 | } |
| 208 | |
| 209 | export function idleCheckTick(): void { |
| 210 | if (shuttingDown) return; |
| 211 | const idle = Date.now() - lastMeaningfulActivity; |
| 212 | if (idle < IDLE_MS) return; |
| 213 | if (hasActiveBoards()) { |
| 214 | if (idleExtensions >= MAX_EXTENSIONS) { |
| 215 | dlog(`idle past hard ceiling with ${nonDoneCount()} active boards — forcing shutdown`); |
| 216 | gracefulShutdown(0); |
| 217 | return; |
| 218 | } |
| 219 | idleExtensions += 1; |
| 220 | // Push lastMeaningfulActivity forward by an extension window without |
| 221 | // marking real activity (so the count stays correct). |
| 222 | lastMeaningfulActivity = Date.now() - IDLE_MS + IDLE_EXTENSION_MS; |
| 223 | dlog( |
| 224 | `idle with ${nonDoneCount()} active boards — extending ${IDLE_EXTENSION_MS / 60000}min (${idleExtensions}/${MAX_EXTENSIONS})`, |
| 225 | ); |
| 226 | return; |
| 227 | } |
| 228 | dlog(`idle for ${Math.floor(idle / 1000)}s — shutting down`); |
| 229 | gracefulShutdown(0); |
| 230 | } |
| 231 | |
| 232 | // ─── Handlers ───────────────────────────────────────────────────── |
| 233 |
no test coverage detected