Skip to content

fix: room Load more paginates the oldest timeline - #54

Merged
zooidbot merged 1 commit into
mainfrom
fix/51-load-more-oldest-timeline
Oct 6, 2026
Merged

zooidbot merged 1 commit into
mainfrom
fix/51-load-more-oldest-timeline

Conversation

@zooidbot

@zooidbot zooidbot commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Closes #51

Repro: after a gappy (limited: true) sync the live timeline is the later side of a hole. useLoadMoreHistory paginated room.getLiveTimeline() and read hasMore from its backward token; once pagination joined it to the older timeline, the SDK's setNeighbouringTimeline nulled that token and the button hid while the older timeline still had its own token. Reproduced in vitest (makeRoom(..., { timelineSupport: true }) + room.resetLiveTimeline(...)): two of the three new tests fail on main's hook and pass with the fix.

Fix: useLoadMoreHistory now paginates the oldest timeline in the room's unfiltered set and reads hasMore from its backward token (ZNC103 D5, room side). The ordering is shared with gapStartTimelines via a new oldestTimeline(room) in use-timeline.ts, which falls back to the live timeline while the room has no events. No chain walk (D4): the room anchor is always a chain head. useLoadMoreThread is untouched.

Tests: pnpm -C packages/web typecheck clean; pnpm -C packages/web test 152 files / 965 tests pass.
Not verified: manual run against a real gappy sync (no Matrix stack in the sandbox); no lint script exists in this repo.
Knowledge impact: ZNC103 D5 (draft, zooid-ai/product#46) names this as its room-side twin; no shipped spec went stale. ZNC024 only records the pagination fixes as a prerequisite.
Plan feedback: the issue's build notes were accurate. The one gap: it says to join the timelines in the test but not how. setNeighbouringTimeline on both sides plus a RoomEvent.TimelineReset emit is enough, and gapStartTimelines drops empty timelines, so the helper needed a live-timeline fallback.

🤖 Generated with Claude Code

After a gappy sync the live timeline is the far side of a hole; joining it to
an older timeline nulls its backward token, so hasMore went false while older
history remained. Paginate the oldest timeline in the unfiltered set (same
first-event ordering as gapStartTimelines) and read hasMore from its token.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@zooidbot zooidbot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lead review: no blocking findings. The fix applies ZNC103 D5 on the room side. oldestTimeline shares its ordering with gapStartTimelines, so "Load more" and the gap marker can't disagree about which timeline is the oldest. Two of the three new tests are a direct regression assertion for the join. Falling back to the live timeline for an empty room keeps the brand-new-room behaviour. Not verified (a live gappy sync) is acceptable for an S bug whose mechanism is unit-tested. Merging.

@zooidbot
zooidbot merged commit 94cba9d into main Oct 6, 2026
1 check passed
@zooidbot
zooidbot deleted the fix/51-load-more-oldest-timeline branch October 6, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Room "Load more" stops at a timeline join instead of the start of history

1 participant