Skip to content

Conversation

@takaokouji
Copy link

Summary

This PR implements automatic creation of broadcast messages when they are received from the mesh network but do not exist in the local project.

Changes

  • Modified broadcastEvent in MeshV2Service to check for message existence on the stage.
  • If missing, the message is created using stage.createVariable with Variable.BROADCAST_MESSAGE_TYPE.
  • this.runtime.requestBlocksUpdate() is called to ensure the new message appears in block dropdowns immediately.
  • The broadcast opcode is triggered using the correct message ID.
  • Added a new unit test: test/unit/mesh_service_v2_broadcast_creation.js.
  • Updated mock in test/unit/mesh_service_v2_integration.js to support the new logic.

Verification Results

  • Unit tests pass: npm run tap:unit (Specifically verified the new test file and integration test).
  • Lint passes: npm run lint.

Fixes #84

takaokouji and others added 3 commits January 5, 2026 01:43
…en received from mesh

- Automatically create broadcast message on the stage when received via meshV2 if it
  doesn't exist locally.
- Ensures the message is selectable in block dropdowns by calling
  this.runtime.requestBlocksUpdate().
- Uses the newly created or existing broadcast message ID when triggering the
  broadcast opcode.
- Added unit test to verify automatic creation and opcode argument handling.
- Updated integration test mock to support new message creation logic.

Fixes #84

Co-Authored-By: Gemini <[email protected]>
- Added isPersistent property to Variable class.
- Modified emitWorkspaceUpdate in virtual-machine.js to skip deletion of
  broadcast messages marked as persistent.
- Set isPersistent = true for messages automatically created from meshV2.
- Updated unit test to verify persistence.

This ensures messages received from mesh remain selectable in block
dropdowns even if they aren't currently used by any block.

Fixes #84
Co-Authored-By: Gemini <[email protected]>
…casts

- Switched from lookupBroadcastMsg to lookupBroadcastByInputValue for
  initial message lookup to ensure case-insensitivity.
- Use the canonical name from the found/created variable when
  triggering event_broadcast.
- Updated mock objects in unit tests.

This prevents duplicate broadcast messages and ensures that event
handlers are correctly triggered even when message names have
different casing.

Fixes duplicate message issue and event triggering failure.
Co-Authored-By: Gemini <[email protected]>
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.

meshV2: Create broadcast message locally if it doesn't exist when received from mesh

2 participants