Skip to content

feat(devtools): select client Vite context deterministically, add Nuxt dock group#1031

Merged
antfu merged 2 commits into
nuxt:mainfrom
antfubot:feat/nuxt-devtools-dock-foundation
Jul 22, 2026
Merged

feat(devtools): select client Vite context deterministically, add Nuxt dock group#1031
antfu merged 2 commits into
nuxt:mainfrom
antfubot:feat/nuxt-devtools-dock-foundation

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Summary

Implements Plan 01 (plans/vite-devtools-integration/01-dock-foundation.md) from the Nuxt DevTools / Devframe 0.7 integration series.

  • Deterministic client-context selection. connectDevToolsKit() previously kept whichever Vite context connected first, assuming (without verifying) that the client Vite instance always wins the race. Replaces that guard with classifyViteDevToolsContext(), a small classifier that reads viteConfig.build.ssr and viteConfig.command (Kit 0.4.2 surfaces ctx.viteConfig/ctx.viteServer). The SSR candidate is ignored outright; an unclassifiable candidate is logged with an actionable diagnostic and also ignored — neither ever falls back to first-wins.
  • Nuxt dock group. Registers a public nuxt group (title: 'Nuxt', category: 'framework', defaultChildId: 'nuxt:devtools') and points the existing nuxt:devtools hub member at it via groupId. Both registrations are guarded by the same classifier, so Nuxt's SSR Vite instance — which runs the same plugin setup() callback — never registers a second, inert group/member.
  • Public extension point. Exports NUXT_DEVTOOLS_GROUP_ID from @nuxt/devtools-kit so other modules can join the Nuxt group natively via ctx.docks.register({ groupId: NUXT_DEVTOOLS_GROUP_ID, ... }).
  • Vite 8 peer range. Narrows @nuxt/devtools' peerDependencies.vite from >=6.0 to ~8.0.14, matching the root override and the Devframe plugins this integration is moving towards. @nuxt/devtools-kit's own peer range is left untouched per the plan.
  • Docs: documents NUXT_DEVTOOLS_GROUP_ID and the Vite 8 requirement in the utils-kit and migration-v4 guides.

Out of scope (per the plan): mounting Code Server/Data Inspector, promoting Nuxt pages, SideNav changes, dock: true on custom tabs, and the Vite Inspect instances[0] ambiguity (left unchanged, flagged as a residual risk needing an upstream discriminator).

Testing

  • New unit coverage: classifyViteDevToolsContext() truth table (client/SSR/unknown/missing config, environment-name red herring), and connectDevToolsKit() end-to-end against a real setupRPC() + fake Nuxt (via hookable + @nuxt/kit's runWithNuxtContext) covering both setup orders, repeated candidates, and the unknown-candidate diagnostic.
  • New e2e spec asserting exactly one nuxt group with the expected shape, the hub member's groupId, and that opening the hub still hydrates the SideNav. Updated a stale "Devframe 0.6" comment in the e2e fixtures.
  • pnpm lint, vue-tsc --noEmit, and vitest run all pass locally.

This PR was created with the help of an agent.

…t dock group

Replace the first-connection-wins guard in connectDevToolsKit() with a
Vite 8 classifier (classifyViteDevToolsContext) based on
viteConfig.build.ssr/command, so the SSR Vite instance can never win the
race regardless of setup order. Unknown candidates are logged and
ignored rather than falling back to first-wins.

Register a public `Nuxt` dock group (category "framework",
defaultChildId "nuxt:devtools") and point the existing nuxt:devtools
hub member at it, both guarded by the same classifier so only the
selected client context registers them. Export NUXT_DEVTOOLS_GROUP_ID
from @nuxt/devtools-kit as the native extension point for module
authors.

Narrow @nuxt/devtools' vite peer range to ~8.0.14 to match the Devframe
plugins this integration depends on.

---

This PR was created with the help of an agent.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f17aac20-161d-45d1-b5cd-c8c8a77c02ad

📥 Commits

Reviewing files that changed from the base of the PR and between 990152a and e4f3f91.

📒 Files selected for processing (8)
  • docs/content/2.module/1.utils-kit.md
  • docs/content/2.module/3.migration-v4.md
  • packages/devtools/package.json
  • packages/devtools/src/module-main.ts
  • packages/devtools/src/server-rpc/index.ts
  • packages/devtools/src/server-rpc/skip-in-ssr.ts
  • packages/devtools/test/connect-devtools-kit.test.ts
  • packages/devtools/test/skip-in-ssr.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/devtools/package.json
  • docs/content/2.module/3.migration-v4.md

📝 Walkthrough

Walkthrough

Nuxt DevTools now integrates with Vite DevTools through a nuxt dock group containing the Nuxt DevTools iframe. SSR Vite contexts are excluded from dock registration and RPC selection. The devtools package now requires Vite ^8.0.14, and the kit exports the shared group identifier. Documentation and tests cover the new registration API, context handling, dock structure, and rendered navigation.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: deterministic client Vite context selection and adding the Nuxt dock group.
Description check ✅ Passed The description is directly related to the changeset and accurately covers the main implementation and documentation updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread packages/devtools/package.json Outdated
},
"peerDependencies": {
"vite": ">=6.0"
"vite": "~8.0.14"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"vite": "~8.0.14"
"vite": "^8.0.14"

Replace the three-way classifyViteDevToolsContext() (client/ssr/unknown,
with a logged-and-ignored unknown branch) with a single boolean
skipInSSR(ctx), reading only viteConfig.build.ssr. Any non-SSR
candidate — including one with an ambiguous or missing config — is now
treated as the client rather than logged and ignored.

Also apply review feedback from nuxt#1031:
- peerDependencies.vite: ~8.0.14 -> ^8.0.14
- docs no longer import/reference NUXT_DEVTOOLS_GROUP_ID; examples use
  the literal groupId: 'nuxt' instead (the constant itself is still
  exported from @nuxt/devtools-kit for module authors who want it).
@antfubot

Copy link
Copy Markdown
Collaborator Author

Updated per review:

  • `peerDependencies.vite`: `~8.0.14` → `^8.0.14`.
  • Simplified `classifyViteDevToolsContext()` (client/ssr/unknown, with a logged unknown branch) down to a single `skipInSSR(ctx)` boolean that only reads `viteConfig.build.ssr`. Any non-SSR candidate is now treated as the client directly.
  • Docs no longer import/reference `NUXT_DEVTOOLS_GROUP_ID`; the examples use the literal `groupId: 'nuxt'`. The constant itself is still exported from `@nuxt/devtools-kit` for module authors who prefer it.

@antfu
antfu merged commit 6b9bff9 into nuxt:main Jul 22, 2026
5 of 6 checks passed
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