feat(kit,core): plugin-declared dock ordering, layout, and window defaults - #515
Draft
dvcolomban wants to merge 3 commits into
Draft
feat(kit,core): plugin-declared dock ordering, layout, and window defaults#515dvcolomban wants to merge 3 commits into
dvcolomban wants to merge 3 commits into
Conversation
…aults Unblocks a downstream Vite plugin that could not control dock-bar category order, float-mode capacity, or first-run window placement. - `DevToolsPluginOptions.dock` (`DevToolsDockConfig`): a plugin declares `categoryOrder`, `maxVisibleItems`, `defaultMode`, `defaultPosition` alongside its `setup()`. Collected across every plugin during the Vite plugin scan (last plugin wins per scalar key, `categoryOrder` shallow-merges), stashed on `ViteDevToolsNodeContext.dockConfig`, and handed to every client once via `ConnectionMeta.dockConfig` — riding the connection handshake every client already does, since the value is fixed for the life of the dev server. - New `docksCategoriesOrder` user setting: category headers in the Settings dock panel are now drag-and-droppable, reusing the same machinery entry rows already use. The outer bar's sort pre-merges the plugin's `categoryOrder` beneath the user's own drag order into the `categoryOrderOverride` slot `docksGroupByCategories` already had for a group's own ordering — no new parameters needed there. - `Dock.vue` folds a declared `maxVisibleItems` into the resolved float layout (an explicit `layout` prop still wins); `resolveDockLayout` clamps it to `>= 1`. - The injected overlay seeds its `vite-devtools-dock-state` localStorage defaults (`mode`/`position`) from a declared `defaultMode`/ `defaultPosition` — only for a developer with no stored preference yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vitest
commit: |
dvcolomban
marked this pull request as draft
August 4, 2026 21:22
Trims the explanatory comment blocks added with the dock-config feature down to one-liners, and simplifies the code they were explaining: - `resolveDockLayout` folds the `maxVisibleItems` clamp into its merge and tolerates an undefined override, so `Dock.vue` spreads the plugin config directly instead of a conditional-spread guard. - `SettingsDocks.vue` resolves the settings record and key through `orderRecord` / `orderKey`, dropping the duplicated category-order branches in `applyOrder` and `resetCustomOrderForContainer` along with their non-null assertions; the template loops over a `categoryHeaders` computed carrying a `dragId` instead of repeating `isCategoryHideable(category)` five times. - Restores the pre-existing `dock-settings.ts` doc wording. Adds a test for the `resolveDockLayout` merge/clamp path. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
dvcolomban
marked this pull request as ready for review
August 4, 2026 21:48
Member
|
Instead of putting it into the connectionMeta, maybe we could have it in sharedState? |
Contributor
Author
|
I did explored moving it to a share state (see this commit), and it is semantically cleaner as dock config aren't really connections metas. However it does mean threading a lot more plumbing 🤔 Not sure if it's a cleaner design, or if it is over-engineering. Maybe dock default state are not worth the increase in complexity ? |
dvcolomban
marked this pull request as draft
August 6, 2026 10:36
dvcolomban
force-pushed
the
feat/dock-config-and-category-order
branch
from
August 6, 2026 11:02
85cdfcd to
f128ced
Compare
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.
Summary
Vite plugins had no way to control dock-bar category order, float-mode capacity, or first-run window placement — category order was decided solely by the upstream
DEFAULT_CATEGORIES_ORDERtable, the float bar's inline-item cap was a fixed constant, and the injected overlay always started in float mode at a fixed position.DevToolsPluginOptions.dock(DevToolsDockConfig): a plugin declarescategoryOrder,maxVisibleItems,defaultMode,defaultPositionalongside itssetup(). Collected across every plugin during the Vite plugin scan (last plugin wins per scalar key,categoryOrdershallow-merges), stashed onViteDevToolsNodeContext.dockConfig, and handed to every client once viaConnectionMeta.dockConfig— riding the connection handshake every client already does, since the value is fixed for the life of the dev server. No new shared-state channel.docksCategoriesOrderuser setting: category headers in the Settings dock panel are now drag-and-droppable, reusing the same machinery entry rows already use (drag detection, self-healing reset-to-default). The outer bar's sort pre-merges the plugin'scategoryOrderbeneath the user's own drag order into thecategoryOrderOverrideslotdocksGroupByCategoriesalready had for a group's own ordering — no new parameters needed on that function.Dock.vuefolds a declaredmaxVisibleItemsinto the resolved float layout (an explicitlayoutprop still wins);resolveDockLayoutclamps it to>= 1. Edge mode is unaffected by design — it shows every entry with no capacity cutoff.vite-devtools-dock-statelocalStorage defaults (mode/position) from a declareddefaultMode/defaultPosition— only for a developer with no stored preference yet; it never overwrites one who already moved their dock.Verification
pnpm lint && pnpm typecheck && pnpm testall pass (full vitest suite, including an updatedtsnapisnapshot for the new public exports).categoryOrderand reversed in-categorydefaultOrder— confirmed correct rendering in an isolated browser profile (bar order matches declared weights exactly; in-category order matchesdefaultOrder;maxVisibleItems: 10caps float mode at exactly 10 inline items + overflow; edge mode shows everything uncapped;defaultMode: 'edge'/defaultPosition: 'left'seeds correctly on a fresh profile).Screenshots
Captured in the core playground with a plugin declaring
dock: { categoryOrder: { web: -60, advanced: -50, app: -40 }, maxVisibleItems: 4 }.maxVisibleItems: 4— 4 inline items, the rest behind the overflow button