Skip to content

Commit bb362aa

Browse files
ASRagabjohannesjo
authored andcommitted
fix(progress): gate merged-lines counter on cleanup
`mergeTask` already gated `recordTaskMerged()` on `cleanup === true` so that only completed merge+cleanup lifecycles count toward "Merged today" (the fix from issue #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.
1 parent a89dae3 commit bb362aa

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/store/tasks.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ import {
152152
updateTaskBranch,
153153
} from './tasks';
154154
import { getCoordinatorChildren } from './sidebar-order';
155-
import { recordTaskMerged } from './completion';
155+
import { recordMergedLines, recordTaskMerged } from './completion';
156156
import { markAgentSpawned, rescheduleTaskStatusPolling } from './taskStatus';
157157
import { saveState } from './persistence';
158158
import { getProjectBranchPrefix, getProjectPath, isProjectMissing } from './projects';
@@ -1116,9 +1116,11 @@ describe('recordTaskMerged counts merges with cleanup, not closures', () => {
11161116
await mergeTask('task-1', { cleanup: true });
11171117

11181118
expect(recordTaskMerged).toHaveBeenCalledTimes(1);
1119+
expect(recordMergedLines).toHaveBeenCalledTimes(1);
1120+
expect(recordMergedLines).toHaveBeenCalledWith(10, 2);
11191121
});
11201122

1121-
it('merging without cleanup does NOT increment the counter', async () => {
1123+
it('merging without cleanup does NOT increment the counter or lines totals', async () => {
11221124
mockTasks['task-1'] = {
11231125
agentIds: [],
11241126
shellAgentIds: [],
@@ -1138,6 +1140,7 @@ describe('recordTaskMerged counts merges with cleanup, not closures', () => {
11381140
await mergeTask('task-1', { cleanup: false });
11391141

11401142
expect(recordTaskMerged).not.toHaveBeenCalled();
1143+
expect(recordMergedLines).not.toHaveBeenCalled();
11411144
});
11421145
});
11431146

src/store/tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@ export async function mergeTask(
589589
message: options?.message,
590590
cleanup,
591591
});
592-
recordMergedLines(mergeResult.lines_added, mergeResult.lines_removed);
593592

594593
if (cleanup) {
594+
recordMergedLines(mergeResult.lines_added, mergeResult.lines_removed);
595595
recordTaskMerged();
596596
await Promise.allSettled(
597597
[...agentIds, ...shellAgentIds].map((id) => invoke(IPC.KillAgent, { agentId: id })),

0 commit comments

Comments
 (0)