Skip to content

Feat/tanstack devtools plugin#440

Open
hunix443 wants to merge 2 commits into
aidenybai:mainfrom
hunix443:feat/tanstack-devtools-plugin
Open

Feat/tanstack devtools plugin#440
hunix443 wants to merge 2 commits into
aidenybai:mainfrom
hunix443:feat/tanstack-devtools-plugin

Conversation

@hunix443
Copy link
Copy Markdown

@hunix443 hunix443 commented May 3, 2026

PR Description Provided By Copilot.

This pull request adds a new TanStack DevTools plugin integration for React Scan, enabling the inspector and controls to be embedded directly inside the TanStack DevTools panel. The changes introduce a new entry point, update the package build and exports, and refactor the toolbar context for reuse.

TanStack DevTools plugin integration:

  • Added a new createReactScanPlugin function in tanstack-plugin/index.tsx to provide a TanStack DevTools-compatible plugin that renders the React Scan inspector, controls, and overlays within the DevTools panel. This includes a custom TanStackPanel component and ensures isolation via a shadow root.
  • Registered the new plugin entry point in the package build (tsup.config.ts) and exports (package.json), ensuring it is bundled and available for consumers. [1] [2] [3] [4]

Codebase refactoring for context sharing:

  • Moved ToolbarElementContext to a dedicated module (web/toolbar-context.ts) for reuse between the widget and the new plugin, and updated imports accordingly. [1] [2] [3]

Note

Medium Risk
Adds a new integration entrypoint that mounts React Scan UI into TanStack DevTools via a shadow root and changes build/exports, which could affect bundling/runtime mounting behavior but doesn’t touch auth or data persistence logic.

Overview
Adds a new react-scan/tanstack-plugin export with createReactScanPlugin() to run scan({showToolbar:false}) and mount the React Scan UI (overlay + main Content) inside a TanStack DevTools panel using a shadow-root container.

Refactors ToolbarElementContext into a shared ~web/toolbar-context module (with ~web/widget re-exporting it) so both the floating widget and TanStack panel can provide a consistent portal/root element.

Updates packaging to ship this new entrypoint: registers it in tsup build entries (including use client directive injection for the new output dir) and exposes types/JS via package.json exports + typesVersions.

Reviewed by Cursor Bugbot for commit d8c398c. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 3, 2026

Someone is attempting to deploy a commit to the Million Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d8c398c. Configure here.

scan({ ...options, showToolbar: false });

// Create an isolated shadow root — same pattern as initRootContainer in core/index.ts.
shadowRoot = el.attachShadow({ mode: 'open' });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attachShadow crashes on repeated render calls

High Severity

The TanStack DevTools plugin lifecycle documentation states that render is "called again when the theme changes." Calling el.attachShadow({ mode: 'open' }) on an element that already hosts a shadow root throws a DOMException. The render method lacks a guard to check for an existing shadow root before attaching a new one—unlike initRootContainer in core/index.ts, which checks before calling attachShadow. This will crash the plugin panel whenever the user toggles the DevTools theme.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d8c398c. Configure here.

id?: string;
name: string;
defaultOpen?: boolean;
render: (el: HTMLDivElement, props: Record<string, unknown>) => void;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugin interface type incompatible with TanStack DevTools

High Severity

The ReactScanTanStackPlugin interface comment says it structurally matches TanStackDevtoolsPlugin, but the render second parameter is typed as props: Record<string, unknown> while the actual TanStack interface uses theme: 'dark' | 'light'. A string literal union is not assignable to Record<string, unknown>, so under --strictFunctionTypes (default in strict mode), consumers passing createReactScanPlugin() to TanStack DevTools' plugins prop will get a TypeScript error. The interface fails its stated purpose of structural compatibility.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d8c398c. Configure here.

container,
);
},
destroy() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
destroy() {
destroy(_pluginId?: string) {

The destroy method implementation doesn't match the interface signature - it doesn't accept the pluginId parameter that the interface defines

Fix on Vercel

name: 'React Scan',
render(el) {
// Start scanning without the floating widget.
scan({ ...options, showToolbar: false });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TanStack DevTools plugin's render() method crashes on multiple calls due to attempting to attach shadow root twice to the same element

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant