Files
improvise/web/index.html
T
Edward Langley 94d26d8705 fix(web): default the socket to TLS, and cache-bust the deployed bundles
?ws= now takes a host:port and the page supplies the scheme: wss:// when it
is itself served over https, ws:// when over http. An explicit ws:// from an
https page is UPGRADED rather than passed through, because an https origin
refuses it as mixed content -- so passing it through can only produce a
failure that reads like 'the server is not running'. The scheme is not the
caller's to get wrong.

And the deploy now stamps ?v=<sha> onto both bundles. Pages serves everything
max-age=600 and the wasm-pack filenames carry no content hash, so for ten
minutes after a deploy a returning visitor runs the PREVIOUS build -- which
made a shipped fix look like it had not shipped, twice, during the first real
browser debugging session.

BOTH halves are stamped, because a fresh glue file does not pull a fresh
.wasm: the glue locates it with new URL('..._bg.wasm', import.meta.url), and
a URL built against a base does not inherit the base's query. Stamping only
the import specifier would refresh the wrapper and keep the stale binary --
exactly the failure this is here to end.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EoW5BB87ZZdm96SvBTWawH
2026-09-19 21:17:08 -07:00

80 lines
3.3 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>improvise</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<!--
The browser shell (improvise-cr3, improvise-djm).
Deliberately four elements and no framework. Everything that could be
*wrong* — what a cell is, whether it may be typed into, where the
selection sits, how the category tree flattens — is decided in Rust and
arrives already decided (see `render.rs`). This page paints it.
Build both wasm bundles first:
./web/build.sh
then serve this directory over http (a module script will not load from
file://):
python3 -m http.server 8080 --directory web
That is the whole standalone deployment: the document lives in an
in-page Web Worker and persists to this browser's private storage.
?doc= and ?seed= name the document and the file it is first seeded from.
To talk to a separate `improvise-ws-server` process instead — which is
how a document open in the TUI is shared — pass ?ws=host:port; the
scheme defaults to wss:// on https and ws:// on http.
-->
<header>
<h1>improvise</h1>
<span id="view-name"></span>
<span id="mode"></span>
<span id="status" role="status"></span>
</header>
<!--
This page is the *client* half and nothing else: it holds no model. What
it now has is a peer it can always reach — a Web Worker in this same tab
hosting the whole App over OPFS (improvise-9x6, improvise-djm) — so a
copy served from a static host, GitHub Pages included, is a working
application rather than a client with nowhere to connect.
The notice below stays static HTML rather than something app.js decides,
for the same reason as before: it is true on every load in either mode,
and a page that cannot reach its peer cannot be trusted to explain why.
What the peer is actually *doing* — starting, connected, unreachable,
gone — is live, and app.js writes it to #status.
-->
<p id="backend-notice">
Everything here runs in this tab: the document lives in a Web Worker
and is saved to this browser's private storage, so edits survive a
reload and never leave the machine. Load a different document with
<code>?doc=name.improv</code>, seeded from
<code>?seed=url</code>. To open a document hosted by a separate
process instead, run
<code>improvise-ws-server model.improv --port 8787</code> and reload
with <code>?ws=host:port</code>. <strong>The scheme defaults to
<code>wss://</code></strong>, because this page is served over https and
an https origin refuses a <code>ws://</code> address as mixed content.
Note that <code>improvise-ws-server</code> speaks plain
<code>ws://</code> only, so reaching it from here means terminating TLS
in front of it. Served over <code>http://localhost</code> the same page
defaults to <code>ws://</code> and pairs with it directly.
</p>
<main>
<aside id="categories" aria-label="Categories"></aside>
<div id="grid" tabindex="0" aria-label="Grid"></div>
</main>
<script type="module" src="./app.js"></script>
</body>
</html>