FE-1560: Add a command registry with a host-provided palette contract - #9457
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR SummaryLow Risk Overview The editor registers undo/redo, canvas tools, auto-layout, search, and panel toggles via a null-rendering The demo wraps the editor in Reviewed by Cursor Bugbot for commit dd48015. Bugbot is set up for automated code reviews on this repo. Configure here. |
51f889b to
403cd26
Compare
4bdd204 to
2f3333c
Compare
Drop `find`, `unregister`, the shortcut-collision warning, and the silent run-refresh snapshots: `register` now replaces by id in place and notifies, and `useCommand` re-registers only when the id, label, category, keywords, or shortcut change, reading the latest `run` through a ref. Move the registry into `core.command-registry` and the React bindings into `react.commands`, export the bindings from `@hashintel/petrinaut/react` only, and add the arch-docs usage manual with a flow diagram. One changeset covers both packages.
2f3333c to
5b2f371
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5b2f371. Configure here.
…ings Move the auto-layout command into the editor's command set, through the mode-aware `usePetrinautCommands`, so nothing writes to the registry during render and the command respects edit mode and the active subnet; `createPetrinaut` loses its `commandRegistry` option. Read the properties panel width from the editor store only, give `useCommands` a server snapshot, return no keycaps for an empty shortcut, close the example palettes on Escape from any element inside them, and keep the sidebar command's label static so it holds its palette position.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9457 +/- ##
==========================================
+ Coverage 61.03% 61.05% +0.02%
==========================================
Files 1449 1449
Lines 144693 144718 +25
Branches 6692 6695 +3
==========================================
+ Hits 88307 88356 +49
+ Misses 55282 55254 -28
- Partials 1104 1108 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|

Summary
Before this PR, Petrinaut's user-invocable actions lived only in the keyboard handler and on toolbar buttons. Nothing enumerated them, so a host could not render a command palette over the editor, and the headless instance had no way to expose actions such as auto-layout to a host UI.
Adds a command registry the host owns. Components declare commands with a hook that registers and unregisters them, the headless instance registers its own imperatively, and the host renders the list and runs entries by id. Petrinaut ships no palette; a Storybook story and the demo website carry reference palettes.
9457.mp4
Links
Changes
Core
createCommandRegistryin@hashintel/petrinaut-core, thecore.command-registrylayercombineCommandRegistriesmerges several registries into one read viewReact bindings
CommandRegistryProvider,useCommand,useCommands,useCommandRegistry, andformatShortcutKeysfrom@hashintel/petrinaut/react, thereact.commandslayeruseCommandregisters while mounted and itswhenoption holdsEditor
EditorCommandsleafPropertiesPanelHost examples
Commands / Command palettewith a palette over host commands and over the full editorReview fixes
EditorCommandsthrough the mode-awareusePetrinautCommandsPropertiesPanelreads its width from the editor store onlyuseCommandspasses a server snapshot touseSyncExternalStoreformatShortcutKeysreturns no keycaps for an empty shortcutKnown issues
Next steps
instance.commandsinto the registryTest coverage
command-registry.test.ts:command-registry.test.tsx:format-shortcut.test.ts:How to test