From bb66531e5c6ad860eb27d8cdde31dd7afeb11537 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sat, 10 Oct 2026 20:15:59 +0000 Subject: [PATCH 1/3] feat(desktop): Lens.app updates itself from each release Tauri's updater checks the latest release's latest.json a minute after launch and every six hours, installs a newer Lens.app whose signature matches the public key built in (LENS_UPDATER_PUBKEY), and restarts quietly in the menu bar. The Desktop workflow signs the update and publishes latest.json when the repository has the update key. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_014VrJQhkYVDyhgVQcok4neG --- .github/workflows/desktop.yml | 48 ++- CHANGELOG.md | 3 +- desktop/README.md | 20 ++ desktop/src-tauri/Cargo.lock | 577 +++++++++++++++++++++++++++++- desktop/src-tauri/Cargo.toml | 1 + desktop/src-tauri/src/main.rs | 116 +++++- desktop/src-tauri/tauri.conf.json | 21 +- docs/get-started.md | 2 + 8 files changed, 765 insertions(+), 23 deletions(-) diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml index e6af443ee..8ddbc44f0 100644 --- a/.github/workflows/desktop.yml +++ b/.github/workflows/desktop.yml @@ -7,6 +7,11 @@ name: Desktop # # Signed and notarized when the repository has the secrets for it (APPLE_CERTIFICATE, APPLE_CERTIFICATE_PASSWORD, # APPLE_SIGNING_IDENTITY, and APPLE_ID, APPLE_PASSWORD, APPLE_TEAM_ID to notarize); else unsigned. +# +# Updates itself when the repository has an update key: the secret TAURI_SIGNING_PRIVATE_KEY (and +# TAURI_SIGNING_PRIVATE_KEY_PASSWORD if it has one) and the variable LENS_UPDATER_PUBKEY, its public half, which is +# built into the app. Each release then also carries Lens-macOS-arm64.app.tar.gz, its signature, and latest.json, which +# the app checks (desktop/README.md#updates). Without them the app is built without updates. on: release: types: [published] @@ -81,6 +86,9 @@ jobs: cargo clippy --locked -- -D warnings - name: Signing, when the secrets are there env: + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + LENS_UPDATER_PUBKEY: ${{ vars.LENS_UPDATER_PUBKEY }} APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }} @@ -89,7 +97,8 @@ jobs: APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | # Tauri signs when these are set, so only the ones that have a value are passed on - for k in APPLE_CERTIFICATE APPLE_CERTIFICATE_PASSWORD APPLE_SIGNING_IDENTITY APPLE_ID APPLE_PASSWORD APPLE_TEAM_ID; do + for k in APPLE_CERTIFICATE APPLE_CERTIFICATE_PASSWORD APPLE_SIGNING_IDENTITY APPLE_ID APPLE_PASSWORD APPLE_TEAM_ID \ + TAURI_SIGNING_PRIVATE_KEY TAURI_SIGNING_PRIVATE_KEY_PASSWORD LENS_UPDATER_PUBKEY; do eval "v=\${$k:-}" if [ -n "$v" ]; then { @@ -99,7 +108,13 @@ jobs: } >>"$GITHUB_ENV" fi done - [ -n "$APPLE_SIGNING_IDENTITY" ] && echo "Signed as the repository's identity" || echo "Unsigned: no signing secrets" + if [ -n "$APPLE_SIGNING_IDENTITY" ]; then echo "Signed as the repository's identity"; else echo "Unsigned: no signing secrets"; fi + if [ -n "$TAURI_SIGNING_PRIVATE_KEY" ] && [ -n "$LENS_UPDATER_PUBKEY" ]; then + echo "LENS_UPDATES=1" >>"$GITHUB_ENV" + echo "Updates itself: the update key is there" + else + echo "Doesn't update itself: no TAURI_SIGNING_PRIVATE_KEY secret and LENS_UPDATER_PUBKEY variable" + fi - name: Build working-directory: desktop env: @@ -111,9 +126,38 @@ jobs: if [ -n "$TAG" ]; then config="$(echo "$config" | python3 -c 'import json,sys; c=json.load(sys.stdin); c["version"]=sys.argv[1].lstrip("v"); print(json.dumps(c))' "$TAG")" fi + if [ "${LENS_UPDATES:-0}" = 1 ]; then # the signed .app.tar.gz the updater downloads + config="$(echo "$config" | python3 -c 'import json,sys; c=json.load(sys.stdin); c["bundle"]["createUpdaterArtifacts"]=True; print(json.dumps(c))')" + fi npx tauri build --config "$config" --bundles app,dmg mkdir -p ../dist/desktop cp src-tauri/target/release/bundle/dmg/*.dmg ../dist/desktop/Lens-macOS-arm64.dmg + if [ "${LENS_UPDATES:-0}" = 1 ]; then + cp src-tauri/target/release/bundle/macos/Lens.app.tar.gz ../dist/desktop/Lens-macOS-arm64.app.tar.gz + cp src-tauri/target/release/bundle/macos/Lens.app.tar.gz.sig ../dist/desktop/Lens-macOS-arm64.app.tar.gz.sig + # what the app checks: releases/latest/download/latest.json + python3 - "${TAG:-}" "${{ github.repository }}" <<'PY' + import datetime, json, sys + tag, repo = sys.argv[1], sys.argv[2] + conf = json.load(open("src-tauri/tauri.conf.json")) + version = tag.lstrip("v") if tag else conf["version"] + ref = tag or "unreleased" + sig = open("../dist/desktop/Lens-macOS-arm64.app.tar.gz.sig").read().strip() + manifest = { + "version": version, + "notes": f"https://github.com/{repo}/releases/tag/{ref}", + "pub_date": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), + "platforms": { + "darwin-aarch64": { + "signature": sig, + "url": f"https://github.com/{repo}/releases/download/{ref}/Lens-macOS-arm64.app.tar.gz", + } + }, + } + json.dump(manifest, open("../dist/desktop/latest.json", "w"), indent=2) + PY + cat ../dist/desktop/latest.json + fi ls -l ../dist/desktop - name: The app carries its helper and microsandbox run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index af520a3ed..c93b47855 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version - **A Mac app.** Lens.app (`Lens-macOS-arm64.dmg`, Apple silicon) installs Lens in the web installer shown in its window, with microsandbox inside it so no Docker is needed, then lives in the menu bar: open, start, stop and update Lens, and show its logs. Lens itself opens in the browser, where passkeys work - ([Get started](docs/get-started.md#the-mac-app)). + ([Get started](docs/get-started.md#the-mac-app)). It updates itself from each release, checking the update's + signature, once the repository has an update key ([desktop/README.md](desktop/README.md#updates)). - **Slack, built in.** Settings › Slack creates a Slack app from Lens's manifest in one click; paste its two tokens and the assistant answers direct messages, what's said to it in channels and `/lens …`, over Socket Mode: no diff --git a/desktop/README.md b/desktop/README.md index 1f0b9cdde..93979ca4e 100644 --- a/desktop/README.md +++ b/desktop/README.md @@ -47,6 +47,26 @@ Application `.p12`), `APPLE_CERTIFICATE_PASSWORD`, `APPLE_SIGNING_IDENTITY`, and `APPLE_PASSWORD` (an app-specific password) and `APPLE_TEAM_ID`. Without them the app is unsigned: right-click it and choose **Open** the first time. +## Updates + +The app updates itself with [Tauri's updater](https://v2.tauri.app/plugin/updater/): a minute after it starts and +every six hours, it reads `latest.json` from the latest release, and when that names a newer version it downloads +`Lens-macOS-arm64.app.tar.gz`, checks its signature against the public key built into the app, replaces itself and +restarts quietly in the menu bar (Lens keeps running meanwhile). **Check for App Updates** in the menu does the same +now. It doesn't update while the web installer is open. Lens itself is updated separately, with **Update Lens**. + +The Desktop workflow signs the update and writes `latest.json` on each release when the repository has an update key. +Make one once, on any computer with Node and the GitHub CLI: + +```bash +npx @tauri-apps/cli signer generate --ci -p "" -w lens-updater.key && + gh secret set TAURI_SIGNING_PRIVATE_KEY -R adeelahmad/lense < lens-updater.key && + gh variable set LENS_UPDATER_PUBKEY -R adeelahmad/lense < lens-updater.key.pub +``` + +Keep `lens-updater.key` somewhere safe: an app built with its public key accepts only updates signed with it. Without +the key, the app is built without updates and its menu says so. + ## Not yet - Starting with the Mac (install.sh's LaunchAgent already starts the sandbox at sign-in). diff --git a/desktop/src-tauri/Cargo.lock b/desktop/src-tauri/Cargo.lock index 157bccd75..03899b460 100644 --- a/desktop/src-tauri/Cargo.lock +++ b/desktop/src-tauri/Cargo.lock @@ -47,6 +47,15 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" +[[package]] +name = "arbitrary" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "atk" version = "0.18.2" @@ -348,6 +357,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation" version = "0.10.1" @@ -371,7 +390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" dependencies = [ "bitflags 2.13.2", - "core-foundation", + "core-foundation 0.10.1", "core-graphics-types", "foreign-types", "libc", @@ -384,7 +403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ "bitflags 2.13.2", - "core-foundation", + "core-foundation 0.10.1", "libc", ] @@ -545,6 +564,17 @@ dependencies = [ "serde_core", ] +[[package]] +name = "derive_arbitrary" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b034bd7d5f032402a2479444dcc6f74e36a03f31854d41680fb240ef682a1ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.7", +] + [[package]] name = "derive_more" version = "2.1.1" @@ -731,6 +761,16 @@ dependencies = [ "typeid", ] +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + [[package]] name = "fastrand" version = "2.5.0" @@ -756,6 +796,16 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "filetime" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" +dependencies = [ + "cfg-if", + "libc", +] + [[package]] name = "find-msvc-tools" version = "0.1.14" @@ -1001,6 +1051,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "getrandom" version = "0.3.4" @@ -1270,6 +1331,21 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.27.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.21" @@ -1289,9 +1365,11 @@ dependencies = [ "percent-encoding", "pin-project-lite", "socket2", + "system-configuration", "tokio", "tower-service", "tracing", + "windows-registry", ] [[package]] @@ -1575,6 +1653,36 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.21", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + [[package]] name = "jni-sys" version = "0.3.1" @@ -1653,6 +1761,7 @@ dependencies = [ "serde_json", "tauri", "tauri-build", + "tauri-plugin-updater", ] [[package]] @@ -1713,6 +1822,12 @@ dependencies = [ "libc", ] +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + [[package]] name = "litemap" version = "0.8.3" @@ -1766,6 +1881,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minisign-verify" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "871285dc19d8d0ebe0eef3d0e99a205f2a71363b122632cbbfa4a6c370a960ce" + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -2015,6 +2136,7 @@ checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ "bitflags 2.13.2", "block2", + "libc", "objc2", "objc2-core-foundation", ] @@ -2030,6 +2152,18 @@ dependencies = [ "objc2-core-foundation", ] +[[package]] +name = "objc2-osa-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f112d1746737b0da274ef79a23aac283376f335f4095a083a267a082f21db0c0" +dependencies = [ + "bitflags 2.13.2", + "objc2", + "objc2-app-kit", + "objc2-foundation", +] + [[package]] name = "objc2-quartz-core" version = "0.3.2" @@ -2093,12 +2227,32 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + [[package]] name = "option-ext" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "osakit" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "732c71caeaa72c065bb69d7ea08717bd3f4863a4f451402fc9513e29dbd5261b" +dependencies = [ + "objc2", + "objc2-foundation", + "objc2-osa-kit", + "serde", + "serde_json", + "thiserror 2.0.21", +] + [[package]] name = "pango" version = "0.18.3" @@ -2473,15 +2627,20 @@ dependencies = [ "http-body", "http-body-util", "hyper", + "hyper-rustls", "hyper-util", "js-sys", "log", "percent-encoding", "pin-project-lite", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", "serde", "serde_json", "sync_wrapper", "tokio", + "tokio-rustls", "tokio-util", "tower", "tower-http", @@ -2493,6 +2652,20 @@ dependencies = [ "web-sys", ] +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rustc-hash" version = "2.1.3" @@ -2508,6 +2681,92 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dab5152771c58876a2146916e53e35057e1a4dfa2b9df0f0305b07f611fdea4d" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys", + "jni 0.22.4", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" + +[[package]] +name = "rustls-webpki" +version = "0.103.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.23" @@ -2523,6 +2782,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "schemars" version = "0.8.22" @@ -2580,6 +2848,29 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags 2.13.2", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "selectors" version = "0.38.0" @@ -2791,6 +3082,22 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "siphasher" version = "1.0.4" @@ -2903,6 +3210,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "swift-rs" version = "1.0.9" @@ -2966,6 +3279,27 @@ dependencies = [ "syn 3.0.7", ] +[[package]] +name = "system-configuration" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" +dependencies = [ + "bitflags 2.13.2", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "system-deps" version = "6.2.2" @@ -2987,7 +3321,7 @@ checksum = "f37f381f4e048e6cdf038b5705f8cf14ad108279d46eb968140a7b291aba9400" dependencies = [ "bitflags 2.13.2", "block2", - "core-foundation", + "core-foundation 0.10.1", "core-graphics", "crossbeam-channel", "dbus", @@ -2997,7 +3331,7 @@ dependencies = [ "gdkwayland-sys", "gdkx11-sys", "gtk", - "jni", + "jni 0.21.1", "libc", "log", "ndk", @@ -3030,6 +3364,17 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "tar" +version = "0.4.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840" +dependencies = [ + "filetime", + "libc", + "xattr", +] + [[package]] name = "target-lexicon" version = "0.12.16" @@ -3053,7 +3398,7 @@ dependencies = [ "gtk", "heck 0.5.0", "http", - "jni", + "jni 0.21.1", "libc", "log", "mime", @@ -3149,6 +3494,56 @@ dependencies = [ "tauri-utils", ] +[[package]] +name = "tauri-plugin" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1140cf34a3b3b836a13103dcab17f18831d5cc3534cbd435dc01a5c6daa65aa2" +dependencies = [ + "anyhow", + "glob", + "plist", + "schemars 0.8.22", + "serde", + "serde_json", + "tauri-utils", + "walkdir", +] + +[[package]] +name = "tauri-plugin-updater" +version = "2.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "855a336eb389d2c1502244fd48fa2d8cb487a430f691bbaed025195f99a04489" +dependencies = [ + "base64 0.22.1", + "dirs", + "flate2", + "futures-util", + "http", + "infer", + "libc", + "log", + "minisign-verify", + "osakit", + "percent-encoding", + "reqwest", + "rustls", + "semver", + "serde", + "serde_json", + "tar", + "tauri", + "tauri-plugin", + "tempfile", + "thiserror 2.0.21", + "time", + "tokio", + "url", + "windows-sys 0.61.2", + "zip", +] + [[package]] name = "tauri-runtime" version = "2.12.1" @@ -3159,7 +3554,7 @@ dependencies = [ "dpi", "gtk", "http", - "jni", + "jni 0.21.1", "objc2", "objc2-ui-kit", "objc2-web-kit", @@ -3182,7 +3577,7 @@ checksum = "7f9e7e0c9f80a5130773cfabb6df4dc924518fb1b2c923726966804634b57d22" dependencies = [ "gtk", "http", - "jni", + "jni 0.21.1", "log", "objc2", "objc2-app-kit", @@ -3249,6 +3644,19 @@ dependencies = [ "toml 1.1.8+spec-1.1.0", ] +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + [[package]] name = "tendril" version = "0.5.1" @@ -3358,6 +3766,16 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "tokio-rustls" +version = "0.26.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.20" @@ -3583,6 +4001,12 @@ version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.8" @@ -3837,6 +4261,15 @@ dependencies = [ "system-deps", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "webview2-com" version = "0.39.1" @@ -4001,6 +4434,17 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + [[package]] name = "windows-result" version = "0.4.1" @@ -4025,7 +4469,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -4043,13 +4496,29 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -4076,42 +4545,90 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winnow" version = "0.5.40" @@ -4170,7 +4687,7 @@ dependencies = [ "gtk", "http", "javascriptcore-rs", - "jni", + "jni 0.21.1", "libc", "ndk", "objc2", @@ -4217,6 +4734,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "xattr" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156" +dependencies = [ + "libc", + "rustix", +] + [[package]] name = "yoke" version = "0.8.3" @@ -4261,6 +4788,12 @@ dependencies = [ "synstructure", ] +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" + [[package]] name = "zerotrie" version = "0.2.5" @@ -4294,6 +4827,18 @@ dependencies = [ "syn 3.0.7", ] +[[package]] +name = "zip" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa8cd6af31c3b31c6631b8f483848b91589021b28fffe50adada48d4f4d2ed1" +dependencies = [ + "arbitrary", + "crc32fast", + "indexmap 2.14.2", + "memchr", +] + [[package]] name = "zlib-rs" version = "0.6.8" diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index 424b09e82..fd0ecd11b 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -12,6 +12,7 @@ tauri-build = { version = "2", features = [] } [dependencies] tauri = { version = "2", features = ["tray-icon"] } serde_json = "1" +tauri-plugin-updater = "2" [profile.release] codegen-units = 1 diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs index 761f1e4dd..a73858c0e 100644 --- a/desktop/src-tauri/src/main.rs +++ b/desktop/src-tauri/src/main.rs @@ -4,12 +4,17 @@ // the web installer, which this app shows in its window; after that it starts Lens and the app opens it in the // browser, since Lens signs in with passkeys and an app's web view can't use them. The menu-bar item starts, stops, // opens and updates Lens. Closing the window leaves the app in the menu bar. +// +// The app updates itself (Tauri's updater): it checks the latest release's latest.json at launch and every six hours, +// and installs a newer Lens.app whose signature checks out against the key built into it, then restarts. A build made +// without that key (LENS_UPDATER_PUBKEY, see desktop/README.md) doesn't update itself. #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] use std::io::{BufRead, BufReader}; use std::path::PathBuf; use std::process::{Command, Stdio}; use std::sync::{Arc, Mutex}; +use std::time::Duration; use tauri::menu::{Menu, MenuItem, PredefinedMenuItem}; use tauri::path::BaseDirectory; @@ -17,6 +22,7 @@ use tauri::tray::TrayIconBuilder; use tauri::{ AppHandle, Manager, Url, WebviewUrl, WebviewWindow, WebviewWindowBuilder, WindowEvent, }; +use tauri_plugin_updater::UpdaterExt; /// The app's own page, as the web view addresses it. #[cfg(any(target_os = "macos", target_os = "ios"))] @@ -24,6 +30,16 @@ const APP_PAGE: &str = "tauri://localhost/index.html"; #[cfg(not(any(target_os = "macos", target_os = "ios")))] const APP_PAGE: &str = "http://tauri.localhost/index.html"; +/// The key that update signatures are checked against; none: the app doesn't update itself. +const UPDATER_PUBKEY: Option<&str> = option_env!("LENS_UPDATER_PUBKEY"); + +/// Set across the restart after an update, so the app comes back quietly in the menu bar. +const UPDATED_ENV: &str = "LENS_APP_UPDATED"; + +fn updates_on() -> bool { + UPDATER_PUBKEY.is_some_and(|k| !k.trim().is_empty()) +} + /// The page the window may show besides its own: the web installer, while it runs. #[derive(Default)] struct Shown(Arc>>); @@ -82,6 +98,11 @@ fn open_in_browser(url: &str) { /// Runs lens-app.sh with a command, and does what its output says (the lines are listed at its top). fn run(app: &AppHandle, command: &'static str) { + run_with(app, command, false) +} + +/// As `run`; `quiet`: Lens isn't opened in the browser when it's running (after an update's restart). +fn run_with(app: &AppHandle, command: &'static str, quiet: bool) { let app = app.clone(); std::thread::spawn(move || { let mut cmd = Command::new("/bin/sh"); @@ -118,7 +139,9 @@ fn run(app: &AppHandle, command: &'static str) { } } "@open" => { - open_in_browser(rest); + if !quiet { + open_in_browser(rest); + } if let Some(w) = window(&app) { set_status( &app, @@ -135,6 +158,56 @@ fn run(app: &AppHandle, command: &'static str) { }); } +/// Checks for a newer Lens.app and installs it, then restarts. `asked`: from the menu, so it says how it went. +fn update_app(app: &AppHandle, asked: bool) { + if !updates_on() { + return; + } + // not while the web installer is in the window: a restart would lose it + if app.state::().0.lock().unwrap().is_some() { + return; + } + let app = app.clone(); + tauri::async_runtime::spawn(async move { + let say = |text: &str, error: bool| { + if asked { + set_status(&app, text, error); + show_window(&app); + } + }; + let update = match app.updater() { + Ok(updater) => updater.check().await, + Err(e) => Err(e), + }; + match update { + Ok(Some(update)) => { + say( + &format!("Updating Lens.app to {}...", update.version), + false, + ); + if let Some(tray) = app.tray_by_id("lens") { + let _ = tray.set_tooltip(Some(format!( + "Lens: updating the app to {}", + update.version + ))); + } + match update.download_and_install(|_, _| {}, || {}).await { + Ok(()) => { + std::env::set_var(UPDATED_ENV, "1"); + app.restart(); + } + Err(e) => say(&format!("Couldn't update Lens.app: {e}"), true), + } + } + Ok(None) => say( + &format!("Lens.app {} is up to date.", app.package_info().version), + false, + ), + Err(e) => say(&format!("Couldn't check for a newer Lens.app: {e}"), true), + } + }); +} + fn origin(url: &Url) -> String { url.origin().ascii_serialization() } @@ -142,7 +215,14 @@ fn origin(url: &Url) -> String { fn main() { let shown = Shown::default(); let allowed = shown.0.clone(); + let updated = std::env::var_os(UPDATED_ENV).is_some(); + std::env::remove_var(UPDATED_ENV); tauri::Builder::default() + .plugin( + tauri_plugin_updater::Builder::new() + .pubkey(UPDATER_PUBKEY.unwrap_or_default()) + .build(), + ) .manage(shown) .setup(move |app| { let handle = app.handle().clone(); @@ -153,6 +233,7 @@ fn main() { .title("Lens") .inner_size(980.0, 760.0) .min_inner_size(520.0, 420.0) + .visible(!updated) .on_navigation(move |url| { if matches!(url.scheme(), "tauri" | "asset") || url.host_str() == Some("tauri.localhost") @@ -189,6 +270,23 @@ fn main() { let update = MenuItem::with_id(app, "update", "Update Lens", true, None::<&str>)?; let window_item = MenuItem::with_id(app, "window", "Show Window", true, None::<&str>)?; let logs = MenuItem::with_id(app, "logs", "Show Logs", true, None::<&str>)?; + let app_update = if updates_on() { + MenuItem::with_id( + app, + "app-update", + "Check for App Updates", + true, + None::<&str>, + )? + } else { + MenuItem::with_id( + app, + "app-update", + "App Updates: Off in This Build", + false, + None::<&str>, + )? + }; let quit = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?; let sep = || PredefinedMenuItem::separator(app); let menu = Menu::with_items( @@ -202,6 +300,7 @@ fn main() { &sep()?, &window_item, &logs, + &app_update, &sep()?, &quit, ], @@ -221,6 +320,7 @@ fn main() { run(app, "update"); } "window" => show_window(app), + "app-update" => update_app(app, true), "logs" => { #[cfg(target_os = "macos")] @@ -235,7 +335,19 @@ fn main() { }) .build(app)?; - run(&handle, "launch"); + run_with(&handle, "launch", updated); + if updates_on() { + let h = handle.clone(); + // a minute after launch (six hours after an update's restart), then every six hours + std::thread::spawn(move || { + let mut wait = if updated { 6 * 3600 } else { 60 }; + loop { + std::thread::sleep(Duration::from_secs(wait)); + update_app(&h, false); + wait = 6 * 3600; + } + }); + } Ok(()) }) .on_window_event(|window, event| { diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json index 0d7c3085b..ff7d21edf 100644 --- a/desktop/src-tauri/tauri.conf.json +++ b/desktop/src-tauri/tauri.conf.json @@ -14,16 +14,33 @@ }, "bundle": { "active": true, - "targets": ["app", "dmg"], + "targets": [ + "app", + "dmg" + ], "category": "Productivity", "shortDescription": "Intelligence for your agent", "copyright": "MIT License", - "icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.png"], + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.png" + ], "resources": { "../resources/lens-app.sh": "lens-app.sh" }, "macOS": { "minimumSystemVersion": "12.0" } + }, + "plugins": { + "updater": { + "endpoints": [ + "https://github.com/adeelahmad/lense/releases/latest/download/latest.json" + ], + "pubkey": "" + } } } diff --git a/docs/get-started.md b/docs/get-started.md index f58744320..4f76dba59 100644 --- a/docs/get-started.md +++ b/docs/get-started.md @@ -81,6 +81,8 @@ running and opens it in the browser, where passkeys work. Its menu-bar item open and shows the logs. It isn't signed or notarized yet: drag it to Applications, right-click it and choose **Open**, then **Open** again. See [desktop/README.md](https://github.com/adeelahmad/lense/blob/main/desktop/README.md). +It updates itself from each release. + **Status: built, early.** Not yet: starting with the Mac, signing, an Intel build. ### Windows From 980897d2f137b8c268b21842b6e8025863024717 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sat, 10 Oct 2026 20:16:04 +0000 Subject: [PATCH 2/3] docs(desktop): say app updates need the update key --- docs/get-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/get-started.md b/docs/get-started.md index 4f76dba59..95072caee 100644 --- a/docs/get-started.md +++ b/docs/get-started.md @@ -81,7 +81,7 @@ running and opens it in the browser, where passkeys work. Its menu-bar item open and shows the logs. It isn't signed or notarized yet: drag it to Applications, right-click it and choose **Open**, then **Open** again. See [desktop/README.md](https://github.com/adeelahmad/lense/blob/main/desktop/README.md). -It updates itself from each release. +Once the repository has an update key, it updates itself from each release. **Status: built, early.** Not yet: starting with the Mac, signing, an Intel build. From 8409e2e6f67fd16e3a384fceebb13859d8d4e479 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sun, 11 Oct 2026 04:00:13 +0000 Subject: [PATCH 3/3] fix(desktop): rebuild when the update key changes Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_014VrJQhkYVDyhgVQcok4neG --- desktop/src-tauri/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop/src-tauri/build.rs b/desktop/src-tauri/build.rs index d860e1e6a..fac277ab0 100644 --- a/desktop/src-tauri/build.rs +++ b/desktop/src-tauri/build.rs @@ -1,3 +1,5 @@ fn main() { + // the update key is built into the app (src/main.rs, UPDATER_PUBKEY) + println!("cargo:rerun-if-env-changed=LENS_UPDATER_PUBKEY"); tauri_build::build() }