From 0101bfa09fad4346e336a4b99c5f5731583bbe19 Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 04:24:03 -0500 Subject: [PATCH 01/12] clean and merge --- package.json | 2 +- src/app/features/call/SmallWidget.ts | 12 ++++++++++++ src/sw.ts | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 233e6f71..70f2fa95 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ }, "devDependencies": { "@cloudflare/vite-plugin": "^1.26.0", - "@element-hq/element-call-embedded": "0.16.3", + "@element-hq/element-call-embedded": "file:element-call/embedded/web", "@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@eslint/compat": "2.0.2", "@eslint/js": "9.39.3", diff --git a/src/app/features/call/SmallWidget.ts b/src/app/features/call/SmallWidget.ts index 63186862..a4176878 100644 --- a/src/app/features/call/SmallWidget.ts +++ b/src/app/features/call/SmallWidget.ts @@ -198,6 +198,18 @@ export class SmallWidget extends EventEmitter { return this.messaging?.transport.reply(ev.detail, { events }); }); + // Acknowledge these so we don't get annoying errors + for (const action of [ + 'io.element.spotlight_layout', + 'io.element.tile_layout', + 'io.element.device_mute', + ]) { + this.messaging.on(`action:${action}`, (ev: CustomEvent) => { + ev.preventDefault(); + this.messaging?.transport.reply(ev.detail, {}); + }); + } + this.client.on(ClientEvent.Event, this.onEvent); this.client.on(MatrixEventEvent.Decrypted, this.onEventDecrypted); this.client.on(RoomStateEvent.Events, this.onStateUpdate); diff --git a/src/sw.ts b/src/sw.ts index 7185fbd3..815c3be7 100644 --- a/src/sw.ts +++ b/src/sw.ts @@ -270,6 +270,20 @@ self.addEventListener('fetch', (event: FetchEvent) => { return; } + // Since widgets like element call have their own client ids, + // we need this logic. We just go through the sessions list and get a session + // with the right base url. Media requests to a homeserver simply are fine with any account + // on the homeserver authenticating it, so this is fine. But it can be technically wrong. + // If you have two tabs for different users on the same homeserver, it might authenticate + // as the wrong one. + // Thus any logic in the future which cares about which user is authenticating the request + // might break this. Also, again, it is technically wrong. + const byBaseUrl = [...sessions.values()].find((s) => validMediaRequest(url, s.baseUrl)); + if (byBaseUrl) { + event.respondWith(fetch(url, { ...fetchConfig(byBaseUrl.accessToken), redirect })); + return; + } + event.respondWith( requestSessionWithTimeout(clientId).then((s) => { if (s && validMediaRequest(url, s.baseUrl)) { From be1826c6085c3d7a8dd2c888d9a834af58d559e3 Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 04:28:01 -0500 Subject: [PATCH 02/12] submodule --- .gitmodules | 3 +++ element-call | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 element-call diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..21b4a2cc --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "element-call"] + path = element-call + url = https://github.com/melogale/element-call.git diff --git a/element-call b/element-call new file mode 160000 index 00000000..c2646a05 --- /dev/null +++ b/element-call @@ -0,0 +1 @@ +Subproject commit c2646a0554f89393bf6dfca7195efb86438537ab From 5b27dbe44f4e3d6fdf4f176fa5154cd6698be54e Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 04:30:11 -0500 Subject: [PATCH 03/12] changeset --- .changeset/avatars.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .changeset/avatars.md diff --git a/.changeset/avatars.md b/.changeset/avatars.md new file mode 100644 index 00000000..cf70e2de --- /dev/null +++ b/.changeset/avatars.md @@ -0,0 +1,30 @@ +--- +sable: minor +--- + +# avatars! + +#227 by @melogale + +I bring in https://github.com/melogale/element-call/tree/avatars as a submodule for now. + +Element call disables thumbnails in widget mode by default, and it can't really be overridden except by janky means. Forking element call allows us to set this up kind of cleanly though! + + +In element call, we add two new capabilities to the host-widget contract. + +`moe.sable.thumbnails` +`moe.sable.media_proxy` + +If neither is set, fallback thumbnails will be used: the letter over color sort. +If `moe.sable.thumbnails` is set, element call will attempt to use the old unauthenticated media endpoint to grab thumbnails. +If `moe.sable.media_proxy` or both are set, will shoot for the authenticated endpoint, and hope and pray the client hosting the widget keeps its promise: adding authentication to the request, via a service worker or something. + + +Sable automatically accepts all capability requests, so these are set, and in fact, we add on authentication to media requests in the service worker! + +Since the frames in which widgets run have separate client ids, I simply look through the session list and find a session with the right base url. This is kind of odd: it could end up being for a different user on another tab. + +But as things are, the server doesn't care: so long as its authenticated by a user on the server. +Ideally it would use the session info for the tab hosting the widget, but I couldn't come up with a super clean way of doing that doesn't distract from the proof of concept. Let me know if anyone has any ideas for that. Or if we don't care for now. + From f78d70d6d4716e6f3360cbbd1f2c62d98aefae6c Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 04:39:55 -0500 Subject: [PATCH 04/12] lock --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d8254635..592ebd01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,7 +71,7 @@ }, "devDependencies": { "@cloudflare/vite-plugin": "^1.26.0", - "@element-hq/element-call-embedded": "0.16.3", + "@element-hq/element-call-embedded": "file:element-call/embedded/web", "@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@eslint/compat": "2.0.2", "@eslint/js": "9.39.3", @@ -26870,4 +26870,4 @@ "dev": true } } -} \ No newline at end of file +} From 610cdf5713aea5144dc3d63492ec74110db9b324 Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 04:40:56 -0500 Subject: [PATCH 05/12] lock --- package-lock.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 592ebd01..53e9f051 100644 --- a/package-lock.json +++ b/package-lock.json @@ -109,6 +109,11 @@ "npm": "11.x" } }, + "element-call/embedded/web": { + "name": "@element-hq/element-call-embedded", + "version": "0.0.0", + "dev": true + }, "node_modules/@apideck/better-ajv-errors": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/@apideck/better-ajv-errors/-/better-ajv-errors-0.3.6.tgz", @@ -1911,10 +1916,8 @@ } }, "node_modules/@element-hq/element-call-embedded": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/@element-hq/element-call-embedded/-/element-call-embedded-0.16.3.tgz", - "integrity": "sha512-OViKJonDaDNVBUW9WdV9mk78/Ruh34C7XsEgt3O8D9z+64C39elbIgllHSoH5S12IRlv9RYrrV37FZLo6QWsDQ==", - "dev": true + "resolved": "element-call/embedded/web", + "link": true }, "node_modules/@emnapi/core": { "version": "1.8.1", @@ -17865,10 +17868,7 @@ } }, "@element-hq/element-call-embedded": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/@element-hq/element-call-embedded/-/element-call-embedded-0.16.3.tgz", - "integrity": "sha512-OViKJonDaDNVBUW9WdV9mk78/Ruh34C7XsEgt3O8D9z+64C39elbIgllHSoH5S12IRlv9RYrrV37FZLo6QWsDQ==", - "dev": true + "version": "file:element-call/embedded/web" }, "@emnapi/core": { "version": "1.8.1", From afded152150b461ce16de4462a2c4554851628c9 Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 04:48:53 -0500 Subject: [PATCH 06/12] oops wrong element version --- element-call | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/element-call b/element-call index c2646a05..3a2b29f1 160000 --- a/element-call +++ b/element-call @@ -1 +1 @@ -Subproject commit c2646a0554f89393bf6dfca7195efb86438537ab +Subproject commit 3a2b29f1280fa823b1fcaac3b5ea91579008443f From 7315486ebc681a39f549f6d4f2cd2c3180634fd2 Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 06:28:10 -0500 Subject: [PATCH 07/12] testing with clean element call --- element-call | 2 +- eslint.config.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/element-call b/element-call index 3a2b29f1..290879a4 160000 --- a/element-call +++ b/element-call @@ -1 +1 @@ -Subproject commit 3a2b29f1280fa823b1fcaac3b5ea91579008443f +Subproject commit 290879a4d492b41fb727572f88fac6f1ac56e57f diff --git a/eslint.config.js b/eslint.config.js index 9fa0c87b..fcd06a9b 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -134,6 +134,7 @@ const projectOverrides = defineConfig([ ]); export default defineConfig([ + { ignores: ['element-call/'] }, includeIgnoreFile(gitignorePath), ...jsConfig, ...reactConfig, From e13f8d509cbf16f8ddc7a39b3ba3125fae35432f Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 06:28:55 -0500 Subject: [PATCH 08/12] skip --- .changeset/avatars.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.changeset/avatars.md b/.changeset/avatars.md index cf70e2de..86f484f1 100644 --- a/.changeset/avatars.md +++ b/.changeset/avatars.md @@ -8,8 +8,7 @@ sable: minor I bring in https://github.com/melogale/element-call/tree/avatars as a submodule for now. -Element call disables thumbnails in widget mode by default, and it can't really be overridden except by janky means. Forking element call allows us to set this up kind of cleanly though! - +Element call disables thumbnails in widget mode by default, and it can't really be overridden except by janky means. Forking element call allows us to set this up kind of cleanly though! In element call, we add two new capabilities to the host-widget contract. @@ -20,11 +19,9 @@ If neither is set, fallback thumbnails will be used: the letter over color sort. If `moe.sable.thumbnails` is set, element call will attempt to use the old unauthenticated media endpoint to grab thumbnails. If `moe.sable.media_proxy` or both are set, will shoot for the authenticated endpoint, and hope and pray the client hosting the widget keeps its promise: adding authentication to the request, via a service worker or something. - Sable automatically accepts all capability requests, so these are set, and in fact, we add on authentication to media requests in the service worker! Since the frames in which widgets run have separate client ids, I simply look through the session list and find a session with the right base url. This is kind of odd: it could end up being for a different user on another tab. But as things are, the server doesn't care: so long as its authenticated by a user on the server. Ideally it would use the session info for the tab hosting the widget, but I couldn't come up with a super clean way of doing that doesn't distract from the proof of concept. Let me know if anyone has any ideas for that. Or if we don't care for now. - From 7b69e916310cb895d2fe71a2c9b4fa3f5d1102ac Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 16:49:10 -0500 Subject: [PATCH 09/12] rebased element fork --- element-call | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/element-call b/element-call index 290879a4..ecef381c 160000 --- a/element-call +++ b/element-call @@ -1 +1 @@ -Subproject commit 290879a4d492b41fb727572f88fac6f1ac56e57f +Subproject commit ecef381c246c177af28b8c99c5076da19878a136 From e48648c91023ab29f8b89cf2542a8d604a353724 Mon Sep 17 00:00:00 2001 From: melogale Date: Sat, 7 Mar 2026 18:14:28 -0500 Subject: [PATCH 10/12] ignore --- .gitignore | 1 + .prettierignore | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 1c110441..5cc8aa47 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ devAssets *.tfbackend !*.tfbackend.example crash.log +build.sh diff --git a/.prettierignore b/.prettierignore index dd3a20e6..cc2e8022 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,6 @@ dist node_modules +element-call package.json package-lock.json LICENSE From 53f6fc8ea8312e22dc43c29c947ba3c6346177bf Mon Sep 17 00:00:00 2001 From: 7w1 Date: Sun, 8 Mar 2026 20:17:36 -0500 Subject: [PATCH 11/12] update changeset --- .changeset/avatars.md | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/.changeset/avatars.md b/.changeset/avatars.md index 86f484f1..001dd778 100644 --- a/.changeset/avatars.md +++ b/.changeset/avatars.md @@ -2,26 +2,5 @@ sable: minor --- -# avatars! +Add avatars to calls by forking element call. -#227 by @melogale - -I bring in https://github.com/melogale/element-call/tree/avatars as a submodule for now. - -Element call disables thumbnails in widget mode by default, and it can't really be overridden except by janky means. Forking element call allows us to set this up kind of cleanly though! - -In element call, we add two new capabilities to the host-widget contract. - -`moe.sable.thumbnails` -`moe.sable.media_proxy` - -If neither is set, fallback thumbnails will be used: the letter over color sort. -If `moe.sable.thumbnails` is set, element call will attempt to use the old unauthenticated media endpoint to grab thumbnails. -If `moe.sable.media_proxy` or both are set, will shoot for the authenticated endpoint, and hope and pray the client hosting the widget keeps its promise: adding authentication to the request, via a service worker or something. - -Sable automatically accepts all capability requests, so these are set, and in fact, we add on authentication to media requests in the service worker! - -Since the frames in which widgets run have separate client ids, I simply look through the session list and find a session with the right base url. This is kind of odd: it could end up being for a different user on another tab. - -But as things are, the server doesn't care: so long as its authenticated by a user on the server. -Ideally it would use the session info for the tab hosting the widget, but I couldn't come up with a super clean way of doing that doesn't distract from the proof of concept. Let me know if anyone has any ideas for that. Or if we don't care for now. From 99314b4fdf414662f89674b3001f4ec6e26327c5 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Sun, 8 Mar 2026 20:24:08 -0500 Subject: [PATCH 12/12] plz work thanks --- .changeset/avatars.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.changeset/avatars.md b/.changeset/avatars.md index 001dd778..954693d0 100644 --- a/.changeset/avatars.md +++ b/.changeset/avatars.md @@ -2,5 +2,4 @@ sable: minor --- -Add avatars to calls by forking element call. - +Add avatars to calls by forking element call, among other things.