Adopt shadcn chat primitives#678
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 492ec3d75e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| requestAnimationFrame(() => { | ||
| const lastItem = lastItemId ? itemMapRef.current.get(lastItemId) : null; | ||
| if (hasNewLastItem && lastItem?.scrollAnchor && lastItemId) { | ||
| scrollToMessage(lastItemId, "smooth"); | ||
| return; | ||
| } | ||
| scrollToEnd("smooth"); | ||
| }); |
There was a problem hiding this comment.
Preserve the requested initial anchor scroll
When a pre-existing transcript mounts with multiple MessageScrollerItems and the last item is an assistant response, the first ref registration sets hasMountedScrollRef and schedules applyDefaultScrollPosition(), but every later initial ref registration then enters this auto-scroll branch while isAtEndRef is still true. The final scheduled callback usually calls scrollToEnd("smooth"), so callers that pass defaultScrollPosition="last-anchor" on desktop/mobile land at the bottom instead of the last user anchor. Treat the initial batch as mounting until all refs have settled, or suppress these auto-scroll callbacks until after the default position has been applied.
Useful? React with 👍 / 👎.
Fixes #677
Summary
Verification
bun test apps/web/components/ui/chat-primitives.test.tsx apps/web/components/tool-calls-summary-bar.test.tsxgit diff --checkbun --bun run ci/sessions/codex-shadcn-chat-smoke-session/chats/codex-shadcn-chat-smoke-chat: rendered seeded transcript, expanded tool marker, uploaded a text attachment, and opened the attachment preview./m/chat/codex-shadcn-chat-smoke-chat: rendered shared scroller/marker/composer at 390x844 and verified DOM scroller slots with 4 items and 2 user anchors.Notes
fetch failed), so browser QA continued with Agent Browser.