fix: stop the auto-refresh timer on unmount (it repaints over other plugins) - #2
Open
AJV009 wants to merge 1 commit into
Open
fix: stop the auto-refresh timer on unmount (it repaints over other plugins)#2AJV009 wants to merge 1 commit into
AJV009 wants to merge 1 commit into
Conversation
`intervalId` and `stopAuto()` are declared inside `mount()`'s closure, but `unmount()` is a separate top-level export with no access to them. It clears the container's innerHTML and removes the injected styles, but never calls `clearInterval`. The 10s auto-refresh timer therefore survives unmount and keeps calling fetchSessions(), which re-renders into the `container` element captured by the closure. CloudCLI reuses one container for the active tab plugin, so a few seconds after switching away from Sessions the timer repaints the session table over whichever plugin is now mounted there. Reproduced with the PRISM plugin: select Sessions, switch to PRISM, and within 10s PRISM's panel is replaced by the Claude Sessions table. Removing this plugin made PRISM render correctly again, confirming the source. Fix: hold the closure's stopAuto in a module-scoped `activeStopAuto` and invoke it from unmount(). dist/index.js is a verbatim copy of src/index.js (no build step), so both are updated. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011WfoF1z5anUFtH61ECn1ZF
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
After visiting the Sessions tab, switching to any other plugin tab shows the Claude Sessions table again a few seconds later — the other plugin's UI is replaced by this one's.
Reproduced against the PRISM plugin:
Uninstalling this plugin made PRISM render correctly and permanently, which isolated the source.
Cause
intervalIdandstopAuto()are declared insidemount()'s closure:but
unmount()is a separate top-level export with no access to that closure:So
clearIntervalis never called. The 10s timer outlives unmount and keeps callingfetchSessions(), which re-renders into thecontainercaptured by the closure. CloudCLI reuses a single container for the active tab plugin, so the orphaned timer paints this plugin's table over whatever is mounted there now.Fix
Hold the closure's
stopAutoin a module-scopedactiveStopAutoand invoke it fromunmount(). Three lines plus a comment.dist/index.jsis a verbatim copy ofsrc/index.js(no build step), so both files are updated identically.Verification
Linux, Chrome, CloudCLI 1.37.2, with PRISM installed alongside:
🤖 Generated with Claude Code
https://claude.ai/code/session_011WfoF1z5anUFtH61ECn1ZF