Skip to content

fix: skip undefined tune data when a tune is in its default state - #3020

Open
Hyhyhyyy wants to merge 1 commit into
codex-team:nextfrom
Hyhyhyyy:fix/skip-undefined-tune-data
Open

fix: skip undefined tune data when a tune is in its default state#3020
Hyhyhyyy wants to merge 1 commit into
codex-team:nextfrom
Hyhyhyyy:fix/skip-undefined-tune-data

Conversation

@Hyhyhyyy

Copy link
Copy Markdown

Summary

Closes #1683.

When a Block Tune's save() returns undefined (i.e. the tune is in its default state and has nothing to persist), the value was still written to tunesData[name]. This leaves an explicit undefined entry in the saved tunes object, which then gets carried through load/save cycles.

This guards the assignment so that only defined tune data is stored:

const tuneData = tune.save() as BlockTuneData | undefined;

if (tuneData !== undefined) {
  tunesData[name] = tuneData;
}

Changes

  • src/components/block/index.ts: skip storing a tune's data when save() returns undefined.

Notes

The BlockTune.save() type is BlockTuneData, but in practice a tune may intentionally return undefined to signal "no data / default state" (as described in the issue). The local as BlockTuneData | undefined cast keeps the type checker happy while allowing the runtime guard.

How to test

  1. Create a block tune whose save() returns undefined in its default state.
  2. Save the block and inspect the output JSON — the tune key should no longer appear with an undefined value.

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.

BlockTunes API should remove "undefined" tune data

1 participant