Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use stable initialMessages for useChat #493

Merged
merged 2 commits into from
Jan 16, 2025
Merged

Conversation

codeincontext
Copy link
Collaborator

@codeincontext codeincontext commented Jan 16, 2025

Description

I've been finding that the frontend has been getting in a render loop that calls getChat constantly. @JBR90 worked out that #459 was probably the PR that introduced it

CleanShot 2025-01-16 at 15 02 48@2x

I've found that initialMessages was different on each render, which might cause useChat to reload and trigger another tRPC request

I've also been finding that the AI SDK calls like append aren't stable. This doesn't seem to completely fix that, though changing initialMessages could be the cause

This PR fixes the feedback loop, though it will still be calling a little too much

Issue(s)

Fixes #

How to test

  1. Open the chat page for an existing lesson plan
  2. Look at the console

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
oak-ai-lesson-assistant ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 16, 2025 5:23pm

Copy link

github-actions bot commented Jan 16, 2025

Playwright test results

passed  17 passed
skipped  2 skipped

Details

report  Open report ↗︎
stats  19 tests across 16 suites
duration  2 minutes, 30 seconds
commit  cc1db58

Skipped tests

No persona › tests/auth.test.ts › authenticate through Clerk UI
No persona › tests/chat-performance.test.ts › Component renders during lesson chat › There are no unnecessary rerenders across left and right side of chat

@codeincontext codeincontext marked this pull request as ready for review January 16, 2025 17:27
@codeincontext codeincontext requested a review from stefl January 16, 2025 17:30
@codeincontext codeincontext merged commit 3233c2e into main Jan 16, 2025
20 of 21 checks passed
@codeincontext codeincontext deleted the fix/usechat-loop branch January 16, 2025 17:30
@oak-machine-user
Copy link
Collaborator

🎉 This PR is included in version 1.22.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants