Skip to content

fix(kit): scope plugin hooks per app - #1162

Merged
webfansplz merged 1 commit into
mainfrom
fix/plugin-adapter-per-app
Oct 16, 2026
Merged

webfansplz merged 1 commit into
mainfrom
fix/plugin-adapter-per-app

Conversation

@webfansplz

Copy link
Copy Markdown
Member

When several Vue apps on one page register the same plugin id (Pinia does this once per app), the kit kept a single adapter per id and overwrote its descriptor.app with the latest app. App scoping then rejected hook payloads for every other app, so their custom inspectors came back empty. For example, only the last app to register Pinia showed its stores in the Pinia tab.

This is a v9 regression. In v8.2.1 each setupDevtoolsPlugin call got its own API bound to its own descriptor.

Fix

  • registry.ts: a private RegisteredPlugin per plugin id keeps one adapter per app. A setup for a known app reuses that app's adapter; a new app gets its own; a setup without an app joins the first. Descriptor metadata is merged into all of them. Hook calls go to every adapter, and each one filters by its own app as before.
  • settings.ts (internal, not exported): PluginSettings holds setting values per plugin id and is shared by all adapters of that id. A change reaches every app's setPluginSettings handlers with the correct oldValue.
  • createPluginApiAdapter takes the settings store as a new optional argument. No existing exported type changes.

Note: plugins.adapters still maps a plugin id to its first adapter. That adapter backs the plugin snapshot and settings commands; per-app adapters are internal.

Verification

New tests in tests/unit/plugin/v6-compat.test.ts:

  • per-app inspector trees for one plugin id (fails on main)
  • setPluginSettings reaches handlers from every app
  • the same handler registered twice runs once
  • settings are shared across apps, and the snapshot lists the plugin once

pnpm vitest run tests/unit tests/integration passes (366 tests).

Manually checked in playground/basic with a second app that has its own Pinia (pinia 4.0.3), querying each app's pinia inspector tree:

App 0 App 1
main counter, lab empty
this PR counter, lab widget

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 15, 2026 08:19
@netlify

netlify Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vue-devtools-docs canceled.

Name Link
🔨 Latest commit e1a4a9d
🔍 Latest deploy log https://app.netlify.com/projects/vue-devtools-docs/deploys/6ad08caed8418efe0e029ffd

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vue/devtools-agent@1162
npm i https://pkg.pr.new/@vue/devtools-api@1162
npm i https://pkg.pr.new/@vue/devtools-kit@1162
npm i https://pkg.pr.new/vite-plugin-vue-devtools@1162

commit: e1a4a9d

@webfansplz
webfansplz merged commit 5d032e6 into main Oct 16, 2026
8 checks passed
@webfansplz
webfansplz deleted the fix/plugin-adapter-per-app branch October 16, 2026 01:43
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.

2 participants