feat(devtools): select client Vite context deterministically, add Nuxt dock group#1031
Conversation
…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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughNuxt DevTools now integrates with Vite DevTools through a Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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
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. Comment |
| }, | ||
| "peerDependencies": { | ||
| "vite": ">=6.0" | ||
| "vite": "~8.0.14" |
There was a problem hiding this comment.
| "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).
|
Updated per review:
|
Summary
Implements Plan 01 (
plans/vite-devtools-integration/01-dock-foundation.md) from the Nuxt DevTools / Devframe 0.7 integration series.connectDevToolsKit()previously kept whichever Vite context connected first, assuming (without verifying) that the client Vite instance always wins the race. Replaces that guard withclassifyViteDevToolsContext(), a small classifier that readsviteConfig.build.ssrandviteConfig.command(Kit 0.4.2 surfacesctx.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.Nuxtdock group. Registers a publicnuxtgroup (title: 'Nuxt',category: 'framework',defaultChildId: 'nuxt:devtools') and points the existingnuxt:devtoolshub member at it viagroupId. Both registrations are guarded by the same classifier, so Nuxt's SSR Vite instance — which runs the same pluginsetup()callback — never registers a second, inert group/member.NUXT_DEVTOOLS_GROUP_IDfrom@nuxt/devtools-kitso other modules can join theNuxtgroup natively viactx.docks.register({ groupId: NUXT_DEVTOOLS_GROUP_ID, ... }).@nuxt/devtools'peerDependencies.vitefrom>=6.0to~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.NUXT_DEVTOOLS_GROUP_IDand 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: trueon custom tabs, and the Vite Inspectinstances[0]ambiguity (left unchanged, flagged as a residual risk needing an upstream discriminator).Testing
classifyViteDevToolsContext()truth table (client/SSR/unknown/missing config, environment-name red herring), andconnectDevToolsKit()end-to-end against a realsetupRPC()+ fakeNuxt(viahookable+@nuxt/kit'srunWithNuxtContext) covering both setup orders, repeated candidates, and the unknown-candidate diagnostic.nuxtgroup with the expected shape, the hub member'sgroupId, 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, andvitest runall pass locally.This PR was created with the help of an agent.