perf(content): minify prod bundle, throttle screenshot drag, reuse ghost-text overlay - #152
Open
zhongnansu wants to merge 1 commit into
Open
perf(content): minify prod bundle, throttle screenshot drag, reuse ghost-text overlay#152zhongnansu wants to merge 1 commit into
zhongnansu wants to merge 1 commit into
Conversation
…e ghost-text overlay - esbuild: minify production builds (minify: !isWatch); dev/watch stays readable. The unminified content.js shipped to every page on every load. - selection.js/screenshot.js: coalesce screenshot-drag mousemove via requestAnimationFrame (one DOM write per frame instead of 60+/s reflows); cancelAnimationFrame on drag-end and mode-exit; final rect stays exact. - ghost-text.js: build the Shadow DOM overlay once and reuse it instead of recreating it (and recomputing getComputedStyle) on every keystroke; recompute styles only on textarea change; guard detached/0x0 textareas. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
📦 PR Preview — Ask AI ExtensionVersion: PermissionsNo permission changes detected. ✅ Preview ChecklistBefore merging, manually test with the artifact above:
Updated by PR Preview Bot — workflow run |
Contributor
📊 Code Coverage Report
Threshold: 80% ✅ Coverage meets the minimum threshold. Updated by Code Coverage workflow |
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.
Three independent content-script / build performance fixes.
1. Minify production bundle
esbuild.config.jsshippedcontent.jsunminified to every page on every load. Nowminify: !isWatch— production builds minify,npm run dev/watch stays readable for debugging.2. rAF-coalesce screenshot drag
The screenshot drag registered an unthrottled document
mousemovethat mutatedrect.style.{left,top,width,height}on every pixel move (60+ reflows/sec). Now the latest coords are stored and a singlerequestAnimationFrameapplies them once per frame;cancelAnimationFramefires on drag-end / mode-exit (no leak, no stale write). The final captured rect is computed directly from the mouseup event, so it stays exact.3. Reuse ghost-text overlay
showGhostText()destroyed and rebuilt the entire Shadow DOM overlay (and calledgetComputedStyle) on every keystroke. Now the host is built once and reused; only the ghost text content updates per call, andgetComputedStyle-derived styles recompute only when the target textarea changes. Added a guard so a detached / 0×0 textarea (SPA re-renders) hides the overlay instead of desyncing.Testing
tests/trigger.test.js,tests/autosuggest-ghost-text.test.js), including new tests for rAF coalescing, overlay reuse, and the detached-textarea guard.🤖 Generated with Claude Code