Skip to content

fix(progress): gate merged-lines counter on cleanup#178

Merged
johannesjo merged 1 commit into
johannesjo:mainfrom
ASRagab:fix/merged-lines-gate-on-cleanup
Jun 15, 2026
Merged

fix(progress): gate merged-lines counter on cleanup#178
johannesjo merged 1 commit into
johannesjo:mainfrom
ASRagab:fix/merged-lines-gate-on-cleanup

Conversation

@ASRagab

@ASRagab ASRagab commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • mergeTask was calling recordMergedLines() unconditionally before the if (cleanup) gate, while recordTaskMerged() (the "Merged today" counter) was correctly gated inside the block — leftover asymmetry from the issue Progress: "Completed today" counts closures instead of merges; metrics use inconsistent time dimensions #151 fix.
  • This let the two side-by-side sidebar stats ("Merged today" / "Merged (total)") drift apart on the non-cleanup merge path.
  • Move recordMergedLines(...) inside if (cleanup) { ... } so both stats share one gate and the same source-of-truth event.

Reproduce on main

  1. Merge a task with the "merge & keep" option (cleanup: false).
  2. mergedLinesAdded / mergedLinesRemoved bump; completedTaskCount does not.
  3. Close the same task later via closeTask — "Merged today" is never incremented, but the lines totals already moved.
  4. Sidebar footer shows lines added/removed for a task that "Merged today" never counted.

After this change both counters react to the same event (cleanup === true), matching the invariant locked in by the issue #151 fix ("only count tasks that complete the full merge+cleanup lifecycle").

Test plan

  • npm run typecheck
  • npm run lint
  • npx vitest run — 1412 pass / 0 fail
  • Existing recordTaskMerged counts merges with cleanup, not closures describe extended with recordMergedLines parity assertions (called once with the merge result on cleanup: true; never called on cleanup: false).

`mergeTask` already gated `recordTaskMerged()` on `cleanup === true` so
that only completed merge+cleanup lifecycles count toward "Merged today"
(the fix from issue johannesjo#151). `recordMergedLines()` sat above the gate and
ran on every merge call regardless of cleanup, so the side-by-side
sidebar counters could drift out of sync:

- Merge without cleanup (e.g. "merge & keep") bumped the lines totals
  but not the merged-today counter.
- A later close via closeTask never bumps merged-today, so the task
  contributed lines but was never counted as a merged task.

Move the call inside the same `if (cleanup)` block so both stats share
one gate and one source-of-truth event.
@johannesjo

Copy link
Copy Markdown
Owner

Thank you very much! <3

@johannesjo johannesjo merged commit bb362aa into johannesjo:main Jun 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants