Repository navigation
fix(chat): stop the transcript settle effect from looping - #840
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The settle effect called setMessages(transcriptData) with no equality guard. The AI SDK copies the array on every set, so messages identity changed, the effect (which lists messages) re-fired, and the two fed each other. experimental_throttle paced it at about ten passive-effect updates per second until React threw error #185. The guard passes for any settled thread that has a transcript, so this was the normal idle state of the chat surface, not an edge case. Deep-compare transcriptData against messages before setting. After the first set the two match, so the next effect run returns early. The compare runs only when the thread is settled and ready, never during streaming. Generated-By: PostHog Desktop Task-Id: a0af39e0-b4ce-4fc6-8d9d-e99ec5e3bdef
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
useWorkspaceAiChat.tscallssetMessages(transcriptData)with no equality guard. The AI SDK copies the array on every set, somessagesidentity changes, the effect (which listsmessages) re-fires, and the two feed each other forever.experimental_throttle: 100paces the loop at roughly ten passive-effect updates per second, so React only throws once the nested passive-update count crosses fifty — about five seconds in.Changes
transcriptsEqualnext toserverTranscriptAdvanced, reusing the sameJSON.stringifycomparison the recovery path already relies on.Test plan
pnpm testfor the affected file (6 passed)pnpm check(format, lint, types — clean)Why
Users with a chat thread open sit in a passive-effect render loop that wastes CPU on the product's core chat surface and eventually crashes the panel.
Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.