From c96f6d8e84caa7edd1ff90aefea9951bd718ab8f Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Tue, 21 Jul 2026 17:55:21 -0700 Subject: [PATCH] --wait keeps the table open on a re-roll answer Live-fire bug from the demo: collecting a re-roll answer deleted the state file, so --update could not find the still-running server and the next hand had nowhere to land. Cleanup is now terminal-only: a re-roll consumes just the answer file and leaves the server state for --update; any other choice cleans up fully as before. Co-Authored-By: Claude Fable 5 --- skill/scripts/serve-question.mjs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/skill/scripts/serve-question.mjs b/skill/scripts/serve-question.mjs index 3f75e3e45..e44908a43 100644 --- a/skill/scripts/serve-question.mjs +++ b/skill/scripts/serve-question.mjs @@ -107,8 +107,14 @@ if (hasFlag('wait')) { await new Promise((r) => setTimeout(r, 1000)); } if (!answered()) { console.log(`WAITING: no answer yet after ${pollSec}s; run --wait --key ${key} again`); process.exit(3); } - console.log(`ANSWER: ${fs.readFileSync(answerFile(key), 'utf8').trim()}`); - try { fs.rmSync(answerFile(key)); fs.rmSync(stateFile(key)); } catch { /* already cleaned */ } + const collected = fs.readFileSync(answerFile(key), 'utf8').trim(); + console.log(`ANSWER: ${collected}`); + // A re-roll keeps the table open: the server stays alive awaiting --update, + // so only the answer file is consumed. Terminal choices clean up fully. + let isRerollAnswer = false; + try { isRerollAnswer = JSON.parse(collected).optionId === 'reroll'; } catch { /* treat as terminal */ } + try { fs.rmSync(answerFile(key)); } catch { /* already gone */ } + if (!isRerollAnswer) { try { fs.rmSync(stateFile(key)); } catch { /* already gone */ } } process.exit(0); }