Feat/highlight engine improvements#4
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the highlight/selection UX in the content script by adjusting where the floating toolbar appears, preventing it from appearing in editable inputs, and blocking highlight creation while an AI response is streaming (to avoid DOM/range instability).
Changes:
- Reposition the floating selection toolbar to appear below the selection and clamp it to viewport bounds.
- Add “streaming” detection to prevent creating highlights while the page is actively updating response content.
- Suppress the toolbar when the selection occurs inside input-like/editable areas; increase mouseup debounce delay.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+473
to
+477
| top = Math.min(top, scrollY + viewportHeight - toolbarHeight - 8); | ||
| left = Math.max(4, Math.min(left, scrollX + viewportWidth - toolbarWidth - 8)); | ||
|
|
||
| tb.style.top = top + "px"; | ||
| tb.style.left = left + "px"; |
Comment on lines
+497
to
+503
| function isNodeInInputArea(node) { | ||
| if (!node) return false; | ||
| let el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node; | ||
| return !!el.closest( | ||
| '[contenteditable="true"], textarea, input, [data-testid*="input"], [role="textbox"], [role="combobox"]' | ||
| ); | ||
| } |
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.
No description provided.