Skip to content

Commit 690a833

Browse files
committed
fix(web): guests keep new items once every earlier turn is loaded
1 parent fa4e467 commit 690a833

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎apps/web/src/components/guest/guestStream.logic.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ describe("applyGuestStreamEvent", () => {
121121
projection,
122122
historyCursor: "cursor-1",
123123
hasMoreHistory: true,
124+
latestLocalTurnOrdinal: 0,
124125
},
125126
};
126127
const page = (id: string, nextCursor: string | null) => ({
@@ -149,6 +150,9 @@ describe("applyGuestStreamEvent", () => {
149150
});
150151
expect(itemIds(merged)).toEqual(["o1", "a1"]);
151152
expect(merged.historyCursor).toBeNull();
153+
// With the whole thread loaded, an item below the old window is new, not unloaded history.
154+
const late = { ...reply("late", "Late"), runId: null, ordinal: 0 };
155+
expect(itemIds(apply([itemEvent(3, late)], merged))).toEqual(["late", "o1", "a1"]);
152156
});
153157

154158
it("replaces the thread on a new snapshot, as after a reconnect", () => {

‎apps/web/src/components/guest/guestStream.logic.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export function applyGuestStreamEvent(
105105
return {
106106
...state,
107107
projection: mergeOlderHistoryIntoProjection(state.projection, event.page.items),
108+
partial: event.page.hasMoreHistory ? state.partial : null,
108109
historyCursor: event.page.hasMoreHistory ? event.page.nextCursor : null,
109110
};
110111
case "view":

0 commit comments

Comments
 (0)