feat: automatically set default values when editing a lookup type#140
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
carlosala
approved these changes
May 14, 2026
There was a problem hiding this comment.
Pull request overview
Improves the default-value behavior when building lookup types (e.g. extrinsics) by recursively pre-filling nested structures. This builds on issue #34 to reduce the number of clicks needed to construct values, and also lets users keep vectors empty by default instead of requiring add+remove of a placeholder item.
Changes:
- New
getDefaultValuerecursive helper insrc/utils/shape.tsthat produces sensible defaults for void/option/sequence/struct/array/tuple/enum (with depth cap of 5). - Replaces
isEnumVoidwithgetEnumDefaultValueso enum selection initializes nested values, not onlyvoidvariants. - Wires the helper into
CSequence.addItemandCOptiontoggle so newly-added items / toggled-on options start with computed defaults.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/utils/shape.ts | Adds getDefaultValue recursive helper and replaces isEnumVoid with getEnumDefaultValue. |
| src/codec-components/EditCodec/CEnum.tsx | Uses getEnumDefaultValue to initialize the value when an enum variant is chosen. |
| src/codec-components/EditCodec/CSequence.tsx | Uses getDefaultValue(shape.value) instead of NOTIN when adding a new sequence item. |
| src/codec-components/EditCodec/codec-components.tsx | COption now initializes the inner value via getDefaultValue when toggled on; removes unused NOTIN import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
To improve on #34, this sets a default value for each entry as you're building a type (e.g. extrinsic)
This also solves the issue where if you wanted to leave a vector as empty, you had to add and then remove one element.