fix(stats): fix duplicate-line cleanup edge cases

- Drain the full write queue before scanning, not just one batch, so pending burst rows aren't missed
- Floor lookback-days before the positivity check so a sub-day value no longer collapses to a zero-day window
- Let the parsed cue list override the streaming dedup heuristic wherever it covers a line
- Reject combining --lifetime with --duplicate-lines and non-positive --lookback-days values
- Widen the burst frame bound to catch heavier typesetting while still sparing longer-spaced runs
- Keep the cleanup modal open until the user closes it so they can read the result before it unmounts
This commit is contained in:
2026-08-10 23:50:48 -07:00
parent 684ab9eaff
commit 039aed79c3
11 changed files with 163 additions and 16 deletions
@@ -98,10 +98,12 @@ export function parseDuplicateLineCleanupBody(body: unknown): {
} {
const source = body && typeof body === 'object' ? (body as Record<string, unknown>) : {};
const rawLookback = source.lookbackDays;
const lookbackDays =
typeof rawLookback === 'number' && Number.isFinite(rawLookback) && rawLookback > 0
// Floor before the bounds check, or a fraction of a day arrives as a zero-day window.
const wholeDays =
typeof rawLookback === 'number' && Number.isFinite(rawLookback)
? Math.floor(rawLookback)
: null;
const lookbackDays = wholeDays !== null && wholeDays >= 1 ? wholeDays : null;
return { dryRun: source.dryRun === true, lookbackDays };
}