MCPcopy
hub / github.com/garrytan/gstack / idleCheckTick

Function idleCheckTick

design/src/daemon.ts:209–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

207}
208
209export 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

Callers 1

daemon.test.tsFile · 0.90

Calls 4

hasActiveBoardsFunction · 0.85
dlogFunction · 0.85
nonDoneCountFunction · 0.85
gracefulShutdownFunction · 0.85

Tested by

no test coverage detected