refactor: use existing functions and panels map #3
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.
Description
Refactor ExtensionManager for Better Maintainability
Simplified panel management logic by leveraging existing helper methods and removing redundant code. This refactor makes the code more maintainable and aligns all methods with the "always reinitialize" design principle.
Changes
🧹 Removed Dead Code
isTogglingandlastToggleTimeproperties from constructor(Note: removing the debounce logic was supposed to have happened in #2, but I must have rebased incorrectly)
♻️ Refactored
togglePanel()openPanel()andclosePanel()instead of duplicating logic🔧 Fixed
cleanupOrphanedPanels()document.querySelectorAll('.cv-panel')(because orphaned panels would not be in the panelMap)initialize()to clean up orphaned panels on extension reload🔧 Fixed
closeAllPanels()cleanupOrphanedPanels()instead of duplicate cleanup code✨ Added Panel Initialization
Benefits (according to Cursor 🤖)
Testing Instructions
Pull down the branch.
Build the Carbon Visualizer extension
Chromium-based Browsers (Chrome, Edge, Brave, etc.)
Load the extension:
chrome://extensions/build/chrome/directoryTest toggle functionality:
#carbon-visualizer-welcome-panelelement be added and removed from the DOM upon inspecting your test page.Screen.Recording.2025-10-21.at.2.07.17.PM.mov
Test extension reload (orphaned panel cleanup):
chrome://extensions/Check console:
Firefox
Load the extension:
about:debugging#/runtime/this-firefoxbuild/firefox/and selectmanifest.jsonTest toggle functionality:
#carbon-visualizer-welcome-panelelement be added and removed from the DOM upon inspecting your test page.Test extension reload (orphaned panel cleanup):
about:debugging#/runtime/this-firefoxCheck console:
Expected Behavior (Both Browsers)