Editor: show block errors instead of silently suppressing the save button - #2353
Open
krobipd wants to merge 5 commits into
Open
Editor: show block errors instead of silently suppressing the save button#2353krobipd wants to merge 5 commits into
krobipd wants to merge 5 commits into
Conversation
The timer and schedule blocks answer getVarModels() with hand-built
variable models in the Blockly 11 shape ({ getId, name, type }).
Blockly 13 reads variable models through methods - Xml.variablesToDom
calls getName()/getType() while the workspace is serialized for saving -
so every save of a script containing such a block threw
'getName is not a function'. The editor's change handler died on that,
and with it the save button (ioBroker#2349).
The models now carry the methods; the bare properties stay for adapter
block files written against the Blockly 11 shape.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
With 'statements' unchecked in the function's mutator dialog the mutation removes the STACK input, and statementToCode() throws for a missing input - the same trap the RETURN input is already guarded against one line below. The throw suppressed the save button for every script containing such a function (ioBroker#1958). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The snapshots only exercise workspaceToCode, but the editor saves with workspaceToCode PLUS Xml.workspaceToDom - the workspace XML travels as a base64 comment behind the generated code. A block whose serialization throws suppresses the save button without any snapshot moving, which is exactly how the timer blocks' variable models broke under Blockly 13. Every corpus entry is now saved the way the editor does it and the saved XML reloaded to the same code. A new fixture covers the function with a return value and no statements, whose generator branch the toolbox (statements on by default) could never reach. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… button The editor only offers Save after it has regenerated the script (workspaceToCode plus Xml.workspaceToDom). A block that throws in that chain used to kill the change handler silently: no save button, no message, only the browser console said why. That is how ioBroker#2349 and ioBroker#1958 stayed invisible to their reporters - and how the next broken block will hide again. The change handler now catches the error and shows it in the editor's error dialog, once per distinct error rather than on every further change while the script stays broken. A failing export (same serialization, triggered from the menu) shows its error too instead of doing nothing. Translations added in all 11 languages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What users see
Every wave of "Blockly scripts cannot be saved anymore" reports (#487 in 2020, #1891 in the 9.0.x line, #2349 now) shares the same experience: the save button simply never appears, and nothing anywhere tells the user why. The reason is always some block throwing while the editor regenerates the script — but the only trace is a stack trace in the browser console, which most reporters never open ("Is it really so hard to press F12???" — that question from #1891 answers itself: for most users, yes).
Why it happens
The editor offers Save only after a change has been regenerated:
workspaceToCodeplusXml.workspaceToDom(the workspace XML travels as a base64 comment behind the code). A block that throws inside that chain kills the change handler, and with it the save button — silently. #2352 fixes the two blocks that currently throw, but the next Blockly upgrade or block bug will hide exactly the same way again.The change
Saving stays blocked while a block is broken — that is correct, because the generated code would be broken too. The difference is that the user now sees which error stands between them and saving, and the next #2349 becomes a precise bug report instead of a wave of "cannot save" issues.
Verified
npm run lint,npm run test:package,npm run test:blockly,npm run build,npm test(declarations + integration, 280 passing) locally on Node 22DialogErrormechanism (same as import errors)🤖 Generated with Claude Code