Skip to content

Genhub gen dolt wasm - #219

Open
bobvh wants to merge 12 commits into
mainfrom
genhub-gen-dolt-wasm
Open

Genhub gen dolt wasm#219
bobvh wants to merge 12 commits into
mainfrom
genhub-gen-dolt-wasm

Conversation

@bobvh

@bobvh bobvh commented Jul 22, 2026

Copy link
Copy Markdown
Member

End product is gen running in the browser, all commands including views, and dolt clone/push/pull working against a live server. Build target is wasm32-unknown-emscripten, which gives you a POSIX-ish environment (threads, a filesystem, subprocess-like semantics) rather than wasm32-unknown-unknown target from earlier experiments and potential future work with Pyodide.

Everything that had to change fell into these buckets:

  1. Dependency graph. A number of crates in gen's dependency tree assume things like real threads, real sockets, an async I/O reactor that don't exist in the browser's single-threaded WASM sandbox. Anything transitively depending on this had no emscripten backend at all and had to be conditionally excluded from the browser build, with slimmed-down or alternate implementations swapped in only where the browser build actually needed the functionality (e.g., a different source of randomness, a different SQLite journaling mode that doesn't rely on memory-mapped lock files).

  2. The C backend from Dolt is compiled as part of the build. Patches were needed to get it to compile at all under emscripten's C library (subtle POSIX header differences caused build failures), and separately, once it compiled, its networking code didn't work in a browser -> see bucket 3.

  3. Transport. Two independent pieces of gen talk over HTTP: gen's own Rust-level control-plane traffic (login, authorization, asset transfer) and the C backend's data-plane traffic (the actual database chunk protocol used by clone/push/pull). Both used networking mechanisms (an HTTP client library and raw sockets with TLS) that were replaced by the browser's native fetch mechanism instead.

  4. Ratatui. Keyboard/mouse input handling without OS-level event-polling (and other things provided by crossterm). I abstracted most of this away into tui-runtime.rs.

@bobvh
bobvh force-pushed the genhub-gen-dolt-wasm branch from acdf7a4 to 098f19f Compare July 22, 2026 17:56
Base automatically changed from genhub-gen-dolt to main July 28, 2026 14:19
@bobvh
bobvh force-pushed the genhub-gen-dolt-wasm branch from 2842d75 to 415b952 Compare July 29, 2026 02:31
bobvh added 9 commits August 4, 2026 19:02
Compile out opendal/tokio thread-spawning and other host-only
dependencies for wasm32-unknown-emscripten, and fix the indicatif
steady-tick thread spawn and LocalFsLocation::checksum return type
mismatch that surfaced under that target.
Point rusqdoltlite at bobvh/rusqdoltlite, which carries the
Emscripten Fetch transport and an fcntl fix needed for the wasm
target, ending on the 0.40.14 version-bumped rev.
Add a browser HTTP transport built on Emscripten Fetch alongside the
existing native transport, an emscripten-http-test command to
exercise it directly, and wire remote::client/operations onto the
new transport. Move normalized_origin into utils so it is available
without depending on the native-only client module.
Add the browser login flow (popup + Cockle host bridge callback,
falling back to a clickable link if the popup is blocked) alongside
the existing native localhost-callback flow, and drop the emscripten
stubs that returned "not supported in this build" for clone/push/pull
now that the browser HTTP transport carries real dolt data transfer.
Add a crossterm event-type shim and select()-based input handling
where the native terminal/TTY APIs are unavailable, and route
inline/full-screen gen view, view-diff, and operations --interactive
through the emscripten backend. Unregister stale service workers on
protocol version mismatch so a rebuilt wasm-cli page doesn't get
served stale assets.
Persist uploaded files to IndexedDB via a DriveFS-backed coincident
worker bridge so they survive across terminal sessions, instead of
living only in the in-memory MEMFS the emscripten build starts with.
Add the wasm32-unknown-emscripten build (make wasm/wasm-test), pull
in cockle's coreutils/grep/less/sed/cockle_fs wasm packages through
micromamba on the emsdk toolchain, and wire the resulting bundle into
a static wasm-cli/ page.
Bundle JetBrains Mono and a WebGL renderer, add Catppuccin light/dark
theming with a toggle, a PIN entry prompt, and polish the intro copy
and prompt colorization.
Spell out the shim re-export list instead of a wildcard, move the
native-only reqwest import to module scope behind its target cfg
instead of importing it inside the function body, bring serde_json's
free functions into scope instead of calling them qualified, prefer
core:: over std:: for error::Error and str::FromStr, and fix expect()
messages to start with "should".
@bobvh
bobvh force-pushed the genhub-gen-dolt-wasm branch from 415b952 to faf677f Compare August 4, 2026 19:43
bobvh and others added 3 commits August 6, 2026 12:15
cockle joins wasmBaseUrl with asset filenames via plain string
concatenation, not URL resolution, so passing the raw page href broke
whenever the terminal was reached via an explicit filename (e.g.
".../demo/index.html") rather than a directory URL.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KbS8hvkPMejvt8LaJVDshu
…ands

The intro copy explaining what the terminal is lives with whoever embeds
it (e.g. GenHub's /terminal page), not this page, so it had no business
hardcoding a single "gen --help" link. Generalizes the postMessage bridge
to run any list of commands (gen-wasm-cli:run-commands) and adds a
gen-wasm-cli:ready message so an embedder can also run commands
automatically once the terminal loads, not just on click.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KbS8hvkPMejvt8LaJVDshu
The terminal is now embedded as a React component in GenHub, which has
its own light/dark setting -- a second, independent toggle inside the
iframe was redundant and could disagree with it. selectThemeMode now
reads an initial ?theme=light|dark query param (falling back to
prefers-color-scheme when opened standalone, e.g. make wasm-test), and
a new gen-wasm-cli:set-theme postMessage lets the embedding page switch
it live. applyThemeBackground now just toggles a data-theme attribute
that style/demo.css's CSS variables already key off of, rather than
hardcoding a handful of element ids -- which also fixes the upload bar
not picking up theme changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KbS8hvkPMejvt8LaJVDshu
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.

1 participant