Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

release: build the browser bundle once and put it in every package

RoversX71d65282a70f
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b7cfb881..53edfe57 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -170,9 +170,63 @@ jobs:
# One job per architecture, each producing its own zip. We deliberately do not
# lipo them into a universal bundle: that doubles the download for an Intel
# audience that is on its way out.
+ # The browser client is the same bytes on every platform, so it is built
+ # once here and dropped into each package's tree before ci/deploy.sh. It
+ # was not built anywhere in this workflow before: deploy.sh copies the
+ # bundle only when it exists, so every package shipped without a page and
+ # the server logged "no web bundle found".
+ web:
+ name: web bundle
+ needs: prepare
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: wasm32-unknown-unknown
+
+ - name: Cache cargo
+ uses: Swatinem/rust-cache@v2
+ with:
+ key: web
+ cache-on-failure: true
+ save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
+
+ # The wasm-bindgen CLI has to match the crate the workspace pins
+ # exactly (ci/build-web.sh refuses any other), so its version is read
+ # from Cargo.toml rather than written here twice. The prebuilt binary
+ # takes seconds where `cargo install` takes minutes. binaryen is
+ # wasm-opt, which takes a quarter off the wasm.
+ - name: Install wasm-bindgen and wasm-opt
+ run: |
+ set -euo pipefail
+ version=$(grep -E '^wasm-bindgen = "=' Cargo.toml | sed -E 's/.*"=([0-9.]+)".*/\1/')
+ dir="wasm-bindgen-${version}-x86_64-unknown-linux-musl"
+ curl -sSfL "https://github.com/rustwasm/wasm-bindgen/releases/download/${version}/${dir}.tar.gz" \
+ | tar -xz -C "$HOME/.cargo/bin" --strip-components=1 "${dir}/wasm-bindgen"
+ sudo apt-get update
+ sudo apt-get install -y --no-install-recommends binaryen
+ wasm-bindgen --version
+ wasm-opt --version
+
+ - name: Build
+ run: bash ci/build-web.sh
+
+ - name: Upload
+ uses: actions/upload-artifact@v7
+ with:
+ name: web-bundle
+ path: thinkterm-web/www
+ if-no-files-found: error
+
macos:
name: macos ${{ matrix.arch }}
- needs: prepare
+ needs: [prepare, web]
if: needs.prepare.outputs.macos_matrix != '[]'
strategy:
fail-fast: false
@@ -234,6 +288,12 @@ jobs:
-p wezterm-mux-server \
-p strip-ansi-escapes
+ - name: Fetch the browser bundle
+ uses: actions/download-artifact@v8
+ with:
+ name: web-bundle
+ path: thinkterm-web/www
+
# Without signing credentials ci/deploy.sh falls back to an ad-hoc
# signature: the bundle is well-formed but Gatekeeper will still warn on
# another machine.
@@ -255,7 +315,7 @@ jobs:
windows:
name: windows x86_64
- needs: prepare
+ needs: [prepare, web]
if: needs.prepare.outputs.windows == 'true'
runs-on: windows-2022
timeout-minutes: 90
@@ -316,6 +376,12 @@ jobs:
PATH C:\Strawberry\perl\bin;%PATH%
cargo build --release -p wezterm -p wezterm-gui -p wezterm-mux-server -p strip-ansi-escapes
+ - name: Fetch the browser bundle
+ uses: actions/download-artifact@v8
+ with:
+ name: web-bundle
+ path: thinkterm-web/www
+
- name: Package
shell: bash
run: bash ci/deploy.sh
@@ -333,7 +399,7 @@ jobs:
# against that distro's glibc, and the arch comes from the runner underneath.
linux:
name: ${{ matrix.name }} ${{ matrix.arch }}
- needs: prepare
+ needs: [prepare, web]
if: needs.prepare.outputs.linux_matrix != '[]'
strategy:
fail-fast: false
@@ -416,6 +482,12 @@ jobs:
-p wezterm-mux-server \
-p strip-ansi-escapes
+ - name: Fetch the browser bundle
+ uses: actions/download-artifact@v8
+ with:
+ name: web-bundle
+ path: thinkterm-web/www
+
- name: Package
run: bash ci/deploy.sh
diff --git a/ci/deploy.sh b/ci/deploy.sh
index 3ea99a2b..bb2606da 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -1,5 +1,22 @@
#!/bin/bash
set -x
+
+# Whether the browser client was built (ci/build-web.sh). A package without
+# it has a server that accepts browser connections and serves no page. The
+# release workflow always builds it, so there its absence is a broken run
+# and this fails; on a laptop it is only a warning, since a local package
+# may deliberately leave it out.
+require_web_bundle() {
+ if [[ -f thinkterm-web/www/pkg/thinkterm_web.js ]] ; then
+ return 0
+ fi
+ if [[ -n "${CI:-}" ]] ; then
+ echo "error: no browser bundle in thinkterm-web/www; ci/build-web.sh did not run before deploy.sh" >&2
+ exit 1
+ fi
+ echo "warning: no browser bundle in thinkterm-web/www (run ci/build-web.sh); packaging without the web client" >&2
+ return 1
+}
set -e
TARGET_DIR=${1:-target}
@@ -49,7 +66,7 @@ case $OSTYPE in
cp LICENSE.md LICENSE-MIT NOTICE $zipdir/ThinkTerm.app/Contents/Resources/
# The browser client, when ci/build-web.sh ran before this: the server
# inside the bundle finds it at <exe>/../Resources/web.
- if [[ -f thinkterm-web/www/pkg/thinkterm_web.js ]] ; then
+ if require_web_bundle ; then
mkdir -p $zipdir/ThinkTerm.app/Contents/Resources/web
# -p throughout: the server decides whether a .gz still stands for
# its file by comparing their modification times, and a copy that
@@ -218,6 +235,17 @@ case $OSTYPE in
# stages a copy of it next to the exe, so take it from assets directly.
mkdir $zipdir/mesa
cp assets/windows/mesa/opengl32.dll $zipdir/mesa
+ # The browser client, beside the executables: the server looks for
+ # <exe>/web on a flat layout like this one. -p keeps the modification
+ # times the .gz freshness check reads.
+ if require_web_bundle ; then
+ mkdir -p $zipdir/web
+ cp -p thinkterm-web/www/index.html thinkterm-web/www/app.js $zipdir/web/
+ for gz in thinkterm-web/www/*.gz ; do
+ [[ -f "$gz" ]] && cp -p "$gz" $zipdir/web/
+ done
+ cp -Rp thinkterm-web/www/pkg thinkterm-web/www/fonts $zipdir/web/
+ fi
7z a -tzip $zipname $zipdir
iscc.exe -DMyAppVersion=${TAG_NAME#nightly} -F${instname} ci/windows-installer.iss
;;
@@ -574,7 +602,7 @@ EOF
install -Dm644 -t "$tardir" NOTICE LICENSE.md LICENSE-MIT
# The browser client, when ci/build-web.sh ran before this: the
# server finds it at <exe>/../share/thinkterm/web.
- if [[ -f thinkterm-web/www/pkg/thinkterm_web.js ]] ; then
+ if require_web_bundle ; then
# -p keeps the modification times the .gz freshness check reads.
install -Dpm644 -t "$tardir/share/thinkterm/web" thinkterm-web/www/index.html thinkterm-web/www/app.js
for gz in thinkterm-web/www/*.gz ; do
diff --git a/ci/macos-package.sh b/ci/macos-package.sh
index 44116e1e..1566c8b0 100755
--- a/ci/macos-package.sh
+++ b/ci/macos-package.sh
@@ -289,9 +289,23 @@ if [[ "$BUILD" == yes ]]; then
-p wezterm-mux-server \
-p strip-ansi-escapes
echo
+ echo "==> Building the browser client"
+ # Into thinkterm-web/www, where deploy.sh picks it up. Needs the wasm32
+ # target and the wasm-bindgen CLI at the pinned version; the script says
+ # which if either is missing.
+ bash ci/build-web.sh
+ echo
echo "==> Checking prerequisites (continued)"
fi
+# A package without the browser client has a server that accepts browser
+# connections and serves no page. Say so here rather than ship it quietly.
+if [[ ! -f thinkterm-web/www/pkg/thinkterm_web.js ]]; then
+ echo "No browser client in thinkterm-web/www." >&2
+ echo "Build it first with 'ci/build-web.sh', or re-run with --build." >&2
+ exit 1
+fi
+
# A plain `cargo build --release` writes to target/release with no target
# directory of its own, and for this Mac's own architecture that is the same
# set of binaries. Keep accepting it, so packaging what is already built does
diff --git a/ci/windows-installer.iss b/ci/windows-installer.iss
index 8cf24637..c0a2aa62 100644
--- a/ci/windows-installer.iss
+++ b/ci/windows-installer.iss
@@ -52,6 +52,7 @@ Source: "..\target\release\libEGL.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\target\release\libGLESv2.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\target\release\conpty.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\target\release\OpenConsole.exe"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\thinkterm-web\www\*"; DestDir: "{app}\web"; Flags: ignoreversion recursesubdirs skipifsourcedoesntexist
Source: "..\target\release\strip-ansi-escapes.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\LICENSE.md"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\LICENSE-MIT"; DestDir: "{app}"; Flags: ignoreversion
diff --git a/docs/thinkterm/web-access.md b/docs/thinkterm/web-access.md
index ba2a8463..b4b93884 100644
--- a/docs/thinkterm/web-access.md
+++ b/docs/thinkterm/web-access.md
@@ -88,11 +88,14 @@ TLS PKI is regenerated every time it starts and is not suitable for that.
`ci/build-web.sh` builds `thinkterm-web` for `wasm32-unknown-unknown`, runs
`wasm-bindgen` (the CLI must match the version pinned in `Cargo.toml`) and
-copies the fonts into `thinkterm-web/www`. The release tarballs and the macOS
-app carry that directory as `share/thinkterm/web` (or `Contents/Resources/web`),
-which is where the server looks by default; `static_dir` in a `web_servers`
-entry or the `THINKTERM_WEB_STATIC_DIR` environment variable point it elsewhere,
-for instance at a development checkout.
+copies the fonts into `thinkterm-web/www`. The release workflow builds it once
+and every package carries that directory: `share/thinkterm/web` in the
+tarballs, deb and rpm, `Contents/Resources/web` in the macOS app, `web` beside
+the executables on Windows. Those are where the server looks by default;
+`static_dir` in a `web_servers` entry or the `THINKTERM_WEB_STATIC_DIR`
+environment variable point it elsewhere, for instance at a development
+checkout. `ci/deploy.sh` refuses to package without the bundle in CI and warns
+on a laptop; `ci/macos-package.sh --build` builds it.
## What the first version does not do
diff --git a/wezterm-mux-server/src/web.rs b/wezterm-mux-server/src/web.rs
index 137024e9..5e97f097 100644
--- a/wezterm-mux-server/src/web.rs
+++ b/wezterm-mux-server/src/web.rs
@@ -132,6 +132,9 @@ fn resolve_static_dir(server: &WebServer) -> Option<PathBuf> {
if let Some(bin) = exe.parent() {
candidates.push(bin.join("../share/thinkterm/web"));
candidates.push(bin.join("../Resources/web"));
+ // The Windows zip and installer are flat: everything beside the
+ // executables, the bundle in web/.
+ candidates.push(bin.join("web"));
}
}
for candidate in candidates {