Skip to content

feat(devtools): devtools:ready hook + nostics-driven deprecation foundation - #1021

Merged
antfu merged 13 commits into
nuxt:mainfrom
antfubot:blue-mails-fix
Jul 14, 2026
Merged

feat(devtools): devtools:ready hook + nostics-driven deprecation foundation#1021
antfu merged 13 commits into
nuxt:mainfrom
antfubot:blue-mails-fix

Conversation

@antfubot

@antfubot antfubot commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

What & why

Implements Plan 00 — compatibility & deprecation foundation (plans/vite-devtools-integration/00-compat-foundation.md) for the new major on top of Vite DevTools 0.4 / devframe 0.6.

We're moving module authors onto the devframe-native API while keeping the existing Nuxt DevTools API working. The migration must be minimal and self-discoverable, so this PR establishes the entry point and the deprecation mechanism, then applies them.

Highlights

devtools:ready hook — the recommended integration entry point

  • New devtools:ready Nuxt hook + onDevtoolsReady((ctx) => …) helper, fired once the Vite DevTools kit connects, handing you the connected ViteDevToolsNodeContext.
  • Inside it, use the full devframe surface directly: ctx.docks / ctx.terminals / ctx.messages / ctx.commands / ctx.rpc / ctx.diagnostics — no connect-timing juggling.
  • nuxt.devtools.devtoolsKit remains as the raw escape hatch (typed as the connected context, undefined until connect).

Self-discoverable deprecations (nostics)

  • A coded deprecation catalog (NDT_DEP_xxxx) + deprecate() helper built on nostics. A single emission per call, deduped, routed to the DevTools diagnostics host once connected (so it also shows in the DevTools UI) and to the terminal otherwise. Each code carries a why, a fix, and a migration-guide link.
  • Deprecations added, all pointing at the ready hook:
    • NDT_DEP_0001startSubprocess().getProcess()getResult()
    • NDT_DEP_0003extendServerRpc()ctx.rpc.register(...)
    • NDT_DEP_0004startSubprocess()ctx.terminals.startChildProcess(...)
    • NDT_DEP_0005addCustomTab()ctx.docks.register(...)
    • NDT_DEP_0006refreshCustomTabs() → dock entry .update()
    • NDT_DEP_0007 — direct nuxt.devtools.rpc.broadcast / .functionsctx.rpc

Terminals migration (devframe 0.6.1)

  • Bumps devframe / @devframes/hub to 0.6.1, whose child-process session now exposes a tinyexec-style getResult() ({ stdout, stderr, exitCode }).
  • Nuxt DevTools' own subprocess usages (npm install/uninstall, analyze build, VS Code server) now run through ctx.terminals.startChildProcess(...) instead of the deprecated startSubprocess.

disableAuthorization stays first-class

  • Kept as a supported option that disables the Vite DevTools client-auth prompt (default on in sandboxes) — not deprecated.

Notes

  • Adds nostics as a dependency of @nuxt/devtools-kit.
  • Custom-tab deprecations (addCustomTab/refreshCustomTabs) note that the docks host doesn't yet cover vnode views / tab categories.
  • Docs: new onDevtoolsReady guidance in the utils-kit page and per-code sections in the v4 migration guide.
  • pnpm lint, pnpm build, pnpm typecheck, and unit tests all pass.

This PR was created with the help of an agent.

… deprecations

Lay the compatibility foundation for the next major on Vite DevTools /
devframe: keep the existing Nuxt DevTools API working while exposing the
devframe-native surface and making deprecations self-discoverable.

- Surface connect-safe `docks`/`terminals`/`messages`/`commands`/`diagnostics`
  accessors on `nuxt.devtools` that forward to the Vite DevTools kit once
  connected and buffer/replay mutating calls made before connect.
- Add a `nostics` deprecation catalog with a `deprecate()` helper that routes to
  the DevTools diagnostics host when connected (surfacing in the DevTools UI)
  and to the terminal otherwise, deduped per code.
- Pilot the mechanism on two APIs: `startSubprocess().getProcess()` (warn) and
  `disableAuthorization`, which becomes functional again by forwarding to Vite
  DevTools' `clientAuth: false` while soft-deprecating in favour of the
  Vite-native option.
- Document the forward path and the deprecation codes in the module docs.

Created with the help of an agent.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 50e9500d-6187-4d55-83ce-8afb97fa642d

📥 Commits

Reviewing files that changed from the base of the PR and between 89eb74a and c3dfac1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • docs/content/2.module/1.utils-kit.md
  • docs/content/2.module/3.migration-v4.md
  • packages/devtools-kit/src/_types/server-ctx.ts
  • packages/devtools-kit/src/diagnostics.ts
  • packages/devtools-kit/src/index.ts
  • packages/devtools/client/composables/rpc.ts
  • packages/devtools/src/integrations/vite-inspect.ts
  • packages/devtools/src/integrations/vscode.ts
  • packages/devtools/src/module-main.ts
  • packages/devtools/src/rpc-namespace.ts
  • packages/devtools/src/server-rpc/analyze-build.ts
  • packages/devtools/src/server-rpc/index.ts
  • packages/devtools/src/server-rpc/npm.ts
  • packages/devtools/src/server-rpc/storage.ts
  • packages/devtools/src/server-rpc/terminals.ts
  • pnpm-workspace.yaml

📝 Walkthrough

Walkthrough

Adds structured deprecation diagnostics with console and DevTools-host reporting, deduplication, migration links, and tests. Introduces the devtools:ready hook and onDevtoolsReady() API with connected Vite DevTools context types. Migrates RPC, subprocess, terminal, storage, VS Code, and build-analysis integrations to the connected host APIs. Adds RPC namespacing, updates authorization handling, and expands migration documentation.

Estimated code review effort: 4 (Complex) | ~60 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.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
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.
Title check ✅ Passed The title clearly summarizes the main changes: a new devtools:ready hook and nostics-based deprecation support.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the new hook, deprecations, and migration guidance.
✨ 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 timed out. The project may have too many dependencies for the sandbox.


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.

…ools RPC registration

Add a connect-safe `nuxt.devtools.rpc.register` that forwards to the Vite
DevTools RPC host (buffering registrations until connect), and soft-deprecate
`extendServerRpc` (NDT_DEP_0003) to point at it. The old API keeps working as a
shim; the compat `rpc.broadcast`/`rpc.functions` are unchanged.

Created with the help of an agent.

@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.

Actionable comments posted: 4

🤖 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.

Inline comments:
In `@packages/devtools-kit/src/index.ts`:
- Around line 126-134: Update the deprecate call inside getProcess to provide a
call-site-specific key for NDT_DEP_0001, using the available startSubprocess
instance identifier so each instance can warn independently while preserving the
existing API and replacement metadata.

In `@packages/devtools/src/module-main.ts`:
- Around line 53-60: Move the deprecation check block keyed by
disableAuthorization in enableModule to execute after setupRPC has initialized
nuxt.devtools. Keep the existing condition and deprecate arguments unchanged,
ensuring the call uses the initialized DevTools context.

In `@packages/devtools/src/server-rpc/connect-safe-hosts.ts`:
- Around line 304-308: Update flushPendingHostCalls to isolate failures from
each queued call: continue invoking all pending calls even when one throws,
while preserving queue cleanup after the flush. Ensure errors are handled
consistently with the existing async deferred-rejection behavior rather than
allowing one synchronous thunk to abort replay.

In `@packages/devtools/src/server-rpc/index.ts`:
- Around line 89-100: Wrap the RPC registration logic inside register’s apply
closure with try/catch, covering both devtoolsKitCtx!.rpc.update and
devtoolsKitCtx!.rpc.register. Handle the caught error using the same guarded
execution pattern already used for serverFunctions in connectDevToolsKit,
allowing flushPendingHostCalls() to continue processing remaining registrations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3db74b66-e01e-4f6a-ad31-2d6008477a87

📥 Commits

Reviewing files that changed from the base of the PR and between 7293498 and 0491588.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • docs/content/2.module/1.utils-kit.md
  • docs/content/2.module/3.migration-v4.md
  • packages/devtools-kit/package.json
  • packages/devtools-kit/src/_types/options.ts
  • packages/devtools-kit/src/_types/server-ctx.ts
  • packages/devtools-kit/src/diagnostics.ts
  • packages/devtools-kit/src/index.ts
  • packages/devtools-kit/test/diagnostics.test.ts
  • packages/devtools/src/module-main.ts
  • packages/devtools/src/server-rpc/connect-safe-hosts.ts
  • packages/devtools/src/server-rpc/index.ts
  • packages/devtools/test/connect-safe-hosts.test.ts
  • pnpm-workspace.yaml

Comment thread packages/devtools-kit/src/index.ts
Comment thread packages/devtools/src/module-main.ts Outdated
Comment on lines 53 to 60
// Soft-deprecate the Nuxt-specific option in favour of the Vite-native one —
// only when the user explicitly set it, not for the sandbox default.
if (nuxt.options.devtools && typeof nuxt.options.devtools !== 'boolean' && 'disableAuthorization' in nuxt.options.devtools) {
logger.warn('[nuxt-devtools] `disableAuthorization` option is deprecated. Auth is now handled by Vite DevTools.')
deprecate(nuxt, 'NDT_DEP_0002', {
api: 'disableAuthorization',
replacement: 'vite: { devtools: { clientAuth: false } }',
})
}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Move deprecate() call after setupRPC to ensure the DevTools context is initialized.

At this point in enableModule, setupRPC has not yet been called, meaning nuxt.devtools is currently undefined. When deprecate() internally resolves the server context via getServerContext(nuxt), it will receive undefined. If the underlying diagnostic state management expects a valid context, this can lead to an early runtime crash or an inconsistent state where the deprecation falls back entirely to the global scope.

Consider moving this deprecation check block below the setupRPC call (around line 170) so that the nuxt.devtools context is reliably populated before emitting any deprecations.

📦 Proposed move
-  // Soft-deprecate the Nuxt-specific option in favour of the Vite-native one —
-  // only when the user explicitly set it, not for the sandbox default.
-  if (nuxt.options.devtools && typeof nuxt.options.devtools !== 'boolean' && 'disableAuthorization' in nuxt.options.devtools) {
-    deprecate(nuxt, 'NDT_DEP_0002', {
-      api: 'disableAuthorization',
-      replacement: 'vite: { devtools: { clientAuth: false } }',
-    })
-  }
-
   if (options.iframeProps) {

Then append it after the setupRPC call:

   const {
     connectDevToolsKit: _connectDevToolsKit,
     ...ctx
   } = setupRPC(nuxt, options)
 
   connectDevToolsKit = _connectDevToolsKit
 
+  // Soft-deprecate the Nuxt-specific option in favour of the Vite-native one —
+  // only when the user explicitly set it, not for the sandbox default.
+  if (nuxt.options.devtools && typeof nuxt.options.devtools !== 'boolean' && 'disableAuthorization' in nuxt.options.devtools) {
+    deprecate(nuxt, 'NDT_DEP_0002', {
+      api: 'disableAuthorization',
+      replacement: 'vite: { devtools: { clientAuth: false } }',
+    })
+  }
+
   const clientDirExists = existsSync(clientDir)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Soft-deprecate the Nuxt-specific option in favour of the Vite-native one —
// only when the user explicitly set it, not for the sandbox default.
if (nuxt.options.devtools && typeof nuxt.options.devtools !== 'boolean' && 'disableAuthorization' in nuxt.options.devtools) {
logger.warn('[nuxt-devtools] `disableAuthorization` option is deprecated. Auth is now handled by Vite DevTools.')
deprecate(nuxt, 'NDT_DEP_0002', {
api: 'disableAuthorization',
replacement: 'vite: { devtools: { clientAuth: false } }',
})
}
🤖 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/module-main.ts` around lines 53 - 60, Move the
deprecation check block keyed by disableAuthorization in enableModule to execute
after setupRPC has initialized nuxt.devtools. Keep the existing condition and
deprecate arguments unchanged, ensuring the call uses the initialized DevTools
context.

Comment on lines +304 to +308
export function flushPendingHostCalls(queue: PendingHostCalls): void {
for (const call of queue)
call()
queue.length = 0
}

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

flushPendingHostCalls has no per-call error isolation.

If any buffered call throws (e.g. lazy.bind((getHost() as any)[prop](...args)) at Line 156, or the syncDefaults/unknown-method thunks at Lines 164 and 175), the for loop aborts and every remaining queued call across all five hosts is silently dropped — undermining the "buffered and replayed" guarantee this file exists to provide. The async branch already isolates errors via deferred.reject (Lines 145-147); the other branches don't.

🩹 Proposed fix
 export function flushPendingHostCalls(queue: PendingHostCalls): void {
-  for (const call of queue)
-    call()
+  for (const call of queue) {
+    try {
+      call()
+    }
+    catch (error) {
+      console.error('[Nuxt DevTools] Failed to replay a buffered host call:', error)
+    }
+  }
   queue.length = 0
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function flushPendingHostCalls(queue: PendingHostCalls): void {
for (const call of queue)
call()
queue.length = 0
}
export function flushPendingHostCalls(queue: PendingHostCalls): void {
for (const call of queue) {
try {
call()
}
catch (error) {
console.error('[Nuxt DevTools] Failed to replay a buffered host call:', error)
}
}
queue.length = 0
}
🤖 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/server-rpc/connect-safe-hosts.ts` around lines 304 -
308, Update flushPendingHostCalls to isolate failures from each queued call:
continue invoking all pending calls even when one throws, while preserving queue
cleanup after the flush. Ensure errors are handled consistently with the
existing async deferred-rejection behavior rather than allowing one synchronous
thunk to abort replay.

Comment thread packages/devtools/src/server-rpc/index.ts Outdated
antfubot added 2 commits July 14, 2026 09:25
…eshCustomTabs

Continue steering module authors onto the devframe-native surface:

- `startSubprocess` (NDT_DEP_0004) → `nuxt.devtools.terminals.startChildProcess`.
  Extract a non-warning internal core so Nuxt DevTools' own npm/analyze-build/
  vscode usage doesn't emit the warning; the real terminals-host migration of
  those call sites is deferred to a later plan (pending devframe gaining an
  awaitable result/exit-code API).
- `addCustomTab` (NDT_DEP_0005) and `refreshCustomTabs` (NDT_DEP_0006) →
  `nuxt.devtools.docks.register(...)`, noting the docks host doesn't yet cover
  vnode views / tab categories.

All shims keep working; docs and the migration guide document each code.

Created with the help of an agent.
Reverse the soft-deprecation of `disableAuthorization`: it stays a valid,
supported module option that disables the DevTools client-auth prompt (still
defaulting to on in sandboxes), with no user-facing nudge toward
`vite.devtools.clientAuth`. The NDT_DEP_0002 code is retired (left unused so the
remaining codes keep their numbers).

Created with the help of an agent.

@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.

♻️ Duplicate comments (1)
packages/devtools-kit/src/index.ts (1)

173-179: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Pass a call-site-specific dedupe key for NDT_DEP_0001.

deprecate() here omits key, so the dedupe key defaults to the code itself — only the first startSubprocess instance whose getProcess() is ever called across the process gets warned; other call sites are silently deduped forever. The sibling NDT_DEP_0003 deprecation (extendServerRpc, in packages/devtools/src/server-rpc/index.ts) passes key: namespace for exactly this reason.

🩹 Proposed fix
     getProcess: () => {
       deprecate(nuxt, 'NDT_DEP_0001', {
         api: 'startSubprocess().getProcess()',
         replacement: 'getResult()',
-      })
+      }, { key: id })
       return result.process
     },
🤖 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-kit/src/index.ts` around lines 173 - 179, Update the
deprecate call in getProcess to provide a call-site-specific key, using the
relevant startSubprocess instance or call-site identifier so each distinct
caller can emit its own NDT_DEP_0001 warning while preserving deduplication for
repeated calls from that caller.
🤖 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.

Duplicate comments:
In `@packages/devtools-kit/src/index.ts`:
- Around line 173-179: Update the deprecate call in getProcess to provide a
call-site-specific key, using the relevant startSubprocess instance or call-site
identifier so each distinct caller can emit its own NDT_DEP_0001 warning while
preserving deduplication for repeated calls from that caller.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f0bd7f6b-42b2-484c-a092-5a3974a367e0

📥 Commits

Reviewing files that changed from the base of the PR and between 0491588 and b65cb3c.

📒 Files selected for processing (10)
  • docs/content/2.module/1.utils-kit.md
  • docs/content/2.module/3.migration-v4.md
  • packages/devtools-kit/src/_types/options.ts
  • packages/devtools-kit/src/diagnostics.ts
  • packages/devtools-kit/src/index.ts
  • packages/devtools-kit/test/diagnostics.test.ts
  • packages/devtools/src/integrations/vscode.ts
  • packages/devtools/src/module-main.ts
  • packages/devtools/src/server-rpc/analyze-build.ts
  • packages/devtools/src/server-rpc/npm.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/devtools-kit/src/_types/options.ts
  • packages/devtools-kit/test/diagnostics.test.ts

antfubot added 3 commits July 14, 2026 09:50
`nuxt.devtools.rpc` is now the devframe RpcFunctionsHost, exposed connect-safe
(register/update/has/get/list/invokeLocal/broadcast/sharedState/streaming/…
forward to the kit once connected, buffering pre-connect mutations).

The legacy Nuxt compat is kept but deprecated (NDT_DEP_0007): `broadcast` is a
hybrid that is callable natively yet still supports the deprecated
`broadcast.<method>.asEvent(...)` proxy, and `functions` remains the deprecated
read/write proxy. Our own internal broadcast/functions usages (terminals,
storage, vscode, vite-inspect) are migrated to the native forms so they don't
self-warn.

Created with the help of an agent.
Fire a `devtools:ready` Nuxt hook once the Vite DevTools kit connects, passing
the connected ViteDevToolsNodeContext, and add an `onDevtoolsReady()` helper.
This is the recommended entry point for module DevTools integration: the kit is
guaranteed available there, so authors can use ctx.docks/terminals/messages/
commands/rpc/diagnostics directly without the connect-safe accessors.

Created with the help of an agent.
…eady hook

Now that `devtools:ready` / `onDevtoolsReady()` hand modules the connected kit
context, the connect-safe host accessors are redundant. Remove
`nuxt.devtools.docks/terminals/messages/commands/diagnostics` and the whole
connect-safe proxy machinery (generic host proxy, lazy handles, deferreds,
buffering). `nuxt.devtools.rpc` reverts to the lean legacy broadcast/functions
compat (broadcast still buffered via the existing queue); the devframe RPC host
is reached through `ctx.rpc` in the hook. Deprecation fixes now point at
`onDevtoolsReady((ctx) => …)`, and the internal vite-inspect registration moves
into the hook. NDT_DEP_0007 is retired.

Created with the help of an agent.

@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.

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
docs/content/2.module/3.migration-v4.md (1)

61-77: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clarify that getResult() replaces getProcess() as the preferred API, not that it was removed.

The implementation still exposes getProcess() as a deprecated shim. Also, deprecate() emits the structured NDT_DEP_0001 diagnostic, so “logs a deprecation warning” is narrower and inconsistent with the surrounding documentation.

Proposed wording
-The return value of `startSubprocess()` now provides `getResult()` instead of `getProcess()`.
+The return value of `startSubprocess()` now also provides `getResult()`; use it instead of the deprecated `getProcess()` method.

-Calling `getProcess()` emits the `NDT_DEP_0001` deprecation diagnostic.
+Calling `getProcess()` emits the `NDT_DEP_0001` deprecation diagnostic.

-- `getProcess()` still works but logs a deprecation warning and returns `ChildProcess | undefined` (was `ExecaChildProcess<string>`)
+- `getProcess()` still works but emits a deprecation diagnostic and returns `ChildProcess | undefined` (was `ExecaChildProcess<string>`)
🤖 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 `@docs/content/2.module/3.migration-v4.md` around lines 61 - 77, Update the
migration section for getProcess() to state that getResult() is the preferred
replacement while getProcess() remains available as a deprecated shim. Replace
the narrower “logs a deprecation warning” wording with language indicating that
calling getProcess() emits the structured NDT_DEP_0001 deprecation diagnostic,
and preserve the existing return-type details and example.
🤖 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.

Inline comments:
In `@docs/content/2.module/1.utils-kit.md`:
- Line 158: Update the availability claim mentioning ViteDevToolsNodeContext by
changing “guaranteed available” to “guaranteed to be available,” preserving the
rest of the sentence.

In `@packages/devtools/src/server-rpc/connect-safe-hosts.ts`:
- Around line 331-344: Update the createHostProxy configuration in the native
proxy setup to explicitly handle the nested sharedState and streaming RPC APIs
before connection, preserving their expected API shapes instead of routing
access through the buffered fallback thunk. Follow the existing maps, emitters,
async, handles, and reads configuration patterns and use the established host
API symbols for these two namespaces.

---

Outside diff comments:
In `@docs/content/2.module/3.migration-v4.md`:
- Around line 61-77: Update the migration section for getProcess() to state that
getResult() is the preferred replacement while getProcess() remains available as
a deprecated shim. Replace the narrower “logs a deprecation warning” wording
with language indicating that calling getProcess() emits the structured
NDT_DEP_0001 deprecation diagnostic, and preserve the existing return-type
details and example.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b4977fa2-676b-4de0-af41-fa5c15268355

📥 Commits

Reviewing files that changed from the base of the PR and between b65cb3c and 89eb74a.

📒 Files selected for processing (15)
  • docs/content/2.module/1.utils-kit.md
  • docs/content/2.module/3.migration-v4.md
  • packages/devtools-kit/src/_types/hooks.ts
  • packages/devtools-kit/src/_types/server-ctx.ts
  • packages/devtools-kit/src/diagnostics.ts
  • packages/devtools-kit/src/index.ts
  • packages/devtools-kit/test/diagnostics.test.ts
  • packages/devtools/src/integrations/vite-inspect.ts
  • packages/devtools/src/integrations/vscode.ts
  • packages/devtools/src/module-main.ts
  • packages/devtools/src/server-rpc/connect-safe-hosts.ts
  • packages/devtools/src/server-rpc/index.ts
  • packages/devtools/src/server-rpc/storage.ts
  • packages/devtools/src/server-rpc/terminals.ts
  • packages/devtools/test/connect-safe-hosts.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/devtools/src/server-rpc/index.ts
  • packages/devtools-kit/test/diagnostics.test.ts
  • packages/devtools-kit/src/diagnostics.ts
  • packages/devtools-kit/src/index.ts

Comment thread docs/content/2.module/1.utils-kit.md Outdated
Comment on lines +331 to +344
const native = createHostProxy<RpcFunctionsHost>(getHost, queue, {
maps: ['definitions'],
emitters: [],
async: ['invokeLocal', 'getHandler'],
handles: [],
reads: {
has: () => false,
list: () => [],
get: () => undefined,
getSchema: () => ({ args: undefined, returns: undefined }),
getCurrentRpcSession: () => undefined,
},
syncDefaults: {},
})

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect createHostProxy's fallback branch for unlisted properties
sed -n '91,183p' packages/devtools/src/server-rpc/connect-safe-hosts.ts

Repository: nuxt/devtools

Length of output: 3123


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- RpcFunctionsHost and native proxy config ---'
sed -n '1,220p' packages/devtools/src/server-rpc/connect-safe-hosts.ts
echo
echo '--- search for sharedState / streaming ---'
rg -n --no-heading '\bsharedState\b|\bstreaming\b' packages/devtools/src | sed -n '1,200p'
echo
echo '--- tests mentioning connect-safe-hosts ---'
rg -n --no-heading 'connect-safe-hosts|createConnectSafeRpc|sharedState|streaming' packages/devtools/src/server-rpc/*.test.* packages/devtools/src/server-rpc/**/*.test.* | sed -n '1,220p'

Repository: nuxt/devtools

Length of output: 7175


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- full native proxy config area ---'
sed -n '300,380p' packages/devtools/src/server-rpc/connect-safe-hosts.ts

echo
echo '--- repo-wide sharedState / streaming references ---'
rg -n --no-heading '\bsharedState\b|\bstreaming\b' . | sed -n '1,240p'

echo
echo '--- connect-safe-hosts tests ---'
git ls-files 'packages/devtools/src/server-rpc/*test*' 'packages/devtools/src/server-rpc/**/*test*' | sed -n '1,200p'

Repository: nuxt/devtools

Length of output: 3752


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- RpcFunctionsHost definition and related types ---'
rg -n --no-heading 'interface RpcFunctionsHost|type RpcFunctionsHost|sharedState|streaming' packages/devtools-kit/src packages/devtools/src | sed -n '1,260p'

echo
echo '--- likely relevant type file ---'
sed -n '1,220p' packages/devtools-kit/src/_types/server-ctx.ts

Repository: nuxt/devtools

Length of output: 5346


🌐 Web query:

"@vitejs/devtools-kit RpcFunctionsHost sharedState streaming source"

💡 Result:

In @vitejs/devtools-kit, the RpcFunctionsHost, sharedState, and streaming are distinct but complementary components of the Vite DevTools communication infrastructure [1][2][3]. RpcFunctionsHost The RpcFunctionsHost is an implementation of the RPC host (built on birpc-x) that manages the registration and broadcasting of functions between the Vite server and the devtools client [4][5]. It serves as the core coordinator for RPC calls [1]. Access to rpc.sharedState is permitted during plugin setup, allowing developers to initialize or subscribe to shared state early in the lifecycle [6]. Shared State The sharedState system is designed for snapshot-based synchronization between server and client [3]. Changes made on either side are broadcast to all connected parties [3]. - Usage: Accessed via ctx.rpc.sharedState.get [3]. - Mutation: Updates are performed via state.mutate, which receives a mutable draft (often leveraging Immer) and automatically syncs changes [3][7]. - Behavior: It is intended for authoritative state that must survive reloads and sync across panels [2]. For large datasets, it is recommended to store IDs in shared state and fetch full records via RPC on demand [3]. Streaming The streaming API is designed for chunk-based data, such as LLM tokens, logs, or build progress, where low-latency delivery is prioritized over persistent state [1][2]. - Implementation: It utilizes the same primitives as the shared state infrastructure but operates as a streaming channel [2][8]. - Integration: Streaming and shared state often compose for complex UIs [2]. For example, a chat application might use a streaming channel for real-time token rendering while maintaining the conversation log in shared state [2][8]. Once a stream completes, the final content is typically committed to shared state to ensure the data is persisted for subsequent reloads [2][8]. In summary, use sharedState for persistent, authoritative data that needs to be synchronized and survive reloads, and use the streaming channel for transient, low-latency chunked data [2][3]. Developers frequently use both in tandem to provide a responsive user experience that maintains state consistency [2][8].

Citations:


Add pre-connect handling for sharedState and streaming.
They’re exposed as nested RPC APIs (ctx.rpc.sharedState.get(...), streaming channels), but this proxy only special-cases methods/emitters/maps. Leaving them to the fallback path turns pre-connect access into a buffered thunk instead of preserving their API shape.

🤖 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/server-rpc/connect-safe-hosts.ts` around lines 331 -
344, Update the createHostProxy configuration in the native proxy setup to
explicitly handle the nested sharedState and streaming RPC APIs before
connection, preserving their expected API shapes instead of routing access
through the buffered fallback thunk. Follow the existing maps, emitters, async,
handles, and reads configuration patterns and use the established host API
symbols for these two namespaces.

antfubot added 3 commits July 14, 2026 10:24
Bump devframe / @devframes/hub to 0.6.1, whose child-process terminal session
now exposes a tinyexec-style `getResult()` ({ stdout, stderr, exitCode }).

Migrate Nuxt DevTools' own subprocess usages (npm install/uninstall, analyze
build, VS Code server) off the deprecated `startSubprocess` onto
`ctx.devtoolsKit.terminals.startChildProcess(...)`, awaiting `getResult()` where
exit code / stderr are needed. The `devtoolsKit` escape hatch is now typed as the
connected `ViteDevToolsNodeContext`. With no internal callers left, the
`startSubprocessInternal` split is folded back into the public (deprecated)
`startSubprocess` shim.

Created with the help of an agent.
…s access

Accessing `nuxt.devtools.rpc.broadcast` or `nuxt.devtools.rpc.functions` now
emits NDT_DEP_0007, steering module authors to the connected `ctx.rpc` from the
`devtools:ready` hook. Our own internal broadcasts (terminals/storage/vscode)
move to the devframe-native `ctx.devtoolsKit.rpc.broadcast(...)` so they don't
trip the warning.

Created with the help of an agent.
@antfubot antfubot changed the title feat(devtools): connect-safe devframe hosts + nostics-driven deprecations feat(devtools): devtools:ready hook + nostics-driven deprecation foundation Jul 14, 2026
- Pass a call-site key (`{ key: id }`) to the `getProcess()` NDT_DEP_0001
  deprecation so each subprocess instance warns independently.
- Docs: clarify `getProcess()` remains a deprecated shim (emits a diagnostic)
  and fix a grammar nit in the onDevtoolsReady section.

Created with the help of an agent.
@antfubot

Copy link
Copy Markdown
Collaborator Author

Addressed CodeRabbit review feedback in c86a7a4:

Applied

  • getProcess() NDT_DEP_0001 now passes a call-site dedupe key ({ key: id }) so each subprocess instance warns independently.
  • Docs: getProcess() migration wording clarified (deprecated shim emitting a diagnostic, getResult() is the preferred replacement), plus a grammar fix in the onDevtoolsReady section.

Skipped (no longer applicable — code removed in later commits of this PR)

  • module-main.ts "move deprecate() after setupRPC" — the disableAuthorization/NDT_DEP_0002 deprecation was dropped; the option is now first-class.
  • connect-safe-hosts.ts flushPendingHostCalls error isolation & sharedState/streaming pre-connect handling — the connect-safe host proxy layer was removed in favour of the devtools:ready hook.
  • server-rpc/index.ts register() try/catch — that method was removed when nuxt.devtools.rpc reverted to the legacy compat surface.

antfubot and others added 2 commits July 14, 2026 10:59
…ntion

Register Nuxt DevTools' own server RPC functions under the devframe-style
`nuxt:devtools:` namespace and have the client call them by that name. Bare,
un-namespaced aliases are still registered for backward compatibility and are
clearly marked (TODO) for removal in the next major.

Also fixes the `DF0021: getComponentsRelationships already registered` crash:
vite-inspect now overwrites the `setupGeneralRPC` placeholder with
`register(..., true)` (force) under the namespaced name.

Created with the help of an agent.
@antfu
antfu merged commit f9dda69 into nuxt:main Jul 14, 2026
5 of 7 checks passed
antfubot added a commit that referenced this pull request Jul 15, 2026
…n 00

Rebased feat/ecosystem-playgrounds onto main after #1021
(devframe-native hosts + nostics deprecation foundation) and
#1023 (client RPC registration fix) merged, and re-ran the full
dogfooding pass. No git conflicts during the rebase.

Findings added to REPORTS.md:
- The earlier DF0022 "RPC function not registered" console errors
  (refresh/callHook/onTerminalData/onTerminalExit/navigateTo) no longer
  reproduce — fixed by #1023.
- Plan 00's deprecation diagnostics are live and already flagging real
  ecosystem usage: NDT_DEP_0003 (extendServerRpc deprecated) fires from both
  @nuxt/fonts and nuxt-og-image's nuxtseo-shared dependency. NDT_DEP_0004
  (startSubprocess deprecated) fires from this repo's own local.ts dev
  helper, not from any ecosystem module.
- @nuxt/scripts's legacy addCustomTab still works but didn't trigger a
  matching deprecation diagnostic — flagged as a follow-up.

Everything else held: all three modules still load, all three tabs are
still reachable (still only via the SideNav overflow menu), builds still
succeed against both the stubbed and fully-built local @nuxt/devtools.

Co-authored-by: opencode <noreply@opencode.ai>
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