Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Commit d738387

Browse files
committed
FEA-1564: Review feedback - future-timestamp guard, synthetic event timestamps
- Guard isRecentlyActive against future sourceUpdatedAt timestamps - Use progressive synthetic timestamps for no-timestamp events to avoid high-water-mark dedup collisions - Already committed: updated_at coalesce for nameless events Testing: typecheck and lint pass
1 parent 03a5103 commit d738387

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

apps/desktop/src/main/collectors/import-session.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export function createImporter(db: DatabaseSync, deps: ImporterDeps): Importer {
118118
Number.isFinite(session.fileModifiedAt) &&
119119
nowMs - session.fileModifiedAt < RECENT_ACTIVITY_MS &&
120120
Number.isFinite(sourceUpdatedAtMs) &&
121+
sourceUpdatedAtMs <= nowMs &&
121122
nowMs - sourceUpdatedAtMs < RECENT_ACTIVITY_MS
122123
);
123124
}
@@ -280,6 +281,7 @@ export function createImporter(db: DatabaseSync, deps: ImporterDeps): Importer {
280281
}
281282

282283
let inserted = 0;
284+
let namelessEventCounter = 0;
283285
const addEvent = (
284286
eventType: string,
285287
agentId: string,
@@ -288,7 +290,12 @@ export function createImporter(db: DatabaseSync, deps: ImporterDeps): Importer {
288290
summary: string | null,
289291
data: string | null,
290292
): void => {
291-
const eventTimestamp = ts ?? startedAt;
293+
const eventTimestamp = ts ?? (() => {
294+
// Synthetic increment to distinguish no-timestamp events in the same
295+
// batch so they don't all collide on the high-water-mark dedup.
296+
const base = Date.parse(sourceUpdatedAt);
297+
return new Date(base + namelessEventCounter++).toISOString();
298+
})();
292299
const prev = highWater.get(eventType);
293300
if (prev != null && eventTimestamp <= prev) return;
294301
insertEventStmt.run(

0 commit comments

Comments
 (0)