Skip to content

Refactor WASM REPL into host-driven stdio runtime with streaming interrupts#78

Draft
Copilot wants to merge 5 commits into
masterfrom
copilot/rework-web-version
Draft

Refactor WASM REPL into host-driven stdio runtime with streaming interrupts#78
Copilot wants to merge 5 commits into
masterfrom
copilot/rework-web-version

Conversation

Copilot AI commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This change pivots the web/WASM path from browser-specific JSFFI callbacks to a decoupled, host-mediated runtime model. The same impli.wasm now runs as a stdio-driven REPL (e.g. in Wasmtime) while the browser frontend acts as an input/output host, including streaming interrupt signaling and read x wait semantics.

  • Runtime contract shift (WASM as decoupled backend)

    • Removed browser-coupled JSFFI control flow from the WASM entry path.
    • Reworked the WASM executable to run as a stdio-driven REPL process model rather than a browser-bound reactor export surface.
  • Host input broker + control messages

    • Added a stdin router in Web.hs that:
      • forwards normal lines to the REPL input queue,
      • treats :interrupt / \ETX as out-of-band control messages,
      • preserves blocking read behavior for read x by waiting on queued input.
  • Asynchronous interrupt plumbing in interpreter semantics

    • Introduced global interrupt primitives in IMP.State (requestInterrupt, consumeInterrupt).
    • Integrated interrupt polling into While execution in both natural and structural semantics, allowing long-running loops to be interrupted by streamed host control messages.
  • Browser frontend as stdio host

    • Reworked web/src/impli.ts to mediate stdin/stdout/stderr through @runno/wasi instead of global impli.* JSFFI methods.
    • Added byte-queue based stdin feeding, Ctrl-C mapping to :interrupt, and continued terminal-driven line input handling.
  • Build/docs alignment

    • Updated cabal config for the new WASM runtime shape (including stm dependency).
    • Updated web architecture docs to describe stdio mediation and removed obsolete stub import usage.
this.terminal.attachCustomKeyEventHandler((event) => {
  if (event.type === "keydown" && event.ctrlKey && event.key.toLowerCase() === "c") {
    this.enqueueLine(":interrupt");
    this.write("^C\r\n");
    return false;
  }
  return true;
});

Copilot AI linked an issue Jun 6, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Rework web version to support inference trees and EBNF checker Add WASM-first web rework architecture proposal with message-passing runtime plan Jun 6, 2026
Copilot AI requested a review from bfeitknecht June 6, 2026 11:22
Copilot AI changed the title Add WASM-first web rework architecture proposal with message-passing runtime plan Refactor WASM REPL into host-driven stdio runtime with streaming interrupts Jun 6, 2026
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.

Rework web version

2 participants