Skip to content

feat: automatically set default values when editing a lookup type#140

Merged
voliva merged 1 commit into
mainfrom
vo/extrinsics-default
May 14, 2026
Merged

feat: automatically set default values when editing a lookup type#140
voliva merged 1 commit into
mainfrom
vo/extrinsics-default

Conversation

@voliva
Copy link
Copy Markdown
Contributor

@voliva voliva commented May 14, 2026

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.

@voliva voliva requested review from carlosala and josepot May 14, 2026 10:43
@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
papi-console Ready Ready Preview, Comment May 14, 2026 10:44am

Request Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 getDefaultValue recursive helper in src/utils/shape.ts that produces sensible defaults for void/option/sequence/struct/array/tuple/enum (with depth cap of 5).
  • Replaces isEnumVoid with getEnumDefaultValue so enum selection initializes nested values, not only void variants.
  • Wires the helper into CSequence.addItem and COption toggle 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.

@voliva voliva merged commit c002186 into main May 14, 2026
3 checks passed
@voliva voliva deleted the vo/extrinsics-default branch May 14, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants