on/off for highlighting feature #20
Draft
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.
I'll open this PR as a draft since there is still a bug. Will get back to it when I get the idea on how to fix it. Here is a quick description.
A toggle button was added in RecordingView.tsx next to the "Stop Recording" button, allowing users to enable/disable highlighting. The feature leverages the WorkflowContext in workflow-provider.tsx to manage state and communicate with the background script (background.ts) via messages like START_HIGHLIGHTING and STOP_HIGHLIGHTING. While the highlighting works as expected when manually triggered, the toggle button consistently throws a Chrome runtime error: "The message port was closed before a response was received". I suspect the issue lies in the useEffect hook or state management within workflow-provider.tsx, possibly due to the lifecycle of the message listener.
Changes Made:
In workflow-provider.tsx, I added highlightingStatus to the context, implemented startHighlighting and stopHighlighting methods, and updated the useEffect hook to listen for highlighting_status_updated messages. In background.ts, I added broadcastHighlightingStatus to notify the side panel. content.ts was updated to handle SET_HIGHLIGHTING_STATUS, and RecordingView.tsx now includes a ToggleButton component (added in button.tsx) for the toggle UI. To debug, check the side panel console (right-click → Inspect) for missing logs (e.g., “Start highlighting acknowledged by background”) and the background console (chrome://extensions/ → “inspect views”) for “Received START_HIGHLIGHTING request.”