fix: clean up timeout in PlanSidebar to prevent memory leaks#949
Open
hobostay wants to merge 1 commit intopingdotgg:mainfrom
Open
fix: clean up timeout in PlanSidebar to prevent memory leaks#949hobostay wants to merge 1 commit intopingdotgg:mainfrom
hobostay wants to merge 1 commit intopingdotgg:mainfrom
Conversation
The copy timeout was not being cleared when the component unmounted or when the copy button was clicked multiple times, potentially causing memory leaks and incorrect UI state. Refs pingdotgg#792
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
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.
Summary
Fix timeout cleanup bug in PlanSidebar that could cause memory leaks and incorrect UI state.
Changes
PlanSidebar.tsx: Store timeout in ref and clear it on unmount or re-clickBug Details
The copy timeout was not being cleared when:
This could cause memory leaks and the "copied" state to persist incorrectly.
Related Issues
Fixes #792 - Toasts keep hanging
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Note
Fix timeout cleanup in
PlanSidebarto prevent memory leaks on unmountcopiedTimerRefref and clears any active timeout before starting a new one, so rapid successive copies no longer stack timers.useEffectcleanup to clear any pending timeout when the component unmounts, preventing post-unmount state updates.useEffectcleanup block was placed inside the returned JSX rather than at the top level of the component function, which is syntactically invalid in TSX and may cause a runtime error.Macroscope summarized 5388f04.