Repository navigation
ariadne: run a .ari in the browser — FTXUI backend on wasm behind xterm.js - #710
Merged
Merged
Conversation
transfix
added a commit
that referenced
this pull request
Oct 19, 2026
…ny screen begin_window clamped the STORED window position to the screen every frame, so one frame drawn on a momentarily tiny screen (a terminal, or a browser page before its first resize) moved every window into the corner for good. Clamp only where the window is drawn (Win::sx/sy); the placement stays what the document, the persisted geometry or a drag set. Found by the wasm/xterm.js session (#710).
… xterm.js The terminal backend now builds for Emscripten, and `ari` gets a web target: ari.js + ari.wasm + ari.html. The page wires xterm.js to the module's stdin/stdout, which is all FTXUI's Emscripten screen talks to, and reports its size through ftxui_on_resize. It is single-threaded, so the gh-pages gallery can serve it without COOP/COEP. This is what roadmap §16.4 picked FTXUI for. - FtxuiBackend::run_loop: in the browser the loop runs on the page's main thread, so the wait between iterations is emscripten_sleep (Asyncify), not sleep_for, which would spin and freeze the page. Ctrl-Z is swallowed (no job control to suspend to); Ctrl-C still goes to on_signal: as SIGINT. - ari: with no argv (a page has none) it runs the document the build baked in, CVC_ARIADNE_WASM_DOC, with the component library at /components. That is the same convention as cvcGL's ariadne_hello. - CMake (EMSCRIPTEN only): embed CVC_ARI_WASM_DOC (default terminal_tour.ari) and the components, link -sASYNCIFY -sFETCH -sEXIT_RUNTIME, export ftxui_on_resize, and generate ari.html next to ari.js. The page uses a plain string replace, because configure_file(@only) would eat "@xterm/xterm@". - ari.html: xterm.js 5.5 + fit + webgl addons, pinned with SRI. The program starts only after the stylesheet and font load. Otherwise the first frames are drawn at a bogus size, and the backend's in-place window clamp piles every window at the origin. - CI: a new ari-wasm job builds the web target against catalog wasm deps. It requires that the configure found yaml-cpp and ftxui, renders the baked tour under node with `ari snapshot`, and uploads the page. - docs/ARIADNE.md: how to build and serve it, and what differs from a terminal. Verified locally (emsdk 5.0.7, deps from cvcpkg; ftxui/yaml-cpp wasm packed from cy-pca/cvcpkg recipes) in a browser on plain http.server: keyboard focus and slider steps, a typed Name with Enter running the on: program, a click on the checkbox, a slider drag, a window dragged by its title, the combo popup, File menu by click and F10, the menu toggling a window, and resize. Ctrl-C asks via on_signal:, and a second Ctrl-C quits with status 0. Under node the snapshot matches the native one.
The frame wait (emscripten_sleep vs sleep_for) and whether Ctrl-Z suspends now live in two helpers above run_loop, so run_loop itself changes by one line each. Less to collide with the run_loop work stacked on #708.
…site The wasm demo gallery (deploy-pages.yml -> https://transfix.github.io/libcvc/) now builds and serves the ari page next to the cvcGL demos. - build-wasm-demo.sh builds the `ari` target when the deps prefix has FTXUI for wasm. Without it the target is the stub that only says FTXUI is missing, so it is skipped with a message. The --pthread gallery skips it too, because the page is single-threaded. - build-pages.py: a target that builds its own host page next to its binaries (bin/<demo>.html) keeps it as <demo>/index.html; the rest still get the canvas template. ari's page is an xterm.js terminal, not a canvas. - deploy-pages.yml installs ftxui for wasm/wasm32 as a required dep (like pegtl), adds ari to DEMOS so the post-deploy live check covers it, and the fallback assembly copies a <demo>.html. - demos.json: an ari card with a thumbnail rendered from `ari snapshot --ansi`. - ari.html: shows an "all examples" link when served as a gallery entry (.../ari/). It fetches ari.wasm and ari.js with cache: 'no-cache' (wasm via Module.wasmBinary, glue inline), so a redeploy can't pair a cached ari.js with a new ari.wasm. This is the same concern the canvas template's ASSET_V handles. Checked locally: build-pages over the wasm bin/ gives the card and ari/index.html. From the gallery path, keys work, Ctrl-C asks then quits, and the link shows. The standalone ari.html still runs, without the link.
transfix
force-pushed
the
feat/ariadne-ftxui-wasm
branch
from
October 19, 2026 03:46
a14985a to
e9ca161
Compare
transfix
added a commit
that referenced
this pull request
Oct 19, 2026
…ny screen begin_window clamped the STORED window position to the screen every frame, so one frame drawn on a momentarily tiny screen (a terminal, or a browser page before its first resize) moved every window into the corner for good. Clamp only where the window is drawn (Win::sx/sy); the placement stays what the document, the persisted geometry or a drag set. Found by the wasm/xterm.js session (#710).
transfix
added a commit
that referenced
this pull request
Oct 19, 2026
…ny screen begin_window clamped the STORED window position to the screen every frame, so one frame drawn on a momentarily tiny screen (a terminal, or a browser page before its first resize) moved every window into the corner for good. Clamp only where the window is drawn (Win::sx/sy); the placement stays what the document, the persisted geometry or a drag set. Found by the wasm/xterm.js session (#710).
transfix
added a commit
that referenced
this pull request
Oct 19, 2026
…ny screen begin_window clamped the STORED window position to the screen every frame, so one frame drawn on a momentarily tiny screen (a terminal, or a browser page before its first resize) moved every window into the corner for good. Clamp only where the window is drawn (Win::sx/sy); the placement stays what the document, the persisted geometry or a drag set. Found by the wasm/xterm.js session (#710).
transfix
added a commit
that referenced
this pull request
Oct 19, 2026
…kg package (#709) * cmake: also rewrite assimp's stale windows z.lib to ZLIB::ZLIB The defensive rewrite of assimp's exported zlib link matched libz.* and zlib.*, but an assimp republished on the windows builder exports $<LINK_ONLY:.../cvcpkg-prefix-assimp-*/lib/z.lib> (zlib's CMake names its windows import library z.lib). Neither pattern matched, so the builder-absolute path survived into cvc.dll's link: `ninja: error: ...lib/z.lib, needed by bin/cvc.dll, missing` in the windows recipe lane and `nvlink fatal: Could not open input file ...lib/z.lib` in package-windows (red on master since the republish). Match a path ending in /z.lib or \z.lib too, through to the end of its list entry so a $<LINK_ONLY:...> wrapper does not leave a stray '>'. * cmake: the same z.lib rewrite for libcvc's consumers (cvcConfig.cmake) With the build-side rewrite fixed, the windows recipe lane got as far as its consumer smoke test and failed there: `LNK1181: cannot open input file ...cvcpkg-prefix-assimp-*\lib\z.lib` in smoke.vcxproj. cvcConfig.cmake re-finds assimp for every consumer and carries its own copy of the stale-zlib rewrite, with the old libz/zlib-only pattern. Give it the same pattern as src/cvc/CMakeLists.txt. * ariadne(tui): draggable grid seams, OS signals to on_signal, `ari` cvcpkg package Follow-ups to the interactive FTXUI backend (#708): - Grid seams drag. A row split is now one framed stack with a separator between panes; dragging a separator resizes the two panes around it and the pane sizes persist to tree.<id>.tracks (seeded apply-once from the persisted / authored sizes). A `resizable` table gets a draggable seam between columns (a blank one-cell seam when it shows no inner borders). - OS signals reach on_signal. RunOptions gains host hooks: on_start (after FTXUI installs its own handlers), on_stop, and a take_signal poll; each pending signal goes to the document's on_signal (source "os") and ends the loop when the document has no handler. run() now returns why it ended (RunExit). The handlers stay in the host: `ari` wires SIGTERM, SIGHUP, SIGINT, SIGQUIT and SIGUSR1/2 through sigaction and exits with 128 + signo on an unhandled one. - `ari` is its own package. It moves to a dual-mode src/ari (in-tree or standalone against an installed libcvc, like src/cvc-cli), gains CVC_BUILD_ARI (OFF in the libcvc / libcvc-cuda recipes), a linux cvcpkg/recipes/ari recipe, and a pack + publish step in publish-cvcpkg.yml modelled on cvcgl-examples. * ariadne(tui): keep a window's placement when a frame is drawn on a tiny screen begin_window clamped the STORED window position to the screen every frame, so one frame drawn on a momentarily tiny screen (a terminal, or a browser page before its first resize) moved every window into the corner for good. Clamp only where the window is drawn (Win::sx/sy); the placement stays what the document, the persisted geometry or a drag set. Found by the wasm/xterm.js session (#710). * ariadne(tui): clang-format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on master. #708 merged as 4fa5620, and this branch was rebased onto master with #708's original commit dropped.
The FTXUI terminal backend now builds for Emscripten, and
arihas a web target:bin/ari.js+ari.wasm+ari.html. The page puts an xterm.js terminal on the module's stdin/stdout. That is all FTXUI's Emscripten screen uses, plusftxui_on_resizefor the size. The build is single-threaded, so it serves over plain http with no COOP/COEP, the same as the gh-pages gallery. This is the reason roadmap §16.4 picked FTXUI.Changes
FtxuiBackend::run_loop. In the browser the loop runs on the page's main thread. Its wait isemscripten_sleep(Asyncify), which hands control back so xterm.js can deliver input and paint;sleep_forwould spin and freeze the page. Ctrl-Z is swallowed, since a page has no job control. Ctrl-C still goes toon_signal:as SIGINT.ari. With no argv (a page has none) it runs the baked documentCVC_ARIADNE_WASM_DOC, with the component library at/components. This is theariadne_helloconvention.CVC_ARI_WASM_DOC(defaultterminal_tour.ari) and the components.-sASYNCIFY -sFETCH -sEXIT_RUNTIMEand exportsftxui_on_resize.ari.htmlnext toari.jswith a plain string replace, becauseconfigure_file(@ONLY)eats the@xterm/xterm@in the CDN URLs.CVC_ARIADNE_FTXUIturns on as before, wheneverftxuiis in the wasm deps prefix.src/cvc/tools/web/ari.html. Loads xterm.js 5.5 with the fit and WebGL addons, pinned with SRI. The program starts only after the stylesheet and font have loaded (see the clamp issue below). When the document quits, the page shows the exit status and a "run again" button.ari-wasm. Path-gated likephysics-wasm. It installs thewasm/wasm32deps from the catalog and requires that the configure found yaml-cpp and ftxui (not stubs). It then runsnode ari.js snapshot /terminal_tour.ariand checks that the tour rendered, and uploads the page as theari-webartifact.docs/ARIADNE.md. How to build and serve it, and what differs from a terminal.Prerequisite for CI (in progress)
ari-wasmneedsftxuiandyaml-cpppublished forwasm/wasm32, and neither is yet:cy-pca/cvcpkg#378 merged (e857aaa0), and populate-server run 39195263737 is publishing both for wasm and wasm-mt. Until it finishes,
ari-wasmfails at the install step; it will be re-run after the publish.Verified locally
Setup: emsdk 5.0.7 and boost/zstd/zlib/bzip2/xz/pegtl from the catalog; ftxui and yaml-cpp packed for
wasmfrom cy-pca/cvcpkg recipes. Served frompython3 -m http.server(no isolation headers) and driven in a browser:joe+ Enter runs the field'son:program (log: hello, joe), and the tooltip showswire: 1), slider drag (agents → 512,visible_whenrow appears), a window dragged by its title, the combo popup (pickedprivate), File menu by click, the menu toggling the Status window off and onon_signal:(log: Ctrl-C again to quit), the second calls(quit), and the page shows[ari exited with status 0]Under node,
ari snapshotof the wasm build matches the native snapshot. clang-format 18 reports nothing on the changed lines. Both edited .cpp files compile natively with and withoutCVC_ARIADNE_WASM_DOC.What can't work, or works differently, in the browser
emscripten_sleep(1000/fps), so a hidden tab's timer throttling slows redraws andon_tick. That is expected for a background page.on_signal:as above. A browser keeps Ctrl-W/T/N and some F-keys for itself. OS signals don't exist in a page.Overlap with #709 (also stacked on #708)
#709 moves
aritosrc/ari/(main.cpp, its ownCMakeLists.txt) and removes theariblock fromsrc/cvc/CMakeLists.txt. Rebasing this PR onto #709 conflicts only in that block.ftxui_backend.cppand the renamedmain.cppmerge cleanly. The resolution:if(EMSCRIPTEN)block moves intosrc/ari/CMakeLists.txt, with paths../cvc/ariadne/...src/ari/web/ari.htmlsrc/arigoes into theari-wasmpath filterThat rebase exists as the local branch
feat/ariadne-ftxui-wasm-on-709(not pushed). I built it for wasm and checked it in the browser: keys, and Ctrl-C asks and then quits through #709's signal hooks.Found in #708's backend (not changed here)
begin_windowclamps a window's storedx/yto the current terminal size on every frame, so one small frame moves windows permanently. I reproduced it:_ftxui_on_resize(3, 2)then back to full size leaves every window piled at (0,1). A native terminal that is shrunk and re-grown does the same. This PR only avoids the startup case in the page. The fix belongs in the backend: clamp the drawn position, not the stored one.GitHub Pages (added after review)
The ari page now ships with the wasm demo gallery at https://transfix.github.io/libcvc/ (
deploy-pages.yml, catx-03; runs on push to master, nightly, and on dispatch):build-wasm-demo.shbuildsariwhen FTXUI is in the deps prefix, non-pthread gallery only.build-pages.pykeeps a target's ownbin/<demo>.htmlas<demo>/index.html; everything else still gets the canvas template.deploy-pages.ymlinstallsftxui(wasm/wasm32) as a required dep and addsarito the post-deploy live check.demos.jsonhas anaricard; its thumbnail is rendered fromari snapshot --ansi.ari.htmlshows an "all examples" link when it is the gallery entry. It fetchesari.wasm/ari.jswithcache: 'no-cache', so a redeploy can't pair a cached script with a new binary.I checked it locally:
build-pages.pyover the wasmbin/, served. The card and theari/page work, and the standaloneari.htmlstill works.Merge order: the ftxui wasm bundle must be published before this lands on master. Otherwise the deploy fails at the ftxui install, by design.
Follow-ups
ftxui+yaml-cppin the published wasm libcvc (publish-cvcgl-wasm.yml, wasm-mt), with a libcvc recipe revision bump. Today that bundle's.ariloader is a stub.