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.

thinkterm-web: Svelte 5 display layer built by Vite

RoversX50395e1e221e
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 53edfe57..42c43967 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -214,9 +214,20 @@ jobs:
wasm-bindgen --version
wasm-opt --version
+ # The page around the terminal is built by Vite from thinkterm-web/ui.
+ - name: Install Node
+ uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: npm
+ cache-dependency-path: thinkterm-web/ui/package-lock.json
+
- name: Build
run: bash ci/build-web.sh
+ - name: Type-check the page
+ run: npm run --prefix thinkterm-web/ui check
+
- name: Upload
uses: actions/upload-artifact@v7
with:
diff --git a/.gitignore b/.gitignore
index 3f229e8f..421b5005 100644
--- a/.gitignore
+++ b/.gitignore
@@ -98,7 +98,11 @@ __pycache__/
# well...
/.claude
-# Built browser bundle (ci/build-web.sh)
+# Built browser bundle (ci/build-web.sh): wasm-bindgen's pkg/, the fonts,
+# and the page Vite builds from thinkterm-web/ui
/thinkterm-web/www/pkg/
/thinkterm-web/www/fonts/
+/thinkterm-web/www/assets/
+/thinkterm-web/www/index.html
/thinkterm-web/www/*.gz
+/thinkterm-web/ui/node_modules/
diff --git a/ci/build-web.sh b/ci/build-web.sh
index fcf9a85b..7db1f6f2 100755
--- a/ci/build-web.sh
+++ b/ci/build-web.sh
@@ -2,9 +2,11 @@
# Build the browser client bundle into thinkterm-web/www:
# pkg/ the wasm and its wasm-bindgen JavaScript glue
# fonts/ the faces the page loads
+# index.html, assets/ the page, built by Vite from thinkterm-web/ui
# Usage: ci/build-web.sh [--debug]
-# Needs the wasm32-unknown-unknown target and the wasm-bindgen CLI at the
-# version the workspace pins (see Cargo.toml). wasm-opt is used if present.
+# Needs the wasm32-unknown-unknown target, the wasm-bindgen CLI at the
+# version the workspace pins (see Cargo.toml), and Node 22+ with npm.
+# wasm-opt is used if present.
set -eu
cd "$(dirname "$0")/.."
@@ -24,18 +26,27 @@ cargo build -p thinkterm-web --target wasm32-unknown-unknown $CARGO_FLAGS
WASM="$TARGET_DIR/wasm32-unknown-unknown/$PROFILE/thinkterm_web.wasm"
OUT=thinkterm-web/www
rm -rf "$OUT/pkg"
-wasm-bindgen --target web --out-dir "$OUT/pkg" --no-typescript "$WASM"
+wasm-bindgen --target web --out-dir "$OUT/pkg" "$WASM"
if command -v wasm-opt >/dev/null 2>&1 && [ "$PROFILE" = release ]; then
wasm-opt -Oz -o "$OUT/pkg/thinkterm_web_bg.wasm" "$OUT/pkg/thinkterm_web_bg.wasm"
fi
mkdir -p "$OUT/fonts"
cp assets/fonts/JetBrainsMono-Regular.ttf assets/fonts/SymbolsNerdFontMono-Regular.ttf "$OUT/fonts/"
+# The page itself. Vite writes index.html and assets/ into $OUT and leaves
+# pkg/ and fonts/ alone (emptyOutDir is off), so the stale hashed assets of
+# an earlier build are cleared here. npm ci installs exactly the lockfile.
+rm -rf "$OUT/assets" "$OUT/index.html" "$OUT/index.html.gz"
+UI=thinkterm-web/ui
+if [ ! -d "$UI/node_modules" ] || [ "$UI/package-lock.json" -nt "$UI/node_modules/.package-lock.json" ]; then
+ npm ci --prefix "$UI" --no-audit --no-fund
+fi
+npm run --prefix "$UI" --silent build
# Precompress what a browser will take compressed. The mux server sends a
# .gz sibling as it is when the client accepts gzip, so this cost is paid
# once here instead of per request, and -9 beats what a server would spend
# in a request's time. -n leaves out the name and timestamp so the output
# is the same for the same input.
-for f in "$OUT/index.html" "$OUT/app.js" "$OUT/pkg"/*.js "$OUT/pkg"/*.wasm "$OUT/fonts"/*.ttf; do
+for f in "$OUT/index.html" "$OUT/assets"/*.js "$OUT/assets"/*.css "$OUT/pkg"/*.js "$OUT/pkg"/*.wasm "$OUT/fonts"/*.ttf; do
[ -f "$f" ] || continue
gzip -9 -n -c "$f" > "$f.gz"
done
diff --git a/ci/deploy.sh b/ci/deploy.sh
index bb2606da..a712b75d 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -71,12 +71,12 @@ case $OSTYPE in
# -p throughout: the server decides whether a .gz still stands for
# its file by comparing their modification times, and a copy that
# rewrites them can make a stale sibling look current.
- cp -p thinkterm-web/www/index.html thinkterm-web/www/app.js $zipdir/ThinkTerm.app/Contents/Resources/web/
+ cp -p thinkterm-web/www/index.html $zipdir/ThinkTerm.app/Contents/Resources/web/
# The precompressed siblings, when ci/build-web.sh made them.
for gz in thinkterm-web/www/*.gz ; do
[[ -f "$gz" ]] && cp -p "$gz" $zipdir/ThinkTerm.app/Contents/Resources/web/
done
- cp -Rp thinkterm-web/www/pkg thinkterm-web/www/fonts $zipdir/ThinkTerm.app/Contents/Resources/web/
+ cp -Rp thinkterm-web/www/assets thinkterm-web/www/pkg thinkterm-web/www/fonts $zipdir/ThinkTerm.app/Contents/Resources/web/
fi
tic -xe wezterm -o $zipdir/ThinkTerm.app/Contents/Resources/terminfo termwiz/data/wezterm.terminfo
@@ -240,11 +240,11 @@ case $OSTYPE in
# 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/
+ cp -p thinkterm-web/www/index.html $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/
+ cp -Rp thinkterm-web/www/assets 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
@@ -604,10 +604,11 @@ EOF
# server finds it at <exe>/../share/thinkterm/web.
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
+ install -Dpm644 -t "$tardir/share/thinkterm/web" thinkterm-web/www/index.html
for gz in thinkterm-web/www/*.gz ; do
[[ -f "$gz" ]] && install -Dpm644 -t "$tardir/share/thinkterm/web" "$gz"
done
+ install -Dpm644 -t "$tardir/share/thinkterm/web/assets" thinkterm-web/www/assets/*
install -Dpm644 -t "$tardir/share/thinkterm/web/pkg" thinkterm-web/www/pkg/*
install -Dpm644 -t "$tardir/share/thinkterm/web/fonts" thinkterm-web/www/fonts/*
fi
diff --git a/thinkterm-web/ui/index.html b/thinkterm-web/ui/index.html
new file mode 100644
index 00000000..214540cd
--- /dev/null
+++ b/thinkterm-web/ui/index.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>ThinkTerm</title>
+</head>
+<body>
+<div id="app"></div>
+<script type="module" src="/src/main.ts"></script>
+</body>
+</html>
diff --git a/thinkterm-web/ui/package-lock.json b/thinkterm-web/ui/package-lock.json
new file mode 100644
index 00000000..42b4a259
--- /dev/null
+++ b/thinkterm-web/ui/package-lock.json
@@ -0,0 +1,1217 @@
+{
+ "name": "thinkterm-ui",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "thinkterm-ui",
+ "devDependencies": {
+ "@sveltejs/vite-plugin-svelte": "^7.3.0",
+ "@tsconfig/svelte": "^5.0.8",
+ "svelte": "^5.57.0",
+ "svelte-check": "^4.7.6",
+ "typescript": "~6.0.2",
+ "vite": "^8.2.2"
+ }
+ },
+ "node_modules/@jridgewell/gen-mapping": {
+ "version": "0.3.13",
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
+ "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/sourcemap-codec": "^1.5.0",
+ "@jridgewell/trace-mapping": "^0.3.24"
+ }
+ },
+ "node_modules/@jridgewell/remapping": {
+ "version": "2.3.5",
+ "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",
+ "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/gen-mapping": "^0.3.5",
+ "@jridgewell/trace-mapping": "^0.3.24"
+ }
+ },
+ "node_modules/@jridgewell/resolve-uri": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
+ "node_modules/@jridgewell/sourcemap-codec": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
+ "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@jridgewell/trace-mapping": {
+ "version": "0.3.31",
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
+ "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/resolve-uri": "^3.1.0",
+ "@jridgewell/sourcemap-codec": "^1.4.14"
+ }
+ },
+ "node_modules/@oxc-project/types": {
+ "version": "0.148.0",
+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.148.0.tgz",
+ "integrity": "sha512-Nm4s/jB+4FpFsPhWGEC4h7rzksesmtnMXomo6rCMcg/b8zLQuOziRgkCS1fxDCXOlJB/6Q8oABOZ/OP6RIPj9A==",
+ "dev": true,
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/oxc-project"
+ }
+ },
+ "node_modules/@rolldown/binding-android-arm-eabi": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.7.tgz",
+ "integrity": "sha512-EypzgnYCwyVY4NDHKzGmNJT5b+XaQEBniHxsMdeIQLB/tcCzZnhqrzHpZFbX9iaxx+5RiB8caATBtfvZP7zVxQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-android-arm64": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.7.tgz",
+ "integrity": "sha512-l17HE9EweWaqJZhuUuNBN/FzM62xw+DECVnJyvMsxn8vJFAGLy5QfLDoYAcronkAN8VxKZHezDpulHDPx95vFw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-darwin-arm64": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.7.tgz",
+ "integrity": "sha512-8ED8ELFvHXc6OCETIn4gXObPiaR6bckM/ipXtbzlPVDRMBfEGjCKgO90F9YtfdpDatVx/ZQw7aZ1vUMf/+T3Mw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-darwin-x64": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.7.tgz",
+ "integrity": "sha512-/WPripjtiAIZ2tWY7ddijORT0Ujg87wxWW/qcoFVCKAWVDPhtY0xr7Dj0M3GyNGz60jGwTElhro/mkF9dT7dDQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-freebsd-x64": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.7.tgz",
+ "integrity": "sha512-14DI4NcqpvbICxSnGLx3PmtDaWqRP/KGSGb6C+JLLVPeZRl6dKdHba3pGsqT3vpdTqhEYIPG0MMQ8c0xYqoJxA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-arm-gnueabihf": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.7.tgz",
+ "integrity": "sha512-bxrWIRvHWQvbJwi+VIie/kDJmQxcNE6xxWwZdqF/ExVAigtHkv54WTLQPb+QsZdnFy18fg7JPfWGL0RH6vwIlQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-arm64-gnu": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.7.tgz",
+ "integrity": "sha512-toOY2BChBZyuxU7OYX6Tn389di4IzAqPTycVcci0O7FSfBqzRB3RZn+K5Is6ANf4tmgRd/K1yZTsNTXbkXsnLg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-arm64-musl": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.7.tgz",
+ "integrity": "sha512-lAIXTH/aiLRLxsTgQvfhjo4K1ydWIp00+V0voOr9beb/9ZmkUFrSIb03dXNFRgMNvkE6oGsF10ioQ6UsI+vS5Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-ppc64-gnu": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.7.tgz",
+ "integrity": "sha512-kdnwS28Pkenp/mZMRwjXXXwxQ7pIsm+bF919LUK93BOyhcLsrVKdP2p9fxpiPNPAbNuch8ypQt0pm2P2LYCAGg==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-s390x-gnu": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.7.tgz",
+ "integrity": "sha512-516OdsyLdr5E65paF3yBF55t8mfm9+gmtCsK3xI7XKXIT7EfRlHhxL8K/NR6Hu8BWSgF5+1w74lTL0+nxcc8Qw==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-x64-gnu": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.7.tgz",
+ "integrity": "sha512-r8/z8n7GFaYRln3xmP1Cxy0HH/HLM0uBUPkEuSVEfKGDA89M0FsZRZJRSwe/tJjRx+fpH/gjorfhB8tmEbSFLA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-x64-musl": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.7.tgz",
+ "integrity": "sha512-pAsE8iiDxUg1xBqdhrTfg45AVDVpirjz00sblEYClGNNcMnDb+e8beQgqIAw6LvauX/APvgxUnwrgun/YYGBhw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-openharmony-arm64": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.7.tgz",
+ "integrity": "sha512-lTcIYmmnQQA8Or/2DatS6oSqcdLHvendjS+zLu+FwgToynWMRSmQdpM65fTANJgIS4mjbMOo5KT2lnT9SAb96w==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openharmony"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-win32-arm64-msvc": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.7.tgz",
+ "integrity": "sha512-e3Gu3WxbNk/UqQhxqU7YIYO+9ZBvWNz3U+h/qRFosscMFzdRPbXYSaSWgSnklv2fz1TgzBTcti2z35c/7irsHw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-win32-x64-msvc": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.7.tgz",
+ "integrity": "sha512-W/jg5qoRSqjsEv0+dZi4e687mcHqmVuU0P4fK6qS/xjetW2Gmc1W8j//z5nAeNcC8Ttm0hV46IjcYeuVwYhuiw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/pluginutils": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",
+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@sveltejs/acorn-typescript": {
+ "version": "1.0.13",
+ "resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.13.tgz",
+ "integrity": "sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ==",
+ "dev": true,
+ "license": "MIT",
+ "peerDependencies": {
+ "acorn": "^8.9.0"
+ }
+ },
+ "node_modules/@sveltejs/load-config": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/@sveltejs/load-config/-/load-config-0.2.3.tgz",
+ "integrity": "sha512-VT3qmUb8pRV2QrZjd8iAmtg8lf4W0TIjZbvXtz5MKei/q96teWZgGJyyidJzOjzZzvdq616eSRVeMYIQChUTAQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 18.0.0"
+ }
+ },
+ "node_modules/@sveltejs/vite-plugin-svelte": {
+ "version": "7.3.0",
+ "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-7.3.0.tgz",
+ "integrity": "sha512-QbRoJyD92e9R0ufeQIWRHrCC0ObcqSv/aBDdrQMoU+sypav3cDx5wytdQ6GLdXjEMO6xjrXGzfkUygng8JMv0A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "deepmerge": "^4.3.1",
+ "magic-string": "^1.0.0",
+ "obug": "^2.1.0",
+ "vitefu": "^1.1.2"
+ },
+ "engines": {
+ "node": "^20.19 || ^22.12 || >=24"
+ },
+ "peerDependencies": {
+ "svelte": "^5.46.4",
+ "vite": "^8.0.0-beta.7 || ^8.0.0"
+ }
+ },
+ "node_modules/@tsconfig/svelte": {
+ "version": "5.0.8",
+ "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-5.0.8.tgz",
+ "integrity": "sha512-UkNnw1/oFEfecR8ypyHIQuWYdkPvHiwcQ78sh+ymIiYoF+uc5H1UBetbjyqT+vgGJ3qQN6nhucJviX6HesWtKQ==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@types/estree": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
+ "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/acorn": {
+ "version": "8.18.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
+ "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "acorn": "bin/acorn"
+ },
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
+ "node_modules/aria-query": {
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz",
+ "integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/axobject-query": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",
+ "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/chokidar": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
+ "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "readdirp": "^4.0.1"
+ },
+ "engines": {
+ "node": ">= 14.16.0"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/clsx": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
+ "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/deepmerge": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
+ "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/detect-libc": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/devalue": {
+ "version": "5.9.2",
+ "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.2.tgz",
+ "integrity": "sha512-po4PAY5c53tw5XMocSnf8A/5OHhbbUftpr93aEN6BBoAdntUmK7vu7wOATqvt7cXO7m1Cl4gMVn6p7n6n4mj0w==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/esm-env": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz",
+ "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/esrap": {
+ "version": "2.3.7",
+ "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.3.7.tgz",
+ "integrity": "sha512-n2nf7fZR3c9yXf0BPEuHuXqT+KW0SJVj4cN5FMEkpCZ3scLjOQWpiccyCxVzCC2q1wubTghuEGzngJY/7Ah0Ow==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/sourcemap-codec": "^1.4.15"
+ },
+ "peerDependencies": {
+ "@typescript-eslint/types": "^8.2.0"
+ },
+ "peerDependenciesMeta": {
+ "@typescript-eslint/types": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/fdir": {
+ "version": "6.5.0",
+ "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.0.0"
+ },
+ "peerDependencies": {
+ "picomatch": "^3 || ^4"
+ },
+ "peerDependenciesMeta": {
+ "picomatch": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/fsevents": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
+ "node_modules/is-reference": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",
+ "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/estree": "^1.0.6"
+ }
+ },
+ "node_modules/lightningcss": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
+ "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",
+ "dev": true,
+ "license": "MPL-2.0",
+ "dependencies": {
+ "detect-libc": "^2.0.3"
+ },
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ },
+ "optionalDependencies": {
+ "lightningcss-android-arm64": "1.33.0",
+ "lightningcss-darwin-arm64": "1.33.0",
+ "lightningcss-darwin-x64": "1.33.0",
+ "lightningcss-freebsd-x64": "1.33.0",
+ "lightningcss-linux-arm-gnueabihf": "1.33.0",
+ "lightningcss-linux-arm64-gnu": "1.33.0",
+ "lightningcss-linux-arm64-musl": "1.33.0",
+ "lightningcss-linux-x64-gnu": "1.33.0",
+ "lightningcss-linux-x64-musl": "1.33.0",
+ "lightningcss-win32-arm64-msvc": "1.33.0",
+ "lightningcss-win32-x64-msvc": "1.33.0"
+ }
+ },
+ "node_modules/lightningcss-android-arm64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz",
+ "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-darwin-arm64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz",
+ "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-darwin-x64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz",
+ "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-freebsd-x64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz",
+ "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm-gnueabihf": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz",
+ "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm64-gnu": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz",
+ "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm64-musl": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz",
+ "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-x64-gnu": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz",
+ "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-x64-musl": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz",
+ "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-win32-arm64-msvc": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz",
+ "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-win32-x64-msvc": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz",
+ "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/locate-character": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",
+ "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/magic-string": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.2.3.tgz",
+ "integrity": "sha512-Bpb0W2TbLKOZ7vJnOUnVRGq3WL2p+ISV29M6hYPL1AFCpyKZpdr5ytiXoTSSxRVhg8YW7f65+6gbG8WG6PCa/g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/sourcemap-codec": "^1.5.5"
+ }
+ },
+ "node_modules/mri": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
+ "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/nanoid": {
+ "version": "3.3.18",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",
+ "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "license": "MIT",
+ "bin": {
+ "nanoid": "bin/nanoid.cjs"
+ },
+ "engines": {
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+ }
+ },
+ "node_modules/obug": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/obug/-/obug-2.2.1.tgz",
+ "integrity": "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==",
+ "dev": true,
+ "funding": [
+ "https://github.com/sponsors/sxzz",
+ "https://opencollective.com/debug"
+ ],
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.20.0"
+ }
+ },
+ "node_modules/picocolors": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/picomatch": {
+ "version": "4.0.7",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
+ "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
+ "node_modules/postcss": {
+ "version": "8.5.28",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz",
+ "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/postcss/"
+ },
+ {
+ "type": "tidelift",
+ "url": "https://tidelift.com/funding/github/npm/postcss"
+ },
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "nanoid": "^3.3.18",
+ "picocolors": "^1.1.1",
+ "source-map-js": "^1.2.1"
+ },
+ "engines": {
+ "node": "^10 || ^12 || >=14"
+ }
+ },
+ "node_modules/readdirp": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
+ "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 14.18.0"
+ },
+ "funding": {
+ "type": "individual",
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/rolldown": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.7.tgz",
+ "integrity": "sha512-g0EtLvBjTUB7jhyV0S/TCup3v/XSVl45vUIGbOGU4QPiyjTenCe4mKuFvW9fEgYmS2Fo42AUssRmNuMziXdrig==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@oxc-project/types": "=0.148.0",
+ "@rolldown/pluginutils": "^1.0.0"
+ },
+ "bin": {
+ "rolldown": "bin/cli.mjs"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "optionalDependencies": {
+ "@rolldown/binding-android-arm-eabi": "1.2.7",
+ "@rolldown/binding-android-arm64": "1.2.7",
+ "@rolldown/binding-darwin-arm64": "1.2.7",
+ "@rolldown/binding-darwin-x64": "1.2.7",
+ "@rolldown/binding-freebsd-x64": "1.2.7",
+ "@rolldown/binding-linux-arm-gnueabihf": "1.2.7",
+ "@rolldown/binding-linux-arm64-gnu": "1.2.7",
+ "@rolldown/binding-linux-arm64-musl": "1.2.7",
+ "@rolldown/binding-linux-ppc64-gnu": "1.2.7",
+ "@rolldown/binding-linux-s390x-gnu": "1.2.7",
+ "@rolldown/binding-linux-x64-gnu": "1.2.7",
+ "@rolldown/binding-linux-x64-musl": "1.2.7",
+ "@rolldown/binding-openharmony-arm64": "1.2.7",
+ "@rolldown/binding-win32-arm64-msvc": "1.2.7",
+ "@rolldown/binding-win32-x64-msvc": "1.2.7"
+ }
+ },
+ "node_modules/sade": {
+ "version": "1.8.1",
+ "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
+ "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "mri": "^1.1.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/source-map-js": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
+ "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/svelte": {
+ "version": "5.57.0",
+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.57.0.tgz",
+ "integrity": "sha512-NdbDn7fl4be1ViUG0oq/lvG6OZy3oENolV2ONjiqqsfVoeAfzaQAKUcEX3MrQod/Bebv1PgwET9rfXhgn9s4Kg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/remapping": "^2.3.4",
+ "@jridgewell/sourcemap-codec": "^1.5.0",
+ "@sveltejs/acorn-typescript": "^1.0.10",
+ "@types/estree": "^1.0.5",
+ "acorn": "^8.12.1",
+ "aria-query": "5.3.1",
+ "axobject-query": "^4.1.0",
+ "clsx": "^2.1.1",
+ "devalue": "^5.8.1",
+ "esm-env": "^1.2.1",
+ "esrap": "^2.2.12",
+ "is-reference": "^3.0.3",
+ "locate-character": "^3.0.0",
+ "magic-string": "^0.30.11",
+ "zimmerframe": "^1.1.2"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/svelte-check": {
+ "version": "4.7.6",
+ "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.7.6.tgz",
+ "integrity": "sha512-t2scM//ZuVbSY/T2w6FSBw1v9s2NEmh/g+sy1lqtosW5ylBV5AF4wFb1Ts9Kf3MbfPDUDJDZ9L436YT0SPTdvw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/trace-mapping": "^0.3.25",
+ "@sveltejs/load-config": "^0.2.3",
+ "chokidar": "^4.0.1",
+ "fdir": "^6.2.0",
+ "picocolors": "^1.0.0",
+ "sade": "^1.7.4"
+ },
+ "bin": {
+ "svelte-check": "bin/svelte-check"
+ },
+ "engines": {
+ "node": ">= 18.0.0"
+ },
+ "peerDependencies": {
+ "svelte": "^4.0.0 || ^5.0.0-next.0",
+ "typescript": "^5.0.0 || ^6.0.0"
+ }
+ },
+ "node_modules/svelte/node_modules/magic-string": {
+ "version": "0.30.21",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/sourcemap-codec": "^1.5.5"
+ }
+ },
+ "node_modules/tinyglobby": {
+ "version": "0.2.17",
+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fdir": "^6.5.0",
+ "picomatch": "^4.0.4"
+ },
+ "engines": {
+ "node": ">=12.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/SuperchupuDev"
+ }
+ },
+ "node_modules/typescript": {
+ "version": "6.0.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
+ "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=14.17"
+ }
+ },
+ "node_modules/vite": {
+ "version": "8.2.2",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.2.tgz",
+ "integrity": "sha512-cFKLV/PRgAUlIRm5WjMjJ86jrftzpqcgH+Us+DS8mI3CDNiH30Whrz8uHL3+MOLPAgqbMBAqWdAHAphOAM+z/Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "lightningcss": "^1.33.0",
+ "picomatch": "^4.0.5",
+ "postcss": "^8.5.26",
+ "rolldown": "~1.2.4",
+ "tinyglobby": "^0.2.17"
+ },
+ "bin": {
+ "vite": "bin/vite.js"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "funding": {
+ "url": "https://github.com/vitejs/vite?sponsor=1"
+ },
+ "optionalDependencies": {
+ "fsevents": "~2.3.3"
+ },
+ "peerDependencies": {
+ "@types/node": "^20.19.0 || >=22.12.0",
+ "@vitejs/devtools": "^0.4.0 || ^0.5.0",
+ "esbuild": "^0.27.0 || ^0.28.0",
+ "jiti": ">=1.21.0",
+ "less": "^4.0.0",
+ "sass": "^1.70.0",
+ "sass-embedded": "^1.70.0",
+ "stylus": ">=0.54.8",
+ "sugarss": "^5.0.0",
+ "terser": "^5.16.0",
+ "tsx": "^4.8.1",
+ "yaml": "^2.4.2"
+ },
+ "peerDependenciesMeta": {
+ "@types/node": {
+ "optional": true
+ },
+ "@vitejs/devtools": {
+ "optional": true
+ },
+ "esbuild": {
+ "optional": true
+ },
+ "jiti": {
+ "optional": true
+ },
+ "less": {
+ "optional": true
+ },
+ "sass": {
+ "optional": true
+ },
+ "sass-embedded": {
+ "optional": true
+ },
+ "stylus": {
+ "optional": true
+ },
+ "sugarss": {
+ "optional": true
+ },
+ "terser": {
+ "optional": true
+ },
+ "tsx": {
+ "optional": true
+ },
+ "yaml": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/vitefu": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.3.tgz",
+ "integrity": "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==",
+ "dev": true,
+ "license": "MIT",
+ "workspaces": [
+ "tests/deps/*",
+ "tests/projects/*",
+ "tests/projects/workspace/packages/*"
+ ],
+ "peerDependencies": {
+ "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "vite": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/zimmerframe": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.5.tgz",
+ "integrity": "sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA==",
+ "dev": true,
+ "license": "MIT"
+ }
+ }
+}
diff --git a/thinkterm-web/ui/package.json b/thinkterm-web/ui/package.json
new file mode 100644
index 00000000..e994c837
--- /dev/null
+++ b/thinkterm-web/ui/package.json
@@ -0,0 +1,18 @@
+{
+ "name": "thinkterm-ui",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build",
+ "check": "svelte-check --tsconfig ./tsconfig.json"
+ },
+ "devDependencies": {
+ "@sveltejs/vite-plugin-svelte": "^7.3.0",
+ "@tsconfig/svelte": "^5.0.8",
+ "svelte": "^5.57.0",
+ "svelte-check": "^4.7.6",
+ "typescript": "~6.0.2",
+ "vite": "^8.2.2"
+ }
+}
diff --git a/thinkterm-web/ui/src/AgentsPanel.svelte b/thinkterm-web/ui/src/AgentsPanel.svelte
new file mode 100644
index 00000000..010c45bf
--- /dev/null
+++ b/thinkterm-web/ui/src/AgentsPanel.svelte
@@ -0,0 +1,148 @@
+<script lang="ts">
+ // The desktop's right-hand Agents panel: one row per pane a coding agent
+ // runs in, with its live state. What `agent_panel.rs` paints, from the
+ // rows the wasm publishes (thinkterm-web/src/agents.rs); a click on a row
+ // brings that pane on show.
+ import { handle } from './client';
+ import { refreshViews, s, views } from './client.svelte';
+ import { agentIcon, circleAlert, circleCheck, loaderCircle } from './icons';
+
+ const rows = $derived(views.agents.rows);
+ const summary = $derived(views.agents.summary);
+
+ // The mark on the body is what makes the tab row, the canvas and the pane
+ // bars leave room on the right; it is the panel's own, so it goes up when
+ // the panel is mounted and comes off with it.
+ $effect(() => {
+ document.body.dataset.agents = '';
+ return () => {
+ delete document.body.dataset.agents;
+ };
+ });
+
+ // A click anywhere in a row is that row's, as it is on the desktop: the
+ // whole row is the target, not a button inside it.
+ function onClick(ev: MouseEvent) {
+ const target = ev.target;
+ if (!(target instanceof Element)) return;
+ const raw = target.closest('.ag')?.getAttribute('data-pane');
+ if (raw === null || raw === undefined) return;
+ const pane = Number(raw);
+ if (!Number.isSafeInteger(pane) || pane < 0) return;
+ ev.preventDefault();
+ // The reveal may have switched tab or window; what it changed is on
+ // show before this returns, as a menu row's outcome is.
+ if (handle.client?.agent_reveal(pane)) refreshViews();
+ }
+
+ // The panel's width: a preference of this browser's, within the bounds
+ // the desktop gives its right sidebar.
+ const STORE = 'thinkterm.agents-width';
+ const MIN = 200;
+ const MAX = 360;
+ const DEFAULT = 260;
+ let width = DEFAULT;
+
+ function setWidth(px: number): number {
+ const w = Math.round(Math.min(MAX, Math.max(MIN, px)));
+ document.documentElement.style.setProperty('--agents-w', `${w}px`);
+ return w;
+ }
+
+ $effect(() => {
+ let stored: number | null = null;
+ try {
+ const raw = localStorage.getItem(STORE);
+ if (raw !== null && raw !== '' && Number.isFinite(Number(raw))) stored = Number(raw);
+ } catch {
+ // A browser that blocks storage keeps the default; not worth a remark.
+ }
+ width = setWidth(stored ?? DEFAULT);
+ });
+
+ let dragging = false;
+ /** The canvas whose box is held still for the drag, so it resizes once. */
+ let frozen: HTMLCanvasElement | null = null;
+
+ function onPointerDown(ev: PointerEvent) {
+ const target = ev.target;
+ if (!(target instanceof HTMLElement) || !target.classList.contains('handle')) return;
+ ev.preventDefault();
+ dragging = true;
+ try {
+ target.setPointerCapture(ev.pointerId);
+ } catch {
+ // Without capture the drag still follows the pointer over the panel.
+ }
+ // As the sidebar's edge does: the terminal is resized from the canvas's
+ // box, so a drag that moved it would resize the whole grid on every
+ // frame. Its size is pinned for the drag, and the one real resize
+ // happens on release.
+ const canvas = document.getElementById('term');
+ if (canvas instanceof HTMLCanvasElement) {
+ const box = canvas.getBoundingClientRect();
+ canvas.style.width = `${box.width}px`;
+ canvas.style.height = `${box.height}px`;
+ frozen = canvas;
+ }
+ }
+
+ // The panel is against the right edge, so its width is what is left of the
+ // window to the right of the pointer.
+ function onPointerMove(ev: PointerEvent) {
+ if (dragging) width = setWidth(window.innerWidth - ev.clientX);
+ }
+
+ function onPointerUp() {
+ if (!dragging) return;
+ dragging = false;
+ try {
+ localStorage.setItem(STORE, String(width));
+ } catch {
+ // As above: the width is then this page load's only.
+ }
+ if (frozen) {
+ frozen.style.width = '';
+ frozen.style.height = '';
+ frozen = null;
+ }
+ }
+</script>
+
+<!-- One delegated handler, as the sidebar has; its children are the rows,
+ not the container. -->
+<!-- svelte-ignore a11y_click_events_have_key_events -->
+<!-- svelte-ignore a11y_no_static_element_interactions -->
+<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
+<aside
+ id="agents"
+ onclick={onClick}
+ onpointerdown={onPointerDown}
+ onpointermove={onPointerMove}
+ onpointerup={onPointerUp}
+ onpointercancel={onPointerUp}
+>
+ <div class="handle"></div>
+ <div class="hd">
+ <span class="ti">{s('web-agents-title')}</span>
+ <span class="sum">{summary}</span>
+ </div>
+ <div class="list">
+ {#each rows as row (row.pane)}
+ <div class="ag" class:elsewhere={!row.here} data-pane={row.pane} title={row.place}>
+ <span class="ic">{@html agentIcon(row.icon)}</span>
+ <span class="tx">
+ <span class="n">{row.name}{#if row.title !== ''}<span class="d"> · {row.title}</span>{/if}</span>
+ <span class="p">{row.state_label}{#if row.place !== ''} · {row.place}{/if}</span>
+ </span>
+ {#if row.state === 'working'}
+ <span class="st spin">{@html loaderCircle}</span>
+ {:else if row.state === 'blocked'}
+ <span class="st alert">{@html circleAlert}</span>
+ {:else if row.state === 'idle'}
+ <span class="st idle">{@html circleCheck}</span>
+ {/if}
+ </div>
+ {/each}
+ </div>
+</aside>
diff --git a/thinkterm-web/ui/src/App.svelte b/thinkterm-web/ui/src/App.svelte
new file mode 100644
index 00000000..c9304f93
--- /dev/null
+++ b/thinkterm-web/ui/src/App.svelte
@@ -0,0 +1,61 @@
+<script lang="ts">
+ // The page's chrome. The sidebar, the tab row, the pane bars, the card
+ // and the remark are drawn here from the views the wasm publishes; the
+ // canvas and the keyboard field are the wasm's, and it finds them by id.
+ import AgentsPanel from './AgentsPanel.svelte';
+ import Card from './Card.svelte';
+ import ContextMenu from './ContextMenu.svelte';
+ import KeyBar from './KeyBar.svelte';
+ import NavBars from './NavBars.svelte';
+ import SearchPalette from './SearchPalette.svelte';
+ import SettingsPanel from './SettingsPanel.svelte';
+ import Sidebar from './Sidebar.svelte';
+ import Status from './Status.svelte';
+ import TabRow from './TabRow.svelte';
+ import { views } from './client.svelte';
+ import { openMenu } from './menu.svelte';
+ import { mobile, openSide } from './mobile.svelte';
+ import { paneAt } from './pane';
+ import { setSetting } from './settings.svelte';
+ import { installSwipe, installTouch } from './touch';
+
+ function onCanvasMenu(ev: MouseEvent) {
+ ev.preventDefault();
+ const canvas = ev.currentTarget;
+ if (!(canvas instanceof HTMLCanvasElement)) return;
+ const pane = paneAt(canvas, ev.clientX, ev.clientY);
+ if (pane === null) return;
+ openMenu('pane', String(pane), ev.clientX, ev.clientY);
+ }
+
+ /** Touch on the canvas, and the drawer's swipes with it. Both are inert
+ until a finger arrives, so they go up whatever shape the page is in. */
+ function touch(node: HTMLCanvasElement) {
+ const off = [installTouch(node), installSwipe()];
+ return { destroy: () => off.forEach((stop) => stop()) };
+ }
+
+ // On a phone the two panels are drawers over the canvas; a press on what
+ // is left of the window puts whichever is out away.
+ const drawn = $derived(mobile.on && (mobile.side || views.settings['agents-panel']));
+ function closeDrawers() {
+ openSide(false);
+ if (views.settings['agents-panel']) setSetting('agents-panel', false);
+ }
+</script>
+
+<Sidebar />
+<TabRow />
+<canvas id="term" data-layout={views.layout} oncontextmenu={onCanvasMenu} use:touch></canvas>
+<NavBars />
+<!-- svelte-ignore a11y_click_events_have_key_events -->
+<!-- svelte-ignore a11y_no_static_element_interactions -->
+{#if drawn}<div id="scrim" onclick={closeDrawers}></div>{/if}
+<Card />
+<textarea id="kbd" wrap="off" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false"></textarea>
+<Status />
+{#if views.settings['agents-panel']}<AgentsPanel />{/if}
+{#if mobile.on}<KeyBar />{/if}
+<ContextMenu />
+<SearchPalette />
+<SettingsPanel />
diff --git a/thinkterm-web/ui/src/Card.svelte b/thinkterm-web/ui/src/Card.svelte
new file mode 100644
index 00000000..a2545658
--- /dev/null
+++ b/thinkterm-web/ui/src/Card.svelte
@@ -0,0 +1,8 @@
+<script lang="ts">
+ // The desktop's words over a terminal another device holds.
+ import { views } from './client.svelte';
+
+ const card = $derived(views.status.card);
+</script>
+
+<div id="card" hidden={!card}><div class="eyes">• •</div><div class="title">{card?.title ?? ''}</div><div class="hint">{card?.hint ?? ''}</div></div>
diff --git a/thinkterm-web/ui/src/ContextMenu.svelte b/thinkterm-web/ui/src/ContextMenu.svelte
new file mode 100644
index 00000000..cd437a8f
--- /dev/null
+++ b/thinkterm-web/ui/src/ContextMenu.svelte
@@ -0,0 +1,233 @@
+<script lang="ts">
+ // The one open context menu, as a panel per open submenu. What each menu
+ // offers and what a row does are the wasm's (thinkterm-web/src/menu.rs);
+ // drawn here, clamped into the viewport, walked with the pointer or the
+ // keyboard, and closed by anything that means the page moved on.
+ import { closeInnermost, closeMenu, menu, runItem } from './menu.svelte';
+ import { chevronRight, iconByName } from './icons';
+ import type { MenuItem } from './model';
+
+ /** How near an edge a panel may come before it flips. */
+ const EDGE = 6;
+ /** How long the pointer rests on a submenu row before it opens. */
+ const HOVER = 150;
+
+ // The panels on show: the root list, then the submenu each open row has.
+ const panels = $derived.by(() => {
+ const out: MenuItem[][] = [];
+ if (menu.items.length === 0) return out;
+ let items = menu.items;
+ out.push(items);
+ for (const i of menu.path) {
+ const sub = items[i]?.submenu;
+ if (!sub || sub.length === 0) break;
+ out.push(sub);
+ items = sub;
+ }
+ return out;
+ });
+
+ const innermost = $derived(panels[panels.length - 1] ?? []);
+ const selectable = (item: MenuItem | undefined) => !!item && item.kind === 'item' && item.enabled;
+
+ let boxes = $state<(HTMLDivElement | null)[]>([]);
+ let at = $state<{ x: number; y: number }[]>([]);
+
+ // Measured, not guessed: a panel's size is its rows' text, and the point
+ // it was asked for can be a few pixels from the edge of the window.
+ $effect(() => {
+ const panelCount = panels.length;
+ const anchor = [menu.x, menu.y];
+ const next: { x: number; y: number }[] = [];
+ for (let k = 0; k < panelCount; k++) {
+ const el = boxes[k];
+ if (!el) {
+ next.push({ x: anchor[0], y: anchor[1] });
+ continue;
+ }
+ const w = el.offsetWidth;
+ const h = el.offsetHeight;
+ const right = window.innerWidth - EDGE;
+ const bottom = window.innerHeight - EDGE;
+ let x: number;
+ let y: number;
+ if (k === 0) {
+ x = anchor[0];
+ y = anchor[1];
+ if (x + w > right) x = Math.max(EDGE, anchor[0] - w);
+ if (y + h > bottom) y = Math.max(EDGE, anchor[1] - h);
+ } else {
+ // Beside the row that opened it, overlapping the panel's padding
+ // so the pointer crosses no gap on its way in.
+ const parent = boxes[k - 1];
+ const box = parent?.getBoundingClientRect();
+ const row = parent?.querySelector(`[data-idx="${menu.path[k - 1]}"]`)?.getBoundingClientRect();
+ x = box ? box.right - 4 : anchor[0];
+ y = row ? row.top - 5 : (box?.top ?? anchor[1]);
+ if (x + w > right && box) x = Math.max(EDGE, box.left - w + 4);
+ if (y + h > bottom) y = Math.max(EDGE, bottom - h);
+ }
+ next.push({ x, y });
+ }
+ at = next;
+ });
+
+ // The menu takes the keyboard while it is open, which means #kbd loses
+ // it; closeMenu hands it back.
+ $effect(() => {
+ const el = boxes[panels.length - 1];
+ if (el && document.activeElement !== el) el.focus({ preventScroll: true });
+ });
+
+ // Anything that means the page moved on closes the menu. The press is
+ // watched in the capture phase so a click meant for what is underneath
+ // does not also act on it.
+ $effect(() => {
+ if (menu.items.length === 0) return;
+ const inside = (target: EventTarget | null) =>
+ target instanceof Node && boxes.some((b) => !!b && b.contains(target));
+ const down = (ev: Event) => {
+ if (!inside(ev.target)) closeMenu();
+ };
+ const away = () => closeMenu();
+ window.addEventListener('pointerdown', down, true);
+ window.addEventListener('blur', away);
+ window.addEventListener('resize', away);
+ window.addEventListener('wheel', away, { capture: true, passive: true });
+ return () => {
+ window.removeEventListener('pointerdown', down, true);
+ window.removeEventListener('blur', away);
+ window.removeEventListener('resize', away);
+ window.removeEventListener('wheel', away, { capture: true });
+ };
+ });
+
+ let timer: ReturnType<typeof setTimeout> | null = null;
+ function stopTimer() {
+ if (timer !== null) {
+ clearTimeout(timer);
+ timer = null;
+ }
+ }
+
+ /** Open the submenu of row `index` in the innermost panel. */
+ function openSub(index: number): boolean {
+ const item = innermost[index];
+ if (!selectable(item) || item.submenu.length === 0) return false;
+ menu.path = [...menu.path, index];
+ menu.selected = item.submenu.findIndex(selectable);
+ return true;
+ }
+
+ /** The keyboard's row, `delta` selectable rows on; headers, separators
+ and disabled rows are passed over. */
+ function move(delta: number) {
+ const items = innermost;
+ let i = menu.selected;
+ for (let n = 0; n < items.length; n++) {
+ i = i < 0 ? (delta > 0 ? 0 : items.length - 1) : (i + delta + items.length) % items.length;
+ if (selectable(items[i])) {
+ menu.selected = i;
+ return;
+ }
+ }
+ }
+
+ function onKeydown(ev: KeyboardEvent) {
+ switch (ev.key) {
+ case 'ArrowDown': move(1); break;
+ case 'ArrowUp': move(-1); break;
+ case 'ArrowRight':
+ if (menu.selected >= 0) openSub(menu.selected);
+ break;
+ case 'ArrowLeft':
+ case 'Escape':
+ stopTimer();
+ closeInnermost();
+ break;
+ case 'Enter': {
+ const item = innermost[menu.selected];
+ if (!item) break;
+ if (item.submenu.length > 0) openSub(menu.selected);
+ else runItem(item);
+ break;
+ }
+ default:
+ return;
+ }
+ // Nothing typed at a menu reaches the terminal.
+ ev.preventDefault();
+ ev.stopPropagation();
+ }
+
+ function onEnterRow(panel: number, index: number) {
+ stopTimer();
+ const item = panels[panel]?.[index];
+ if (!selectable(item)) return;
+ const already = menu.path.length > panel && menu.path[panel] === index;
+ if (already) return;
+ // The pointer chose this panel: whatever was open deeper is stale.
+ if (menu.path.length > panel) menu.path = menu.path.slice(0, panel);
+ menu.selected = index;
+ if (item.submenu.length === 0) return;
+ timer = setTimeout(() => {
+ timer = null;
+ menu.path = [...menu.path.slice(0, panel), index];
+ menu.selected = item.submenu.findIndex(selectable);
+ }, HOVER);
+ }
+
+ function onClickRow(panel: number, index: number) {
+ stopTimer();
+ const item = panels[panel]?.[index];
+ if (!selectable(item)) return;
+ if (item.submenu.length > 0) {
+ menu.path = [...menu.path.slice(0, panel), index];
+ menu.selected = item.submenu.findIndex(selectable);
+ return;
+ }
+ runItem(item);
+ }
+</script>
+
+<!-- The rows are the menu's, delegated per panel; a row is not a button
+ and never takes focus, which stays on the panel for the keyboard. -->
+<!-- svelte-ignore a11y_click_events_have_key_events -->
+{#each panels as items, k (k)}
+ <div
+ id={k === 0 ? 'menu' : undefined}
+ class="menu"
+ role="menu"
+ tabindex="-1"
+ bind:this={boxes[k]}
+ style="left:{(at[k]?.x ?? menu.x).toFixed(2)}px;top:{(at[k]?.y ?? menu.y).toFixed(2)}px"
+ onkeydown={onKeydown}
+ onpointerleave={stopTimer}
+ >
+ {#each items as item, i (i)}
+ {#if item.kind === 'separator'}
+ <hr class="ms" />
+ {:else if item.kind === 'header'}
+ <div class="mh">{item.label}</div>
+ {:else}
+ <div
+ class="mi"
+ class:checked={item.checked}
+ class:disabled={!item.enabled}
+ class:on={k === panels.length - 1 && menu.selected === i}
+ role="menuitem"
+ tabindex="-1"
+ aria-disabled={!item.enabled}
+ data-id={item.id}
+ data-idx={i}
+ onclick={() => onClickRow(k, i)}
+ onpointerenter={() => onEnterRow(k, i)}
+ >
+ <span class="ic">{#if item.icon}{@html iconByName(item.icon) ?? ''}{/if}</span><span
+ class="lb">{item.label}</span
+ >{#if item.submenu.length > 0}<span class="sub">{@html chevronRight}</span>{/if}
+ </div>
+ {/if}
+ {/each}
+ </div>
+{/each}
diff --git a/thinkterm-web/ui/src/KeyBar.svelte b/thinkterm-web/ui/src/KeyBar.svelte
new file mode 100644
index 00000000..e9c8f949
--- /dev/null
+++ b/thinkterm-web/ui/src/KeyBar.svelte
@@ -0,0 +1,193 @@
+<script lang="ts">
+ // The key bar a phone types with: the keys a terminal needs and a soft
+ // keyboard has not got, along the foot of the visual viewport so the soft
+ // keyboard itself never covers it. Every press goes to the terminal
+ // through `client.key`, which is a keydown on #kbd by another name
+ // (thinkterm-web/src/bridge.rs); Ctrl and Alt are sticky, and apply to
+ // the next key from the bar or from the soft keyboard, whichever comes.
+ import { handle } from './client';
+ import { KEYBAR } from './mobile.svelte';
+
+ /** A key: `name` is the DOM name the wasm maps, `label` what it says. */
+ type Key = { name: string; label: string };
+
+ /** Ahead of the modifiers. */
+ const HEAD: Key[] = [
+ { name: 'Escape', label: 'Esc' },
+ { name: 'Tab', label: 'Tab' },
+ ];
+ /** After them: the arrows, the jumps, and the four characters a soft
+ keyboard buries behind a page of symbols. */
+ const REST: Key[] = [
+ { name: 'ArrowLeft', label: '←' },
+ { name: 'ArrowUp', label: '↑' },
+ { name: 'ArrowDown', label: '↓' },
+ { name: 'ArrowRight', label: '→' },
+ { name: 'Home', label: 'Home' },
+ { name: 'End', label: 'End' },
+ { name: 'PageUp', label: 'PgUp' },
+ { name: 'PageDown', label: 'PgDn' },
+ { name: '-', label: '-' },
+ { name: '/', label: '/' },
+ { name: '|', label: '|' },
+ { name: '~', label: '~' },
+ ];
+ /** The keys a long press repeats. */
+ const REPEATS = new Set(['ArrowLeft', 'ArrowUp', 'ArrowDown', 'ArrowRight']);
+ /** How long an arrow is held before it repeats, and how often it then does. */
+ const HOLD = 500;
+ const EVERY = 60;
+
+ /** The sticky modifiers: armed by a tap, spent by the next key. */
+ let ctrl = $state(false);
+ let alt = $state(false);
+
+ /** Where the bar sits: the foot of the *visual* viewport, which is what
+ the soft keyboard takes a bite out of. */
+ let top = $state(0);
+
+ function disarm() {
+ ctrl = false;
+ alt = false;
+ }
+
+ function send(name: string) {
+ handle.client?.key(name, ctrl, alt, false);
+ disarm();
+ }
+
+ let delay: ReturnType<typeof setTimeout> | null = null;
+ let ticker: ReturnType<typeof setInterval> | null = null;
+
+ function stopRepeat() {
+ if (delay !== null) {
+ clearTimeout(delay);
+ delay = null;
+ }
+ if (ticker !== null) {
+ clearInterval(ticker);
+ ticker = null;
+ }
+ }
+
+ function startRepeat(name: string) {
+ stopRepeat();
+ delay = setTimeout(() => {
+ delay = null;
+ // The modifiers were spent on the first press; a repeat is the bare key.
+ ticker = setInterval(() => handle.client?.key(name, false, false, false), EVERY);
+ }, HOLD);
+ }
+
+ /** Ask for the soft keyboard, or send it away. */
+ function toggleKeyboard() {
+ const kbd = document.getElementById('kbd');
+ if (!(kbd instanceof HTMLTextAreaElement)) return;
+ if (document.activeElement === kbd) kbd.blur();
+ else kbd.focus();
+ }
+
+ // One delegated handler, as the tab row and the sidebar have. The press
+ // must not move focus: #kbd keeps it, so the soft keyboard stays up while
+ // the bar is used.
+ function onDown(ev: PointerEvent) {
+ const hit = ev.target instanceof Element ? ev.target.closest('.k') : null;
+ if (!hit) return;
+ ev.preventDefault();
+ const name = hit.getAttribute('data-key');
+ if (name === null) return;
+ if (name === 'Control') {
+ ctrl = !ctrl;
+ return;
+ }
+ if (name === 'Alt') {
+ alt = !alt;
+ return;
+ }
+ if (name === 'kbd') {
+ toggleKeyboard();
+ return;
+ }
+ send(name);
+ if (REPEATS.has(name)) startRepeat(name);
+ }
+
+ // An armed modifier applies to the soft keyboard's next key too. #kbd's
+ // own listener is the wasm's and sits on the same element without
+ // capture, so this one runs first and takes the key instead.
+ $effect(() => {
+ const kbd = document.getElementById('kbd');
+ if (!(kbd instanceof HTMLTextAreaElement)) return;
+ /** The character an armed key was sent for has still to be swallowed. */
+ let spent = false;
+ const onKeydown = (ev: KeyboardEvent) => {
+ if (!ctrl && !alt) return;
+ if (ev.key === 'Control' || ev.key === 'Alt' || ev.key === 'Shift' || ev.key === 'Meta') return;
+ ev.preventDefault();
+ ev.stopImmediatePropagation();
+ handle.client?.key(ev.key, ctrl, alt, ev.shiftKey);
+ disarm();
+ // A soft keyboard inserts its character whatever preventDefault says,
+ // and the wasm sends whatever lands in the field as bytes; the insert
+ // this key is about to make is not typed a second time.
+ spent = true;
+ kbd.value = '';
+ setTimeout(() => {
+ spent = false;
+ }, 0);
+ };
+ const onInput = (ev: Event) => {
+ if (!spent) return;
+ spent = false;
+ ev.stopImmediatePropagation();
+ kbd.value = '';
+ };
+ kbd.addEventListener('keydown', onKeydown, true);
+ kbd.addEventListener('input', onInput, true);
+ return () => {
+ kbd.removeEventListener('keydown', onKeydown, true);
+ kbd.removeEventListener('input', onInput, true);
+ };
+ });
+
+ // The bar follows the visual viewport, and the canvas and the drawers are
+ // sized from the same height (--vvh and --keybar in tokens.css): the soft
+ // keyboard shrinks that viewport and nothing else.
+ $effect(() => {
+ const vv = window.visualViewport;
+ const read = () => {
+ const height = vv ? vv.height : window.innerHeight;
+ top = (vv ? vv.offsetTop : 0) + height - KEYBAR;
+ document.documentElement.style.setProperty('--vvh', `${height}px`);
+ };
+ document.documentElement.style.setProperty('--keybar', `${KEYBAR}px`);
+ read();
+ vv?.addEventListener('resize', read);
+ vv?.addEventListener('scroll', read);
+ window.addEventListener('resize', read);
+ return () => {
+ vv?.removeEventListener('resize', read);
+ vv?.removeEventListener('scroll', read);
+ window.removeEventListener('resize', read);
+ document.documentElement.style.removeProperty('--keybar');
+ document.documentElement.style.removeProperty('--vvh');
+ };
+ });
+
+ $effect(() => stopRepeat);
+</script>
+
+<!-- The keys are the bar's, delegated, as the tab row's and the sidebar's
+ are; a release anywhere ends a repeat. -->
+<svelte:window onpointerup={stopRepeat} onpointercancel={stopRepeat} />
+<div id="keybar" role="toolbar" aria-label="Terminal keys" tabindex="-1" style="top:{top.toFixed(2)}px" onpointerdown={onDown}>
+ {#each HEAD as k (k.name)}
+ <button class="k" type="button" data-key={k.name} aria-label={k.label}>{k.label}</button>
+ {/each}
+ <button class="k" class:armed={ctrl} type="button" data-key="Control" aria-pressed={ctrl}>Ctrl</button>
+ <button class="k" class:armed={alt} type="button" data-key="Alt" aria-pressed={alt}>Alt</button>
+ {#each REST as k (k.name)}
+ <button class="k" type="button" data-key={k.name} aria-label={k.name}>{k.label}</button>
+ {/each}
+ <button class="k" type="button" data-key="kbd" aria-label="Keyboard">&#9000;</button>
+</div>
diff --git a/thinkterm-web/ui/src/NavBars.svelte b/thinkterm-web/ui/src/NavBars.svelte
new file mode 100644
index 00000000..0b43892f
--- /dev/null
+++ b/thinkterm-web/ui/src/NavBars.svelte
@@ -0,0 +1,49 @@
+<script lang="ts">
+ // One bar over each drawn pane, laid out from the canvas's cells: the
+ // pane's capsules and the buttons that split, zoom and close it. What
+ // `navbar::NavBars::html` drew.
+ import { onChromeClick } from './chrome';
+ import { s, views } from './client.svelte';
+ import { loaderCircle, maximize2, minimize2, plus, squareSplitHorizontal, squareSplitVertical, squareTerminal, x } from './icons';
+
+ const px = (n: number) => n.toFixed(2);
+</script>
+
+<!-- The row is one delegated handler, as the wasm had it; its children
+ are the controls, not the container. -->
+<!-- svelte-ignore a11y_click_events_have_key_events -->
+<!-- svelte-ignore a11y_no_static_element_interactions -->
+<div id="panes" onclick={onChromeClick}>
+ {#each views.navs as bar (bar.rect.pane)}
+ <div
+ class="nav"
+ class:focused={bar.focused}
+ data-nav={bar.rect.pane}
+ style="left:{px(bar.rect.left)}px;top:{px(bar.rect.top)}px;width:{px(bar.rect.width)}px;height:{px(bar.rect.height)}px"
+ ><span class="caps">{#each bar.members as m (m.pane)}<span
+ class="cap"
+ class:current={m.current}
+ data-pane={m.pane}
+ title={m.title}
+ >{#if m.busy}<span class="spin">{@html loaderCircle}</span>{:else}{@html squareTerminal}{/if}<span class="t">{m.title}</span><span
+ class="x"
+ class:danger={bar.closing && m.current}
+ data-action="close-pane"
+ data-pane={m.pane}
+ title={s('web-tip-close-pane')}
+ >{#if bar.closing && m.current}{s('web-confirm-close')}{:else}{@html x}{/if}</span></span>{/each}</span><span class="acts"><span
+ class="act"
+ data-action="new-tab"
+ title={s('web-tip-new-tab')}>{@html plus}</span><span
+ class="act"
+ data-action="split-below"
+ title={s('web-tip-split-down')}>{@html squareSplitVertical}</span><span
+ class="act"
+ data-action="split-right"
+ title={s('web-tip-split-right')}>{@html squareSplitHorizontal}</span><span
+ class="act"
+ data-action="zoom"
+ title={bar.zoomed ? s('web-tip-unzoom') : s('web-tip-zoom')}
+ >{#if bar.zoomed}{@html minimize2}{:else}{@html maximize2}{/if}</span></span></div>
+ {/each}
+</div>
diff --git a/thinkterm-web/ui/src/SearchPalette.svelte b/thinkterm-web/ui/src/SearchPalette.svelte
new file mode 100644
index 00000000..2229982e
--- /dev/null
+++ b/thinkterm-web/ui/src/SearchPalette.svelte
@@ -0,0 +1,92 @@
+<script lang="ts">
+ // The search palette: a field, and what the wasm ranked for what is in
+ // it, in sections. What can be found and what a pick does are the
+ // wasm's (thinkterm-web/src/palette.rs); drawn here, walked with the
+ // arrows, and closed by anything that means the page moved on.
+ import { iconByName } from './icons';
+ import { closePalette, move, palette, run, search, select, selectedId, shownSections } from './palette.svelte';
+
+ const sections = $derived(shownSections());
+ const current = $derived(selectedId());
+
+ /** The field is opened to be typed in. */
+ function typeHere(node: HTMLInputElement) {
+ node.focus();
+ node.select();
+ }
+
+ function onInput(ev: Event) {
+ const field = ev.currentTarget;
+ if (field instanceof HTMLInputElement) search(field.value);
+ }
+
+ // Nothing typed at the palette reaches the terminal.
+ function onKeydown(ev: KeyboardEvent) {
+ ev.stopPropagation();
+ switch (ev.key) {
+ case 'Escape': closePalette(); break;
+ case 'ArrowDown': move(1); break;
+ case 'ArrowUp': move(-1); break;
+ case 'Enter': run(current); break;
+ // The field is the only thing to move to, so Tab would only take
+ // the keyboard out of the palette.
+ case 'Tab': break;
+ default: return;
+ }
+ ev.preventDefault();
+ }
+
+ let list = $state<HTMLDivElement | null>(null);
+
+ // The keyboard can walk past the bottom of the list; the row it is on is
+ // brought back into sight rather than left off-screen.
+ $effect(() => {
+ const id = current;
+ if (!list || id === '') return;
+ list.querySelector(`.pe[data-id="${CSS.escape(id)}"]`)?.scrollIntoView({ block: 'nearest' });
+ });
+</script>
+
+<!-- The rows are the palette's, not buttons; the keyboard stays in the
+ field, which is what the pointer selecting a row keeps true. -->
+<!-- svelte-ignore a11y_click_events_have_key_events -->
+<!-- svelte-ignore a11y_no_static_element_interactions -->
+{#if palette.open}
+ <div id="palette-back" onpointerdown={closePalette}></div>
+ <div id="palette" role="dialog" aria-modal="true">
+ <input
+ class="q"
+ value={palette.query}
+ placeholder={palette.results.placeholder}
+ spellcheck="false"
+ autocomplete="off"
+ autocapitalize="off"
+ autocorrect="off"
+ oninput={onInput}
+ onkeydown={onKeydown}
+ use:typeHere
+ />
+ <div class="pl" bind:this={list}>
+ {#each sections as section (section.group)}
+ <div class="ph">{section.label}</div>
+ {#each section.entries as entry (entry.id)}
+ <div
+ class="pe"
+ class:on={entry.id === current}
+ data-id={entry.id}
+ onpointerenter={() => select(entry.id)}
+ onclick={() => run(entry.id)}
+ >
+ <span class="ic">{#if entry.icon}{@html iconByName(entry.icon) ?? ''}{/if}</span><span
+ class="t">{entry.title}</span
+ >{#if entry.subtitle}<span class="st">{entry.subtitle}</span>{/if}{#if entry.accessory}<span
+ class="acc">{entry.accessory}</span
+ >{/if}
+ </div>
+ {/each}
+ {:else}
+ <div class="pn">{palette.results.empty}</div>
+ {/each}
+ </div>
+ </div>
+{/if}
diff --git a/thinkterm-web/ui/src/SettingsPanel.svelte b/thinkterm-web/ui/src/SettingsPanel.svelte
new file mode 100644
index 00000000..69bd755f
--- /dev/null
+++ b/thinkterm-web/ui/src/SettingsPanel.svelte
@@ -0,0 +1,255 @@
+<script lang="ts">
+ // The settings panel: the page's own preferences, one row each. The wasm
+ // holds them (thinkterm-web/src/settings.rs) and applies the language and
+ // the font itself; the theme is painted here, and the rest is read by
+ // whatever it concerns.
+ import { s, views } from './client.svelte';
+ import { bot, info, minus, palette, panelLeft, plus, rotateCcw, search, slidersHorizontal, x } from './icons';
+ import { applyTheme, closeSettings, panel, setSetting } from './settings.svelte';
+ import type { Hotkey, Theme } from './model';
+
+ const settings = $derived(views.settings);
+
+ // The window's sections, as the desktop's settings window lists them
+ // on the left; the page has fewer rows, so fewer sections.
+ type Section = 'general' | 'appearance' | 'sidebar' | 'agents' | 'about';
+ const SECTIONS: [Section, string, string][] = [
+ ['general', 'settings-section-general', slidersHorizontal],
+ ['appearance', 'settings-section-appearance', palette],
+ ['sidebar', 'settings-section-sidebar', panelLeft],
+ ['agents', 'settings-section-agents', bot],
+ ['about', 'settings-section-about', info],
+ ];
+ let section = $state<Section>('general');
+ let query = $state('');
+
+ /** A description: its catalogue text, or nothing while the key is missing. */
+ const d = (id: string) => (views.strings[id] === undefined ? '' : views.strings[id]);
+
+ /** Whether a row is on show: its section's, or anywhere when searching. */
+ function shows(where: Section, label: string): boolean {
+ const q = query.trim().toLowerCase();
+ if (q !== '') return label.toLowerCase().includes(q);
+ return section === where;
+ }
+
+ function step(by: number) {
+ pin(Math.round((pt + by) * 2) / 2);
+ }
+ const font = $derived(settings.font);
+ const pinned = $derived(font.mode === 'pinned');
+
+ const THEMES: [Theme, string][] = [
+ ['dark', 'web-theme-dark'],
+ ['light', 'web-theme-light'],
+ ['system', 'web-theme-system'],
+ ];
+ // The shortcuts as they are pressed, not as they are stored.
+ const HOTKEYS: [Hotkey, string][] = [
+ ['cmd-k', '⌘K'],
+ ['cmd-shift-p', '⌘⇧P'],
+ ['ctrl-shift-p', 'Ctrl+Shift+P'],
+ ];
+
+ // The theme is the page's to paint, whether the panel is open or not.
+ $effect(() => applyTheme(settings.theme));
+
+ // The size the "Fixed size" field offers: the pinned one, else the size
+ // the terminal is drawn at now, so choosing "Fixed size" pins what is
+ // already on screen rather than a number out of nowhere.
+ let pt = $state(12);
+ $effect(() => {
+ if (!panel.open) return;
+ const current = settings.font;
+ if (current.mode === 'pinned') {
+ pt = current.pt;
+ return;
+ }
+ try {
+ const layout = JSON.parse((document.getElementById('term') as HTMLCanvasElement | null)?.dataset.layout || '{}');
+ if (Number.isFinite(layout.font_pt) && layout.font_pt > 0) pt = layout.font_pt;
+ } catch {
+ // Before the first frame there is no layout; the default stands.
+ }
+ });
+
+ function pin(size: number) {
+ pt = Math.min(72, Math.max(6, Number.isFinite(size) ? size : 12));
+ setSetting('font', { mode: 'pinned', pt });
+ }
+
+ function onSize(ev: Event) {
+ const field = ev.currentTarget;
+ if (field instanceof HTMLInputElement) pin(Number(field.value));
+ }
+
+ function onLanguage(ev: Event) {
+ const field = ev.currentTarget;
+ if (field instanceof HTMLSelectElement) setSetting('language', field.value);
+ }
+
+ function onHotkey(ev: Event) {
+ const field = ev.currentTarget;
+ if (field instanceof HTMLSelectElement) setSetting('palette-hotkey', field.value);
+ }
+
+ function onFlag(key: string, ev: Event) {
+ const field = ev.currentTarget;
+ if (field instanceof HTMLInputElement) setSetting(key, field.checked);
+ }
+
+ /** The sidebar's width is this browser's, kept under the Sidebar's own
+ key; the reset puts the panel and the key back to the default. */
+ function resetSidebar() {
+ document.documentElement.style.setProperty('--side-w', '220px');
+ document.documentElement.style.setProperty('--side-px', '220px');
+ try {
+ localStorage.setItem('thinkterm.sidebar', '220');
+ } catch {
+ // A browser that blocks storage keeps it for this load only.
+ }
+ setSetting('sidebar-width', 220);
+ }
+
+ // The locale the language preference actually came to, and where the
+ // page is served from. Re-read when the language changes.
+ const about = $derived.by(() => {
+ void settings.language;
+ const locale = document.documentElement.lang;
+ return locale ? `${locale} · ${location.host}` : location.host;
+ });
+
+ // The panel takes the keyboard while it is up, so nothing typed into it
+ // reaches the terminal; closing hands focus back.
+ function onKeydown(ev: KeyboardEvent) {
+ ev.stopPropagation();
+ if (ev.key !== 'Escape') return;
+ ev.preventDefault();
+ closeSettings();
+ }
+
+ function focusHere(node: HTMLDivElement) {
+ node.focus({ preventScroll: true });
+ }
+</script>
+
+<!-- The desktop's settings window: sections on the left, the section's
+ cards on the right, a search field that finds a row wherever it is. -->
+<!-- svelte-ignore a11y_click_events_have_key_events -->
+<!-- svelte-ignore a11y_no_static_element_interactions -->
+{#if panel.open}
+ <div id="settings-back" onpointerdown={closeSettings}></div>
+ <div id="settings" role="dialog" aria-modal="true" tabindex="-1" onkeydown={onKeydown} use:focusHere>
+ <button class="sc" type="button" title={s('web-settings-close')} onclick={closeSettings}>{@html x}</button>
+ <div class="snav">
+ <div class="app">ThinkTerm</div>
+ <label class="find">{@html search}<input placeholder={s('web-settings-search')} bind:value={query} spellcheck="false" /></label>
+ <div class="secs">
+ {#each SECTIONS as [id, label, icon] (id)}
+ <div class="sec" class:on={query.trim() === '' && section === id} data-section={id} onclick={() => { section = id; query = ''; }}>{@html icon}<span>{s(label)}</span></div>
+ {/each}
+ </div>
+ </div>
+ <div class="body">
+ <div class="title">{query.trim() === '' ? s(SECTIONS.find(([id]) => id === section)?.[1] ?? '') : s('web-settings-search')}</div>
+
+ {#if shows('general', s('settings-language')) || shows('general', s('web-settings-palette-hotkey'))}
+ <div class="card">
+ {#if shows('general', s('settings-language'))}
+ <div class="srow">
+ <div class="tx"><div class="lab">{s('settings-language')}</div><div class="desc">{d('web-settings-language-description')}</div></div>
+ <select class="pillsel" data-setting="language" value={settings.language} onchange={onLanguage}>
+ {#each panel.languages as option (option.preference)}
+ <option value={option.preference}>{option.label}</option>
+ {:else}
+ <option value="system">{s('language-system')}</option>
+ {/each}
+ </select>
+ </div>
+ {/if}
+ {#if shows('general', s('web-settings-palette-hotkey'))}
+ <div class="srow">
+ <div class="tx"><div class="lab">{s('web-settings-palette-hotkey')}</div><div class="desc">{d('web-settings-hotkey-description')}</div></div>
+ <select class="pillsel" data-setting="palette-hotkey" value={settings['palette-hotkey']} onchange={onHotkey}>
+ {#each HOTKEYS as [value, label] (value)}
+ <option value={value}>{label}</option>
+ {/each}
+ </select>
+ </div>
+ {/if}
+ </div>
+ {/if}
+
+ {#if shows('appearance', s('web-settings-theme')) || shows('appearance', s('web-settings-font'))}
+ <div class="card">
+ {#if shows('appearance', s('web-settings-theme'))}
+ <div class="srow">
+ <div class="tx"><div class="lab">{s('web-settings-theme')}</div><div class="desc">{d('web-settings-theme-description')}</div></div>
+ <select class="pillsel" data-setting="theme" value={settings.theme} onchange={(ev) => setSetting('theme', (ev.currentTarget as HTMLSelectElement).value)}>
+ {#each THEMES as [value, label] (value)}
+ <option value={value}>{s(label)}</option>
+ {/each}
+ </select>
+ </div>
+ {/if}
+ {#if shows('appearance', s('web-settings-font'))}
+ <div class="srow">
+ <div class="tx"><div class="lab">{s('web-settings-font')}</div><div class="desc">{d('web-settings-font-description')}</div></div>
+ <div class="ctl">
+ <span class="seg">
+ <label class="sg" class:on={!pinned}><input type="radio" name="font" data-font="follow" checked={!pinned} onchange={() => setSetting('font', { mode: 'follow' })} />{s('web-font-follow')}</label>
+ <label class="sg" class:on={pinned}><input type="radio" name="font" data-font="pinned" checked={pinned} onchange={() => pin(pt)} />{s('web-font-pinned')}</label>
+ </span>
+ <button class="reset" type="button" title={s('web-cmd-font-reset')} disabled={!pinned} onclick={() => pin(12)}>{@html rotateCcw}</button>
+ <span class="stepper" class:off={!pinned}>
+ <button type="button" disabled={!pinned} onclick={() => step(-0.5)}>{@html minus}</button>
+ <input class="num" type="number" min="6" max="72" step="0.5" value={pt} disabled={!pinned} onchange={onSize} />
+ <button type="button" disabled={!pinned} onclick={() => step(0.5)}>{@html plus}</button>
+ </span>
+ </div>
+ </div>
+ {/if}
+ </div>
+ {/if}
+
+ {#if shows('sidebar', s('web-settings-hover-reveal')) || shows('sidebar', s('web-settings-sidebar-reset'))}
+ <div class="card">
+ {#if shows('sidebar', s('web-settings-hover-reveal'))}
+ <div class="srow">
+ <div class="tx"><div class="lab">{s('web-settings-hover-reveal')}</div><div class="desc">{d('web-settings-hover-reveal-description')}</div></div>
+ <label class="switch"><input type="checkbox" data-setting="hover-reveal" checked={settings['hover-reveal']} onchange={(ev) => onFlag('hover-reveal', ev)} /><span class="knob"></span></label>
+ </div>
+ {/if}
+ {#if shows('sidebar', s('web-settings-sidebar-reset'))}
+ <div class="srow">
+ <div class="tx"><div class="lab">{s('web-settings-sidebar-reset')}</div><div class="desc">{d('web-settings-sidebar-reset-description')}</div></div>
+ <button class="pillbtn" type="button" data-action="reset-sidebar" onclick={resetSidebar}>{s('common-reset')}</button>
+ </div>
+ {/if}
+ </div>
+ {/if}
+
+ {#if shows('agents', s('web-settings-agents-panel'))}
+ <div class="card">
+ <div class="srow">
+ <div class="tx"><div class="lab">{s('web-settings-agents-panel')}</div><div class="desc">{d('web-settings-agents-panel-description')}</div></div>
+ <label class="switch"><input type="checkbox" data-setting="agents-panel" checked={settings['agents-panel']} onchange={(ev) => onFlag('agents-panel', ev)} /><span class="knob"></span></label>
+ </div>
+ </div>
+ {/if}
+
+ {#if shows('about', s('settings-section-about'))}
+ <div class="card">
+ <div class="srow">
+ <div class="tx"><div class="lab">{s('settings-section-about')}</div><div class="desc">{about}</div></div>
+ </div>
+ <div class="srow">
+ <div class="tx"><div class="lab">{s('web-settings-build')}</div><div class="desc">{import.meta.env.MODE}</div></div>
+ </div>
+ </div>
+ {/if}
+
+ {#if panel.error !== ''}<div class="err">{panel.error}</div>{/if}
+ </div>
+ </div>
+{/if}
diff --git a/thinkterm-web/ui/src/Sidebar.svelte b/thinkterm-web/ui/src/Sidebar.svelte
new file mode 100644
index 00000000..caf6cede
--- /dev/null
+++ b/thinkterm-web/ui/src/Sidebar.svelte
@@ -0,0 +1,389 @@
+<script lang="ts">
+ // The desktop's left panel: Spaces, Projects and Threads, plus the
+ // windows that belong to no thread. What `sidebar::html` drew, from the
+ // rows the wasm publishes; the clicks and the inline name go back to it.
+ import { s, views, sideClick, sideKey } from './client.svelte';
+ import {
+ archive, archiveRestore, chevronDown, chevronRight, circleAlert, circleCheck, circlePlus,
+ bell, ellipsis, folder, folderOpen, folderPlus, layers, loaderCircle, pin, pinOff, plus,
+ trash2,
+ } from './icons';
+ import { menu, openMenu } from './menu.svelte';
+ import { search as searchIcon, settings as settingsIcon } from './icons';
+ import { openPalette } from './palette.svelte';
+ import { openSettings } from './settings.svelte';
+ import { mobile, openSide } from './mobile.svelte';
+ import { palette } from './palette.svelte';
+ import { followSpace, panel } from './settings.svelte';
+ import type { SideRow } from './model';
+
+ const rows = $derived(views.sidebar.rows);
+ const editing = $derived(views.sidebar.editing);
+ const editingThread = (id: string) => editing.kind === 'thread' && editing.id === id;
+ const editingProject = (id: string) => editing.kind === 'project' && editing.id === id;
+ const editingSpace = (id: string) => editing.kind === 'space' && editing.id === id;
+
+ // The Space on show is this browser's; the next load opens on it, and
+ // this is where that load asks for it back.
+ $effect(() => {
+ const space = views.sidebar.space;
+ if (space) followSpace(space);
+ });
+
+ // One row is one element, so a re-listing keeps the DOM it already has --
+ // which is what lets the name being typed into a row survive it.
+ function key(row: SideRow): string {
+ switch (row.kind) {
+ case 'space': return `s:${row.id}`;
+ case 'thread': return `t:${row.id}`;
+ case 'project': return `p:${row.id}`;
+ case 'window': return `w:${row.id}`;
+ default: return row.kind;
+ }
+ }
+
+ /** The field is opened to be typed in, over a name that is being replaced. */
+ function typeHere(node: HTMLInputElement) {
+ node.focus();
+ node.select();
+ }
+
+ // What a click landed on, as `sidebar::Sidebar::click_target` read it: the
+ // nearest element carrying one of the four marks. A click on a row's text
+ // or dot is the row; the small buttons and the headers' actions are their
+ // own.
+ function onClick(ev: MouseEvent) {
+ const target = ev.target;
+ if (!(target instanceof Element)) return;
+ const hit = target.closest('[data-action],[data-thread],[data-window],[data-project]');
+ if (!hit) return;
+ const thread = hit.getAttribute('data-thread');
+ const project = hit.getAttribute('data-project');
+ const action = hit.getAttribute('data-action');
+ let handled = false;
+ switch (action) {
+ // The footer's two: the page's own panels, not the model's.
+ case 'settings': openSettings(); handled = true; break;
+ case 'search': openPalette('threads'); handled = true; break;
+ case 'new-thread': handled = sideClick('new-thread', project); break;
+ case 'new-project': handled = sideClick('new-project'); break;
+ case 'archived': handled = sideClick('toggle-archived'); break;
+ case 'pin': handled = sideClick('pin', thread, true); break;
+ case 'unpin': handled = sideClick('pin', thread, false); break;
+ case 'delete': handled = sideClick('delete', thread); break;
+ case 'archive': handled = sideClick('archive', project); break;
+ case 'unarchive': handled = sideClick('unarchive', project); break;
+ // Anchored under the button, as the view options are: the Spaces
+ // are a list to pick from, not a menu for a point.
+ case 'space-menu': {
+ const box = hit.getBoundingClientRect();
+ openMenu('space', '', box.left, box.bottom + 4);
+ handled = true;
+ break;
+ }
+ case 'notifications': {
+ const box = hit.getBoundingClientRect();
+ openMenu('notifications', '', box.left, box.bottom + 4);
+ handled = true;
+ break;
+ }
+ // The panel's own: what it shows is the page's, not the server's,
+ // so the menu is anchored under the button rather than at a point.
+ case 'sidebar-options': {
+ const box = hit.getBoundingClientRect();
+ openMenu('sidebar-options', '', box.left, box.bottom + 4);
+ handled = true;
+ break;
+ }
+ // A single click on a name is the row; renaming is a double click.
+ case 'rename-thread': handled = sideClick(ev.detail >= 2 ? 'rename-thread' : 'thread', thread); break;
+ case 'rename-project': handled = sideClick(ev.detail >= 2 ? 'rename-project' : 'toggle-project', project); break;
+ case null:
+ if (thread !== null) handled = sideClick('thread', thread);
+ else if (hit.hasAttribute('data-window')) handled = sideClick('window', hit.getAttribute('data-window'));
+ else handled = sideClick('toggle-project', project);
+ break;
+ }
+ if (handled) ev.preventDefault();
+ // On a phone the panel is a drawer over the canvas: picking a terminal
+ // is what it was opened for, so it goes away again.
+ if (handled && mobile.on && (thread !== null || hit.hasAttribute('data-window'))) openSide(false);
+ }
+
+ // A press on a row is that row's menu: a thread's, a project's, or an
+ // archived project's, which is a different list.
+ function onMenu(ev: MouseEvent) {
+ const target = ev.target;
+ if (!(target instanceof Element)) return;
+ const row = target.closest('.row.thread[data-thread],.row.project[data-project]');
+ if (!row) return;
+ ev.preventDefault();
+ const thread = row.getAttribute('data-thread');
+ if (thread !== null) {
+ openMenu('thread', thread, ev.clientX, ev.clientY);
+ return;
+ }
+ const project = row.getAttribute('data-project');
+ if (project !== null) {
+ openMenu(row.classList.contains('archived') ? 'archived-project' : 'project', project, ev.clientX, ev.clientY);
+ }
+ }
+
+ // Enter commits the name, Escape drops it; nothing typed in here reaches
+ // the terminal's keyboard field.
+ function onKeydown(ev: KeyboardEvent) {
+ ev.stopPropagation();
+ const input = ev.target;
+ if (!(input instanceof HTMLInputElement)) return;
+ if (ev.key === 'Enter' || ev.key === 'Escape') {
+ ev.preventDefault();
+ sideKey(ev.key, input.value);
+ }
+ }
+
+ // The panel's width: a preference of this browser's, within the desktop's
+ // bounds (sidebar::MIN_WIDTH..MAX_WIDTH).
+ const STORE = 'thinkterm.sidebar';
+ const MIN = 127;
+ const MAX = 260;
+ const DEFAULT = 220;
+ let width = DEFAULT;
+
+ function setWidth(px: number): number {
+ const w = Math.round(Math.min(MAX, Math.max(MIN, px)));
+ document.documentElement.style.setProperty('--side-w', `${w}px`);
+ // What the panel is worth when it is put away: `--side-w` goes to 0
+ // there, and the hover reveal paints at this instead.
+ document.documentElement.style.setProperty('--side-px', `${w}px`);
+ return w;
+ }
+
+ $effect(() => {
+ let stored: number | null = null;
+ try {
+ const raw = localStorage.getItem(STORE);
+ if (raw !== null && raw !== '' && Number.isFinite(Number(raw))) stored = Number(raw);
+ } catch {
+ // A browser that blocks storage keeps the default; not worth a remark.
+ }
+ width = setWidth(stored ?? DEFAULT);
+ });
+
+
+ // The hover reveal: with the panel put away, the window's left edge and
+ // the tab row's toggle bring it back as an overlay over the canvas.
+ // Nothing is resized -- `--side-w` stays 0 -- so this is the panel's own
+ // display state and nothing else's.
+ /** How far into the window the edge trigger reaches, in client px. */
+ const EDGE = 6;
+ const REVEAL_DELAY = 150;
+ const RETREAT_DELAY = 250;
+ let revealed = $state(false);
+ let revealTimer: ReturnType<typeof setTimeout> | null = null;
+ let retreatTimer: ReturnType<typeof setTimeout> | null = null;
+
+ /** Something the reveal would land under, or fight with, is up. */
+ function suppressed(): boolean {
+ return menu.items.length > 0 || palette.open || panel.open || views.sidebar.editing.kind !== 'none';
+ }
+
+ function collapsed(): boolean {
+ return document.body.dataset.side === 'off';
+ }
+
+ function armed(): boolean {
+ return collapsed() && views.settings['hover-reveal'] && !suppressed();
+ }
+
+ function cancelReveal() {
+ if (revealTimer === null) return;
+ clearTimeout(revealTimer);
+ revealTimer = null;
+ }
+
+ function cancelRetreat() {
+ if (retreatTimer === null) return;
+ clearTimeout(retreatTimer);
+ retreatTimer = null;
+ }
+
+ function scheduleReveal() {
+ cancelRetreat();
+ if (revealed || revealTimer !== null || !armed()) return;
+ revealTimer = setTimeout(() => {
+ revealTimer = null;
+ if (armed()) revealed = true;
+ }, REVEAL_DELAY);
+ }
+
+ function scheduleRetreat() {
+ cancelReveal();
+ // A menu or a palette opened over the revealed panel keeps it there:
+ // the pointer went to them, not away from it.
+ if (!revealed || retreatTimer !== null || suppressed()) return;
+ retreatTimer = setTimeout(() => {
+ retreatTimer = null;
+ if (!suppressed()) revealed = false;
+ }, RETREAT_DELAY);
+ }
+
+ function hide() {
+ cancelReveal();
+ cancelRetreat();
+ revealed = false;
+ }
+
+ // One cheap test per pointer move: the two triggers, the two places the
+ // pointer may rest, and everything else, which retreats. The panel's own
+ // enter/leave below are what keep it up when the pointer is inside it
+ // without moving.
+ function onWindowPointerMove(ev: PointerEvent) {
+ if (!collapsed() || !views.settings['hover-reveal']) {
+ if (revealed) hide();
+ return;
+ }
+ const target = ev.target instanceof Element ? ev.target : null;
+ if (target?.closest('#side')) {
+ cancelRetreat();
+ return;
+ }
+ if (target?.closest('[data-action=sidebar]') || ev.clientX <= EDGE) {
+ scheduleReveal();
+ return;
+ }
+ if (revealed) scheduleRetreat();
+ else cancelReveal();
+ }
+
+ // A press on the toggle pins the panel open the ordinary way; the reveal
+ // is then over, whichever way that press went.
+ function onWindowClick(ev: MouseEvent) {
+ const target = ev.target;
+ if (target instanceof Element && target.closest('[data-action=sidebar]')) hide();
+ }
+
+ $effect(() => {
+ window.addEventListener('pointermove', onWindowPointerMove);
+ window.addEventListener('click', onWindowClick);
+ return () => {
+ window.removeEventListener('pointermove', onWindowPointerMove);
+ window.removeEventListener('click', onWindowClick);
+ cancelReveal();
+ cancelRetreat();
+ };
+ });
+
+ let dragging = false;
+ /** The canvas whose box is held still for the drag, so it resizes once. */
+ let frozen: HTMLCanvasElement | null = null;
+
+ function onPointerDown(ev: PointerEvent) {
+ const target = ev.target;
+ if (!(target instanceof HTMLElement) || !target.classList.contains('handle')) return;
+ ev.preventDefault();
+ dragging = true;
+ try {
+ target.setPointerCapture(ev.pointerId);
+ } catch {
+ // Without capture the drag still follows the pointer over the panel.
+ }
+ // The terminal is resized from the canvas's box, so a drag that moved it
+ // resized the whole grid on every frame -- which is what flickered. Its
+ // size is pinned for the drag; only its left edge moves, and the one
+ // real resize happens on release.
+ const canvas = document.getElementById('term');
+ if (canvas instanceof HTMLCanvasElement) {
+ const box = canvas.getBoundingClientRect();
+ canvas.style.width = `${box.width}px`;
+ canvas.style.height = `${box.height}px`;
+ frozen = canvas;
+ }
+ }
+
+ function onPointerMove(ev: PointerEvent) {
+ if (dragging) width = setWidth(ev.clientX);
+ }
+
+ function onPointerUp() {
+ if (!dragging) return;
+ dragging = false;
+ try {
+ localStorage.setItem(STORE, String(width));
+ } catch {
+ // As above: the width is then this page load's only.
+ }
+ if (frozen) {
+ frozen.style.width = '';
+ frozen.style.height = '';
+ frozen = null;
+ }
+ }
+</script>
+
+<!-- The panel is one delegated handler, as the wasm had it; its children
+ are the rows and their buttons, not the container. -->
+<!-- svelte-ignore a11y_click_events_have_key_events -->
+<!-- svelte-ignore a11y_no_static_element_interactions -->
+<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
+<aside
+ id="side"
+ class:revealed
+ class:open={mobile.on && mobile.side}
+ data-rows={JSON.stringify(rows)}
+ onclick={onClick}
+ oncontextmenu={onMenu}
+ onkeydown={onKeydown}
+ onpointerdown={onPointerDown}
+ onpointermove={onPointerMove}
+ onpointerup={onPointerUp}
+ onpointercancel={onPointerUp}
+ onpointerenter={cancelRetreat}
+ onpointerleave={scheduleRetreat}
+>
+ <div class="handle"></div>
+ <div class="list">
+ {#each rows as row (key(row))}
+ {#if row.kind === 'space'}
+ <div class="row space">{@html layers}{#if editingSpace(row.id)}<input class="rename" value={row.name} spellcheck="false" use:typeHere>{:else}<span class="t">{row.name}</span>{/if}<span class="act" data-action="space-menu" title={s('web-tip-space')}>{@html ellipsis}</span></div>
+ {:else if row.kind === 'new-thread'}
+ <div class="top"><div class="pill" data-action="new-thread" title={s('web-tip-new-thread')}>{@html circlePlus}<span>{s('sidebar-new-thread')}</span></div><span class="act round" data-action="notifications" title={s('tooltip-sidebar-notifications')}>{@html bell}</span></div>
+ {:else if row.kind === 'pinned'}
+ <div class="hdr">{@html pin}<span>{s('sidebar-pinned')}</span></div>
+ {:else if row.kind === 'workspaces'}
+ <div class="hdr"><span>{s('sidebar-workspaces')}</span><span class="act round" data-action="new-project" title={s('web-tip-new-project')}>{@html folderPlus}</span></div>
+ {#if editing.kind === 'new-project'}
+ <div class="path"><input placeholder={s('web-path-placeholder')} spellcheck="false" use:typeHere></div>
+ {/if}
+ {:else if row.kind === 'project' && row.archived}
+ <div class="row project archived" data-project={row.id} title={row.path}>{@html archive}<span class="t">{row.name}</span><span class="hov"><span class="act" data-action="unarchive" data-project={row.id} title={s('web-tip-restore')}>{@html archiveRestore}</span></span></div>
+ {:else if row.kind === 'project'}
+ <div class="row project" data-project={row.id} title={row.path}><span class="chev">{@html row.collapsed ? chevronRight : chevronDown}</span>{@html row.collapsed ? folder : folderOpen}{#if editingProject(row.id)}<input class="rename" value={row.name} spellcheck="false" use:typeHere>{:else}<span class="t" data-action="rename-project" data-project={row.id}>{row.name}</span>{/if}<span class="hov"><span class="act" data-action="archive" data-project={row.id} title={s('web-tip-archive')}>{@html archive}</span></span><span class="act round" data-action="new-thread" data-project={row.id} title={s('web-tip-new-thread-here')}>{@html plus}</span></div>
+ {:else if row.kind === 'thread'}
+ <div class="row thread" class:selected={row.selected} data-thread={row.id}>{#if row.status === 'Running'}<span class="st spin">{@html loaderCircle}</span>{:else if row.status === 'NeedsAttention'}<span class="st alert">{@html circleAlert}</span>{:else if row.status === 'Done'}<span class="st done">{@html circleCheck}</span>{:else}<span class="st dot {row.dot.toLowerCase()}"></span>{/if}{#if editingThread(row.id)}<input class="rename" value={row.name} spellcheck="false" use:typeHere>{:else}<span class="t" data-action="rename-thread" data-thread={row.id}>{row.name}</span>{/if}<span class="hov"><span
+ class="act"
+ data-action={row.pinned ? 'unpin' : 'pin'}
+ data-thread={row.id}
+ title={row.pinned ? s('web-tip-unpin') : s('web-tip-pin')}
+ >{@html row.pinned ? pinOff : pin}</span><span
+ class="act"
+ class:danger={row.deleting}
+ data-action="delete"
+ data-thread={row.id}
+ title={s('web-tip-delete-thread')}
+ >{#if row.deleting}{s('web-confirm-delete')}{:else}{@html trash2}{/if}</span></span></div>
+ {:else if row.kind === 'archived'}
+ <div class="hdr sub" data-action="archived"><span class="chev">{@html row.open ? chevronDown : chevronRight}</span>{@html archive}<span>{row.label}</span></div>
+ {:else if row.kind === 'others'}
+ <div class="hdr"><span>{s('web-sidebar-other-windows')}</span></div>
+ {:else if row.kind === 'window'}
+ <div class="row thread" class:selected={row.selected} data-window={row.id}><span class="st dot {row.selected ? 'active' : 'open'}"></span><span class="t">{row.title}</span></div>
+ {/if}
+ {/each}
+ </div>
+ <!-- The footer, as the desktop's sidebar ends: Settings on the left,
+ the thread search on the right. -->
+ <div class="foot">
+ <span class="act" data-action="settings" title={s('tooltip-sidebar-settings')}>{@html settingsIcon}</span>
+ <span class="act" data-action="search" title={s('tooltip-sidebar-thread-search')}>{@html searchIcon}</span>
+ </div>
+</aside>
diff --git a/thinkterm-web/ui/src/Status.svelte b/thinkterm-web/ui/src/Status.svelte
new file mode 100644
index 00000000..0728e8d3
--- /dev/null
+++ b/thinkterm-web/ui/src/Status.svelte
@@ -0,0 +1,33 @@
+<script lang="ts">
+ // A passing remark, bottom right, gone after a few seconds; it stays
+ // while the connection is down, which is not a remark but the state.
+ // Before the client exists it carries the boot's progress instead, which
+ // is where the probes (?check=…) leave their one-line result.
+ import { views } from './client.svelte';
+
+ const LIFE = 4000;
+
+ const toast = $derived(views.status.toast);
+ // Only moves when a toast's life runs out; reading it is what makes the
+ // text below go away on its own.
+ let now = $state(performance.now());
+ $effect(() => {
+ const t = toast;
+ if (!t || t.sticky) return;
+ const left = t.at + LIFE - performance.now();
+ if (left <= 0) {
+ now = performance.now();
+ return;
+ }
+ const timer = setTimeout(() => { now = performance.now(); }, left);
+ return () => clearTimeout(timer);
+ });
+
+ const text = $derived.by(() => {
+ if (!views.ready) return views.boot;
+ if (!toast) return '';
+ return toast.sticky || now < toast.at + LIFE ? toast.text : '';
+ });
+</script>
+
+<div id="status" hidden={text === ''} class:error={views.bootFailed} data-summary={views.status.summary}>{text}</div>
diff --git a/thinkterm-web/ui/src/TabRow.svelte b/thinkterm-web/ui/src/TabRow.svelte
new file mode 100644
index 00000000..9a29734f
--- /dev/null
+++ b/thinkterm-web/ui/src/TabRow.svelte
@@ -0,0 +1,53 @@
+<script lang="ts">
+ // The window's tab row: the sidebar toggle, a capsule per tab of this
+ // window, the new-tab button, and the hint that the tab is fitted to
+ // this window. What `chrome::TabStrip::render` drew.
+ import { onChromeClick } from './chrome';
+ import { s, views } from './client.svelte';
+ import { panelLeft, panelRight, plus, squareTerminal, x } from './icons';
+ import { openMenu } from './menu.svelte';
+ import { short } from './title';
+
+ const tabs = $derived(views.tabs?.tabs ?? []);
+ const controls = $derived(views.tabs?.controls ?? null);
+
+ // A press on a capsule -- its close button included -- is that tab's.
+ function onMenu(ev: MouseEvent) {
+ const target = ev.target;
+ if (!(target instanceof Element)) return;
+ const tab = target.closest('.tab')?.getAttribute('data-tab');
+ if (tab === null || tab === undefined) return;
+ ev.preventDefault();
+ openMenu('tab', tab, ev.clientX, ev.clientY);
+ }
+</script>
+
+<!-- The row is one delegated handler, as the wasm had it; its children
+ are the controls, not the container. -->
+<!-- svelte-ignore a11y_click_events_have_key_events -->
+<!-- svelte-ignore a11y_no_static_element_interactions -->
+<div id="tabs" onclick={onChromeClick} oncontextmenu={onMenu}>
+ <span class="act" data-action="sidebar" title={s('web-tip-sidebar')}>{@html panelLeft}</span>
+ {#each tabs as tab (tab.tab)}
+ <span class="tab" class:current={tab.current} data-pane={tab.target} data-tab={tab.tab} title={tab.title}>
+ {@html squareTerminal}<span class="t">{short(tab.label)}</span><span
+ class="x"
+ class:danger={controls?.closing === tab.tab}
+ data-action="close-tab"
+ data-tab={tab.tab}
+ title={s('web-tip-close-tab')}
+ >{#if controls?.closing === tab.tab}{s('web-confirm-close')}{:else}{@html x}{/if}</span>
+ </span>
+ {/each}
+ <span class="act" data-action="new-tab" title={s('web-tip-new-tab')}>{@html plus}</span>
+ <!-- The row's right end, as the desktop's tab bar has it: the hint that
+ the tab is fitted to this window, then the right panel's toggle. -->
+ <span class="trail">
+ {#if controls?.fit}<span class="hint" title={s('web-tip-fitted')}>{s('web-fitted')}</span>{/if}
+ <span
+ class="act"
+ class:on={views.settings['agents-panel']}
+ data-action="agents"
+ title={s('web-tip-agents')}>{@html panelRight}</span>
+ </span>
+</div>
diff --git a/thinkterm-web/ui/src/chrome.ts b/thinkterm-web/ui/src/chrome.ts
new file mode 100644
index 00000000..4eb97c39
--- /dev/null
+++ b/thinkterm-web/ui/src/chrome.ts
@@ -0,0 +1,73 @@
+// What a click on the chrome meant, as `chrome::TabStrip::click_target`
+// read it: the nearest element that carries one of the three marks, and
+// the bar it sits in for the buttons that act on a bar's pane.
+
+import { chromeClick, views } from './client.svelte';
+import { mobile, openSide } from './mobile.svelte';
+import { openPalette } from './palette.svelte';
+import { openSettings, setSetting } from './settings.svelte';
+
+/** Show or hide the sidebar. The page's own: nothing the wasm shows
+ depends on it, and the canvas's observer resizes the terminal when its
+ box moves. Also what the palette's Toggle Sidebar comes to.
+
+ On a phone there is no room beside the canvas, so the panel is a drawer
+ over it and this is what puts it out and away; nothing is resized, and
+ `body[data-side]` -- which is what makes room -- stays off it. */
+export function toggleSidebar() {
+ if (mobile.on) {
+ openSide(!mobile.side);
+ return;
+ }
+ const off = document.body.dataset.side === 'off';
+ if (off) delete document.body.dataset.side; else document.body.dataset.side = 'off';
+ document.getElementById('kbd')?.focus();
+}
+
+function id(el: Element | null, attr: string): number | null {
+ const raw = el?.getAttribute(attr);
+ if (raw === null || raw === undefined) return null;
+ const n = Number(raw);
+ return Number.isSafeInteger(n) && n >= 0 ? n : null;
+}
+
+export function onChromeClick(ev: MouseEvent) {
+ const target = ev.target;
+ if (!(target instanceof Element)) return;
+ const hit = target.closest('[data-pane],[data-follow],[data-action]');
+ if (!hit) return;
+ let handled = false;
+ const action = hit.hasAttribute('data-follow') ? 'follow' : hit.getAttribute('data-action');
+ if (action === null) {
+ const pane = id(hit, 'data-pane');
+ handled = pane !== null && chromeClick('pane', pane);
+ } else if (action === 'close-pane') {
+ const pane = id(hit, 'data-pane');
+ handled = pane !== null && chromeClick('close-pane', pane);
+ } else if (action === 'close-tab') {
+ const tab = id(hit, 'data-tab');
+ handled = tab !== null && chromeClick('close-tab', null, tab);
+ } else if (action === 'sidebar') {
+ toggleSidebar();
+ handled = true;
+ } else if (action === 'search') {
+ // The page's own, as the sidebar toggle is: the palette and the
+ // settings panel are drawn here, not by the wasm.
+ openPalette();
+ handled = true;
+ } else if (action === 'settings') {
+ openSettings();
+ handled = true;
+ } else if (action === 'agents') {
+ // Also the page's own: the panel is drawn here, and whether it is on
+ // is a preference the wasm keeps.
+ setSetting('agents-panel', !views.settings['agents-panel']);
+ handled = true;
+ } else if (action === 'split-right' || action === 'split-below' || action === 'zoom') {
+ // A bar's buttons act on the bar's pane, whichever is focused.
+ handled = chromeClick(action, id(hit.closest('[data-nav]'), 'data-nav'));
+ } else {
+ handled = chromeClick(action);
+ }
+ if (handled) ev.preventDefault();
+}
diff --git a/thinkterm-web/ui/src/client.svelte.ts b/thinkterm-web/ui/src/client.svelte.ts
new file mode 100644
index 00000000..89b4bc64
--- /dev/null
+++ b/thinkterm-web/ui/src/client.svelte.ts
@@ -0,0 +1,157 @@
+// What the chrome draws: the wasm's views, re-read whenever it says
+// something changed. The wasm owns the state; this is a copy of what it
+// shows, kept in runes so the components follow it.
+
+import { flushSync } from 'svelte';
+import { handle, type Client } from './client';
+import type { AgentsView, NavsView, SidebarView, StatusView, Strings, TabsView, WebSettings } from './model';
+
+export const views = $state({
+ tabs: null as TabsView | null,
+ navs: [] as NavsView,
+ status: { toast: null, card: null, summary: '' } as StatusView,
+ sidebar: { rows: [], editing: { kind: 'none' }, space: null } as SidebarView,
+ /** The right-hand panel's rows, whether it is on show or not. */
+ agents: { rows: [], summary: '' } as AgentsView,
+ /** The page's own preferences, as the wasm holds them (settings.rs). */
+ settings: {
+ language: 'system',
+ theme: 'dark',
+ font: { mode: 'follow' },
+ 'hover-reveal': true,
+ 'agents-panel': false,
+ 'palette-hotkey': 'cmd-k',
+ 'sidebar-width': 220,
+ } as WebSettings,
+ layout: '',
+ /** The page's own labels in the active language; empty until attached. */
+ strings: {} as Strings,
+ /** What the page says before the client exists: the boot, or its failure. */
+ boot: 'loading…',
+ bootFailed: false,
+ /** The client is attached; the views below are its, not the boot's. */
+ ready: false,
+});
+
+/** A label by catalogue id; the id itself until the client is attached. */
+export function s(id: string): string {
+ return views.strings[id] ?? id;
+}
+
+/** The boot's progress, and the probes' one-line results. */
+export function setBoot(text: string, failed = false) {
+ views.boot = text;
+ views.bootFailed = failed;
+}
+
+/** Re-read every view now. Set by `attach`; a no-op before it. */
+let refresh: () => void = () => {};
+
+/** Follow a client's views. Called once, right after `start()` resolves. */
+export function attach(client: Client) {
+ // The views are re-listed every frame something moved and are mostly the
+ // same string as last time; parsing only what changed keeps the whole
+ // chrome from being diffed for a cursor blink.
+ let lastTabs = '';
+ let lastNavs = '';
+ let lastStatus = '';
+ let lastStrings = '';
+ let lastSidebar = '';
+ let lastAgents = '';
+ let lastSettings = '';
+ const read = () => {
+ const strings = client.strings();
+ if (strings !== lastStrings) {
+ lastStrings = strings;
+ views.strings = JSON.parse(strings) as Strings;
+ }
+ const tabs = client.tabs();
+ if (tabs !== lastTabs) {
+ lastTabs = tabs;
+ views.tabs = JSON.parse(tabs) as TabsView;
+ }
+ const navs = client.navs();
+ if (navs !== lastNavs) {
+ lastNavs = navs;
+ views.navs = JSON.parse(navs) as NavsView;
+ }
+ const status = client.status();
+ if (status !== lastStatus) {
+ lastStatus = status;
+ views.status = JSON.parse(status) as StatusView;
+ }
+ const sidebar = client.sidebar();
+ if (sidebar !== lastSidebar) {
+ lastSidebar = sidebar;
+ views.sidebar = JSON.parse(sidebar) as SidebarView;
+ }
+ const agents = client.agents();
+ if (agents !== lastAgents) {
+ lastAgents = agents;
+ views.agents = JSON.parse(agents) as AgentsView;
+ }
+ const settings = client.settings();
+ if (settings !== lastSettings) {
+ lastSettings = settings;
+ views.settings = JSON.parse(settings) as WebSettings;
+ }
+ views.layout = client.layout();
+ };
+ refresh = read;
+ views.ready = true;
+ // Registering calls it once, so the first frame is the client's.
+ client.on_change(read);
+}
+
+/** Re-read every view and put it on show now, for a caller that went to
+ the wasm itself and wants what it changed drawn before it returns. */
+export function refreshViews() {
+ refresh();
+ flushSync();
+}
+
+/** Switch the interface language; returns the locale it resolved to. */
+export function setLocale(preference: string): string {
+ if (!handle.client) return '';
+ const code = handle.client.set_locale(preference, Array.from(navigator.languages ?? [navigator.language]));
+ refresh();
+ flushSync();
+ return code;
+}
+
+/** A click on the tab row or a pane's bar, delivered to the wasm. */
+export function chromeClick(action: string, pane: number | null = null, tab: number | null = null): boolean {
+ if (!handle.client) return false;
+ const handled = handle.client.chrome_click(action, pane, tab);
+ if (handled) {
+ // What the click changed is on show before the handler returns, as it
+ // was when the wasm wrote the markup itself: the client's own notice
+ // is a frame away, and a two-press close is read back straight after
+ // the press that asked for it.
+ refresh();
+ flushSync();
+ }
+ return handled;
+}
+
+/** A click in the sidebar, delivered to the wasm. */
+export function sideClick(kind: string, id: string | null = null, flag: boolean | null = null): boolean {
+ if (!handle.client) return false;
+ const handled = handle.client.side_click(kind, id, flag);
+ // As for the chrome: what the click changed is on show before the handler
+ // returns, since the client's own notice is a frame away and a two-press
+ // delete is read back straight after the press that asked for it.
+ if (handled) {
+ refresh();
+ flushSync();
+ }
+ return handled;
+}
+
+/** Enter or Escape in the sidebar's inline input, with what was typed. */
+export function sideKey(key: 'Enter' | 'Escape', value: string) {
+ if (!handle.client) return;
+ handle.client.side_key(key, value);
+ refresh();
+ flushSync();
+}
diff --git a/thinkterm-web/ui/src/client.ts b/thinkterm-web/ui/src/client.ts
new file mode 100644
index 00000000..250d98b6
--- /dev/null
+++ b/thinkterm-web/ui/src/client.ts
@@ -0,0 +1,15 @@
+// The handle the wasm client hands back once attached. The chrome reads
+// its views through it; nothing here is set until `start()` resolves.
+import type { Client } from '../../www/pkg/thinkterm_web.js';
+
+export type { Client };
+
+export const handle: { client: Client | null } = { client: null };
+
+// For probes and the smoke tests, which drive the page from outside.
+declare global {
+ interface Window {
+ thinkterm: { client: Client | null };
+ }
+}
+window.thinkterm = handle;
diff --git a/thinkterm-web/ui/src/icons.ts b/thinkterm-web/ui/src/icons.ts
new file mode 100644
index 00000000..57d4e2e3
--- /dev/null
+++ b/thinkterm-web/ui/src/icons.ts
@@ -0,0 +1,170 @@
+// The lucide icons the desktop draws its chrome with, inlined as the wasm
+// inlined them (thinkterm-web/src/icons.rs): the file verbatim, taking its
+// colour from CSS `color` and its size from CSS.
+
+import archive from '../../../third_party/lucide/icons/archive.svg?raw';
+import archiveRestore from '../../../third_party/lucide/icons/archive-restore.svg?raw';
+import bell from '../../../third_party/lucide/icons/bell.svg?raw';
+import info from '../../../third_party/lucide/icons/info.svg?raw';
+import minus from '../../../third_party/lucide/icons/minus.svg?raw';
+import palette from '../../../third_party/lucide/icons/palette.svg?raw';
+import bot from '../../../third_party/lucide/icons/bot.svg?raw';
+import check from '../../../third_party/lucide/icons/check.svg?raw';
+import chevronDown from '../../../third_party/lucide/icons/chevron-down.svg?raw';
+import chevronRight from '../../../third_party/lucide/icons/chevron-right.svg?raw';
+import circleAlert from '../../../third_party/lucide/icons/circle-alert.svg?raw';
+import circleCheck from '../../../third_party/lucide/icons/circle-check.svg?raw';
+import circlePlus from '../../../third_party/lucide/icons/circle-plus.svg?raw';
+import clipboardPaste from '../../../third_party/lucide/icons/clipboard-paste.svg?raw';
+import copy from '../../../third_party/lucide/icons/copy.svg?raw';
+import ellipsis from '../../../third_party/lucide/icons/ellipsis.svg?raw';
+import eye from '../../../third_party/lucide/icons/eye.svg?raw';
+import folder from '../../../third_party/lucide/icons/folder.svg?raw';
+import folderOpen from '../../../third_party/lucide/icons/folder-open.svg?raw';
+import folderPlus from '../../../third_party/lucide/icons/folder-plus.svg?raw';
+import house from '../../../third_party/lucide/icons/house.svg?raw';
+import languages from '../../../third_party/lucide/icons/languages.svg?raw';
+import layers from '../../../third_party/lucide/icons/layers.svg?raw';
+import loaderCircle from '../../../third_party/lucide/icons/loader-circle.svg?raw';
+import mail from '../../../third_party/lucide/icons/mail.svg?raw';
+import maximize2 from '../../../third_party/lucide/icons/maximize-2.svg?raw';
+import minimize2 from '../../../third_party/lucide/icons/minimize-2.svg?raw';
+import panelLeft from '../../../third_party/lucide/icons/panel-left.svg?raw';
+import panelRight from '../../../third_party/lucide/icons/panel-right.svg?raw';
+import pencil from '../../../third_party/lucide/icons/pencil.svg?raw';
+import pin from '../../../third_party/lucide/icons/pin.svg?raw';
+import pinOff from '../../../third_party/lucide/icons/pin-off.svg?raw';
+import plus from '../../../third_party/lucide/icons/plus.svg?raw';
+import rotateCcw from '../../../third_party/lucide/icons/rotate-ccw.svg?raw';
+import search from '../../../third_party/lucide/icons/search.svg?raw';
+import settings from '../../../third_party/lucide/icons/settings.svg?raw';
+import slidersHorizontal from '../../../third_party/lucide/icons/sliders-horizontal.svg?raw';
+import squareSplitHorizontal from '../../../third_party/lucide/icons/square-split-horizontal.svg?raw';
+import squareSplitVertical from '../../../third_party/lucide/icons/square-split-vertical.svg?raw';
+import squareTerminal from '../../../third_party/lucide/icons/square-terminal.svg?raw';
+import trash2 from '../../../third_party/lucide/icons/trash-2.svg?raw';
+import x from '../../../third_party/lucide/icons/x.svg?raw';
+import zoomIn from '../../../third_party/lucide/icons/zoom-in.svg?raw';
+import zoomOut from '../../../third_party/lucide/icons/zoom-out.svg?raw';
+// The two brand marks the Agents panel draws (simple-icons): a single
+// fill-less path, so they take their colour from CSS `fill: currentColor`
+// rather than from `stroke` as the lucide icons above do.
+import brandClaude from '../../../third_party/simple-icons/icons/claude.svg?raw';
+import brandCopilot from '../../../third_party/simple-icons/icons/githubcopilot.svg?raw';
+
+export {
+ archive,
+ archiveRestore,
+ bell,
+ bot,
+ brandClaude,
+ brandCopilot,
+ check,
+ chevronDown,
+ chevronRight,
+ circleAlert,
+ circleCheck,
+ circlePlus,
+ clipboardPaste,
+ copy,
+ ellipsis,
+ eye,
+ folder,
+ folderOpen,
+ folderPlus,
+ house,
+ info,
+ languages,
+ layers,
+ loaderCircle,
+ mail,
+ maximize2,
+ minimize2,
+ minus,
+ palette,
+ panelLeft,
+ panelRight,
+ pencil,
+ pin,
+ pinOff,
+ plus,
+ rotateCcw,
+ search,
+ settings,
+ slidersHorizontal,
+ squareSplitHorizontal,
+ squareSplitVertical,
+ squareTerminal,
+ trash2,
+ x,
+ zoomIn,
+ zoomOut,
+};
+
+// The menus name their icon the way lucide does (thinkterm-web/src/menu.rs),
+// so a row's `icon` is looked up here rather than matched on in the markup.
+const BY_NAME: Record<string, string> = {
+ palette,
+ minus,
+ info,
+ bell,
+ archive,
+ 'archive-restore': archiveRestore,
+ bot,
+ check,
+ 'chevron-down': chevronDown,
+ 'chevron-right': chevronRight,
+ 'circle-alert': circleAlert,
+ 'circle-check': circleCheck,
+ 'circle-plus': circlePlus,
+ 'clipboard-paste': clipboardPaste,
+ copy,
+ ellipsis,
+ eye,
+ folder,
+ 'folder-open': folderOpen,
+ 'folder-plus': folderPlus,
+ house,
+ languages,
+ layers,
+ 'loader-circle': loaderCircle,
+ mail,
+ 'maximize-2': maximize2,
+ 'minimize-2': minimize2,
+ 'panel-left': panelLeft,
+ 'panel-right': panelRight,
+ pencil,
+ pin,
+ 'pin-off': pinOff,
+ plus,
+ 'rotate-ccw': rotateCcw,
+ search,
+ settings,
+ 'sliders-horizontal': slidersHorizontal,
+ 'square-split-horizontal': squareSplitHorizontal,
+ 'square-split-vertical': squareSplitVertical,
+ 'square-terminal': squareTerminal,
+ 'trash-2': trash2,
+ x,
+ 'zoom-in': zoomIn,
+ 'zoom-out': zoomOut,
+};
+
+/** A lucide icon by its name; nothing for a name the page has not inlined. */
+export function iconByName(name: string): string | undefined {
+ return BY_NAME[name];
+}
+
+// An agent row names its mark the way `agents.rs` does: a brand when the
+// page has one, `bot` otherwise. Kept apart from `BY_NAME` above, which is
+// lucide's names and nothing else.
+const AGENT_ICONS: Record<string, string> = {
+ 'brand-claude': brandClaude,
+ 'brand-copilot': brandCopilot,
+ bot,
+};
+
+/** An agent row's icon by its name; the bot for one the page has not inlined. */
+export function agentIcon(name: string): string {
+ return AGENT_ICONS[name] ?? bot;
+}
diff --git a/thinkterm-web/ui/src/main.ts b/thinkterm-web/ui/src/main.ts
new file mode 100644
index 00000000..f357e499
--- /dev/null
+++ b/thinkterm-web/ui/src/main.ts
@@ -0,0 +1,141 @@
+// The page: pick up the token, fetch the fonts, start the wasm client.
+import { flushSync, mount } from 'svelte';
+import App from './App.svelte';
+import { handle } from './client';
+import { attach, setBoot } from './client.svelte';
+import { watchMobile } from './mobile.svelte';
+import { storedPicks, watchHotkey } from './palette.svelte';
+import { applyTheme, storedSettings, storedSpace } from './settings.svelte';
+import type { Theme } from './model';
+import './tokens.css';
+
+// Which shape the page is in -- the desktop's, or the phone's -- before it
+// is drawn, so the first frame is already the right one and the canvas is
+// never sized for a key bar that is about to appear.
+watchMobile();
+// The chrome goes up first and synchronously: #side, #term and #kbd are what
+// the client looks for by id, so none of them may arrive a tick late. The
+// boot's own progress goes through the store, since #status is drawn here.
+mount(App, { target: document.getElementById('app') as HTMLElement });
+flushSync();
+
+// The wasm-bindgen glue is served next to the page, not bundled with it: it
+// resolves its own .wasm from its own URL, so it has to keep that URL. Its
+// types are the ones wasm-bindgen wrote beside it (ci/build-web.sh).
+type Glue = typeof import('../../www/pkg/thinkterm_web.js');
+
+const fail = (msg: string) => { setBoot(msg, true); console.error(msg); };
+
+// The token arrives once in the URL fragment -- never sent to the server,
+// never in a Referer -- and is kept for this tab only; the address bar is
+// cleaned so it is not copied or bookmarked by accident.
+const params = new URLSearchParams(location.search);
+const fragment = new URLSearchParams(location.hash.replace(/^#/, ""));
+// A browser that blocks storage throws on the first touch; the token then
+// lives only in this page load, and the failure is reported, not silent.
+let token = fragment.get("token");
+if (token) {
+ // Out of the address bar first, and outside the try: a browser that
+ // blocks storage throws on setItem, and doing this after it meant the
+ // token stayed in the URL -- visible in the bar, in a screenshot, and in
+ // whatever the user pastes next -- in exactly the case the comment said
+ // it would not.
+ history.replaceState(null, "", location.pathname + location.search);
+}
+try {
+ if (token) {
+ sessionStorage.setItem("thinkterm.token", token);
+ } else {
+ token = sessionStorage.getItem("thinkterm.token");
+ }
+} catch (e) {
+ console.warn("session storage unavailable; the token is kept for this load only", e);
+}
+// What this browser last chose, and the URL's overrides for this load
+// only: `?lang=`, `?theme=` and `?font=` are for a probe or a link, and
+// are never written back.
+const settings = storedSettings();
+const lang = params.get("lang");
+if (lang) settings.language = lang;
+const theme = params.get("theme");
+if (theme === "light" || theme === "dark" || theme === "system") settings.theme = theme;
+const requested = Number(params.get("font"));
+if (Number.isFinite(requested) && requested >= 6 && requested <= 72) settings.font = { mode: "pinned", pt: requested };
+
+// Without a pinned size the page takes the desktop's cell size once
+// attached; 12 is only what it draws with until then.
+const font = settings.font as { mode?: string; pt?: number } | undefined;
+const pinned = font?.mode === "pinned" ? Number(font.pt) : NaN;
+const fontPinned = Number.isFinite(pinned) && pinned >= 6 && pinned <= 72;
+const fontSize = fontPinned ? pinned : 12;
+// The CSS font stack the glyph fallback draws with. This is also how the
+// regional shape of a Han character is chosen; see canvas.rs.
+const glyphFont = params.get("glyphfont") || "";
+// The desktop is dark unless told otherwise; so is the page. Painted here
+// rather than after the client attaches, so the boot is not the wrong
+// colour for as long as the wasm takes to arrive.
+applyTheme(typeof settings.theme === "string" ? (settings.theme as Theme) : "dark");
+// The interface language: the stored preference, else the browser's own
+// list ("system").
+const locale = typeof settings.language === "string" && settings.language !== "" ? settings.language : "system";
+const languages = Array.from(navigator.languages ?? [navigator.language]);
+// The palette's shortcut is watched from here on, whatever the settings
+// name it; before the client attaches it is the default.
+watchHotkey();
+
+const FONTS: [string, string][] = [
+ ["JetBrains Mono", "./fonts/JetBrainsMono-Regular.ttf"],
+ ["Symbols Nerd Font Mono", "./fonts/SymbolsNerdFontMono-Regular.ttf"],
+];
+
+async function fetchFont(url: string): Promise<Uint8Array> {
+ const res = await fetch(url);
+ if (!res.ok) throw new Error(`${url}: ${res.status}`);
+ return new Uint8Array(await res.arrayBuffer());
+}
+
+try {
+ const glueUrl = new URL("pkg/thinkterm_web.js", document.baseURI).href;
+ const mod = await import(/* @vite-ignore */ glueUrl) as Glue;
+ await mod.default();
+ const check = params.get("check");
+ if (check === "fallback") {
+ // Deliberately before the WebGPU check: this one draws on a 2D canvas
+ // and needs no GPU, no token and no pane, which is what lets it run on
+ // Safari, on Firefox, and on a machine with hardly any fonts installed
+ // -- the place the glyph fallback is most likely to fail.
+ const names = FONTS.map(([n]) => n);
+ const data = await Promise.all(FONTS.map(([, u]) => fetchFont(u)));
+ setBoot("FALLBACK " + mod.fallback_check(names, data, fontSize, glyphFont));
+ } else if (!navigator.gpu) {
+ throw new Error("WebGPU is not available: open the page over https or http://localhost in a browser with WebGPU enabled");
+ } else if (check === "color") {
+ setBoot("COLOR " + await mod.color_check("term"));
+ } else if (check === "graphics") {
+ const names = FONTS.map(([n]) => n);
+ const data = await Promise.all(FONTS.map(([, u]) => fetchFont(u)));
+ setBoot("GRAPHICS " + await mod.graphics_check(names, data, fontSize));
+ } else {
+ if (!token) throw new Error("no token: open the URL that `thinkterm cli web-token mint` printed");
+ const names = FONTS.map(([n]) => n);
+ const data = await Promise.all(FONTS.map(([, u]) => fetchFont(u)));
+ const scheme = location.protocol === "https:" ? "wss" : "ws";
+ handle.client = await mod.start("term", "kbd", `${scheme}://${location.host}/ws`, token, names, data, fontSize, glyphFont, fontPinned, locale, languages);
+ // The preferences go over whole: the wasm checks them and applies the
+ // language and the font itself. A refusal is worth a line in the
+ // console, not a failed boot -- the defaults are perfectly usable.
+ const refused = handle.client.apply_settings(JSON.stringify(settings));
+ if (refused !== "") console.warn("stored settings: " + refused);
+ attach(handle.client);
+ // Which locale the preference came to, for the settings panel to name.
+ document.documentElement.lang = handle.client.set_locale(locale, languages);
+ handle.client.set_recent(storedPicks());
+ // The Space this browser was last showing; gone from the server since,
+ // and the sidebar simply stays where it landed.
+ const space = storedSpace();
+ if (space !== "") handle.client.set_space(space);
+ }
+} catch (e) {
+ const err = e as { message?: string } | null;
+ fail(String(err && err.message ? err.message : e));
+}
diff --git a/thinkterm-web/ui/src/menu.svelte.ts b/thinkterm-web/ui/src/menu.svelte.ts
new file mode 100644
index 00000000..3000c87b
--- /dev/null
+++ b/thinkterm-web/ui/src/menu.svelte.ts
@@ -0,0 +1,98 @@
+// The one context menu the page has open: what the wasm offered for what
+// was clicked (thinkterm-web/src/menu.rs), where it was clicked, and how
+// far into its submenus the pointer or the keyboard has gone. The wasm
+// owns what a menu offers and what a row does; this owns only the fact
+// that one is open.
+
+import { handle } from './client';
+import { refreshViews } from './client.svelte';
+import type { MenuItem, MenuOutcome } from './model';
+
+export const menu = $state({
+ /** The root list; empty when no menu is open. */
+ items: [] as MenuItem[],
+ /** Where it was asked for, in client px. */
+ x: 0,
+ y: 0,
+ /** What it was asked for: the wasm's kind and id. */
+ kind: '',
+ id: '',
+ /** The open submenus, as the row's index within each panel. */
+ path: [] as number[],
+ /** The row the keyboard is on, within the innermost panel; -1 for none. */
+ selected: -1,
+});
+
+/** The menu for `kind`/`id` at a point, if the wasm has one to offer. */
+export function openMenu(kind: string, id: string, clientX: number, clientY: number) {
+ if (!handle.client) return;
+ let items: MenuItem[];
+ try {
+ items = JSON.parse(handle.client.context_menu(kind, id)) as MenuItem[];
+ } catch {
+ return;
+ }
+ // Nothing to offer is not an empty menu: the page shows none at all.
+ if (!Array.isArray(items) || items.length === 0) return;
+ menu.items = items;
+ menu.kind = kind;
+ menu.id = id;
+ menu.x = clientX;
+ menu.y = clientY;
+ menu.path = [];
+ menu.selected = -1;
+}
+
+/** Close the whole thing; the keyboard goes back to the terminal. */
+export function closeMenu() {
+ if (menu.items.length === 0) return;
+ menu.items = [];
+ menu.path = [];
+ menu.selected = -1;
+ // The menu took focus off the field the terminal types through, so
+ // closing it has to hand focus back or the next key goes nowhere.
+ document.getElementById('kbd')?.focus();
+}
+
+/** Close the innermost submenu; the whole menu when none is open. */
+export function closeInnermost() {
+ if (menu.path.length === 0) {
+ closeMenu();
+ return;
+ }
+ menu.selected = menu.path[menu.path.length - 1];
+ menu.path = menu.path.slice(0, -1);
+}
+
+/** Do what a row asks, then close. A row that only opens a submenu, one
+ that is disabled, and a header or separator do nothing. */
+export function runItem(item: MenuItem) {
+ if (item.kind !== 'item' || !item.enabled || item.submenu.length > 0 || item.id === '') return;
+ const client = handle.client;
+ if (!client) return;
+ let outcome: MenuOutcome;
+ try {
+ outcome = JSON.parse(client.menu_action(item.id)) as MenuOutcome;
+ } catch {
+ closeMenu();
+ return;
+ }
+ closeMenu();
+ if (!outcome.handled) return;
+ // What the row changed is on show before this returns, as it is for a
+ // click on the chrome: the client's own notice is a frame away.
+ refreshViews();
+ if (typeof outcome.copy === 'string') {
+ // A clipboard the browser refuses is not worth a remark: the
+ // terminal's own Cmd+C still works.
+ navigator.clipboard?.writeText(outcome.copy).catch(() => {});
+ }
+ if (outcome.paste) {
+ navigator.clipboard
+ ?.readText()
+ .then((text) => {
+ if (text) client.paste(text);
+ })
+ .catch(() => {});
+ }
+}
diff --git a/thinkterm-web/ui/src/mobile.svelte.ts b/thinkterm-web/ui/src/mobile.svelte.ts
new file mode 100644
index 00000000..3b94f370
--- /dev/null
+++ b/thinkterm-web/ui/src/mobile.svelte.ts
@@ -0,0 +1,50 @@
+// Whether the page is drawn for a thumb. Termux is the shape this follows:
+// the terminal takes the whole window, the panels become drawers over it,
+// and a key bar supplies what a soft keyboard has not got. Everything the
+// phone shape changes hangs off `body[data-mobile]`, so a desktop browser
+// is served exactly the page it was before.
+
+/** A window narrower than this is the phone shape whatever the pointer is. */
+const NARROW = 720;
+
+/** The key bar's height. The canvas and the drawers leave room for it, and
+ it is what the bar is offset by from the foot of the visual viewport. */
+export const KEYBAR = 44;
+
+export const mobile = $state({
+ /** The page is in its phone shape. */
+ on: false,
+ /** The left panel is out as a drawer. Only read in the phone shape. */
+ side: false,
+});
+
+function paint(on: boolean) {
+ if (mobile.on === on) return;
+ mobile.on = on;
+ if (on) {
+ document.body.dataset.mobile = '';
+ return;
+ }
+ delete document.body.dataset.mobile;
+ // The drawer is the phone shape's; a window that grew back into the
+ // desktop shape shows the panel beside the canvas again.
+ mobile.side = false;
+}
+
+/** Follow the pointer and the window's width from here on. */
+export function watchMobile() {
+ const coarse = window.matchMedia('(pointer: coarse)');
+ const read = () => paint(coarse.matches || window.innerWidth < NARROW);
+ coarse.addEventListener('change', read);
+ window.addEventListener('resize', read);
+ read();
+}
+
+/** Put the left drawer out, or away. */
+export function openSide(open: boolean) {
+ if (mobile.side === open) return;
+ mobile.side = open;
+ // The soft keyboard would cover most of the drawer, so it goes away while
+ // the drawer is out; the next tap on a pane asks for it back.
+ if (open) (document.getElementById('kbd') as HTMLTextAreaElement | null)?.blur();
+}
diff --git a/thinkterm-web/ui/src/model.ts b/thinkterm-web/ui/src/model.ts
new file mode 100644
index 00000000..394db965
--- /dev/null
+++ b/thinkterm-web/ui/src/model.ts
@@ -0,0 +1,188 @@
+// The shapes the wasm hands over as JSON (thinkterm-web/src/views.rs and the
+// models it serialises: chrome.rs, navbar.rs). Field names are the serde
+// ones, so `pane`/`tab`/`window` rather than the Rust struct's own.
+
+export type PaneView = { pane: number; title: string; current: boolean };
+
+export type TabView = {
+ tab: number;
+ window: number;
+ /** The tab's title as the server has it: the tooltip. */
+ title: string;
+ /** What the capsule says: the desktop's title rule, applied by the wasm. */
+ label: string;
+ /** The pane a click on the tab shows. */
+ target: number;
+ current: boolean;
+ panes: PaneView[];
+};
+
+export type Controls = {
+ following: boolean;
+ fit: boolean;
+ /** The tab whose close button was pressed once. */
+ closing: number | null;
+ clipped: [number, number] | null;
+};
+
+export type TabsView = { tabs: TabView[]; controls: Controls };
+
+export type NavRect = { pane: number; left: number; top: number; width: number; height: number };
+
+export type CapsuleView = { pane: number; title: string; busy: boolean; current: boolean };
+
+export type NavView = {
+ rect: NavRect;
+ members: CapsuleView[];
+ focused: boolean;
+ zoomed: boolean;
+ closing: boolean;
+};
+
+export type NavsView = NavView[];
+
+/** The page's own labels, keyed by catalogue id (thinkterm-web/src/views.rs STRING_KEYS). */
+export type Strings = Record<string, string>;
+
+export type Toast = { text: string; sticky: boolean; at: number };
+export type Card = { title: string; hint: string };
+export type StatusView = { toast: Toast | null; card: Card | null; summary: string };
+
+// The sidebar (thinkterm-web/src/tree.rs `Row`, `ThreadRow`; sidebar.rs
+// `Editing`), tagged by `kind` the way serde writes it.
+
+export type ThreadStatus = 'Idle' | 'Running' | 'NeedsAttention' | 'Done';
+export type ThreadDot = 'Active' | 'Unread' | 'Pinned' | 'Open' | 'Quiet';
+
+export type ThreadRow = {
+ kind: 'thread';
+ id: string;
+ /** The project the thread belongs to. */
+ project: string;
+ name: string;
+ status: ThreadStatus;
+ dot: ThreadDot;
+ pinned: boolean;
+ unread: boolean;
+ /** The thread has terminals on the server. */
+ live: boolean;
+ selected: boolean;
+ /** Its delete button was pressed once and waits for the press that means it. */
+ deleting: boolean;
+};
+
+export type SideRow =
+ | { kind: 'space'; id: string; name: string }
+ | { kind: 'new-thread' }
+ | { kind: 'pinned' }
+ | { kind: 'workspaces' }
+ | { kind: 'project'; id: string; name: string; path: string; collapsed: boolean; archived: boolean }
+ | ThreadRow
+ | { kind: 'archived'; count: number; open: boolean; label: string }
+ | { kind: 'others' }
+ | { kind: 'window'; id: number; title: string; selected: boolean };
+
+/** A name or path being typed into the panel. */
+export type Editing =
+ | { kind: 'none' }
+ | { kind: 'new-project' }
+ | { kind: 'thread'; id: string }
+ | { kind: 'project'; id: string }
+ | { kind: 'space'; id: string };
+
+/** `space` is the Space on show, for the page to remember. */
+export type SidebarView = { rows: SideRow[]; editing: Editing; space: string | null };
+
+// The context menus (thinkterm-web/src/menu.rs `MenuItem`, `Kind`; views.rs
+// `MenuOutcome`): what a menu offers, and what running a row came to.
+
+export type MenuKind = 'item' | 'header' | 'separator';
+
+export type MenuItem = {
+ /** The action id (`"split:right:12"`); empty for a header, a separator
+ or a row that only opens a submenu. */
+ id: string;
+ label: string;
+ /** A lucide icon name, when the row has one. */
+ icon: string | null;
+ kind: MenuKind;
+ enabled: boolean;
+ checked: boolean;
+ submenu: MenuItem[];
+};
+
+/** `copy` is text for the page to put on the clipboard; `paste` asks it to
+ read the clipboard and type what is there. */
+export type MenuOutcome = { handled: boolean; copy: string | null; paste: boolean };
+
+// The search palette (thinkterm-web/src/palette.rs `Results`, `Section`,
+// `Entry`; views.rs `PaletteOutcome`): what a query found, and what
+// running a pick came to.
+
+export type PaletteGroup = 'threads' | 'tabs' | 'panes' | 'spaces' | 'commands';
+
+export type PaletteEntry = {
+ /** `thread:<id>`, `tab:<id>`, `pane:<id>`, `space:<id>`, `cmd:<name>`, `lang:<tag>`. */
+ id: string;
+ title: string;
+ subtitle: string;
+ /** A lucide icon name. */
+ icon: string;
+ /** Right-hand text: a shortcut, a Space, a state. */
+ accessory: string;
+ group: PaletteGroup;
+};
+
+export type PaletteSection = { group: PaletteGroup; label: string; entries: PaletteEntry[] };
+
+export type PaletteResults = { sections: PaletteSection[]; placeholder: string; empty: string };
+
+/** `page` names what only the page does; `recent` is the updated list of
+ picks for the page to keep. */
+export type PaletteOutcome = { handled: boolean; page: string | null; recent: string[] };
+
+// The right-hand Agents panel (thinkterm-web/src/agents.rs `AgentRow`,
+// `AgentsView`): one row per pane an agent runs in, and the line above them.
+
+export type AgentState = 'working' | 'blocked' | 'idle' | 'unknown';
+
+export type AgentRow = {
+ pane: number;
+ /** The window the pane is in; nothing while the server has not said. */
+ window: number | null;
+ /** The pane is in the window this page shows. */
+ here: boolean;
+ agent_id: string;
+ name: string;
+ title: string;
+ state: AgentState;
+ state_label: string;
+ /** "Project \u00b7 Thread", or the workspace when no thread claims it. */
+ place: string;
+ /** `brand-claude`, `brand-copilot` or `bot`. */
+ icon: string;
+};
+
+/** `summary` is the line above the rows; "No agents detected" when empty. */
+export type AgentsView = { rows: AgentRow[]; summary: string };
+
+// The page's own preferences (thinkterm-web/src/settings.rs `WebSettings`),
+// whose JSON names are kebab-case.
+
+export type Theme = 'dark' | 'light' | 'system';
+export type FontMode = { mode: 'follow' } | { mode: 'pinned'; pt: number };
+export type Hotkey = 'cmd-k' | 'cmd-shift-p' | 'ctrl-shift-p';
+
+export type WebSettings = {
+ /** `"system"` or a locale tag. */
+ language: string;
+ theme: Theme;
+ font: FontMode;
+ 'hover-reveal': boolean;
+ 'agents-panel': boolean;
+ 'palette-hotkey': Hotkey;
+ 'sidebar-width': number;
+};
+
+/** One row of `client.languages()`. */
+export type LanguageOption = { preference: string; label: string };
diff --git a/thinkterm-web/ui/src/palette.svelte.ts b/thinkterm-web/ui/src/palette.svelte.ts
new file mode 100644
index 00000000..45b28a2f
--- /dev/null
+++ b/thinkterm-web/ui/src/palette.svelte.ts
@@ -0,0 +1,174 @@
+// The one search palette the page has open: what the wasm found for what
+// was typed (thinkterm-web/src/palette.rs), which entry the keyboard is
+// on, and what running a pick came to. The wasm owns what can be found,
+// how a query ranks it and what a pick does; this owns only the fact that
+// the palette is open and the picks this browser remembers.
+
+import { handle } from './client';
+import { refreshViews, views } from './client.svelte';
+import { toggleSidebar } from './chrome';
+import type { Hotkey, PaletteEntry, PaletteOutcome, PaletteResults } from './model';
+import { openSettings, setSetting } from './settings.svelte';
+
+/** Where this browser keeps the picks, most recent first. */
+const RECENT = 'thinkterm.recent';
+
+const EMPTY: PaletteResults = { sections: [], placeholder: '', empty: '' };
+
+export const palette = $state({
+ open: false,
+ /** What has been typed, which is what the results are for. */
+ query: '',
+ results: EMPTY as PaletteResults,
+ /** The row the keyboard is on, as an index into `entries()`. */
+ selected: 0,
+ /** One section only, when opened for it (the sidebar's thread search). */
+ only: '' as '' | 'threads',
+});
+
+/** Every entry on show, in the order the arrows walk them. */
+/** The sections on show: every one, or the one the palette was opened for. */
+export function shownSections() {
+ return palette.only === '' ? palette.results.sections : palette.results.sections.filter((s) => s.group === palette.only);
+}
+
+export function entries(): PaletteEntry[] {
+ return shownSections().flatMap((section) => section.entries);
+}
+
+/** Ask the wasm what `query` finds. Synchronous and cheap: it ranks what
+ the model already has. */
+export function search(query: string) {
+ palette.query = query;
+ const client = handle.client;
+ if (!client) {
+ palette.results = EMPTY;
+ palette.selected = 0;
+ return;
+ }
+ try {
+ palette.results = JSON.parse(client.palette(query)) as PaletteResults;
+ } catch {
+ palette.results = EMPTY;
+ }
+ palette.selected = 0;
+}
+
+export function openPalette(only: '' | 'threads' = '') {
+ palette.only = only;
+ palette.open = true;
+ search('');
+}
+
+export function closePalette() {
+ if (!palette.open) return;
+ palette.open = false;
+ palette.only = '';
+ palette.query = '';
+ palette.results = EMPTY;
+ palette.selected = 0;
+ // The palette took focus off the field the terminal types through.
+ document.getElementById('kbd')?.focus();
+}
+
+/** The keyboard's row, `delta` rows on, wrapping through every section. */
+export function move(delta: number) {
+ const count = entries().length;
+ if (count === 0) {
+ palette.selected = 0;
+ return;
+ }
+ palette.selected = (((palette.selected + delta) % count) + count) % count;
+}
+
+/** Put the keyboard on an entry the pointer is over. */
+export function select(id: string) {
+ const at = entries().findIndex((entry) => entry.id === id);
+ if (at >= 0) palette.selected = at;
+}
+
+/** The entry the keyboard is on; nothing when the query found none. */
+export function selectedId(): string {
+ return entries()[palette.selected]?.id ?? '';
+}
+
+/** Do what a pick asks, then close. What only the page can do comes back
+ as `page`; everything else the wasm has already done. */
+export function run(id: string) {
+ const client = handle.client;
+ if (!client || id === '') return;
+ let outcome: PaletteOutcome;
+ try {
+ outcome = JSON.parse(client.palette_run(id)) as PaletteOutcome;
+ } catch {
+ closePalette();
+ return;
+ }
+ closePalette();
+ if (!outcome.handled) return;
+ // What the pick changed is on show before this returns, as it is for a
+ // menu row: the client's own notice is a frame away.
+ refreshViews();
+ rememberPicks(outcome.recent);
+ const page = outcome.page;
+ if (page === 'toggle-sidebar') toggleSidebar();
+ else if (page === 'settings') openSettings();
+ else if (page !== null && page.startsWith('lang:')) {
+ // The wasm activated the language; the preference is the page's to
+ // keep, and storing it is what makes the next load open in it.
+ setSetting('language', page.slice('lang:'.length));
+ }
+}
+
+function rememberPicks(ids: string[]) {
+ try {
+ localStorage.setItem(RECENT, JSON.stringify(ids));
+ } catch {
+ // A browser that blocks storage keeps them for this load only.
+ }
+}
+
+/** The picks this browser remembers, for the wasm to rank an empty query by. */
+export function storedPicks(): string[] {
+ try {
+ const raw = localStorage.getItem(RECENT);
+ if (!raw) return [];
+ const value: unknown = JSON.parse(raw);
+ return Array.isArray(value) ? value.filter((id): id is string => typeof id === 'string') : [];
+ } catch {
+ return [];
+ }
+}
+
+/** Cmd on a Mac, Ctrl everywhere else. `navigator.platform` is deprecated
+ but still the only thing every browser answers; the newer field wins
+ where there is one. */
+function onMac(): boolean {
+ const data = (navigator as Navigator & { userAgentData?: { platform?: string } }).userAgentData;
+ return /mac|iphone|ipad|ipod/i.test(data?.platform || navigator.platform || '');
+}
+
+function isHotkey(ev: KeyboardEvent, hotkey: Hotkey): boolean {
+ const key = ev.key.toLowerCase();
+ const primary = onMac() ? ev.metaKey && !ev.ctrlKey : ev.ctrlKey && !ev.metaKey;
+ switch (hotkey) {
+ case 'cmd-k': return primary && !ev.altKey && !ev.shiftKey && key === 'k';
+ case 'cmd-shift-p': return primary && !ev.altKey && ev.shiftKey && key === 'p';
+ case 'ctrl-shift-p': return ev.ctrlKey && !ev.metaKey && !ev.altKey && ev.shiftKey && key === 'p';
+ }
+}
+
+/** Watch for the shortcut the settings name. In the capture phase so the
+ terminal's keyboard field never sees the press. */
+export function watchHotkey() {
+ window.addEventListener(
+ 'keydown',
+ (ev) => {
+ if (palette.open || !isHotkey(ev, views.settings['palette-hotkey'])) return;
+ ev.preventDefault();
+ ev.stopPropagation();
+ openPalette();
+ },
+ true,
+ );
+}
diff --git a/thinkterm-web/ui/src/pane.ts b/thinkterm-web/ui/src/pane.ts
new file mode 100644
index 00000000..6870b461
--- /dev/null
+++ b/thinkterm-web/ui/src/pane.ts
@@ -0,0 +1,46 @@
+// Which pane a point on the canvas is in, from the layout the wasm
+// publishes. Its own module because two callers need it: the right-click
+// on the canvas (App.svelte) and the long press that stands in for one on
+// a phone (touch.ts).
+
+type Layout = {
+ cell?: [number, number];
+ focused?: number;
+ panes?: { id: number; left: number; top: number; cols: number; rows: number }[];
+};
+
+/** The pane under a point on the canvas: the grid starts a cell in from the
+ left and half a cell down, as the desktop pads it (App::pad), and a
+ placement's box is in those cells. */
+export function paneAt(canvas: HTMLCanvasElement, clientX: number, clientY: number): number | null {
+ let layout: Layout;
+ try {
+ layout = JSON.parse(canvas.dataset.layout || '{}') as Layout;
+ } catch {
+ return null;
+ }
+ const cell = layout.cell;
+ const focused = typeof layout.focused === 'number' ? layout.focused : null;
+ if (!cell || !(cell[0] > 0) || !(cell[1] > 0) || !Array.isArray(layout.panes)) return focused;
+ const box = canvas.getBoundingClientRect();
+ const col = Math.floor((clientX - box.left - cell[0]) / cell[0]);
+ const row = Math.floor((clientY - box.top - cell[1] / 2) / cell[1]);
+ const hit = layout.panes.find(
+ (p) => col >= p.left && col < p.left + p.cols && row >= p.top && row < p.top + p.rows,
+ );
+ // A press in a divider or past the tab is still a press in this tab: the
+ // menu is the focused pane's, as the desktop's would be.
+ return hit ? hit.id : focused;
+}
+
+/** A pane's cell height in CSS px, for a gesture that scrolls by cells;
+ `fallback` when the layout has not named one yet. */
+export function cellHeight(canvas: HTMLCanvasElement, fallback: number): number {
+ try {
+ const layout = JSON.parse(canvas.dataset.layout || '{}') as Layout;
+ const h = layout.cell?.[1];
+ return typeof h === 'number' && h > 1 ? h : fallback;
+ } catch {
+ return fallback;
+ }
+}
diff --git a/thinkterm-web/ui/src/settings.svelte.ts b/thinkterm-web/ui/src/settings.svelte.ts
new file mode 100644
index 00000000..304a169d
--- /dev/null
+++ b/thinkterm-web/ui/src/settings.svelte.ts
@@ -0,0 +1,146 @@
+// The settings panel, and what this browser remembers between loads: the
+// preferences themselves (thinkterm-web/src/settings.rs, which the wasm
+// holds and hands back through `views.settings`), the Space that was on
+// show, and the palette's recent picks. The wasm applies what concerns it
+// -- the language and the font -- and the page applies the rest.
+
+import { handle } from './client';
+import { refreshViews, setLocale, views } from './client.svelte';
+import type { LanguageOption, Theme } from './model';
+
+/** Where this browser keeps the preferences, whole, as the wasm's JSON. */
+const STORE = 'thinkterm.settings';
+/** The Space the sidebar was showing, so the next load opens on it. */
+const SPACE = 'thinkterm.space';
+
+export const panel = $state({
+ /** The modal is up. */
+ open: false,
+ /** What the wasm said about the last change; empty when it took it. */
+ error: '',
+ /** The languages the page can be set to, in the active language. */
+ languages: [] as LanguageOption[],
+});
+
+export function openSettings() {
+ panel.error = '';
+ reread();
+ panel.open = true;
+}
+
+export function closeSettings() {
+ if (!panel.open) return;
+ panel.open = false;
+ // The panel took focus off the field the terminal types through.
+ document.getElementById('kbd')?.focus();
+}
+
+/** Read the wasm's views back and the language list with them: a change of
+ language relabels the list itself. */
+function reread() {
+ refreshViews();
+ const client = handle.client;
+ if (!client) return;
+ try {
+ panel.languages = JSON.parse(client.languages()) as LanguageOption[];
+ } catch {
+ panel.languages = [];
+ }
+}
+
+/** Put the preferences, whole, where the next load will find them. */
+export function persist() {
+ try {
+ localStorage.setItem(STORE, JSON.stringify(views.settings));
+ } catch {
+ // A browser that blocks storage keeps them for this load only.
+ }
+}
+
+/** The stored preferences as they were written, or nothing. Parsed loosely
+ on purpose: the wasm checks them, and one bad field is not a reason to
+ lose the rest. */
+export function storedSettings(): Record<string, unknown> {
+ try {
+ const raw = localStorage.getItem(STORE);
+ if (!raw) return {};
+ const value: unknown = JSON.parse(raw);
+ return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};
+ } catch {
+ return {};
+ }
+}
+
+/** One preference, by its JSON name. The wasm's refusal is shown rather
+ than thrown; what it took is read back and stored. */
+export function setSetting(key: string, value: unknown) {
+ const client = handle.client;
+ if (!client) return;
+ panel.error = client.set_setting(key, JSON.stringify(value));
+ // The wasm activated the language itself; this is how the page learns
+ // which locale that came to, for the About line.
+ if (key === 'language' && panel.error === '') {
+ document.documentElement.lang = setLocale(String(value));
+ }
+ reread();
+ persist();
+}
+
+export function storedSpace(): string {
+ try {
+ return localStorage.getItem(SPACE) ?? '';
+ } catch {
+ return '';
+ }
+}
+
+/** Whether the Space this browser was showing has still to be asked for.
+ The boot asks once, but the server's tree almost always arrives after
+ it, and until it does no Space is known by name. */
+let restoring = true;
+
+/** The Space the sidebar is showing. The first time the tree has named one
+ -- which is the first time there is a Space to ask for at all -- the one
+ this browser was last showing is asked for instead; from then on what is
+ on show is what is remembered. */
+export function followSpace(showing: string) {
+ if (restoring) {
+ restoring = false;
+ const wanted = storedSpace();
+ // False when that Space is gone from the server: the sidebar stays
+ // where it landed, and that is what is remembered from here on.
+ if (wanted !== '' && wanted !== showing && handle.client?.set_space(wanted)) return;
+ }
+ try {
+ localStorage.setItem(SPACE, showing);
+ } catch {
+ // As above: this load's only.
+ }
+}
+
+// The theme is the page's to paint: dark is the default and carries no
+// mark, light sets one, and "system" follows the browser until it is
+// changed again. Only one listener is ever registered.
+let media: MediaQueryList | null = null;
+let follow: (() => void) | null = null;
+
+function paint(dark: boolean) {
+ if (dark) delete document.documentElement.dataset.theme;
+ else document.documentElement.dataset.theme = 'light';
+}
+
+export function applyTheme(theme: Theme) {
+ if (media && follow) media.removeEventListener('change', follow);
+ media = null;
+ follow = null;
+ if (theme === 'light' || theme === 'dark') {
+ paint(theme === 'dark');
+ return;
+ }
+ const query = window.matchMedia('(prefers-color-scheme: dark)');
+ const listener = () => paint(query.matches);
+ query.addEventListener('change', listener);
+ media = query;
+ follow = listener;
+ paint(query.matches);
+}
diff --git a/thinkterm-web/ui/src/svelte-html.d.ts b/thinkterm-web/ui/src/svelte-html.d.ts
new file mode 100644
index 00000000..c9d91320
--- /dev/null
+++ b/thinkterm-web/ui/src/svelte-html.d.ts
@@ -0,0 +1,7 @@
+// `autocorrect` is in svelte/elements for <input> only; #kbd is a <textarea>
+// and Safari honours it there too, so tell svelte-check the attribute exists.
+declare namespace svelteHTML {
+ interface HTMLAttributes<T> {
+ autocorrect?: 'on' | 'off';
+ }
+}
diff --git a/thinkterm-web/ui/src/title.ts b/thinkterm-web/ui/src/title.ts
new file mode 100644
index 00000000..d510d9ac
--- /dev/null
+++ b/thinkterm-web/ui/src/title.ts
@@ -0,0 +1,8 @@
+// Titles are shown short; the full one is the tooltip. What a title says
+// is the wasm's rule (`navbar::display_title`); how much of it fits a
+// capsule is the page's.
+export function short(title: string): string {
+ const MAX = 28;
+ const chars = Array.from(title);
+ return chars.length <= MAX ? title : chars.slice(0, MAX - 1).join('') + '…';
+}
diff --git a/thinkterm-web/ui/src/tokens.css b/thinkterm-web/ui/src/tokens.css
new file mode 100644
index 00000000..851919ec
--- /dev/null
+++ b/thinkterm-web/ui/src/tokens.css
@@ -0,0 +1,307 @@
+/* The desktop's chrome (wezterm-gui/src/ui/tokens.rs, fancy_tab_bar.rs,
+ render/pane.rs): its palette, its 40 px tab row of 160 px capsules,
+ its bar above every pane. Dark is the desktop's default whatever the
+ OS says; ?theme=light picks the other set. */
+:root {
+ --bg: #19191A; --side-bg: #121214; --sep: rgba(84,84,88,.22);
+ --ctl: rgba(45,45,47,.98); --ctl-hover: rgba(55,55,57,.98); --ctl-pressed: rgba(66,66,69,.98); --ctl-border: rgba(118,118,128,.28);
+ --text: #F2F2F7; --text2: #C7C7CC; --muted: #8E8E93; --accent: #0A84FF; --danger: #FF453A;
+ --wash: rgba(242,242,247,.025); --ring: rgba(242,242,247,.12); --edge: rgba(242,242,247,.38); --shadow: 0 .5px 0 1px rgba(0,0,0,.12);
+ --ui: -apple-system, "SF Pro Text", "Helvetica Neue", Roboto, system-ui, sans-serif;
+ --tabs: 40px; --side-w: 220px; --side-px: 220px; --agents-w: 0px; --keybar: 0px;
+ --done: #7CE5A2; --open: #61B8FF; --warn: #DB7320;
+}
+body[data-side=off] { --side-w: 0px; }
+/* The right panel's width lives on the root, as the sidebar's does; without
+ the mark on the body -- which the panel itself puts there -- nothing
+ leaves room for it. */
+body:not([data-agents]) { --agents-w: 0px; }
+[data-theme=light] {
+ --bg: #EEEEF2; --side-bg: #E2E2E8; --sep: rgba(60,60,67,.18);
+ --ctl: rgba(255,255,255,.94); --ctl-hover: rgba(247,247,250,.98); --ctl-pressed: rgba(232,242,255,.98); --ctl-border: rgba(60,60,67,.20);
+ --text: #1C1C1E; --text2: #48484A; --muted: #8E8E93; --accent: #007AFF; --danger: #D7263D;
+ --wash: rgba(28,28,30,.025); --ring: rgba(28,28,30,.12); --edge: rgba(28,28,30,.38); --shadow: 0 .5px 0 1px rgba(0,0,0,.04);
+ --warn: #C05F14;
+}
+html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text2); font: 500 14px var(--ui); overflow: hidden; }
+/* The page is mounted into #app; it generates no box of its own, so the
+ chrome below is laid out against the viewport exactly as it was when it
+ sat directly in the body. */
+#app { display: contents; }
+svg { width: 16px; height: 16px; flex: none; }
+/* The window's tab row. Capsules never shrink; the row scrolls. */
+#tabs { position: absolute; left: var(--side-w); right: var(--agents-w); top: 0; height: var(--tabs); box-sizing: border-box; display: flex; align-items: center; gap: 9px; padding: 2px 8px 0 8px; background: var(--bg); overflow-x: auto; overflow-y: hidden; white-space: nowrap; user-select: none; scrollbar-width: none; }
+#tabs::-webkit-scrollbar { display: none; }
+#tabs .tab { display: inline-flex; align-items: center; flex: 0 0 auto; width: 160px; height: 30px; box-sizing: border-box; padding: 0 9px; border-radius: 999px; border: 1px solid transparent; color: var(--text2); cursor: default; }
+#tabs .tab:hover { background: var(--ctl-hover); }
+#tabs .tab.current { background: var(--ctl); border-color: var(--ctl-border); box-shadow: var(--shadow); color: var(--text); }
+.t { margin-left: 4px; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.x { display: none; margin-left: 4px; width: 22px; height: 22px; border-radius: 999px; align-items: center; justify-content: center; opacity: .82; flex: none; }
+.current .x, .tab:hover .x, .cap:hover .x { display: inline-flex; }
+.x:hover { background: var(--ring); opacity: 1; }
+.x.danger { width: auto; padding: 0 6px; font-size: 11px; color: var(--danger); opacity: 1; }
+.act { width: 30px; height: 30px; flex: none; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; box-sizing: border-box; color: var(--text2); }
+.act:hover { background: var(--ctl-hover); border-color: var(--edge); color: var(--text); }
+#tabs .act.on { color: var(--accent); }
+#tabs .trail { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
+#tabs .hint { color: var(--muted); font-size: 12px; padding: 0 6px; }
+#tabs .follow { color: var(--muted); font-size: 12px; padding: 0 8px; height: 24px; line-height: 24px; border-radius: 999px; cursor: default; }
+#tabs .follow.on { color: var(--accent); }
+#tabs .follow:hover { background: var(--ctl-hover); }
+#term { position: absolute; inset: var(--tabs) var(--agents-w) 0 var(--side-w); width: calc(100% - var(--side-w) - var(--agents-w)); height: calc(100% - var(--tabs)); display: block; outline: none; }
+/* Its own layer: the sidebar's edge moves the canvas on every drag frame,
+ and a promoted layer moves instead of being laid out again. */
+canvas#term { will-change: transform; }
+/* One bar over each pane, laid out from the canvas's cells. */
+#panes { position: absolute; inset: var(--tabs) var(--agents-w) 0 var(--side-w); pointer-events: none; overflow: hidden; }
+/* The desktop's left sidebar: Spaces, Projects, Threads. */
+#side { position: absolute; left: 0; top: 0; bottom: 0; width: var(--side-w); box-sizing: border-box; background: var(--side-bg); border-right: 1px solid var(--sep); font: 500 15px var(--ui); color: var(--text2); user-select: none; overflow: hidden; }
+body[data-side=off] #side:not(.revealed) { display: none; }
+/* Hovering the window's left edge, or the toggle, while the panel is put
+ away: it comes back over the canvas rather than beside it, so nothing is
+ resized -- `--side-w` stays 0 and the width comes from `--side-px`. */
+#side.revealed { top: var(--tabs); width: var(--side-px); z-index: 15; box-shadow: 0 8px 28px rgba(0,0,0,.42); }
+#side .list { position: absolute; inset: 26px 5px 44px 5px; overflow-y: auto; scrollbar-width: thin; display: flex; flex-direction: column; gap: 5px; padding-bottom: 8px; }
+/* The footer, as the desktop's sidebar ends: Settings as a row on the left,
+ the thread search as a button on the right. */
+/* The footer as the desktop ends its sidebar: a row of icons, the gear
+ at the left inset and the thread search at the right, no rule above. */
+#side .foot { position: absolute; left: 12px; right: 12px; bottom: 0; height: 44px; display: flex; align-items: center; justify-content: space-between; }
+#side .foot .act { width: 28px; height: 28px; color: var(--text2); border-radius: 8px; }
+#side .foot .act svg { width: 15px; height: 15px; }
+#side .foot .act:hover { color: var(--text); background: rgba(42,42,44,.98); }
+#side .handle { position: absolute; right: -2px; top: 0; bottom: 0; width: 4px; cursor: col-resize; z-index: 1; }
+#side .row { display: flex; align-items: center; min-height: 33px; box-sizing: border-box; padding: 0 5px; border-radius: 10px; border: 1px solid transparent; flex: none; }
+#side .row.thread { padding-left: 25px; }
+#side .row .t { margin-left: 5px; color: var(--text); }
+#side .row.project .t, #side .row.space .t { color: var(--text2); }
+#side .row:hover { background: rgba(42,42,44,.98); }
+#side .row.selected { background: rgba(62,62,65,.98); border-color: rgba(118,118,128,.22); box-shadow: var(--shadow); }
+#side .row.archived { opacity: .55; }
+#side .chev { display: inline-flex; width: 16px; margin-right: 2px; color: var(--muted); }
+#side .hov { display: none; margin-left: auto; gap: 2px; }
+#side .row:hover .hov { display: inline-flex; }
+#side .act { width: 24px; height: 24px; }
+#side .act svg { width: 13px; height: 13px; }
+/* The desktop's round buttons: the bell, the new project, a project's plus. */
+#side .act.round { width: 28px; height: 28px; border-radius: 999px; border: 1px solid rgba(118,118,128,.22); background: rgba(36,36,38,.94); color: var(--text); flex: none; }
+#side .act.round:hover { background: rgba(48,48,50,.98); }
+#side .act.round svg { width: 14px; height: 14px; }
+#side .top { display: flex; align-items: center; gap: 8px; margin: 4px 10px 6px 10px; flex: none; }
+#side .top .pill { flex: 1 1 auto; margin: 0; }
+#side .row.project .act.round { margin-left: auto; }
+#side .row.project .hov { margin-left: auto; margin-right: 2px; }
+#side .row.project:hover .act.round { margin-left: 0; }
+#side .hdr { display: flex; align-items: center; gap: 5px; min-height: 33px; padding: 0 10px; color: var(--text2); font-size: 14px; margin-top: 6px; }
+#side .hdr .act { margin-left: auto; }
+#side .hdr.sub { cursor: default; }
+#side .pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; margin: 4px 10px 6px 10px; border-radius: 999px; background: rgba(36,36,38,.94); border: 1px solid rgba(118,118,128,.22); color: var(--text); flex: none; }
+#side .pill:hover { background: rgba(48,48,50,.98); }
+#side .st { display: inline-flex; width: 13px; height: 13px; align-items: center; justify-content: center; margin-left: 6px; flex: none; }
+#side .st svg { width: 13px; height: 13px; }
+#side .st.alert svg { width: 10px; height: 10px; }
+#side .st.done { color: var(--done); }
+#side .st.dot::before { content: ""; width: 5px; height: 5px; border-radius: 999px; background: rgba(242,242,247,.16); }
+#side .st.dot.active::before { background: var(--done); }
+#side .st.dot.unread::before { background: #3A3A3C; }
+#side .st.dot.pinned::before { background: rgba(242,242,247,.68); }
+#side .st.dot.open::before { background: var(--open); }
+#side input.rename { font: 500 15px var(--ui); color: var(--text); background: #3A3A3C; border: 0; border-radius: 4px; padding: 2px 4px; margin-left: 5px; flex: 1 1 auto; min-width: 0; outline: none; }
+#side .path { display: flex; align-items: center; gap: 5px; padding: 0 10px; }
+#side .path input { flex: 1 1 auto; min-width: 0; font: 14px var(--ui); color: var(--text); background: var(--ctl); border: 1px solid var(--ctl-border); border-radius: 6px; padding: 4px 6px; outline: none; }
+/* The desktop's right-hand Agents panel: one row per pane an agent runs
+ in (wezterm-gui/src/termwindow/ui/agent_panel.rs). */
+#agents { position: absolute; right: 0; top: 0; bottom: 0; width: var(--agents-w); box-sizing: border-box; background: var(--side-bg); border-left: 1px solid var(--sep); font: 500 13px var(--ui); color: var(--text2); user-select: none; overflow: hidden; }
+#agents .handle { position: absolute; left: -2px; top: 0; bottom: 0; width: 4px; cursor: col-resize; z-index: 1; }
+#agents .hd { position: absolute; left: 0; right: 0; top: 0; box-sizing: border-box; padding: 9px 12px 7px 12px; display: flex; flex-direction: column; gap: 2px; }
+#agents .hd .ti { color: var(--text); font-size: 14px; }
+#agents .hd .sum { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+#agents .list { position: absolute; inset: 56px 5px 0 5px; overflow-y: auto; scrollbar-width: thin; display: flex; flex-direction: column; gap: 2px; padding-bottom: 32px; }
+/* Two lines and a chip, the row height the desktop gives them. */
+#agents .ag { display: flex; align-items: center; gap: 9px; min-height: 46px; box-sizing: border-box; padding: 5px 7px; border-radius: 10px; flex: none; }
+#agents .ag:hover { background: rgba(42,42,44,.98); }
+#agents .ag.elsewhere { opacity: .62; }
+#agents .ic { display: inline-flex; width: 20px; height: 20px; flex: none; align-items: center; justify-content: center; color: var(--text2); }
+#agents .ic svg { width: 20px; height: 20px; }
+/* The brand marks carry no stroke and no fill of their own. */
+#agents .ic svg[role=img] { fill: currentColor; }
+#agents .tx { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
+#agents .n { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+#agents .n .d { color: var(--muted); }
+#agents .p { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+#agents .st { display: inline-flex; width: 16px; height: 16px; flex: none; align-items: center; justify-content: center; }
+#agents .st svg { width: 16px; height: 16px; }
+#agents .st.alert { color: var(--warn); }
+#agents .st.idle { color: var(--muted); }
+.nav { position: absolute; pointer-events: auto; box-sizing: border-box; display: flex; align-items: center; gap: 9px; padding: 0 5px; background: var(--bg); color: var(--text2); user-select: none; overflow: hidden; }
+.nav.focused { color: var(--text); }
+.nav .caps { display: flex; gap: 9px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
+.nav .cap { display: inline-flex; align-items: center; flex: 0 0 auto; width: 160px; height: 30px; box-sizing: border-box; padding: 0 9px; border-radius: 999px; border: 1px solid transparent; background: var(--wash); color: var(--text2); cursor: default; }
+.nav .cap.current { background: var(--ctl); border-color: var(--ctl-border); box-shadow: var(--shadow); color: inherit; }
+.nav .cap:hover:not(.current) { background: var(--ctl-hover); }
+.nav .acts { display: flex; gap: 2px; margin-left: auto; flex: none; }
+.nav .act svg { width: 13px; height: 13px; }
+.spin { display: inline-flex; animation: spin .96s steps(12) infinite; }
+@keyframes spin { to { transform: rotate(360deg); } }
+/* What the desktop shows over a terminal another device holds. */
+#card { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); text-align: center; padding: 26px 36px; border-radius: 18px; background: color-mix(in srgb, var(--bg) 86%, transparent); border: 1px solid var(--ctl-border); pointer-events: none; user-select: none; }
+#card .eyes { font: 17px var(--ui); color: var(--muted); letter-spacing: 2px; margin-bottom: 8px; }
+#card .title { font: 500 17px var(--ui); color: var(--text); }
+#card .hint { font: 15px var(--ui); color: var(--text2); margin-top: 10px; }
+/* Passing remarks: refusals, reconnects. */
+#status { position: absolute; right: 12px; bottom: 12px; max-width: 60%; padding: 7px 11px; border-radius: 8px; background: var(--ctl); border: 1px solid var(--ctl-border); color: var(--text); font: 13px var(--ui); box-shadow: 0 2px 12px rgba(0,0,0,.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
+#status.error { color: var(--danger); }
+/* The context menus: one panel per open submenu, over everything the page
+ draws, the desktop's control colours at the page's smaller size. */
+.menu { position: fixed; z-index: 20; min-width: 168px; max-width: 340px; box-sizing: border-box; padding: 5px; border-radius: 10px; background: var(--ctl); border: 1px solid var(--ctl-border); box-shadow: 0 8px 28px rgba(0,0,0,.42); color: var(--text); font: 500 13px var(--ui); user-select: none; outline: none; }
+.menu .mi { display: flex; align-items: center; gap: 8px; height: 28px; box-sizing: border-box; padding: 0 8px; border-radius: 6px; white-space: nowrap; }
+.menu .mi:hover, .menu .mi.on { background: var(--ctl-hover); }
+.menu .mi.disabled { color: var(--muted); }
+.menu .mi.disabled:hover, .menu .mi.disabled.on { background: transparent; }
+/* A row without an icon keeps its width, so the labels line up. */
+.menu .ic { display: inline-flex; width: 16px; height: 16px; flex: none; align-items: center; justify-content: center; }
+.menu .ic svg { width: 14px; height: 14px; }
+.menu .lb { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
+.menu .sub { display: inline-flex; margin-left: 6px; color: var(--muted); flex: none; }
+.menu .sub svg { width: 13px; height: 13px; }
+.menu .mi.checked .lb { color: var(--text); }
+.menu .mh { padding: 5px 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
+.menu .ms { height: 0; margin: 4px 0; border: 0; border-top: 1px solid var(--sep); }
+/* The search palette: a field near the top of the window and what the
+ wasm ranked for it, in sections. Over everything the page draws, its
+ own backdrop behind it. */
+#palette-back, #settings-back { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.28); }
+#palette { position: fixed; z-index: 31; left: 50%; top: 12vh; transform: translateX(-50%); width: min(640px, 90vw); box-sizing: border-box; display: flex; flex-direction: column; border-radius: 12px; background: var(--ctl); border: 1px solid var(--ctl-border); box-shadow: 0 16px 48px rgba(0,0,0,.46); color: var(--text); font: 500 13px var(--ui); overflow: hidden; }
+#palette .q { flex: none; box-sizing: border-box; width: 100%; padding: 12px; font: 400 15px var(--ui); color: var(--text); background: transparent; border: 0; border-bottom: 1px solid var(--sep); outline: none; }
+#palette .q::placeholder { color: var(--muted); }
+#palette .pl { flex: 1 1 auto; max-height: 52vh; overflow-y: auto; scrollbar-width: thin; padding: 5px; }
+#palette .ph { padding: 7px 9px 3px 9px; color: var(--muted); font-size: 11px; }
+#palette .pe { display: flex; align-items: center; gap: 8px; height: 32px; box-sizing: border-box; padding: 0 9px; border-radius: 6px; white-space: nowrap; }
+#palette .pe.on { background: var(--ctl-hover); }
+#palette .ic { display: inline-flex; width: 16px; height: 16px; flex: none; align-items: center; justify-content: center; color: var(--muted); }
+#palette .t { color: var(--text); }
+#palette .st { flex: none; max-width: 34%; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
+#palette .acc { flex: none; margin-left: auto; padding-left: 10px; color: var(--muted); font-size: 12px; }
+#palette .pn { padding: 14px 9px; color: var(--muted); }
+/* The settings panel: the page's own preferences, one row each. */
+/* The settings window, as the desktop draws it: a nav column with the
+ sections, and the section's cards of rows on the right. */
+#settings { position: fixed; z-index: 31; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(920px, 94vw); height: min(602px, 90vh); box-sizing: border-box; display: flex; background: var(--bg); border: 1px solid var(--ctl-border); border-radius: 12px; box-shadow: 0 24px 80px rgba(0,0,0,.55); color: var(--text); font: 500 14px var(--ui); overflow: hidden; outline: none; }
+#settings .sc { position: absolute; right: 12px; top: 12px; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 999px; background: transparent; border: 0; color: var(--muted); }
+#settings .sc:hover { color: var(--text); background: var(--ctl-hover); }
+#settings .sc svg { width: 15px; height: 15px; }
+#settings .snav { flex: 0 0 220px; box-sizing: border-box; padding: 18px 14px; background: var(--side-bg); border-right: 1px solid var(--sep); display: flex; flex-direction: column; gap: 10px; }
+#settings .app { font-size: 17px; font-weight: 700; color: var(--text); padding: 12px 2px 6px 2px; }
+#settings .find { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px; background: var(--ctl); border: 1px solid var(--ctl-border); color: var(--muted); }
+#settings .find svg { width: 14px; height: 14px; flex: none; }
+#settings .find input { flex: 1 1 auto; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text); font: 500 14px var(--ui); }
+#settings .secs { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
+#settings .sec { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; border-radius: 10px; color: var(--text); cursor: default; }
+#settings .sec svg { width: 16px; height: 16px; flex: none; color: var(--text2); }
+#settings .sec:hover { background: rgba(42,42,44,.98); }
+#settings .sec.on { background: var(--ctl); border: 1px solid var(--ctl-border); box-shadow: var(--shadow); }
+#settings .body { flex: 1 1 auto; min-width: 0; overflow-y: auto; scrollbar-width: thin; padding: 30px 34px 24px 24px; }
+#settings .title { font-size: 20px; font-weight: 700; margin: 6px 0 18px 0; }
+#settings .card { background: var(--ctl); border: 1px solid var(--ctl-border); border-radius: 12px; padding: 0 18px; margin-bottom: 18px; }
+#settings .srow { display: flex; align-items: center; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--sep); }
+#settings .srow:last-child { border-bottom: 0; }
+#settings .tx { flex: 1 1 auto; min-width: 0; }
+#settings .lab { font-weight: 600; color: var(--text); }
+#settings .desc { margin-top: 3px; color: var(--muted); font-size: 13px; font-weight: 500; }
+#settings .ctl { display: flex; align-items: center; gap: 10px; flex: none; }
+#settings .pillsel, #settings .pillbtn { flex: none; font: 500 13px var(--ui); color: var(--text); background: var(--ctl-hover); border: 1px solid var(--ctl-border); border-radius: 8px; padding: 6px 12px; min-width: 120px; }
+#settings .pillsel { appearance: none; -webkit-appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--text2) 50%), linear-gradient(135deg, var(--text2) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
+#settings .pillbtn { min-width: 0; }
+#settings .pillbtn:hover { background: var(--ctl-pressed); }
+#settings .seg { display: inline-flex; border: 1px solid var(--ctl-border); border-radius: 8px; overflow: hidden; }
+#settings .sg { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; color: var(--text2); font: 500 13px var(--ui); cursor: default; }
+#settings .sg input { position: absolute; opacity: 0; width: 0; height: 0; }
+#settings .sg.on { background: var(--ctl-pressed); color: var(--text); }
+#settings .stepper { display: inline-flex; align-items: center; height: 30px; border-radius: 8px; background: var(--ctl-hover); border: 1px solid var(--ctl-border); overflow: hidden; }
+#settings .stepper.off { opacity: .5; }
+#settings .stepper button { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 0; color: var(--text); }
+#settings .stepper button svg { width: 13px; height: 13px; }
+#settings .stepper .num { width: 54px; height: 28px; text-align: center; background: transparent; border: 0; color: var(--text); font: 500 13px var(--ui); outline: none; -moz-appearance: textfield; }
+#settings .stepper .num::-webkit-inner-spin-button { display: none; }
+#settings .reset { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 999px; background: transparent; border: 0; color: var(--muted); }
+#settings .reset:hover:not(:disabled) { color: var(--text); background: var(--ctl-hover); }
+#settings .reset:disabled { opacity: .35; }
+#settings .reset svg { width: 15px; height: 15px; }
+#settings .switch { position: relative; display: inline-block; width: 40px; height: 24px; flex: none; }
+#settings .switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: default; }
+#settings .switch .knob { position: absolute; inset: 0; border-radius: 999px; background: rgba(118,118,128,.32); transition: background .15s; }
+#settings .switch .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); transition: transform .15s; }
+#settings .switch input:checked + .knob { background: var(--accent); }
+#settings .switch input:checked + .knob::after { transform: translateX(16px); }
+#settings .err { padding: 0 2px 8px 2px; color: var(--danger); font-size: 12px; }
+/* Focus lives here so the IME composes into a real text field; the
+ field itself stays out of sight. */
+#kbd { position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; margin: 0; resize: none; overflow: hidden; pointer-events: none; }
+
+/* The phone shape. `body[data-mobile]` is put there by mobile.svelte.ts when
+ the pointer is coarse or the window is too narrow for the desktop's
+ chrome, and everything below is scoped to it: a desktop browser is served
+ exactly the page it was. Termux is the shape this follows -- the terminal
+ takes the width, the two panels become drawers over it, and a key bar
+ supplies the keys a soft keyboard has not got. */
+body[data-mobile] { --side-w: 0px; --agents-w: 0px; }
+/* The soft keyboard shrinks the *visual* viewport and nothing else, so the
+ canvas is sized from that rather than from the window: --vvh and --keybar
+ are KeyBar.svelte's, set on the root while the bar is mounted. */
+body[data-mobile] #term,
+body[data-mobile] #panes {
+ inset: var(--tabs) 0 auto 0;
+ width: 100%;
+ height: calc(var(--vvh, 100%) - var(--tabs) - var(--keybar));
+}
+/* The browser must not pan or zoom the page: every finger on the canvas is
+ the terminal's, and touch.ts decides what it meant. */
+body[data-mobile] canvas#term { touch-action: none; }
+body[data-mobile] #tabs { -webkit-overflow-scrolling: touch; }
+/* Only the zoom button fits beside the capsules on a phone; a split and a
+ new tab are the tab row's and the menus'. */
+body[data-mobile] .nav .act[data-action=new-tab],
+body[data-mobile] .nav .act[data-action=split-right],
+body[data-mobile] .nav .act[data-action=split-below] { display: none; }
+/* The two panels are drawers: over the canvas, resizing nothing, or not
+ there at all. */
+body[data-mobile] #side,
+body[data-mobile] #agents {
+ top: var(--tabs);
+ bottom: auto;
+ height: calc(var(--vvh, 100%) - var(--tabs) - var(--keybar));
+ width: min(300px, 85vw);
+ z-index: 15;
+ box-shadow: 0 8px 28px rgba(0,0,0,.42);
+}
+body[data-mobile] #side { display: none; }
+body[data-mobile] #side.open { display: block; }
+/* Their edges are dragged with a pointer, which a phone has not got. */
+body[data-mobile] #side .handle,
+body[data-mobile] #agents .handle { display: none; }
+/* Behind whichever drawer is out: a press here puts it away. */
+#scrim { position: fixed; inset: 0; z-index: 14; background: rgba(0,0,0,.34); }
+/* A menu row a finger can hit. */
+body[data-mobile] .menu .mi { height: 40px; }
+/* The key bar, along the foot of the visual viewport; `top` is the bar's
+ own, since the soft keyboard moves that foot up the window. It scrolls
+ sideways when the keys do not fit. */
+#keybar {
+ position: fixed; left: 0; right: 0; height: 44px; z-index: 16; box-sizing: border-box;
+ display: flex; align-items: center; gap: 4px; padding: 0 6px;
+ background: var(--ctl); border-top: 1px solid var(--ctl-border);
+ overflow-x: auto; overflow-y: hidden; white-space: nowrap;
+ scrollbar-width: none; user-select: none; touch-action: manipulation;
+}
+#keybar::-webkit-scrollbar { display: none; }
+#keybar .k {
+ flex: 0 0 auto; min-width: 44px; height: 34px; margin: 0; padding: 0 8px;
+ display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
+ border-radius: 8px; border: 1px solid var(--ctl-border); background: var(--ctl-hover);
+ color: var(--text); font: 500 13px var(--ui);
+ touch-action: manipulation; -webkit-tap-highlight-color: transparent;
+}
+#keybar .k:active { background: var(--ctl-pressed); }
+/* An armed modifier: it is spent on the next key, from here or from the
+ soft keyboard. */
+#keybar .k.armed { background: var(--accent); border-color: transparent; color: #FFFFFF; }
diff --git a/thinkterm-web/ui/src/touch.ts b/thinkterm-web/ui/src/touch.ts
new file mode 100644
index 00000000..33a1209d
--- /dev/null
+++ b/thinkterm-web/ui/src/touch.ts
@@ -0,0 +1,275 @@
+// Touch on the terminal canvas, and the drawer's swipes.
+//
+// The canvas's handlers are installed in the CAPTURE phase on the canvas
+// itself, so they run before the wasm's own (thinkterm-web/src/input.rs),
+// which sit on the same element without capture. A tap is left to them --
+// their pointerdown focuses the pane and takes the terminal over, their
+// pointerup completes the click -- while a drag becomes wheel notches and
+// a long press becomes the pane's menu; both of those swallow the rest of
+// the gesture so the wasm never starts a selection.
+//
+// The wasm has already seen the pointerdown by the time a gesture turns
+// into a drag, so it is told the press is over with a synthetic
+// `pointercancel` -- which it handles as an Up -- dispatched at the point
+// the press began. At the anchor the selection is empty, which is the one
+// case its Up throws the selection away instead of copying it.
+
+import { openMenu } from './menu.svelte';
+import { mobile, openSide } from './mobile.svelte';
+import { cellHeight, paneAt } from './pane';
+
+/** How far a finger may wander and still be a tap. */
+const SLOP = 8;
+/** How long a press has to rest before it is the pane's menu. */
+const HOLD = 500;
+/** A press shorter than this, that did not wander, is a tap. */
+const TAP = 300;
+/** A cell to scroll by while the layout has not named one. */
+const CELL = 17;
+/** How long after a long press the browser's own menu is still refused. */
+const SETTLED = 1000;
+
+type Finger = { x: number; y: number };
+
+/** What the gesture turned out to be; `press` until it is decided. */
+type Mode = 'press' | 'scroll' | 'menu';
+
+export function installTouch(canvas: HTMLCanvasElement): () => void {
+ const fingers = new Map<number, Finger>();
+ /** The finger the gesture belongs to: the first one down. */
+ let first: number | null = null;
+ let startX = 0;
+ let startY = 0;
+ let startAt = 0;
+ let mode: Mode = 'press';
+ let hold: ReturnType<typeof setTimeout> | null = null;
+ /** Where the last wheel was measured from, and the pixels not yet worth
+ a whole cell. */
+ let lastY = 0;
+ let pending = 0;
+ /** When the long press last opened a menu, so the browser's own -- which
+ some phones fire on top of it -- can be refused. */
+ let opened = 0;
+
+ const stopHold = () => {
+ if (hold === null) return;
+ clearTimeout(hold);
+ hold = null;
+ };
+
+ /** The midpoint of the fingers down, which is what two of them scroll by. */
+ const midpoint = (): Finger | null => {
+ let x = 0;
+ let y = 0;
+ let n = 0;
+ for (const f of fingers.values()) {
+ x += f.x;
+ y += f.y;
+ n += 1;
+ }
+ return n === 0 ? null : { x: x / n, y: y / n };
+ };
+
+ /** Tell the wasm the press it saw is over, at the point it began. */
+ const cancelPress = () => {
+ canvas.dispatchEvent(
+ new PointerEvent('pointercancel', {
+ pointerId: first ?? 1,
+ pointerType: 'touch',
+ isPrimary: true,
+ bubbles: true,
+ cancelable: true,
+ clientX: startX,
+ clientY: startY,
+ }),
+ );
+ };
+
+ /** Scroll by what the fingers moved, a whole cell at a time: the wasm
+ rounds any wheel up to one notch, so a few pixels handed over one
+ event at a time would run away from the finger. */
+ const scrollBy = (dy: number, at: Finger) => {
+ pending += dy;
+ const cell = cellHeight(canvas, CELL);
+ const cells = Math.trunc(pending / cell);
+ if (cells === 0) return;
+ pending -= cells * cell;
+ // Down the screen is back through the scrollback, as a wheel's is.
+ canvas.dispatchEvent(
+ new WheelEvent('wheel', {
+ deltaY: -cells * cell,
+ deltaMode: 0,
+ bubbles: true,
+ cancelable: true,
+ clientX: at.x,
+ clientY: at.y,
+ }),
+ );
+ };
+
+ /** The gesture is the page's from here on: the wasm's press is undone
+ and every event left in the gesture is swallowed. */
+ const takeOver = (next: Mode) => {
+ stopHold();
+ mode = next;
+ cancelPress();
+ const mid = midpoint();
+ lastY = mid ? mid.y : startY;
+ pending = 0;
+ };
+
+ const down = (ev: PointerEvent) => {
+ if (!ev.isTrusted || ev.pointerType !== 'touch') return;
+ fingers.set(ev.pointerId, { x: ev.clientX, y: ev.clientY });
+ if (first === null) {
+ first = ev.pointerId;
+ startX = ev.clientX;
+ startY = ev.clientY;
+ startAt = ev.timeStamp;
+ lastY = ev.clientY;
+ pending = 0;
+ mode = 'press';
+ hold = setTimeout(() => {
+ hold = null;
+ if (mode !== 'press') return;
+ takeOver('menu');
+ opened = Date.now();
+ const pane = paneAt(canvas, startX, startY);
+ if (pane !== null) openMenu('pane', String(pane), startX, startY);
+ }, HOLD);
+ // The press itself goes to the wasm: it focuses the pane and takes
+ // the terminal over, which is what a tap is for.
+ return;
+ }
+ // A second finger is the page's, not the wasm's: two fingers scroll.
+ ev.stopImmediatePropagation();
+ ev.preventDefault();
+ if (mode === 'press') takeOver('scroll');
+ };
+
+ const move = (ev: PointerEvent) => {
+ if (!ev.isTrusted || ev.pointerType !== 'touch') return;
+ if (!fingers.has(ev.pointerId)) return;
+ fingers.set(ev.pointerId, { x: ev.clientX, y: ev.clientY });
+ if (mode === 'menu') {
+ ev.stopImmediatePropagation();
+ return;
+ }
+ if (mode === 'press') {
+ const far = Math.abs(ev.clientX - startX) > SLOP || Math.abs(ev.clientY - startY) > SLOP;
+ if (!far) return;
+ takeOver('scroll');
+ }
+ ev.stopImmediatePropagation();
+ const mid = midpoint();
+ if (!mid) return;
+ const dy = mid.y - lastY;
+ lastY = mid.y;
+ if (dy !== 0) scrollBy(dy, mid);
+ };
+
+ const up = (ev: PointerEvent) => {
+ if (!ev.isTrusted || ev.pointerType !== 'touch') return;
+ if (!fingers.delete(ev.pointerId)) return;
+ if (mode !== 'press') {
+ // The wasm was told the press was cancelled; the release must not
+ // reach it as a click in whatever cell the finger ended over.
+ ev.stopImmediatePropagation();
+ } else if (
+ ev.pointerId === first &&
+ ev.timeStamp - startAt < TAP &&
+ Math.abs(ev.clientX - startX) <= SLOP &&
+ Math.abs(ev.clientY - startY) <= SLOP
+ ) {
+ // A tap goes through untouched. The soft keyboard is the page's to
+ // ask for, and asking has to happen inside the press itself.
+ document.getElementById('kbd')?.focus();
+ }
+ if (ev.pointerId !== first) return;
+ stopHold();
+ first = null;
+ mode = 'press';
+ fingers.clear();
+ };
+
+ const contextmenu = (ev: Event) => {
+ // The long press already put the pane's menu up; a phone that fires
+ // its own contextmenu on top of that must not open a second one.
+ if (Date.now() - opened > SETTLED) return;
+ ev.preventDefault();
+ ev.stopImmediatePropagation();
+ };
+
+ canvas.addEventListener('pointerdown', down, true);
+ canvas.addEventListener('pointermove', move, true);
+ canvas.addEventListener('pointerup', up, true);
+ canvas.addEventListener('pointercancel', up, true);
+ canvas.addEventListener('contextmenu', contextmenu, true);
+ return () => {
+ stopHold();
+ canvas.removeEventListener('pointerdown', down, true);
+ canvas.removeEventListener('pointermove', move, true);
+ canvas.removeEventListener('pointerup', up, true);
+ canvas.removeEventListener('pointercancel', up, true);
+ canvas.removeEventListener('contextmenu', contextmenu, true);
+ };
+}
+
+/** How near the window's left edge a swipe has to start to be the drawer's. */
+const EDGE = 20;
+/** How far it has to travel before it counts. */
+const TRAVEL = 60;
+
+/** The drawer's swipes: from the window's left edge to bring the panel out,
+ back to the left to put it away. Watched on the window in the capture
+ phase, so a finger on the canvas is seen before the canvas's own
+ handlers swallow it. */
+export function installSwipe(): () => void {
+ let id: number | null = null;
+ let x0 = 0;
+ let y0 = 0;
+ /** What this gesture could still do, once it has travelled far enough. */
+ let want: 'open' | 'close' | null = null;
+
+ const down = (ev: PointerEvent) => {
+ if (!ev.isTrusted || ev.pointerType !== 'touch' || id !== null || !mobile.on) return;
+ if (mobile.side) want = 'close';
+ else if (ev.clientX <= EDGE) want = 'open';
+ else return;
+ id = ev.pointerId;
+ x0 = ev.clientX;
+ y0 = ev.clientY;
+ };
+
+ const move = (ev: PointerEvent) => {
+ if (!ev.isTrusted || ev.pointerId !== id || want === null) return;
+ const dx = ev.clientX - x0;
+ const dy = ev.clientY - y0;
+ // A finger going mostly down the screen is scrolling a list, not
+ // moving the drawer.
+ if (Math.abs(dx) < TRAVEL || Math.abs(dx) <= Math.abs(dy)) return;
+ if (want === 'open' && dx > 0) openSide(true);
+ else if (want === 'close' && dx < 0) openSide(false);
+ want = null;
+ };
+
+ const up = (ev: PointerEvent) => {
+ // The canvas cancels the press it handed the wasm when a gesture turns
+ // into a drag, and that cancellation reaches this listener too: it is
+ // not the finger leaving the glass, and must not end the swipe.
+ if (!ev.isTrusted || ev.pointerId !== id) return;
+ id = null;
+ want = null;
+ };
+
+ window.addEventListener('pointerdown', down, true);
+ window.addEventListener('pointermove', move, true);
+ window.addEventListener('pointerup', up, true);
+ window.addEventListener('pointercancel', up, true);
+ return () => {
+ window.removeEventListener('pointerdown', down, true);
+ window.removeEventListener('pointermove', move, true);
+ window.removeEventListener('pointerup', up, true);
+ window.removeEventListener('pointercancel', up, true);
+ };
+}
diff --git a/thinkterm-web/ui/svelte.config.js b/thinkterm-web/ui/svelte.config.js
new file mode 100644
index 00000000..36c98fd0
--- /dev/null
+++ b/thinkterm-web/ui/svelte.config.js
@@ -0,0 +1,3 @@
+import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
+
+export default { preprocess: vitePreprocess() };
diff --git a/thinkterm-web/ui/tsconfig.json b/thinkterm-web/ui/tsconfig.json
new file mode 100644
index 00000000..8d94bedb
--- /dev/null
+++ b/thinkterm-web/ui/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "extends": "@tsconfig/svelte/tsconfig.json",
+ "compilerOptions": {
+ "target": "es2023",
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "types": ["svelte", "vite/client"],
+ "strict": true,
+ "noEmit": true,
+ "verbatimModuleSyntax": true
+ },
+ "include": ["src/**/*.ts", "src/**/*.svelte", "src/**/*.d.ts"]
+}
diff --git a/thinkterm-web/ui/vite.config.ts b/thinkterm-web/ui/vite.config.ts
new file mode 100644
index 00000000..925cd969
--- /dev/null
+++ b/thinkterm-web/ui/vite.config.ts
@@ -0,0 +1,20 @@
+import { defineConfig } from 'vite';
+import { svelte } from '@sveltejs/vite-plugin-svelte';
+
+// The page is served from whatever directory the mux server was pointed at,
+// so every URL it emits has to be relative; pkg/ and fonts/ are written into
+// the same directory by ci/build-web.sh and must survive the build.
+export default defineConfig({
+ plugins: [svelte()],
+ base: './',
+ publicDir: false,
+ build: {
+ outDir: '../www',
+ emptyOutDir: false,
+ target: 'esnext',
+ cssCodeSplit: false,
+ assetsDir: 'assets',
+ sourcemap: false,
+ modulePreload: { polyfill: false },
+ },
+});
diff --git a/thinkterm-web/www/app.js b/thinkterm-web/www/app.js
deleted file mode 100644
index b1d0aa15..00000000
--- a/thinkterm-web/www/app.js
+++ /dev/null
@@ -1,81 +0,0 @@
-// The page: pick up the token, fetch the fonts, start the wasm client.
-import init, { start, color_check, fallback_check, graphics_check } from "./pkg/thinkterm_web.js";
-
-const status = document.getElementById("status");
-const fail = (msg) => { status.textContent = msg; status.classList.add("error"); console.error(msg); };
-
-// The token arrives once in the URL fragment -- never sent to the server,
-// never in a Referer -- and is kept for this tab only; the address bar is
-// cleaned so it is not copied or bookmarked by accident.
-const params = new URLSearchParams(location.search);
-const fragment = new URLSearchParams(location.hash.replace(/^#/, ""));
-// A browser that blocks storage throws on the first touch; the token then
-// lives only in this page load, and the failure is reported, not silent.
-let token = fragment.get("token");
-if (token) {
- // Out of the address bar first, and outside the try: a browser that
- // blocks storage throws on setItem, and doing this after it meant the
- // token stayed in the URL -- visible in the bar, in a screenshot, and in
- // whatever the user pastes next -- in exactly the case the comment said
- // it would not.
- history.replaceState(null, "", location.pathname + location.search);
-}
-try {
- if (token) {
- sessionStorage.setItem("thinkterm.token", token);
- } else {
- token = sessionStorage.getItem("thinkterm.token");
- }
-} catch (e) {
- console.warn("session storage unavailable; the token is kept for this load only", e);
-}
-const requested = Number(params.get("font"));
-// Without `?font=` the page takes the desktop's cell size once attached.
-const fontPinned = Number.isFinite(requested) && requested >= 6 && requested <= 72;
-const fontSize = fontPinned ? requested : 12;
-// The CSS font stack the glyph fallback draws with. This is also how the
-// regional shape of a Han character is chosen; see canvas.rs.
-const glyphFont = params.get("glyphfont") || "";
-// The desktop is dark unless told otherwise; so is the page.
-if (params.get("theme") === "light") document.documentElement.dataset.theme = "light";
-
-const FONTS = [
- ["JetBrains Mono", "./fonts/JetBrainsMono-Regular.ttf"],
- ["Symbols Nerd Font Mono", "./fonts/SymbolsNerdFontMono-Regular.ttf"],
-];
-
-async function fetchFont(url) {
- const res = await fetch(url);
- if (!res.ok) throw new Error(`${url}: ${res.status}`);
- return new Uint8Array(await res.arrayBuffer());
-}
-
-try {
- await init();
- const check = params.get("check");
- if (check === "fallback") {
- // Deliberately before the WebGPU check: this one draws on a 2D canvas
- // and needs no GPU, no token and no pane, which is what lets it run on
- // Safari, on Firefox, and on a machine with hardly any fonts installed
- // -- the place the glyph fallback is most likely to fail.
- const names = FONTS.map(([n]) => n);
- const data = await Promise.all(FONTS.map(([, u]) => fetchFont(u)));
- status.textContent = "FALLBACK " + fallback_check(names, data, fontSize, glyphFont);
- } else if (!navigator.gpu) {
- throw new Error("WebGPU is not available: open the page over https or http://localhost in a browser with WebGPU enabled");
- } else if (check === "color") {
- status.textContent = "COLOR " + await color_check("term");
- } else if (check === "graphics") {
- const names = FONTS.map(([n]) => n);
- const data = await Promise.all(FONTS.map(([, u]) => fetchFont(u)));
- status.textContent = "GRAPHICS " + await graphics_check(names, data, fontSize);
- } else {
- if (!token) throw new Error("no token: open the URL that `thinkterm cli web-token mint` printed");
- const names = FONTS.map(([n]) => n);
- const data = await Promise.all(FONTS.map(([, u]) => fetchFont(u)));
- const scheme = location.protocol === "https:" ? "wss" : "ws";
- await start("term", "kbd", "status", `${scheme}://${location.host}/ws`, token, names, data, fontSize, glyphFont, fontPinned);
- }
-} catch (e) {
- fail(String(e && e.message ? e.message : e));
-}
diff --git a/thinkterm-web/www/index.html b/thinkterm-web/www/index.html
index c490fa0f..690360d8 100644
--- a/thinkterm-web/www/index.html
+++ b/thinkterm-web/www/index.html
@@ -4,115 +4,10 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ThinkTerm</title>
-<style>
- /* The desktop's chrome (wezterm-gui/src/ui/tokens.rs, fancy_tab_bar.rs,
- render/pane.rs): its palette, its 40 px tab row of 160 px capsules,
- its bar above every pane. Dark is the desktop's default whatever the
- OS says; ?theme=light picks the other set. */
- :root {
- --bg: #19191A; --side-bg: #121214; --sep: rgba(84,84,88,.22);
- --ctl: rgba(45,45,47,.98); --ctl-hover: rgba(55,55,57,.98); --ctl-pressed: rgba(66,66,69,.98); --ctl-border: rgba(118,118,128,.28);
- --text: #F2F2F7; --text2: #C7C7CC; --muted: #8E8E93; --accent: #0A84FF; --danger: #FF453A;
- --wash: rgba(242,242,247,.025); --ring: rgba(242,242,247,.12); --edge: rgba(242,242,247,.38); --shadow: 0 .5px 0 1px rgba(0,0,0,.12);
- --ui: -apple-system, "SF Pro Text", "Helvetica Neue", Roboto, system-ui, sans-serif;
- --tabs: 40px; --side-w: 220px;
- --done: #7CE5A2; --open: #61B8FF;
- }
- body[data-side=off] { --side-w: 0px; }
- [data-theme=light] {
- --bg: #EEEEF2; --side-bg: #E2E2E8; --sep: rgba(60,60,67,.18);
- --ctl: rgba(255,255,255,.94); --ctl-hover: rgba(247,247,250,.98); --ctl-pressed: rgba(232,242,255,.98); --ctl-border: rgba(60,60,67,.20);
- --text: #1C1C1E; --text2: #48484A; --muted: #8E8E93; --accent: #007AFF; --danger: #D7263D;
- --wash: rgba(28,28,30,.025); --ring: rgba(28,28,30,.12); --edge: rgba(28,28,30,.38); --shadow: 0 .5px 0 1px rgba(0,0,0,.04);
- }
- html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text2); font: 500 14px var(--ui); overflow: hidden; }
- svg { width: 16px; height: 16px; flex: none; }
- /* The window's tab row. Capsules never shrink; the row scrolls. */
- #tabs { position: absolute; left: var(--side-w); right: 0; top: 0; height: var(--tabs); box-sizing: border-box; display: flex; align-items: center; gap: 9px; padding: 2px 8px 0 8px; background: var(--bg); overflow-x: auto; overflow-y: hidden; white-space: nowrap; user-select: none; scrollbar-width: none; }
- #tabs::-webkit-scrollbar { display: none; }
- #tabs .tab { display: inline-flex; align-items: center; flex: 0 0 auto; width: 160px; height: 30px; box-sizing: border-box; padding: 0 9px; border-radius: 999px; border: 1px solid transparent; color: var(--text2); cursor: default; }
- #tabs .tab:hover { background: var(--ctl-hover); }
- #tabs .tab.current { background: var(--ctl); border-color: var(--ctl-border); box-shadow: var(--shadow); color: var(--text); }
- .t { margin-left: 4px; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
- .x { display: none; margin-left: 4px; width: 22px; height: 22px; border-radius: 999px; align-items: center; justify-content: center; opacity: .82; flex: none; }
- .current .x, .tab:hover .x, .cap:hover .x { display: inline-flex; }
- .x:hover { background: var(--ring); opacity: 1; }
- .x.danger { width: auto; padding: 0 6px; font-size: 11px; color: var(--danger); opacity: 1; }
- .act { width: 30px; height: 30px; flex: none; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; box-sizing: border-box; color: var(--text2); }
- .act:hover { background: var(--ctl-hover); border-color: var(--edge); color: var(--text); }
- #tabs .trail { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
- #tabs .hint { color: var(--muted); font-size: 12px; padding: 0 6px; }
- #tabs .follow { color: var(--muted); font-size: 12px; padding: 0 8px; height: 24px; line-height: 24px; border-radius: 999px; cursor: default; }
- #tabs .follow.on { color: var(--accent); }
- #tabs .follow:hover { background: var(--ctl-hover); }
- #term { position: absolute; inset: var(--tabs) 0 0 var(--side-w); width: calc(100% - var(--side-w)); height: calc(100% - var(--tabs)); display: block; outline: none; }
- /* One bar over each pane, laid out from the canvas's cells. */
- #panes { position: absolute; inset: var(--tabs) 0 0 var(--side-w); pointer-events: none; overflow: hidden; }
- /* The desktop's left sidebar: Spaces, Projects, Threads. */
- #side { position: absolute; left: 0; top: 0; bottom: 0; width: var(--side-w); box-sizing: border-box; background: var(--side-bg); border-right: 1px solid var(--sep); font: 500 15px var(--ui); color: var(--text2); user-select: none; overflow: hidden; }
- body[data-side=off] #side { display: none; }
- #side .list { position: absolute; inset: 26px 5px 0 5px; overflow-y: auto; scrollbar-width: thin; display: flex; flex-direction: column; gap: 5px; padding-bottom: 32px; }
- #side .handle { position: absolute; right: -2px; top: 0; bottom: 0; width: 4px; cursor: col-resize; z-index: 1; }
- #side .row { display: flex; align-items: center; min-height: 33px; box-sizing: border-box; padding: 0 5px; border-radius: 10px; border: 1px solid transparent; flex: none; }
- #side .row.thread { padding-left: 25px; }
- #side .row .t { margin-left: 5px; color: var(--text); }
- #side .row.project .t, #side .row.space .t { color: var(--text2); }
- #side .row:hover { background: rgba(42,42,44,.98); }
- #side .row.selected { background: rgba(62,62,65,.98); border-color: rgba(118,118,128,.22); box-shadow: var(--shadow); }
- #side .row.archived { opacity: .55; }
- #side .chev { display: inline-flex; width: 16px; margin-right: 2px; color: var(--muted); }
- #side .hov { display: none; margin-left: auto; gap: 2px; }
- #side .row:hover .hov { display: inline-flex; }
- #side .act { width: 24px; height: 24px; }
- #side .act svg { width: 13px; height: 13px; }
- #side .hdr { display: flex; align-items: center; gap: 5px; min-height: 33px; padding: 0 10px; color: var(--text2); font-size: 14px; margin-top: 6px; }
- #side .hdr .act { margin-left: auto; }
- #side .hdr.sub { cursor: default; }
- #side .pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; margin: 4px 10px 6px 10px; border-radius: 999px; background: rgba(36,36,38,.94); border: 1px solid rgba(118,118,128,.22); color: var(--text); flex: none; }
- #side .pill:hover { background: rgba(48,48,50,.98); }
- #side .st { display: inline-flex; width: 13px; height: 13px; align-items: center; justify-content: center; margin-left: 6px; flex: none; }
- #side .st svg { width: 13px; height: 13px; }
- #side .st.alert svg { width: 10px; height: 10px; }
- #side .st.done { color: var(--done); }
- #side .st.dot::before { content: ""; width: 5px; height: 5px; border-radius: 999px; background: rgba(242,242,247,.16); }
- #side .st.dot.active::before { background: var(--done); }
- #side .st.dot.unread::before { background: #3A3A3C; }
- #side .st.dot.pinned::before { background: rgba(242,242,247,.68); }
- #side .st.dot.open::before { background: var(--open); }
- #side input.rename { font: 500 15px var(--ui); color: var(--text); background: #3A3A3C; border: 0; border-radius: 4px; padding: 2px 4px; margin-left: 5px; flex: 1 1 auto; min-width: 0; outline: none; }
- #side .path { display: flex; align-items: center; gap: 5px; padding: 0 10px; }
- #side .path input { flex: 1 1 auto; min-width: 0; font: 14px var(--ui); color: var(--text); background: var(--ctl); border: 1px solid var(--ctl-border); border-radius: 6px; padding: 4px 6px; outline: none; }
- .nav { position: absolute; pointer-events: auto; box-sizing: border-box; display: flex; align-items: center; gap: 9px; padding: 0 5px; background: var(--bg); color: var(--text2); user-select: none; overflow: hidden; }
- .nav.focused { color: var(--text); }
- .nav .caps { display: flex; gap: 9px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
- .nav .cap { display: inline-flex; align-items: center; flex: 0 0 auto; width: 160px; height: 30px; box-sizing: border-box; padding: 0 9px; border-radius: 999px; border: 1px solid transparent; background: var(--wash); color: var(--text2); cursor: default; }
- .nav .cap.current { background: var(--ctl); border-color: var(--ctl-border); box-shadow: var(--shadow); color: inherit; }
- .nav .cap:hover:not(.current) { background: var(--ctl-hover); }
- .nav .acts { display: flex; gap: 2px; margin-left: auto; flex: none; }
- .nav .act svg { width: 13px; height: 13px; }
- .spin { display: inline-flex; animation: spin .96s steps(12) infinite; }
- @keyframes spin { to { transform: rotate(360deg); } }
- /* What the desktop shows over a terminal another device holds. */
- #card { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); text-align: center; padding: 26px 36px; border-radius: 18px; background: color-mix(in srgb, var(--bg) 86%, transparent); border: 1px solid var(--ctl-border); pointer-events: none; user-select: none; }
- #card .eyes { font: 17px var(--ui); color: var(--muted); letter-spacing: 2px; margin-bottom: 8px; }
- #card .title { font: 500 17px var(--ui); color: var(--text); }
- #card .hint { font: 15px var(--ui); color: var(--text2); margin-top: 10px; }
- /* Passing remarks: refusals, reconnects. */
- #status { position: absolute; right: 12px; bottom: 12px; max-width: 60%; padding: 7px 11px; border-radius: 8px; background: var(--ctl); border: 1px solid var(--ctl-border); color: var(--text); font: 13px var(--ui); box-shadow: 0 2px 12px rgba(0,0,0,.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
- #status.error { color: var(--danger); }
- /* Focus lives here so the IME composes into a real text field; the
- field itself stays out of sight. */
- #kbd { position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; margin: 0; resize: none; overflow: hidden; pointer-events: none; }
-</style>
+ <script type="module" crossorigin src="./assets/index-DMyqPlHN.js"></script>
+ <link rel="stylesheet" crossorigin href="./assets/style-CjBBEP7C.css">
</head>
<body>
-<aside id="side"></aside>
-<div id="tabs"></div>
-<canvas id="term"></canvas>
-<div id="panes"></div>
-<div id="card" hidden><div class="eyes">• •</div><div class="title"></div><div class="hint"></div></div>
-<textarea id="kbd" wrap="off" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false"></textarea>
-<div id="status">loading…</div>
-<script type="module" src="./app.js"></script>
+<div id="app"></div>
</body>
</html>