wokwi/wokwi-features

VSCode WokWi Diagram Editor documentation unclear, leading to custom chips labeled as "Missing" and with no connections shown

Opened this issue · 3 comments

Describe the bug

When running the WokWi Diagram Editor as the editor in an editor tab in VSCode, for diagram.json, if there is a custom chip in the project, e.g. custom.chip.json and custom.chip.c files, and the diagram.json is referring to this in parts as "type": "chip-custom", the WokWi Diagram Editor shows a confusing error message Missing chip chip-custom in the part image in the editor and drops the connections with the custom chip.

To Reproduce

  1. Install VSCode and WokWi Simulator extension to VSCode (if you don't have them already)
  2. Clone any suitable WokWi GIT repository, with a custom chip, to VSCode, e.g. https://github.com/wokwi/inverter-chip which is used by the documentation
  3. Open diagram.json for editing
  4. See the WokWi Diagram Editor to appear.

Expected behavior

The custom chip in the project (Inverter) should appear as the defined custom chip, with connections to the other chips.

Current behavior

The custom chip in the project (Inverter) appears as a Missing chip, with no connections to other chips.

Work around

There must be a dist folder, with chip.json and chip.wasm. At this point, VSCode does not produce them automatically but one must build the dist folder and its contents manually.

Environment

macOS 15.2 (24C101)
Safari 18.2 (20620.1.16.11.8)
VSCodium 1.96.2 Release: 24355,
WokWi Simulator extension 2.6.0 - 2024-12-10.

This bug appears to be there also with the WokWi Pro license activated.

Additional context

At https://wokwi.com/_next/static/chunks/4729-9dd899e2e960fade.js in function getChip(t), the chips are only looked at https://wokwi.com/api/external/chips. This does not make sense here, since the chip definition is on the local disk of the VScode host. For custom chips defined in the project, the WokWi extension should first upload the local file to somewhere in the wokwi.com domain so that the WokWi Editor, running in the iframe, could download and read it. The WokWi Editor cannot try to read the file directly from the local disk, as the iframe cannot escape its sandbox. Or, if the WokWi Simulator extension already does upload the file for including it in https://wokwi.com/api/external/chips, there appears to be a bug somewhere else.

As a workaround, one could add a possibility to define a custom URL path for custom chips, allowing the WokWi Editor in the iframe to load the code from a custom URL (if allowed by sandboxing, I don't remember...).

( I hate debugging closed source obfuscated JS code. Hence, there may be errors in my analysis. I didn't want to spend too much time in debugging this. )

I`m facing the same problem with no evolution in solutions.

Also facing this issue as of now. This is the only issue found as of now. Any updates?

Thanks for reporting!

Currently, custom chips have to be compiled to .wasm files, and then they can be declared in the wokwi.toml file, as explain in the project config documentation.

I know this is non ideal, and looking for ideas on how to improve this experience.