feat(core): add passive mode for the injected overlay#465
Merged
Conversation
The embedded DevTools client now starts in passive mode by default: the floating docks stay hidden and the console prints a hint to reveal them with Shift+Alt+D. Activating persists a per-project flag in node_modules, so later dev sessions on the machine boot straight into normal mode. A "Hide DevTools" command returns to passive mode; `passive: false` opts out.
Replace the boolean `passive` DevTools option with a clearer `visibility: 'passive' | 'normal'` enum, defaulting to `'passive'`.
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vitest
commit: |
# Conflicts: # packages/core/src/client/webcomponents/state/context.ts
Move the passive-vs-normal decision to the node side: the injection plugin now picks which client entry to inject per HTML request from the project's resolved visibility (and the persisted flag), instead of one client that fetches its mode at runtime. - `@vitejs/devtools/client/inject` — normal, mounts the docks immediately - `@vitejs/devtools/client/inject-passive` — passive, hint + shortcut - shared runtime handles in-page activate / hide transitions (no reload)
`hidden` keeps the docks hidden and reveals them with the shortcut for the current session only — every load starts hidden and nothing is persisted, unlike `passive` which remembers the reveal. Adds a third client entry `@vitejs/devtools/client/inject-hidden`; node picks the entry per HTML request from the resolved visibility.
…oint - Default `visibility` is now `'normal'` (docks shown immediately); `passive` and `hidden` are opt-in. - `/__devtools/__mode.json` is now POST-only persistence: the injection plugin reads the node_modules flag directly to pick the client entry, so the GET branch, `isPassive`, and the `visibility` plumbing through the WS/middleware options are gone. - Regenerate the export snapshot in the tsnapi 1.2.0 format used by CI.
`DEVTOOLS_MODE_FILENAME` and `DEVTOOLS_HIDE_EVENT` are Vite-DevTools overlay concerns, not framework-neutral kit surface. Move them to a core-owned `packages/core/src/constants.ts` shared by the node middleware and the injected client, and drop them from `@vitejs/devtools-kit/constants`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduces visibility modes for the embedded (injected) DevTools overlay, modeled on Nuxt DevTools' opt-in reveal.
DevTools({ visibility })accepts'normal' | 'passive' | 'hidden'(default'normal').Modes
normal(default) — docks shown immediately.passive— docks hidden; the console prints a hint to reveal them withShift+Alt+D(⇧ ⌥ Don macOS). Revealing persists a per-project flag innode_modules/.vite-devtools/mode.json, so later dev sessions on this machine start with the docks shown.hidden— docks hidden; the shortcut reveals them for the current session only. Every load starts hidden and nothing is persisted.Architecture
transformIndexHtml, so no cache invalidation) and injects one of@vitejs/devtools/client/inject(normal),@vitejs/devtools/client/inject-passive, or@vitejs/devtools/client/inject-hidden.passiveupgrades to the normal entry once the project's flag is set (read directly fromnode_modules).inject/runtime.tsstartDevTools(mode); onlypassivepersists on activate. In-page transitions (activate via shortcut, "Hide DevTools (Passive Mode)" palette command) switch modes without a reload.POST /__devtools/__mode.json { enabled }writes/clears the flag (served unauthenticated — it only writes a local marker; the docks still require WS trust for project data).hiddennever POSTs.DTK0033(mode-persist failure) with docs, a node-side unit test, and updates the Getting Started + Client Context guides.Verification
pnpm typecheck,pnpm test(343 pass),pnpm build,pnpm lintall green.Linked Issues
Additional context
Reviewers may want to focus on the node-side entry selection in
packages/core/src/node/plugins/injection.tsand the unauthenticated persistence endpoint inpackages/core/src/node/server.ts.This PR was created with the help of an agent.