Skip to content

Windows/webkitgtk front-end support: build jsaddle-terminal on Windows, expose the WebView2 HWND - #167

Merged
hamishmack merged 3 commits into
masterfrom
hkm/windows-frontend
Jul 6, 2026
Merged

hamishmack merged 3 commits into
masterfrom
hkm/windows-frontend

Conversation

@hamishmack

Copy link
Copy Markdown
Member

Summary

Three small changes needed to embed jsaddle in native front ends (a
GTK4/WebKitGTK 6.0 app on Linux and a WebView2 app on Windows). No behaviour
changes on existing platforms.

jsaddle-terminal: build the library on Windows (pure modules only)

The whole package was buildable: False on Windows because the tunnel runner
(Language.Javascript.JSaddle.Terminal) needs raw-mode stdin/termios, which is
POSIX-only. But the framing (.Terminal.Protocol) and the iframe bootstrap JS
(.Terminal.Bootstrap) are pure and build everywhere.

IDE-side consumers only import those two modules, so the library now exposes
them unconditionally and gates just the runner module — plus its deps — behind
if !os(windows). This lets an embedder link jsaddle-terminal on Windows.

The runner's deps (aeson, jsaddle-warp, stm, text, unix, warp,
websockets) move under the same guard. This also drops jsaddle-warp from
the Windows build, which matters because jsaddle-warp caps aeson < 2.3 and
would otherwise constrain the whole plan.

jsaddle-webview2: expose the host window's HWND

Adds wv2GetHwnd (C) / webView2Hwnd :: WebView2 -> IO (Ptr ()) (Haskell) so
the embedding application can reach the Win32 HWND of the window hosting the
WebView2 and do native window integration — install a menu bar, run file
dialogs, etc. Only meaningful once the run' callback has been entered (the
HWND exists by then).

Testing

  • jsaddle-terminal library builds on the Windows cross (ucrt64) and unchanged
    on POSIX.
  • jsaddle-webview2 builds; webView2Hwnd returns the shim's HWND at runtime.
  • Both are consumed by leksah's new leksah-webkitgtk and leksah-webview2
    front ends (Linux native + Windows cross), which build via haskell.nix.

The tunnel runner (Language.Javascript.JSaddle.Terminal) needs raw-mode
stdin/termios, so it stays POSIX-only — but the framing (Protocol) and
iframe JS (Bootstrap) are pure.  Replace the blanket Windows buildable:
False with a conditional that drops just the Terminal module and the
unix dependency, so IDE-side consumers (leksah's Windows front end)
can link the library.
webView2Hwnd (C: wv2GetHwnd) returns the Win32 HWND of the window
hosting the WebView2, so embedding applications can do native window
integration (menu bar, dialogs) from the run' callback.
The warp fallback (jsaddle-warp, warp, websockets, stm, aeson, text) is
only used by the POSIX-only Terminal module; keeping jsaddle-warp in the
Windows dependency set made solving impossible for consumers whose plan
needs aeson >=2.3 (jsaddle-warp caps aeson <2.3).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds small integration-oriented features to support embedding jsaddle in native front ends: it makes jsaddle-terminal’s pure library modules build on Windows, and exposes the host window HWND from jsaddle-webview2 for Win32-native integration.

Changes:

  • jsaddle-terminal: expose only Terminal.Protocol + Terminal.Bootstrap on Windows while gating the POSIX-only runner module (and its deps) behind if !os(windows).
  • jsaddle-webview2: add a new webView2Hwnd Haskell API backed by a C shim function wv2GetHwnd returning the host window handle.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
jsaddle-webview2/src/Language/Javascript/JSaddle/WebView2.hs Exports webView2Hwnd :: WebView2 -> IO (Ptr ()) via FFI to surface the hosting window’s HWND.
jsaddle-webview2/cbits/WebView2Shim.c Implements wv2GetHwnd returning app->hwnd for the Haskell binding.
jsaddle-terminal/jsaddle-terminal.cabal Makes the library buildable on Windows by exposing only pure modules and conditionally including the POSIX runner + deps on non-Windows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hamishmack
hamishmack merged commit e6693c5 into master Jul 6, 2026
12 checks passed
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.

2 participants