Skip to content

fix: clean up timeout in PlanSidebar to prevent memory leaks#949

Open
hobostay wants to merge 1 commit intopingdotgg:mainfrom
hobostay:fix/plan-sidebar-timeout-cleanup
Open

fix: clean up timeout in PlanSidebar to prevent memory leaks#949
hobostay wants to merge 1 commit intopingdotgg:mainfrom
hobostay:fix/plan-sidebar-timeout-cleanup

Conversation

@hobostay
Copy link

@hobostay hobostay commented Mar 12, 2026

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-click

Bug Details

The copy timeout was not being cleared when:

  1. The component unmounted
  2. The copy button was clicked multiple times

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 PlanSidebar to prevent memory leaks on unmount

  • Stores the copy feedback timeout ID in a copiedTimerRef ref and clears any active timeout before starting a new one, so rapid successive copies no longer stack timers.
  • Adds a useEffect cleanup to clear any pending timeout when the component unmounts, preventing post-unmount state updates.
  • Risk: the useEffect cleanup 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.

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
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 06da1e69-54d1-467d-b1a6-6b8d1c77639c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toasts keep hanging

1 participant