Registry Mirror
Skip to content

Conversation

@zspriggs

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes

Proposed Changes

Adds a check to the change listener in index.ts so that it waits to generate the code output until the blocks that should be disabled are actually disabled.

Reason for Changes

This bug predates my changes but I found it while testing. Value blocks don't have header code generators (and they shouldn't). This normally isn't a problem since these blocks are disabled if they're not attached to the factory block. But, value blocks are very briefly top level and enabled when swapping one out for another.

Repro:

  1. Open the console on developer tools
  2. Drag a new color block directly from the toolbox into the factory block.
  3. Generator errors ensue

Test Coverage

Documentation

Additional Information

@zspriggs
zspriggs requested a review from a team as a code owner November 25, 2026 17:36
@zspriggs
zspriggs requested review from mikeharv and removed request for a team November 25, 2026 17:36

@mikeharv mikeharv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It actually feels a little fragile to me that we rely on disabling orphans to correctly generate code for the single factory_base block. What if instead of looking at the whole workspace (all top blocks), we just generated code for the single expected top block?
We could add a private method to the Controller that takes a CodeGenerator and calls blockToCode with it, then replace each workspaceToCode call site in the file with this. Then there's no chance of attempting to generate for the wrong block.

Something like:

private generate(generator) {
  const baseBlock = ...
  generator.init(workspace);
  return generator.finish(generator.blockToCode(baseBlock);
}

@zspriggs

zspriggs commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@mikeharv I agree that generating code for just the factory block is better form, but I looked into it and I'd need to also refactor the generators themselves in order to make this work. The header generators return '' in blockToCode and add the actual headers via side effect, and workspaceToCode does some cleanup for the JavascriptDefinitionGenerator and GeneratorStubGenerator that I'd need to incorporate in (probably in an override of finish). I'm definitely willing to implement it this way if you still think I should, but it might be overkill for this bug

This branch has not been deployed

No deployments
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.

2 participants