Skip to content

feat(devtools): unify Data Inspector Vite instance and refresh builtin queries - #1047

Merged
antfu merged 2 commits into
nuxt:mainfrom
antfubot:tall-animals-remain
Jul 28, 2026
Merged

feat(devtools): unify Data Inspector Vite instance and refresh builtin queries#1047
antfu merged 2 commits into
nuxt:mainfrom
antfubot:tall-animals-remain

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Summary

Nuxt 5 merged the separate client and SSR Vite dev servers into a single instance. This aligns the Data Inspector's live Nuxt Application source with that reality and refreshes its suggested queries.

  • The live source now captures and surfaces one unified Vite config as vite, instead of a vite: { client, ssr } split. The former per-environment configs remain reachable under vite.environments.
  • Refreshed the source's builtin suggested queries to the surfaces authors actually care about:
    • Overview
    • Nuxt modulesnuxt.modules
    • Vite pluginsvite.plugins
    • Vite configvite
    • Vite environmentsvite.environments
    • Nitro routesnitro.handlers
  • The deprecated getServerData() shim keeps its legacy vite: { server, client } contract independently, by projecting the single captured config onto both fields (each normalized separately).

Unit tests updated to cover the unified capture flow, the new query set, and the shim's projection behavior.

This PR was created with the help of an agent.

…n queries

Nuxt 5 merged the separate client and SSR Vite dev servers into a single
instance, so the Data Inspector's live source now captures and surfaces one
Vite config (the former per-environment configs live under `vite.environments`)
instead of a `vite: { client, ssr }` split.

Refresh the source's suggested queries to target the surfaces authors care
about: Nuxt modules, Vite plugins, Vite config, Vite environments, and Nitro
routes.

The deprecated `getServerData()` shim keeps its legacy `vite: { server, client }`
contract independently by projecting the one captured config onto both fields.
@coderabbitai

coderabbitai Bot commented Jul 28, 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 Plus

Run ID: d7ff7a11-ed20-4273-974b-5caad120487f

📥 Commits

Reviewing files that changed from the base of the PR and between 367f8f2 and 9bc781b.

📒 Files selected for processing (2)
  • packages/devtools/src/integrations/data-inspector.ts
  • packages/devtools/test/data-inspector.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/devtools/src/integrations/data-inspector.ts

📝 Walkthrough

Walkthrough

Nuxt DevTools now captures the unified Vite development server through vite:serverCreated and exposes it as data.vite in the Data Inspector source. Suggested queries and lifecycle cleanup were updated accordingly. The deprecated getServerData shim reads captured.vite.config and projects the unified configuration into normalized vite.server and vite.client fields. Tests cover unified capture, source population, query entries, and legacy RPC projection.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: unifying the Data Inspector Vite instance and updating builtin queries.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the unified Vite capture, queries, and shim behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/devtools/src/integrations/data-inspector.ts (1)

137-154: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Make the legacy projections deeply independent.

normalizeViteConfig() only shallow-copies config, so nested branches such as build, resolve, and server are shared by vite.server and vite.client. This contradicts the stated mutation-isolation guarantee; the current test checks only root identity. Deeply clone/sanitize retained nested branches and add a nested-mutation assertion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/devtools/src/integrations/data-inspector.ts` around lines 137 - 154,
Update getServerData and normalizeViteConfig so the vite.server and vite.client
projections do not share nested objects, especially within build, resolve, and
server; deeply clone or sanitize retained configuration branches while
preserving the existing normalization behavior. Extend the relevant test to
mutate a nested branch in one projection and assert the corresponding branch in
the other remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/devtools/src/integrations/data-inspector.ts`:
- Around line 137-154: Update getServerData and normalizeViteConfig so the
vite.server and vite.client projections do not share nested objects, especially
within build, resolve, and server; deeply clone or sanitize retained
configuration branches while preserving the existing normalization behavior.
Extend the relevant test to mutate a nested branch in one projection and assert
the corresponding branch in the other remains unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bba5d8e9-fd0c-486c-a77f-2d07eba79534

📥 Commits

Reviewing files that changed from the base of the PR and between 8badc89 and 367f8f2.

📒 Files selected for processing (2)
  • packages/devtools/src/integrations/data-inspector.ts
  • packages/devtools/test/data-inspector.test.ts

…s config

The Data Inspector's `vite` object is now the live Vite dev server instance
(captured from `vite:serverCreated`), which carries the runtime environments,
module graph, and websocket in addition to the resolved config at
`vite.config`. Suggested queries and the deprecated `getServerData()` shim read
the config through `vite.config` accordingly.
@antfu
antfu merged commit 5a6c4e8 into nuxt:main Jul 28, 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