Repository navigation
fix(scan): triage sweep across open issues - #437
Merged
Merged
Conversation
Older webpack/babel-loader configs without @babel/preset-env for ES2020 fail to parse the optional chaining (\`?.\`) and nullish coalescing (\`??\`) that esbuild emits at \`target: esnext\`. Targeting es2019 transpiles those operators down so the same bundles parse in those toolchains without forcing every consumer to add a babel transform. Verified the published \`auto.global.js\`, \`index.mjs\`, \`index.js\`, and \`lite/index.mjs\` contain 0 occurrences of \`?.\` after the rebuild. Closes #287, #336.
…tions Production-environment detection (#402) --------------------------------------- \`getIsProduction()\` cached \`true\` as soon as any single registered React renderer reported a production build. Modern dev tooling commonly mounts multiple roots from different React copies — the Next.js dev overlay ships a production React build alongside the user's dev React, and the extra production renderer was enough to disable React Scan entirely. The fix preserves a permanent \`false\` cache once a non-production renderer is observed, but no longer caches \`true\` — a later dev renderer can still flip the result, even after the production overlay registered first. Adds a unit-test matrix that mocks bippy's \`getRDTHook\` / \`detectReactBuildType\` to lock the contract: - empty renderers -> null (don't know yet) - all production -> true - mixed -> false - production-then-dev (regression guard) -> flips to false - dev-then-anything -> stays false (cache) This likely also resolves #404 / #400 where the documented workaround is \`react-scan/all-environments\`, which bypassed the same broken check. New Options scaffolding ----------------------- Adds \`safeArea\` and \`useOffscreenCanvasWorker\` to the Options interface, plus runtime validation. The actual wiring is in the follow-up commit.
A Content-Security-Policy of \`worker-src 'self'\` rejects the blob: worker React Scan creates for OffscreenCanvas rendering. The fallback to main-thread rendering already worked, but the failure path \`console.warn\`'d on every page load. Changes: - \`useOffscreenCanvasWorker: false\` (new Options field) lets users with strict CSP skip the attempt entirely. - The catch block now suppresses CSP-style failures unless the user set \`_debug: 'verbose'\`, so the console isn't spammed for a fallback that's working as designed. Closes #372.
safeArea (#430) --------------- Other dev overlays (most notably the Next.js dev indicator) sit in the same screen corners as the React Scan toolbar. The expanded toolbar and collapsed bookmark would overlap them with no way for the user to inset the toolbar. Adds an \`Options.safeArea\` field that accepts either: - a single number (insets all four edges, default 24) - a per-edge \`{ top?, right?, bottom?, left? }\` object Refactors the hard-coded \`SAFE_AREA\` constant out of widget positioning math (\`calculatePosition\`, \`calculateNewSizeAndPosition\`, \`WindowDimensions\`, collapsed-corner positioning, max-size CSS) to read from a new \`getSafeArea()\` helper that resolves per-edge from options at runtime. Module-init defaults still use the raw \`SAFE_AREA\` constant — options haven't been set yet at that point, and reading them through \`ReactScanInternals.options.value\` from a top-level module would create a load-bearing optional chain through a circular import. \`defaultWidgetConfig\` is preserved as a deprecated alias of \`getDefaultWidgetConfig()\` for one minor version. \`parseSafeAreaOption\` is split out as a standalone utility (one function per file per AGENTS.md) with a unit-test matrix covering arrays, NaN, negative numbers, partial objects, and non-objects. Toolbar text selection (#415) ----------------------------- The toolbar root has \`select-none\` (so dragging the bar doesn't start a text selection), and its root \`onPointerDown\` handler calls \`e.preventDefault()\` (which suppresses focus and selection on every click). Together those two made the AI-prompt \`<pre>\` text impossible to highlight or copy. Fix: - New \`TOOLBAR_INTERACTIVE_SELECTOR\` constant lists the elements that should bypass drag and accept native focus/selection. Used from both the JSX (drag handler bail-out) and the CSS (\`user-select: text\` re-enable). Single source of truth. - \`handleDrag\` now bails — without calling \`preventDefault()\` — when the pointerdown lands on a button, link, input, textarea, select, pre, contenteditable, or \`[data-react-scan-selectable]\`. - Flat CSS selectors (no nesting) so the rule applies in older Firefox/Safari that lack native CSS nesting. Note: this is a small behavior change for button clicks — the original code called \`preventDefault()\` even on button hits; buttons now receive native focus on pointerdown.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
\`safe-area.ts\` and \`parse-safe-area-option.ts\` each defined their own copy of the same two predicates. If validation logic ever diverged (e.g. one gets a bugfix the other doesn't), runtime behavior would silently differ between option validation at \`scan()\` time and the \`getSafeArea()\` read path. Extracts both into their own files in \`web/utils/\` (one utility per file per AGENTS.md) and imports them from both consumers. Addresses Cursor Bugbot review on #437.
The predicate accepts \`value >= 0\`, which includes zero, but the \`isFinitePositive\` name implies strictly > 0 (the standard math meaning of "positive"). The error messages already correctly say "non-negative number". Renames the helper file + export to match the actual semantics so a future caller doesn't rely on the misleading name to exclude zero. Addresses Cursor Bugbot review on #437.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8cd91fb. Configure here.
The pre-asymmetric \`SAFE_AREA\` constant masked a longstanding bug in the RTL positioning math. \`calculatePosition\` used \`x = -leftBound\` for right corners and \`x = -rightBound\` for left corners — fine when both bounds embed the same number, but wrong when \`safeArea.left !== safeArea.right\`. In RTL the toolbar is right-anchored (\`position: fixed\` with both \`left:0\` and \`right:0\` plus an explicit width pins to inline-end), so a translateX(-N) leaves an N-pixel gap on the *physical* right edge. To inset physical right by \`safeArea.right\` and physical left by \`safeArea.left\`, the corner offsets must be: - right corners: \`-safeArea.right\` - left corners: \`-(windowWidth - width - safeArea.left)\` Same fix applied to the bound clamping in \`calculateNewSizeAndPosition\`. With symmetric values these collapse to the original \`-leftBound\` / \`-rightBound\` so behavior is unchanged for users who don't set \`safeArea\`. Addresses Cursor Bugbot review on #437.
This was referenced May 2, 2026
Closed
hunixcode
pushed a commit
to hunixcode/react-scan
that referenced
this pull request
Jul 3, 2026
This branch was successfully deployed
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.

Summary
Triage pass over the open issues queue. Each commit is atomic and references the issues it closes; this PR description aggregates them.
Module parse failed: Unexpected token(?.()) in old webpack/babel-loader configschore(scan): lower published bundle target from esnext to es2019Refused to create a worker from blob:(CSPworker-src 'self')fix(scan): make OffscreenCanvas worker CSP-safe + add opt-outfix(scan): correct production-environment detection + scaffold new optionsfix(scan): use "could have" instead of "could of" in optimize promptsfeat(scan): add safeArea option + allow text selection inside toolbarreact-scan/all-environments, which bypassed the same broken production checkWhat's in each commit
1.
fix(scan): use "could have" instead of "could of" in optimize prompts— #403Pure text fix in
optimize.tsx. 4 instances of the same prompt template.2.
chore(scan): lower published bundle target from esnext to es2019— #287, #336esbuild was emitting
?.,??,?.()straight into the published bundles. Older webpack + babel-loader configs without@babel/preset-envfor ES2020 fail to parse them. Lowering totarget: 'es2019'transpiles those operators down so the same bundles parse in those toolchains without forcing every consumer to add a babel transform.Verified the published
auto.global.js,index.mjs,index.js, andlite/index.mjscontain 0 occurrences of?.after the rebuild.3.
fix(scan): correct production-environment detection + scaffold new options— #402getIsProduction()cachedtrueafter seeing any single production renderer. The Next.js dev overlay registers a production React build alongside the user's dev React, so React Scan disabled itself.The fix preserves a permanent
falsecache once a non-production renderer is observed, but no longer cachestrue— a later dev renderer can still flip the result, even after the production overlay registered first.Adds a unit-test matrix that mocks bippy's
getRDTHook/detectReactBuildType:null(don't know yet)truefalsefalsefalse(cache)Also adds
safeAreaanduseOffscreenCanvasWorkerto the Options interface plus runtime validation; wiring is in commit 5.4.
fix(scan): make OffscreenCanvas worker CSP-safe + add opt-out— #372useOffscreenCanvasWorker: falseOptions field skips the worker entirely for users on a strict CSP._debug: 'verbose'is set, so the console isn't spammed for a fallback that's working as designed.console.warnfor genuine non-CSP failures.5.
feat(scan): add safeArea option + allow text selection inside toolbar— #430, #415safeArea(#430) — toolbar viewport insets. Acceptsnumber | { top?, right?, bottom?, left? }. Default 24. Refactors theSAFE_AREAconstant out of widget positioning math (calculatePosition,calculateNewSizeAndPosition,WindowDimensions, collapsed-corner positioning, max-size CSS) into agetSafeArea()helper that resolves per-edge from options at runtime. Module-init defaults still use the constant — options haven't been set yet at that point.parseSafeAreaOptionis a standalone utility with a unit-test matrix covering arrays, NaN, negative numbers, partial objects, and non-objects.Toolbar text selection (#415) — the toolbar root has
select-none(so dragging the bar doesn't start a text selection) and itsonPointerDownhandler callse.preventDefault()(which suppresses focus and selection on every click). Together they made the AI-prompt<pre>impossible to highlight. Fix:TOOLBAR_INTERACTIVE_SELECTORconstant (single source of truth) lists elements that bypass drag and accept native focus/selection. Used from both the JSX and the CSS.handleDragbails — withoutpreventDefault()— when the pointerdown lands onbutton, a, input, textarea, select, pre, [contenteditable], [data-react-scan-selectable].defaultWidgetConfigis preserved as a deprecated alias ofgetDefaultWidgetConfig()for one minor version.What I deliberately didn't fix
inspectState.kind === 'inspecting' | 'focused'andWidget(containingScanOverlay) is unmounted whenshowToolbar: false. Need user reproduction to identify which UI surface they mean.getCanvasEl()is called beforesetupToolbar()and uses iframe-localdocument. User says toolbar shows but[data-react-scan]host doesn't. Likely Storybook-specific React-renderer setup that I can't reproduce here.Cannot read '__H'. Preact-internals error from bippy bundling, not addressable fromreact-scan.react-scan/all-environmentswhich bypassed the same check), but the underlying bippy hook-installation race when DevTools sets the hook after bippy with no renderers yet registered is an upstreambippyfix.Test plan
Local verification:
pnpm --filter react-scan typecheck— passespnpm --filter react-scan test— 177/177 passing (was 161; +16 new tests forgetIsProductionandparseSafeAreaOptionregression matrices)pnpm --filter react-scan build— succeeds, all entriesauto.global.js,index.mjs,index.js,lite/index.mjs) contain 0 occurrences of?.Suggested manual checks for reviewer:
react-scaninto a Next.js 15 dev project — toolbar should now appear (was suppressed by Incorrect production enviroment detection #402)scan({ safeArea: { right: 96, bottom: 96 } })— toolbar should sit further from the bottom-right cornerworker-src 'self') without console warnings — outlines should still render via main threadNote
Medium Risk
Touches core environment gating, outline rendering initialization, and toolbar positioning/drag behavior; regressions could disable scan or break overlays in some apps, though changes are guarded with new unit tests and fallbacks.
Overview
Fixes production-environment detection by changing
getIsProduction()to returnnulluntil a renderer is registered, never cachetrue, and cachefalsepermanently once any non-production renderer is seen (plus a new regression test matrix).Adds new
scan()options:safeArea(numeric or per-edge insets) to keep the toolbar away from viewport edges/other overlays, anduseOffscreenCanvasWorkerto opt out of blob-worker outline rendering for strict CSP; worker init failures now fall back silently unless_debug: 'verbose'.Refactors widget sizing/positioning (including RTL and collapsed states) to use runtime safe-area insets, updates drag handling and CSS so text inputs/
<pre>content inside the toolbar can be selected/focused, and lowers published browser bundle targets toes2019for older tooling compatibility.Reviewed by Cursor Bugbot for commit 22b8f46. Bugbot is set up for automated code reviews on this repo. Configure here.