From c84f8a74925aecc1bd278c6904c3f3bf71e4e8af Mon Sep 17 00:00:00 2001 From: Collin Rijock Date: Wed, 21 Oct 2026 00:03:46 +0000 Subject: [PATCH 1/2] Canvas App: pin the vendored build to a canvas-app commit crates/copper-cloud/assets/CANVAS_APP_REF names the canvas-app commit whose dist/web/index.html is vendored as canvas-app.html (62228f5, what 0.11.1 ships). packaging/sync-canvas-app.sh now works from the pin, as Copper's Canvas/sync.sh does: no argument re-fetches the pinned build, REF pins a new commit and fetches it, --check compares the vendored file with the pinned build, --from vendors a local one. Co-Authored-By: Claude Opus 5.5 --- crates/copper-cloud/assets/CANVAS_APP_REF | 1 + crates/copper-cloud/src/canvas_app.rs | 15 +++---- docs/canvas.md | 9 ++-- packaging/sync-canvas-app.sh | 51 ++++++++++++++--------- 4 files changed, 46 insertions(+), 30 deletions(-) create mode 100644 crates/copper-cloud/assets/CANVAS_APP_REF diff --git a/crates/copper-cloud/assets/CANVAS_APP_REF b/crates/copper-cloud/assets/CANVAS_APP_REF new file mode 100644 index 0000000..0af3123 --- /dev/null +++ b/crates/copper-cloud/assets/CANVAS_APP_REF @@ -0,0 +1 @@ +62228f56ddbf320e8a89aa55cdaada243c639609 diff --git a/crates/copper-cloud/src/canvas_app.rs b/crates/copper-cloud/src/canvas_app.rs index 9354089..664a13f 100644 --- a/crates/copper-cloud/src/canvas_app.rs +++ b/crates/copper-cloud/src/canvas_app.rs @@ -1,11 +1,12 @@ //! Canvas App at `/canvas/`: the canvas in any browser, for people who are not on Copper -//! (`copper-browser/canvas-app`, its `dist/web/index.html`, vendored as `assets/canvas-app.html` -//! by `packaging/sync-canvas-app.sh`). Served from the server's own origin so its REST calls -//! need no CORS (the server grants none, and the gate would refuse a preflight); it reaches -//! the linked Canvas Cloud through the same `/v1/canvases…` proxy Copper uses, and its room -//! socket carries the gate credential as `?instance=` -//! (`copper_cloud_core::app::INSTANCE_QUERY`), since a browser cannot set headers on a -//! WebSocket. The page is one self-contained file with its own CSP in a `` tag. +//! (`copper-browser/canvas-app`, its `dist/web/index.html` at the commit pinned in +//! `assets/CANVAS_APP_REF`, vendored as `assets/canvas-app.html` by +//! `packaging/sync-canvas-app.sh`). Served from the server's own origin so its REST calls need +//! no CORS (the server grants none, and the gate would refuse a preflight); it reaches the +//! linked Canvas Cloud through the same `/v1/canvases…` proxy Copper uses, and its room socket +//! carries the gate credential as `?instance=` (`copper_cloud_core::app::INSTANCE_QUERY`), since +//! a browser cannot set headers on a WebSocket. The page is one self-contained file with its own +//! CSP in a `` tag. use axum::http::{header, HeaderValue, StatusCode}; use axum::response::{IntoResponse, Redirect, Response}; diff --git a/docs/canvas.md b/docs/canvas.md index b0b8664..985b9fd 100644 --- a/docs/canvas.md +++ b/docs/canvas.md @@ -142,9 +142,12 @@ Under the Copper button it links to `/canvas/#/join/{token}` for people who are ## Canvas App (`/canvas/`) `GET /canvas/` serves [Canvas App](https://github.com/copper-browser/canvas-app): the canvas in -any browser. It is one self-contained file, vendored as -`crates/copper-cloud/assets/canvas-app.html`. `packaging/sync-canvas-app.sh [REF]` updates it; -`--check` compares it. The route is ungated, like the landing page, and holds no data. +any browser. It is one self-contained file, canvas-app's `dist/web/index.html` at the commit +pinned in `crates/copper-cloud/assets/CANVAS_APP_REF`, vendored as +`crates/copper-cloud/assets/canvas-app.html`. `packaging/sync-canvas-app.sh REF` pins a new +commit and fetches its build; with no argument it re-fetches the pinned one, and `--check` +compares the vendored file with it. The route is ungated, like the landing page, and holds no +data. The app reaches the linked Canvas Cloud through the same proxy Copper uses. It runs on the server's own origin, so its REST calls need no CORS, which copper-cloud never grants. To use it, diff --git a/packaging/sync-canvas-app.sh b/packaging/sync-canvas-app.sh index 5cc9c5b..6a2d056 100755 --- a/packaging/sync-canvas-app.sh +++ b/packaging/sync-canvas-app.sh @@ -1,24 +1,35 @@ #!/usr/bin/env bash -# Vendor Canvas App (copper-browser/canvas-app, dist/web/index.html) as +# Canvas App lives in copper-browser/canvas-app. copper-cloud vendors its web build, +# dist/web/index.html, at the commit pinned in crates/copper-cloud/assets/CANVAS_APP_REF, as # crates/copper-cloud/assets/canvas-app.html, which the server serves at /canvas/. -# packaging/sync-canvas-app.sh [REF] fetch REF (default main) from GitHub -# packaging/sync-canvas-app.sh --from FILE copy a local build -# packaging/sync-canvas-app.sh --check [REF] exit 1 if the vendored copy differs +# packaging/sync-canvas-app.sh re-fetch the pinned build (e.g. after editing CANVAS_APP_REF) +# packaging/sync-canvas-app.sh REF pin REF (a canvas-app commit, tag or branch, resolved to a commit) and fetch it +# packaging/sync-canvas-app.sh --check exit 1 if canvas-app.html is not the pinned build +# packaging/sync-canvas-app.sh --from FILE vendor a local build (canvas-app: bun run build) — for trying changes; pin before merging set -euo pipefail -cd "$(dirname "$0")/.." -dest=crates/copper-cloud/assets/canvas-app.html -check=0 -if [[ "${1:-}" == --check ]]; then check=1; shift; fi +cd "$(dirname "$0")/../crates/copper-cloud/assets" +repo=copper-browser/canvas-app +pin=CANVAS_APP_REF +dest=canvas-app.html +fetch() { + curl -fsSL "https://raw.githubusercontent.com/$repo/$1/dist/web/index.html" -o "$2" + grep -q 'id="web-root"' "$2" || { echo "sync: $1 has no Canvas App web build" >&2; exit 2; } +} tmp=$(mktemp); trap 'rm -f "$tmp"' EXIT -if [[ "${1:-}" == --from ]]; then - cp "$2" "$tmp" -else - ref=${1:-main} - curl -fsSL "https://raw.githubusercontent.com/copper-browser/canvas-app/$ref/dist/web/index.html" -o "$tmp" -fi -grep -q 'id="web-root"' "$tmp" || { echo "not a Canvas App build" >&2; exit 2; } -if (( check )); then - cmp -s "$tmp" "$dest" && echo "canvas-app.html is up to date" || { echo "canvas-app.html differs from ${ref:-the given file}" >&2; exit 1; } -else - cp "$tmp" "$dest" && echo "vendored $(wc -c <"$dest") bytes into $dest" -fi +case "${1:-}" in + --check) + fetch "$(cat "$pin")" "$tmp" + cmp -s "$tmp" "$dest" && echo "canvas-app.html matches canvas-app $(cat "$pin")" || { echo "canvas-app.html differs from canvas-app $(cat "$pin"): run packaging/sync-canvas-app.sh" >&2; exit 1; } + ;; + --from) + cp "$2" "$dest"; echo "vendored $2 (not pinned: run packaging/sync-canvas-app.sh REF before merging)" + ;; + "") + fetch "$(cat "$pin")" "$dest"; echo "vendored canvas-app $(cat "$pin")" + ;; + *) + sha=$(gh api "repos/$repo/commits/$1" --jq .sha 2>/dev/null || git ls-remote "https://github.com/$repo.git" "$1" | cut -f1) + [[ -n "$sha" ]] || { echo "sync: no canvas-app ref $1" >&2; exit 2; } + fetch "$sha" "$dest"; echo "$sha" > "$pin"; echo "pinned canvas-app $sha" + ;; +esac From faf615886f0fdc4be3afd2382b8744f2afbc1f6f Mon Sep 17 00:00:00 2001 From: Collin Rijock Date: Wed, 21 Oct 2026 00:04:36 +0000 Subject: [PATCH 2/2] Canvas App: take canvas-app c425198 (Continue with Google, link landings, invites, account menu) Vendors canvas-app main's web build. Served by copper-cloud (not canvas-cloud) the new sign-in paths stay out of the way: the page's GET /v1/info goes without the gate header, gets 401 instance_key, and the app treats the origin as a plain static server, so there are no single sign-on buttons and the sign-in form keeps its server / link-code field. Signed in with a link code, invites list through the canvas link's /v1/invites proxy. https://github.com/copper-browser/canvas-app/compare/62228f56ddbf...c425198d038b Co-Authored-By: Claude Opus 5.5 --- crates/copper-cloud/assets/CANVAS_APP_REF | 2 +- crates/copper-cloud/assets/canvas-app.html | 87 +++++++++++----------- 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/crates/copper-cloud/assets/CANVAS_APP_REF b/crates/copper-cloud/assets/CANVAS_APP_REF index 0af3123..b1758d0 100644 --- a/crates/copper-cloud/assets/CANVAS_APP_REF +++ b/crates/copper-cloud/assets/CANVAS_APP_REF @@ -1 +1 @@ -62228f56ddbf320e8a89aa55cdaada243c639609 +c425198d038b3d563acb3e9102f0f5e71676f6a8 diff --git a/crates/copper-cloud/assets/canvas-app.html b/crates/copper-cloud/assets/canvas-app.html index 139903a..4dccca6 100644 --- a/crates/copper-cloud/assets/canvas-app.html +++ b/crates/copper-cloud/assets/canvas-app.html @@ -7,49 +7,49 @@ Canvas - -