feat: commands system, commands palette, shortcuts and when clauses#247
Merged
feat: commands system, commands palette, shortcuts and when clauses#247
Conversation
Extract keybinding logic (formatKeybinding, normalizeKeyEvent, evaluateWhen, collectAllKeybindings) into standalone keybindings.ts module with tests. Decompose CommandPalette.vue into CommandPaletteItem and KeybindingBadge sub-components. Split ViewBuiltinSettings.vue (800 lines) into SettingsAppearance, SettingsShortcuts, and SettingsDocks components. Convert KNOWN_BROWSER_SHORTCUTS from Set to Record with descriptions for better conflict messages. Remove default Escape keybinding from close-panel. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-rolldown
@vitejs/devtools-rpc
@vitejs/devtools-self-inspect
commit: |
Contributor
|
wow this is so cool! do you plan default shortcuts for some of the commands? |
Add `when?: string` to DevToolsCommandBase so commands can be conditionally visible in the palette and conditionally executable based on context. The `when` evaluator now supports: clientType, dockOpen, paletteOpen, dockSelectedId, plus custom plugin variables via index signature. Group dock navigation commands under a "devtools:docks" parent command instead of registering each as a top-level command. The parent re-registers reactively when dock entries change. Wire up real WhenContext values (dockOpen from panelStore, dockSelectedId from selectedId) instead of hardcoded defaults. Add `when: 'dockOpen'` to close-panel and `when: 'clientType == embedded'` to dock-mode commands. Comprehensive evaluateWhen tests (237 total). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ocks
Move evaluateWhen/WhenContext/getContextValue to packages/kit/src/utils/when.ts
as a dedicated module exported from @vitejs/devtools-kit. Core keybindings.ts
now re-exports from kit.
Replace isHidden?: boolean on DevToolsDockEntryBase with when?: string, using
the same expression syntax as command when clauses. The ~terminals dock now
uses `get when() { return sessions.size === 0 ? 'false' : undefined }`.
evaluateWhen now supports 'true' and 'false' as literal values, enabling
unconditional hide/show without a context variable.
DockEntries.vue evaluates dock when clauses client-side with a reactive
WhenContext. docksGroupByCategories accepts optional whenContext for filtering.
Comprehensive when.test.ts in kit (32 test files, 245 tests total).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add docs/kit/when-clauses.md as a dedicated page covering expression syntax, operators, built-in context variables, namespaced keys, and API reference. Added to VitePress sidebar and nav. Commands page now links to it instead of inlining the full reference. Support namespaced context keys with . or : separators in when expressions. getContextValue resolves via exact match first, then falls back to nested object path traversal. This allows plugins to use keys like vite.mode or rolldown:buildStep without collisions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolve conflicts in ViewBuiltinSettings.vue (keep decomposed sub-component approach) and .generated/css.ts (auto-merged). Incorporate HashBadge for action entries from main into SettingsDocks.vue. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move "Reset All Settings" out of Appearance tab into a new Advanced tab. Add granular reset buttons: Reset Shortcuts (clears shortcut overrides), Reset Docks (restores default visibility, order, pinning), and Reset All (resets everything including appearance, docks, and shortcuts). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allow showInPalette to accept 'without-children' alongside boolean. When set, the command appears in the palette but its children are not flattened into top-level search results — they remain accessible only via drill-down when the parent is selected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add WhenClauseContext interface with a reactive context getter to DocksContext. Accessible as ctx.when.context, returning the current WhenContext snapshot with all built-in and custom variables. DockEntries.vue now uses ctx.when.context instead of constructing its own WhenContext. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update commands.md and when-clauses.md to reflect that when clauses are only supported on commands and dock entries, not on keybindings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the when field from DevToolsCommandKeybinding type and the keybinding-level when check from the shortcut listener. When clauses are now only on commands and dock entries. Fix import paths to use @vitejs/devtools-kit/utils/when subpath export. Add utils/when to kit package.json exports map. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
I think I would avoid adding too many default shortcuts, as it would have more potential of shortcut collision with the user's app, and would introduce uncessary breaking changes when we change the defaults. |
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.
resolves #243