Mulang a pilas-app#355
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR integrates Mulang-based static analysis/expectations into the Blockly execution flow, surfacing feedback both as block warnings and in the end-of-challenge dialog, and wires Mulang into the build/runtime via a copied browser bundle.
Changes:
- Adds Mulang parsing/expectations + validation pipeline (
runBlocklyValidations) and connects it to run/step execution. - Updates the end dialog to display “scored expectations” results alongside the solved status.
- Adds build/runtime wiring for Mulang (dependency + postinstall copy to
public/assets+ script include) and new i18n resources.
Reviewed changes
Copilot reviewed 28 out of 32 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/mulang.d.ts | Declares global mulang / window.mulang types. |
| src/test/unit/components/interpreter.test.tsx | Updates mocks for i18n + blockly/core and new hook return fields. |
| src/components/challengeView/SceneButtons/useInterpreterRunner.ts | Adds validation hook-in + mulang results/solved state + clears highlights. |
| src/components/challengeView/SceneButtons/StepByStep.tsx | Runs Blockly validations before step execution; passes results to end dialog. |
| src/components/challengeView/SceneButtons/Execute.tsx | Runs Blockly validations before full execution; passes results to end dialog. |
| src/components/challengeView/SceneButtons/interpreterFactory.ts | Implements block highlighting + clearing. |
| src/components/challengeView/SceneButtons/EndChallengeDialog.tsx | Replaces old “congratulations” modal with scored-expectations UI. |
| src/components/blockly/utils.ts | Updates warning visibility API usage. |
| src/components/blockly/blockly.ts | Updates warning visibility API usage in variable revalidation. |
| src/components/blockly/blocklyValidations.ts | Adds missing-input validation + Mulang analysis + block feedback. |
| src/components/blockly/mulang/pilasMulangAnalyzer.ts | Adds Mulang analysis bridge (AST -> mulang -> expectation results). |
| src/components/blockly/mulang/pilasMulang.ts | Adds Blockly workspace -> Mulang AST parsing. |
| src/components/blockly/mulang/pilasAst.ts | Adds minimal AST node helpers/types. |
| src/components/blockly/mulang/mulangResults.ts | Adds Mulang result decoding/typing. |
| src/components/blockly/mulang/expectations.ts | Adds expectation DSL builders + encoding/decoding helpers. |
| src/components/blockly/mulang/expectationMessages.ts | Adds i18n message lookup for failed expectations. |
| src/components/blockly/mulang/challengeExpectations.ts | Maps challenge config -> expectation generation. |
| src/components/blockly/mulang/blockUtils.ts | Adds workspace utilities used by expectations. |
| src/components/blockly/mulang/blockFeedback.ts | Shows Mulang feedback as Blockly warnings on relevant blocks. |
| scripts/copyMulang.js | Copies/paches Mulang bundle into public/assets and exposes window.mulang. |
| scripts/remove-mulang-require.js | Adds a patch helper (currently not wired into scripts). |
| package.json / package-lock.json | Adds Mulang dependency and postinstall hook to copy it. |
| locales/*/mulang.json | Adds Mulang expectation/suggestion translations. |
| locales/*/challenge.json | Adds scored-expectations modal translations. |
| index.html | Loads Mulang bundle at runtime. |
| .gitignore | Ignores .vscode/settings.json. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+84
to
96
| highlightBlock(id: any) { | ||
| const blockId = id ? id.toString() : '' | ||
| const workspace = Blockly.getMainWorkspace() as Blockly.WorkspaceSvg | ||
|
|
||
| if (!blockId || !workspace) return | ||
|
|
||
| workspace.highlightBlock(blockId) | ||
| } | ||
|
|
||
| clearHighlight() { | ||
| const workspace = Blockly.getMainWorkspace() as Blockly.WorkspaceSvg | ||
| workspace?.highlightBlock(null) | ||
| } |
| @@ -91,23 +109,33 @@ export const useInterpreterRunner = ( | |||
| }, [challenge, mode, setRunning, getBlocklyXML]); | |||
|
|
||
| setMulangResults(validationResult?.mulangResults || []) | ||
|
|
||
| executeUntilEnd(); |
Comment on lines
250
to
252
| if (block.warning && typeof block.warning.setVisible === 'function') { | ||
| block.warning.setVisible(false); | ||
| block.warning.setBubbleVisible(false); | ||
| } |
Comment on lines
109
to
114
| const addWarningToBlock = (block: { setWarningText?: any; warning: any; }, itemChar: string, message: string, index: any, colour: string, secondaryColour: string, visible = true) => { | ||
| const text = `${itemChar} ${lineWrap(message)}` | ||
| block.setWarningText(text, index) | ||
| setWarningColour(block, colour, secondaryColour) | ||
| block.warning.setVisible(visible) | ||
| block.warning.setBubbleVisible(visible) | ||
| } |
Comment on lines
+19
to
+25
| console.log( | ||
| 'MULANG CODE CONTENT', | ||
| JSON.stringify(astCode.content, null, 2) | ||
| ) | ||
|
|
||
| console.log('MULANG AST CODE OK', astCode) | ||
|
|
Comment on lines
+31
to
+32
| console.log('MULANG RESULTS', results) | ||
| console.log('MULANG PARSED RESULTS', parsedResults) |
Comment on lines
82
to
86
| "js-interpreter": "^5.1.2", | ||
| "makensis": "^2.0.8", | ||
| "mini-css-extract-plugin": "^2.4.5", | ||
| "mulang": "^6.0.5", | ||
| "pilas-bloques-exercises": "^1.4.34", |
| <div id="root"></div> | ||
| <!-- | ||
| <body> | ||
| <script id="mulang.js" src="/assets/mulang.js"></script> |
Comment on lines
+53
to
+59
| <script> | ||
| console.log('MULANG SCRIPT LOADED?', { | ||
| windowMulang: window.mulang, | ||
| globalMulang: globalThis.mulang, | ||
| keys: Object.keys(window).filter(k => k.toLowerCase().includes('mulang')) | ||
| }) | ||
| </script> |
This was referenced Jun 26, 2026
MayAmatista
approved these changes
Jun 29, 2026
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.
Hago el draft con el trabajazo de @danielferro69 así lo podemos ver mejor!!
resolves #255
resolves #256