Skip to content

feat(conversation): add useHistoryWindow and ConversationEarlier - #10

Closed
pratikbuilds wants to merge 1 commit into
conversation/04-messagefrom
conversation/06-history-window
Closed

pratikbuilds wants to merge 1 commit into
conversation/04-messagefrom
conversation/06-history-window

Conversation

@pratikbuilds

Copy link
Copy Markdown
Owner

useHistoryWindow keeps a window of the latest items, adds earlier ones as the reader nears the top, freezes while the reader has scrolled away and trims back once they return to the end. It works with history the host pages in asynchronously, and the item in view stays put within a pixel as earlier items load. ConversationEarlier marks the top with a loading state and a retry when a page brings nothing. The doc comment records why this windows rather than virtualizes, and its ceiling.

Stacked on #9: review only this commit. Part of corbitsdev#94.

Notes for review

  • stalled only applies while the window starts at the first held item (the only place the host is asked); a failed or empty page never blocks revealing items already held above the window.
  • A page that settles while the chat is hidden under still lands (no unmount-only guard).
  • Retry keeps focus: the marker takes focus while loading, returns it to the button if the retry stalls again, and hands it to the log when the last page lands and the marker goes away.
  • The hook's own captureAnchor/restoreAnchor are covered by a cancel-out test (append + trim of equal height, so nothing resizes); it drifts 63px without them.

Verification

  • This commit passes bun run typecheck and bun run lint on its own (the stack is checked commit by commit).
  • At the top of the stack: bun run check, bun run build, bun run dep-guard, bun run contrast-test and bun run test:e2e (Playwright specs and the Storybook axe sweep in light and dark) pass.

Closes corbitsdev#100

useHistoryWindow keeps a window of the latest items, adds earlier ones
as the reader nears the top, freezes while the reader has scrolled away
and trims back once they return to the end. It works with history the
host pages in asynchronously, and the item in view stays put within a
pixel as earlier items load. ConversationEarlier marks the top with a
loading state and a retry when a page brings nothing. The doc comment
records why this windows rather than virtualizes, and its ceiling.
@pratikbuilds

Copy link
Copy Markdown
Owner Author

Moved upstream: corbitsdev#122

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.

1 participant