Fix timeline catch-up for projected overlap

This commit is contained in:
Mohamed Boudra
2026-04-22 20:21:26 +07:00
parent 4b867c2f41
commit 484e453401
2 changed files with 46 additions and 3 deletions
@@ -53,6 +53,7 @@ type InitRequestDirection = "tail" | "after";
type TimelineResponseEntry = {
seqStart: number;
seqEnd: number;
provider: string;
item: Record<string, unknown>;
timestamp: string;
@@ -122,6 +123,7 @@ export function processTimelineResponse(
// ------------------------------------------------------------------
const timelineUnits = payload.entries.map((entry) => ({
seq: entry.seqStart,
seqEnd: entry.seqEnd,
event: {
type: "timeline",
provider: entry.provider,
@@ -200,7 +202,14 @@ export function processTimelineResponse(
gapCursor = cursor ? { epoch: cursor.epoch, endSeq: cursor.endSeq } : null;
break;
}
if (decision === "drop_stale" || decision === "drop_epoch") {
if (decision === "drop_stale") {
if (cursor && unit.seqEnd > cursor.endSeq) {
gapCursor = { epoch: cursor.epoch, endSeq: cursor.endSeq };
break;
}
continue;
}
if (decision === "drop_epoch") {
continue;
}
@@ -209,7 +218,7 @@ export function processTimelineResponse(
cursor = {
epoch: payload.epoch,
startSeq: unit.seq,
endSeq: unit.seq,
endSeq: unit.seqEnd,
};
continue;
}
@@ -218,7 +227,7 @@ export function processTimelineResponse(
}
cursor = {
...cursor,
endSeq: unit.seq,
endSeq: unit.seqEnd,
};
}