fix(desktop): retain live rows after window exhaustion (#1810)

Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
Wes
2026-07-14 12:05:10 -06:00
committed by GitHub
parent af190c93e1
commit fa6f4819b3
2 changed files with 33 additions and 3 deletions

View File

@@ -154,7 +154,7 @@ test("live backdated rows stay outside pages and render in order", () => {
);
});
test("live rows below the oldest retained boundary wait for paging", () => {
test("live rows below an open oldest boundary wait for paging", () => {
const store = replaceNewestChannelWindow(
emptyChannelWindowStore(),
page(null, [event("n", 110), event("a", 100)]),
@@ -162,6 +162,30 @@ test("live rows below the oldest retained boundary wait for paging", () => {
assert.equal(mergeLiveChannelWindowEvent(store, event("old", 90)), store);
});
test("same-second live rows enter an exhausted short window regardless of id order", () => {
const store = replaceNewestChannelWindow(
emptyChannelWindowStore(),
page(null, [event("a", 100), event("m", 100)], { hasMore: false }),
);
const live = event("z", 100);
const withLive = mergeLiveChannelWindowEvent(store, live);
assert.notEqual(withLive, store);
assert.deepEqual(
flattenChannelWindowEvents(withLive).map((item) => item.content),
["z", "m", "a"],
);
});
test("older live rows stay below an exhausted window", () => {
const store = replaceNewestChannelWindow(
emptyChannelWindowStore(),
page(null, [event("a", 100)], { hasMore: false }),
);
assert.equal(mergeLiveChannelWindowEvent(store, event("old", 99)), store);
});
test("live aux stays separate from authoritative page closure", () => {
const store = replaceNewestChannelWindow(
emptyChannelWindowStore(),

View File

@@ -178,7 +178,7 @@ export function mergeLiveThreadSummary(
/**
* Merge a live top-level event without mutating authoritative page boundaries.
* Events below the oldest loaded boundary wait for ordinary relay pagination.
* Events below an open oldest boundary wait for ordinary relay pagination.
*/
export function mergeLiveChannelWindowEvent(
current: ChannelWindowStore,
@@ -205,7 +205,13 @@ export function mergeLiveChannelWindowEvent(
}
const oldestPage = current.pages[current.pages.length - 1];
const oldest = oldestPage?.rows[oldestPage.rows.length - 1]?.event;
if (oldest && compareRelayOrder(event, oldest) >= 0) return current;
if (
oldest &&
(event.created_at < oldest.created_at ||
(oldestPage.hasMore && compareRelayOrder(event, oldest) >= 0))
) {
return current;
}
return {
...current,
liveOverlay: current.liveOverlay