@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
23 lines • 814 B
JavaScript
/** Absolute question countdown. An external deadline is display-only; its owner settles the request. */
export class AskUserCountdown {
constructor(timeoutMs, tui, onTick, onExpire, getDeadlineAtMs) {
const deadline = Date.now() + timeoutMs;
const tick = () => {
const remaining = Math.max(0, (getDeadlineAtMs?.() ?? deadline) - Date.now());
onTick(remaining);
tui?.requestRender();
if (remaining === 0 && !getDeadlineAtMs) {
this.dispose();
onExpire();
}
};
this.timer = setInterval(tick, 1_000);
this.timer.unref();
tick();
}
dispose() {
clearInterval(this.timer);
this.timer = undefined;
}
}
//# sourceMappingURL=ask-user-countdown.js.map