From 01eae09c7130426ab174934a4603cddf1f404f95 Mon Sep 17 00:00:00 2001 From: vycdev2 Date: Sun, 9 Aug 2026 23:10:02 +0000 Subject: [PATCH] fix: summarize single daily exchanges --- CHANGELOG.md | 1 + src/storage/summaries.ts | 2 +- tests/summaryWorkload.test.mjs | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d927b6..9da155b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Fixed +- Generate daily summaries for days containing a complete single exchange. - Prevent mixed reaction replies from narrating the bot's internal choice to react while preserving natural reaction-plus-text responses. - Run Discord-initiated Claude login in a pseudo-terminal so the CLI accepts submitted OAuth codes. - Isolate saved history and summaries by Discord channel ID in dedicated storage namespaces so same-named channels do not share automatic context. diff --git a/src/storage/summaries.ts b/src/storage/summaries.ts index bea842f..7b75869 100644 --- a/src/storage/summaries.ts +++ b/src/storage/summaries.ts @@ -65,7 +65,7 @@ export async function generateDailySummary( summariesInProgress.add(summaryPath); try { const log = fs.readFileSync(logPath, "utf-8").trim(); - if (!log || log.split("\n").length < 3) { + if (!log || log.split("\n").length < 2) { fs.writeFileSync(summaryPath, log, "utf-8"); return; } diff --git a/tests/summaryWorkload.test.mjs b/tests/summaryWorkload.test.mjs index 55739d7..5cf43b2 100644 --- a/tests/summaryWorkload.test.mjs +++ b/tests/summaryWorkload.test.mjs @@ -44,3 +44,26 @@ test("daily summaries declare the daily-summary workload", async () => { "A useful summary", ); }); + +test("daily summaries include a single user-and-bot exchange", async () => { + const date = new Date("2026-08-02T12:00:00Z"); + const logPath = getDailyLogPath("channel-2", date, "general"); + fs.writeFileSync(logPath, "user: question\nbot: answer\n", "utf8"); + + let capturedLog; + await generateDailySummary( + "channel-2", + "general", + date, + async (_args, input) => { + capturedLog = input; + return { stdout: "A single-exchange summary", stderr: "" }; + }, + ); + + assert.equal(capturedLog, "user: question\nbot: answer"); + assert.equal( + fs.readFileSync(getSummaryPath("channel-2", date, "general"), "utf8"), + "A single-exchange summary", + ); +});