Skip to content

First pass at a web interface - includes wasm BUILD refactor#163

Open
tameware wants to merge 40 commits into
dds-bridge:developfrom
tameware:web
Open

First pass at a web interface - includes wasm BUILD refactor#163
tameware wants to merge 40 commits into
dds-bridge:developfrom
tameware:web

Conversation

@tameware
Copy link
Copy Markdown
Contributor

@tameware tameware commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

First pass at a browser-based DDS demo: a static HTML/JS UI that calls CalcDDtablePBN via an Emscripten-built WASM module embedded as base64 so the page works over both file:// and HTTP. Also restructures the existing WASM build plumbing — moves wasm_cc_binary example targets into a new //examples/wasm package, replaces the --config=wasm flow with wasm_cc_binary's platform transition, factors shared Emscripten link flags into wasm_compat.bzl, and removes the now-unused wasm_sources filegroups.

Changes:

  • New web/ package: dds_mvp.html/.css/.js UI, dds_mvp_wasm.cpp C entry point, BUILD.bazel, and Python/shell helpers (update_wasm.sh, gen_wasm_bin_js.py, patch_mvp_wasm.py, verify_wasm_js.py).
  • WASM build refactor: //:build_wasm switched to constraint_values, --config=wasm removed from .bazelrc, examples WASM rules moved to //examples/wasm, CI updated, docs rewritten.
  • system.cpp gets an Emscripten branch returning a conservative 512MB-of-KB / 1-core hardware report; examples/calc_dd_table_pbn.cpp adds __WASM__ to its threading guard.

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
web/dds_mvp.html New demo page; input grid, result table, script tags.
web/dds_mvp.css Styles for the input grid.
web/dds_mvp.js UI logic; loads WASM module and calls dds_mvp_calc_table.
web/dds_mvp_wasm.cpp Emscripten entry point wrapping CalcDDtablePBN.
web/BUILD.bazel Builds dds_mvp_wasm via wasm_cc_binary.
web/update_wasm.sh Local script: build, copy artifacts, base64-embed, patch, verify.
web/gen_wasm_bin_js.py Generates base64 wasm-bytes JS file.
web/patch_mvp_wasm.py Patches isFileURI line in Emscripten output.
web/verify_wasm_js.py Sanity-checks wasm compiles under Node.
.bazelrc Removes build:wasm profile.
BUILD.bazel build_wasm config_setting now uses platform constraints.
wasm_compat.bzl Shared WASM_LINKOPTS.
wasm/BUILD.bazel Empty package marker.
examples/BUILD.bazel Drops old wasm filegroups; aliases all_examples_wasm.
examples/wasm/BUILD.bazel New home for wasm_cc_binary example targets.
examples/calc_dd_table_pbn.cpp Adds __WASM__ to threading guard.
library/src/**/BUILD.bazel Removes obsolete wasm_sources filegroups.
library/src/system/system.cpp Emscripten-specific hardware-info fallback.
library/tests/**/BUILD.bazel Whitespace-only changes.
docs/wasm_build.md Docs rewritten for the new flow.
.github/workflows/ci_wasm.yml Drops --config=wasm; new target/output paths.

Comment thread web/dds_mvp.html Outdated
Comment thread web/dds_mvp.js
Comment thread web/dds_mvp_wasm.cpp Outdated
Comment thread web/dds_mvp_wasm.cpp Outdated
Comment thread web/dds_mvp.js
Comment thread library/src/system/system.cpp Outdated
Comment thread web/patch_mvp_wasm.py Outdated
Comment thread web/gen_wasm_bin_js.py
tameware added 5 commits June 2, 2026 10:21
debug_build_windows now requires:
cpu = x64_windows
compilation_mode = dbg
That prevents Windows-native flags from applying to wasm transition builds (cpu=wasm), including //web:dds_mvp_wasm_cc.
.bazelrc had:
build:windows --cxxopt=/std:c++20
build:windows --host_cxxopt=/std:c++20
Those options are too broad and can bleed into wasm builds on Windows hosts, which is exactly why emcc saw /std:c++20.

Removed those two lines and left Windows C++ standard selection to CPPVARIABLES.bzl (//:build_windows selects), which keeps native Windows builds on C++20 without contaminating wasm transitions.
…o old for designated initializers), causing error C7555.

Fixed by:

loading DDS_CPPOPTS from CPPVARIABLES.bzl and
applying copts = DDS_CPPOPTS to both tests in that file:
solve_board_test and
analyse_play_consistency_test
library/src/init.cpp uses stringstream (and i/o manipulators like setw, left, right) in GetDDSInfo, but didn’t include the required standard headers directly.

Added

#include <sstream>
#include <iomanip>
to library/src/init.cpp.

That should resolve the CI wasm compile error:

implicit instantiation of undefined template 'std::basic_stringstream<char>'
…dows CI path.

Changed library/src/solve_board.cpp to use std::thread + explicit join() instead of std::jthread in solve_all_boards_n().

Before: std::vector<std::jthread>
After: std::vector<std::thread> and a join loop
@tameware
Copy link
Copy Markdown
Contributor Author

tameware commented Jun 2, 2026 via email

@tameware tameware marked this pull request as draft June 2, 2026 09:24
tameware added 4 commits June 2, 2026 11:42
loadDdsModule() now clears ddsModulePromise inside .catch(...) before rethrowing, so later calls can retry.
Removed the no-op .then((module) => ...) block entirely.
Now a transient createDdsModule(...) failure won’t permanently poison future attempts.
@tameware
Copy link
Copy Markdown
Contributor Author

tameware commented Jun 2, 2026

Everything builds successfully now, but I'm stlll working on implementing Copilot's suggestions. I tried to turn the PR into a draft, but I was not successful. I'll post another comment when it's ready for human review.

@tameware
Copy link
Copy Markdown
Contributor Author

tameware commented Jun 2, 2026

Aha! I see I was successful, I just didn't know it. It's a draft - perfect.

@tameware tameware marked this pull request as ready for review June 2, 2026 14:03
@tameware
Copy link
Copy Markdown
Contributor Author

tameware commented Jun 2, 2026

Someone with Copilot Pro or better, please request a re-review. µSoft won't let me purchase a subscription - they say "New plan sign-ups are temporarily paused as we ensure a high-quality experience."

@zzcgumn
Copy link
Copy Markdown
Collaborator

zzcgumn commented Jun 2, 2026

"New plan sign-ups are temporarily paused as we ensure a high-quality experience."

They gave me a free subscription as an open source contributor a couple of months back. I have found it is very good at code reviews. I guess it has a lot of them to learn from.

@zzcgumn
Copy link
Copy Markdown
Collaborator

zzcgumn commented Jun 2, 2026

If it's OK with you, I'll make the fixes here and not cherry-pick them back.

Perfectly fine with me. Please close the WASM pull request when it is not needed anymore.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 47 out of 48 changed files in this pull request and generated 7 comments.

Comment thread web/verify_wasm_js.py Outdated
Comment thread web/dds_mvp.js
Comment thread library/src/system/system.cpp Outdated
Comment thread web/dds_mvp_wasm.cpp
Comment thread MODULE.bazel
Comment thread web/dds_mvp.js Outdated
Comment thread web/dds_mvp.css Outdated
@tameware tameware changed the title First pass at a web interface First pass at a web interface - includes WASM refactor Jun 3, 2026
@tameware tameware changed the title First pass at a web interface - includes WASM refactor First pass at a web interface - includes wasm BUILD refactor Jun 3, 2026
tameware and others added 9 commits June 3, 2026 07:33
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Error — still uses err.message
null / undefined — shows "Unknown error"
Anything else — uses String(err) (numbers, strings, etc.) without throwing again
Normal failures from loadDdsModule() (rejected promises with Error) behave as before; odd throws from Emscripten or elsewhere get a visible message instead of masking the failure.
…eb/requirements_lock.txt with Python 3.14 (via bazel run @python_3_14//:python3). The header now says 3.14, matching pip.parse in MODULE.bazel. Package pins and hashes are unchanged — only the version comment differed between 3.13 and 3.14 for this dependency set.

Updated web/requirements.in with the exact bazel run commands so the lock is not regenerated accidentally with system Python 3.13.
…on __linux__ / __APPLE__, while the matching example examples/calc_dd_table_pbn.cpp and other WASM examples use __WASM__ as well. On WASM builds, __WASM__ is set via DDS_LOCAL_DEFINES in CPPVARIABLES.bzl, but the test target did not pass those defines and the preprocessor guard did not include WASM.

Changes:

Extended the guard to || defined(__WASM__), matching calc_dd_table_pbn.cpp.
Set local_defines = DDS_LOCAL_DEFINES on //examples/wasm:calc_dd_table_pbn_test so __WASM__ is actually defined when that target is built under the WASM configuration.
@tameware tameware marked this pull request as draft June 3, 2026 07:04
@tameware tameware marked this pull request as ready for review June 3, 2026 07:27
@tameware
Copy link
Copy Markdown
Contributor Author

tameware commented Jun 3, 2026

Copilot issues addressed. Please ask it to have another look.

I added an end-to-end test for the web UI, but it makes bazel test /... slow. Should I look for a way to exclude it from a default test run?

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.

3 participants