feat(devtools): client-side onDevtoolsReady + expose Vite DevTools client; fix client RPC registration#1023
Conversation
…ndClientRpc
The legacy client RPC proxy registered its event functions (refresh, callHook,
onTerminalData, onTerminalExit, navigateTo) via a has()->update()/register()
dance that could throw DF0022 ("not registered"). Force-register instead so it
is an idempotent override, fixing the errors and making registration robust
across (re)connect and integration overrides.
`extendClientRpc` now overrides by default (via the forced upsert) and is
deprecated in favour of registering on the devframe client context
(`getDevToolsRpcClient()` / `getDevToolsClientContext()` from
`@vitejs/devtools-kit/client`).
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe change exposes a connected Estimated code review effort: 2 (Simple) | ~10 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
packages/devtools/client/composables/rpc.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in 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. Comment |
Mirror the server-side `nuxt.devtools.devtoolsKit` on the client: the injected `client.devtools` now carries `devtoolsKit`, the connected Vite DevTools RPC client, giving module authors full devframe-native access (register client RPC functions, call server functions, shared state, streaming, scoping) without importing from `@vitejs/devtools-kit/client` themselves. `extendClientRpc`'s deprecation now points at `client.devtools.devtoolsKit?.client.register(...)`. Created with the help of an agent.
Mirror the server's `onDevtoolsReady` on the client: exported from `@nuxt/devtools-kit/iframe-client`, it runs once the Vite DevTools client is connected and hands back the `DevToolsRpcClient` (`client.devtools.devtoolsKit`), the recommended entry point for client-side integration (register client RPC, call server functions, shared state, streaming, ...). `extendClientRpc`'s deprecation now points at this hook. Created with the help of an agent.
…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>
What & why
Follow-up to #1021, bringing the client-side RPC surface to parity with the server.
Client-side
onDevtoolsReady()Mirror of the server's
onDevtoolsReady, exported from@nuxt/devtools-kit/iframe-client. Runs once the Vite DevTools client connects and hands back theDevToolsRpcClient— the recommended entry point for client-side integration:Expose the Vite DevTools client (symmetry with the server)
client.devtools.devtoolsKitis now the connectedDevToolsRpcClient, mirroringnuxt.devtools.devtoolsKiton the server — full devframe-native access (register client RPC, call server functions, shared state, streaming, scoping) with no@vitejs/devtools-kit/clientimport needed.Deprecate
extendClientRpcDeprecated in favour of
onDevtoolsReady((kit) => kit.client.register(...))(or the exposeddevtoolsKit). Now also overrides by default via the forced upsert below.Fix the
DF0022client RPC errorsThe legacy client RPC proxy registered its event functions (
refresh,callHook,onTerminalData,onTerminalExit,navigateTo) via ahas() ? update() : register()dance that could throwDF0022: RPC function "…" is not registered.upsertClientFunctionnow force-registers (register(def, true)) — an idempotent override that never trips DF0021/DF0022 across (re)connect or overrides.Notes
pnpm lint,pnpm build,pnpm typecheck, and unit tests all pass.This PR was created with the help of an agent.