Compare commits

..
Author SHA1 Message Date
Lotus CIandClaude Opus 5.5 848dcaafa9 chore(lotus): 0.25.0-lotus.26
CI / Build embedded bundle (push) Successful in 1m55s
CI / Publish to Gitea npm registry (push) In progress
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 12:41:55 -04:00
jared 1ad32e56c7 Merge pull request 'feat(lotus): accept decorations from chat.lotusguild.org (matrix #22)' (#56) from feat/decorations-origin into lotus
CI / Build embedded bundle (push) Canceled after 1m46s
CI / Publish to Gitea npm registry (push) Canceled after 0s
2026-10-19 12:40:07 -04:00
Lotus CIandClaude Opus 5.5 090edc5c2c feat(lotus): accept decorations from chat.lotusguild.org (matrix #22)
CI / Build embedded bundle (pull_request) Successful in 1m42s
CI / Publish to Gitea npm registry (pull_request) Skipped
Decorations moved off Nextcloud to https://chat.lotusguild.org/decorations.
Add that origin to ALLOWED_DECORATION_ORIGINS (first, so tests use it);
keep drive.lotusguild.org until no host build points there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 12:37:53 -04:00
jared dbf77cdc60 Merge pull request 'docs(lotus): LOTUS.md lists io.lotus.call_error and io.lotus.reconnect (#50)' (#55) from docs/lotus-call-error into lotus
CI / Build embedded bundle (push) Successful in 2m8s
CI / Publish to Gitea npm registry (push) Skipped
2026-10-19 01:36:12 -04:00
Lotus CIandClaude Opus 5.5 2ef80cef2c docs(lotus): LOTUS.md lists io.lotus.call_error and io.lotus.reconnect (#50)
CI / Build embedded bundle (pull_request) Successful in 2m1s
CI / Publish to Gitea npm registry (pull_request) Skipped
Regenerate the action table from lotusActions.ts: add the two actions
from #50, and note which cinny PR handles each one still in flight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 00:01:18 -04:00
Lotus CIandClaude Opus 5.5 88c648ba8b chore(lotus): 0.25.0-lotus.25
CI / Build embedded bundle (push) Successful in 2m35s
CI / Publish to Gitea npm registry (push) Successful in 55s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-18 15:27:50 -04:00
jared 0aa543cc7d Merge pull request 'docs(lotus): LOTUS.md: the io.lotus.* widget protocol, URL flags and release flow (#43)' (#53) from docs/lotus-protocol into lotus
CI / Build embedded bundle (push) Successful in 3m6s
CI / Publish to Gitea npm registry (push) Skipped
2026-10-18 07:49:15 -04:00
jared cc57292bf4 Merge pull request 'fix(lotus): soundboard says "not permitted" in audio-only rooms instead of failing silently (#47)' (#52) from lotus-soundboard-not-permitted into lotus
CI / Build embedded bundle (push) Canceled after 0s
CI / Publish to Gitea npm registry (push) Canceled after 0s
2026-10-18 07:42:09 -04:00
jared 22f9083768 Merge pull request 'fix(lotus): restart the shared mic sampler only when the LiveKit rooms change (#45)' (#51) from lotus-mic-sampler-churn into lotus
CI / Build embedded bundle (push) Canceled after 0s
CI / Publish to Gitea npm registry (push) Canceled after 0s
2026-10-18 07:38:41 -04:00
jared d7d75cbba5 Merge pull request 'feat(lotus): tell the host when the call drops, and let it press Reconnect (cinny #318)' (#50) from lotus-call-error into lotus
CI / Build embedded bundle (push) Canceled after 0s
CI / Publish to Gitea npm registry (push) Canceled after 0s
2026-10-18 07:32:17 -04:00
jared 4be3e92eb6 Merge pull request 'fix(lotus): a homeserver stall shorter than the delayed-leave window no longer ends the call (#46)' (#54) from lotus-stall-retry into lotus
CI / Build embedded bundle (push) Canceled after 0s
CI / Publish to Gitea npm registry (push) Canceled after 0s
2026-10-18 04:52:15 -04:00
Lotus CIandClaude Opus 5.5 a1dd0e254c fix(lotus): a homeserver stall shorter than the delayed-leave window no longer ends the call (#46)
CI / Build embedded bundle (pull_request) Successful in 3m33s
CI / Publish to Gitea npm registry (pull_request) Skipped
maximumNetworkErrorRetryCount was sized to min(sync grace period,
leave delay), i.e. 10 s, so the membership manager gave up 20-35 s into
a homeserver stall and showed "Connection lost", even when the server
would keep the membership for 60 s (prod config). Size it to the leave
delay instead: the embedded call has no /sync loop for the grace period
to describe, and the server's delayed leave is what actually ends the
membership.

Fixes #46

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-18 02:47:36 -04:00
Lotus CIandClaude Opus 5.5 888ed1a66c fix(lotus): soundboard says "not permitted" in audio-only rooms instead of failing silently (#47)
CI / Build embedded bundle (pull_request) Successful in 3m20s
CI / Publish to Gitea npm registry (pull_request) Skipped
Clips publish as an Unknown-source track. In audio-only rooms the guard
signs a microphone-only token, LiveKit refuses the publish, and since
the fork had already replied {} the host never heard. Check the grants
up front and reply { played: false, reason: "not_permitted" }.

Refs #47

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-18 01:22:49 -04:00
Lotus CIandClaude Opus 5.5 73bf2133dc fix(lotus): restart the shared mic sampler only when the LiveKit rooms change (#45)
CI / Build embedded bundle (pull_request) Successful in 3m16s
CI / Publish to Gitea npm registry (pull_request) Skipped
observeLocalMicSample$ switchMapped on every allConnections$ emission,
which re-emits far more often than the set of rooms changes. Each one
stopped the clone, closed the AudioContext and emitted null, and the
null reset the muted-speech gate, so the "You're muted" nudge could
never stay true long enough to fire. Map to the room list and only
restart when it actually changes.

Fixes #45

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-18 01:17:06 -04:00
Lotus CIandClaude Opus 5.5 07e1506dd8 feat(lotus): tell the host when the call drops, and let it press Reconnect (cinny #318)
CI / Build embedded bundle (pull_request) Successful in 3m2s
CI / Publish to Gitea npm registry (pull_request) Skipped
After a homeserver stall the frame shows "Connection lost · Reconnect"
while the host kept showing the call as joined, with controls that did
nothing. While the error page is up, report io.lotus.call_error
{ code, recoverable } (and { code: null } when it clears), and accept
io.lotus.reconnect to run the page's own Reconnect / Try again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-18 00:54:48 -04:00
12 changed files with 153 additions and 14 deletions
+5 -4
View File
@@ -42,10 +42,10 @@ checked against cinny's `lotus` branch.
| `io.lotus.decorations` | host → call | per-user avatar-decoration image URLs for in-call tiles. | yes | | `io.lotus.decorations` | host → call | per-user avatar-decoration image URLs for in-call tiles. | yes |
| `io.lotus.set_deafen` | host → call | deafen remote audio (and optionally mute screenshare audio). | yes | | `io.lotus.set_deafen` | host → call | deafen remote audio (and optionally mute screenshare audio). | yes |
| `io.lotus.request_state` | call → host | sent on (re)registration of a lotus toWidget handler (e.g. decorations) so the host can re-push state that would otherwise only be sent on change (decorations roster, the current focus pin) after an EC-side reconnect/remount. cinny's `resendForkState()` should respond to this the same way it responds to a fresh join. | yes | | `io.lotus.request_state` | call → host | sent on (re)registration of a lotus toWidget handler (e.g. decorations) so the host can re-push state that would otherwise only be sent on change (decorations roster, the current focus pin) after an EC-side reconnect/remount. cinny's `resendForkState()` should respond to this the same way it responds to a fresh join. | yes |
| `io.lotus.denoise_state` | call → host | real state of the in-source denoise engine — `{ active: boolean, model: string, error?: string }` — sent once the processor attaches (or after the rnnoise fallback also fails), so the host toggle can reflect reality rather than the requested state. | **no** | | `io.lotus.denoise_state` | call → host | real state of the in-source denoise engine — `{ active: boolean, model: string, error?: string }` — sent once the processor attaches (or after the rnnoise fallback also fails), so the host toggle can reflect reality rather than the requested state. | yes |
| `io.lotus.call_summary` | call → host | one-shot end-of-call readout for the local participant — `{ durationMs, reconnects, poorMs, verdict }` (#143) — sent on SFU disconnect or in-call teardown, whichever comes first. | yes | | `io.lotus.call_summary` | call → host | one-shot end-of-call readout for the local participant — `{ durationMs, reconnects, poorMs, verdict }` (#143) — sent on SFU disconnect or in-call teardown, whichever comes first. | yes |
| `io.lotus.set_audio_output` | host → call | select the audio output device `{ deviceId }` (#119). | yes | | `io.lotus.set_audio_output` | host → call | select the audio output device `{ deviceId }` (#119). | yes |
| `io.lotus.audio_output_state` | call → host | the currently selected output `{ deviceId }` (#119). | **no** | | `io.lotus.audio_output_state` | call → host | the currently selected output `{ deviceId }` (#119). | cinny #417 |
| `io.lotus.screenshare_notice` | call → host | local screenshare reminder `{ kind: "ended" \| "no-frames" \| "alone" }` — window closed, no frames for 15 s, or 30 min of sharing with nobody else in the call (#39). Each fires at most once per share. | yes | | `io.lotus.screenshare_notice` | call → host | local screenshare reminder `{ kind: "ended" \| "no-frames" \| "alone" }` — window closed, no frames for 15 s, or 30 min of sharing with nobody else in the call (#39). Each fires at most once per share. | yes |
| `io.lotus.set_layout` | host → call | switch the call layout `{ layout: "grid" \| "spotlight" }` (cinny #43 — replaces the host clicking EC's hidden layout radio). | yes | | `io.lotus.set_layout` | host → call | switch the call layout `{ layout: "grid" \| "spotlight" }` (cinny #43 — replaces the host clicking EC's hidden layout radio). | yes |
| `io.lotus.open_settings` | host → call | open EC's settings modal, or close it with `{ open: false }`; omit `open` to toggle (cinny #43). | yes | | `io.lotus.open_settings` | host → call | open EC's settings modal, or close it with `{ open: false }`; omit `open` to toggle (cinny #43). | yes |
@@ -57,9 +57,10 @@ checked against cinny's `lotus` branch.
| `io.lotus.hotkey` | call → host | a watched key went down/up here, or this window's focus changed; see `LotusHotkeyReport` (cinny #43). | yes | | `io.lotus.hotkey` | call → host | a watched key went down/up here, or this window's focus changed; see `LotusHotkeyReport` (cinny #43). | yes |
| `io.lotus.controls_state` | call → host | `{ screensharing: boolean, layout: "grid" \| "spotlight" \| null, screenshareAction: true, hotkeys: true, frameScreenshare: false, screensharePrompt: boolean, screensharePromptOpen: boolean }` whenever either changes (cinny #43), so the host stops reading EC's DOM for them. Its arrival also tells the host this fork supports the actions above. | yes | | `io.lotus.controls_state` | call → host | `{ screensharing: boolean, layout: "grid" \| "spotlight" \| null, screenshareAction: true, hotkeys: true, frameScreenshare: false, screensharePrompt: boolean, screensharePromptOpen: boolean }` whenever either changes (cinny #43), so the host stops reading EC's DOM for them. Its arrival also tells the host this fork supports the actions above. | yes |
| `io.lotus.mic_level` | call → host | local mic level `{ bars: 0 \| 1 \| 2 \| 3 }` (cinny #146), sent only when it changes (≤ 10 Hz); 0 while muted or with no mic. | yes | | `io.lotus.mic_level` | call → host | local mic level `{ bars: 0 \| 1 \| 2 \| 3 }` (cinny #146), sent only when it changes (≤ 10 Hz); 0 while muted or with no mic. | yes |
| `io.lotus.call_error` | call → host | the call's error page is up (`{ code, recoverable }`) or cleared (`{ code: null }`) (cinny #318), so the host stops showing the call as joined after "Connection lost". | cinny #418 |
| `io.lotus.reconnect` | host → call | press the error page's Reconnect / Try again (cinny #318). | cinny #418 |
The two unhandled actions are covered by pending cinny PRs (#413 for Entries naming a cinny PR are handled once that PR merges.
`denoise_state`; the #310 change for `audio_output_state`).
## Fork-only behaviour (no flag needed) ## Fork-only behaviour (no flag needed)
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@lotusguild/element-call-embedded", "name": "@lotusguild/element-call-embedded",
"version": "0.25.0-lotus.24", "version": "0.25.0-lotus.26",
"files": [ "files": [
"README.md", "README.md",
"LICENSE-AGPL-3.0", "LICENSE-AGPL-3.0",
+2
View File
@@ -34,6 +34,7 @@ describe("LotusWidgetActions", () => {
LotusWidgetActions.SetHotkeys, LotusWidgetActions.SetHotkeys,
LotusWidgetActions.SetFrameScreenshare, LotusWidgetActions.SetFrameScreenshare,
LotusWidgetActions.PromptScreenshare, LotusWidgetActions.PromptScreenshare,
LotusWidgetActions.Reconnect,
]; ];
expect(new Set(LOTUS_TO_WIDGET_ACTIONS)).toEqual(new Set(expectedToWidget)); expect(new Set(LOTUS_TO_WIDGET_ACTIONS)).toEqual(new Set(expectedToWidget));
@@ -56,5 +57,6 @@ describe("LotusWidgetActions", () => {
); );
expect(LOTUS_TO_WIDGET_ACTIONS).not.toContain(LotusWidgetActions.MicLevel); expect(LOTUS_TO_WIDGET_ACTIONS).not.toContain(LotusWidgetActions.MicLevel);
expect(LOTUS_TO_WIDGET_ACTIONS).not.toContain(LotusWidgetActions.Hotkey); expect(LOTUS_TO_WIDGET_ACTIONS).not.toContain(LotusWidgetActions.Hotkey);
expect(LOTUS_TO_WIDGET_ACTIONS).not.toContain(LotusWidgetActions.CallError);
}); });
}); });
+9
View File
@@ -116,6 +116,14 @@ export enum LotusWidgetActions {
* only when it changes (≤ 10 Hz); 0 while muted or with no mic. * only when it changes (≤ 10 Hz); 0 while muted or with no mic.
*/ */
MicLevel = "io.lotus.mic_level", MicLevel = "io.lotus.mic_level",
/**
* fromWidget: the call's error page is up (`{ code, recoverable }`) or
* cleared (`{ code: null }`) (cinny #318), so the host stops showing the call
* as joined after "Connection lost".
*/
CallError = "io.lotus.call_error",
/** toWidget: press the error page's Reconnect / Try again (cinny #318). */
Reconnect = "io.lotus.reconnect",
} }
/** toWidget Lotus actions that must be allow-listed in `initializeWidget`. */ /** toWidget Lotus actions that must be allow-listed in `initializeWidget`. */
@@ -133,4 +141,5 @@ export const LOTUS_TO_WIDGET_ACTIONS: LotusWidgetActions[] = [
LotusWidgetActions.SetHotkeys, LotusWidgetActions.SetHotkeys,
LotusWidgetActions.SetFrameScreenshare, LotusWidgetActions.SetFrameScreenshare,
LotusWidgetActions.PromptScreenshare, LotusWidgetActions.PromptScreenshare,
LotusWidgetActions.Reconnect,
]; ];
+15
View File
@@ -11,6 +11,7 @@ import { of } from "rxjs";
import { type CallViewModel } from "../state/CallViewModel/CallViewModel"; import { type CallViewModel } from "../state/CallViewModel/CallViewModel";
import { import {
canPublishSoundboard,
MAX_INJECT_BYTES, MAX_INJECT_BYTES,
parseInjectSource, parseInjectSource,
startLotusAudioInject, startLotusAudioInject,
@@ -258,3 +259,17 @@ test("parseInjectSource rejects oversized or non-buffer audio", () => {
expect(parseInjectSource({ audio: "not bytes" })).toBeNull(); expect(parseInjectSource({ audio: "not bytes" })).toBeNull();
expect(parseInjectSource({ audio: new Uint8Array(4) })).toBeNull(); expect(parseInjectSource({ audio: new Uint8Array(4) })).toBeNull();
}); });
test("canPublishSoundboard: refused by a microphone-only grant (EC #47)", () => {
expect(canPublishSoundboard(undefined)).toBe(true);
expect(
canPublishSoundboard({ canPublish: true, canPublishSources: [] }),
).toBe(true);
expect(
canPublishSoundboard({ canPublish: true, canPublishSources: [2] }),
).toBe(false);
expect(
canPublishSoundboard({ canPublish: true, canPublishSources: [2, 0] }),
).toBe(true);
expect(canPublishSoundboard({ canPublish: false })).toBe(false);
});
+29
View File
@@ -60,6 +60,22 @@ function acquireSharedAudio(): {
* No effect unless the host sends the action. Returns a teardown function that * No effect unless the host sends the action. Returns a teardown function that
* also aborts any clip still playing. * also aborts any clip still playing.
*/ */
/**
* Pure: whether these LiveKit permissions allow publishing the soundboard's
* Unknown-source track (EC #47). No permissions or an empty source list
* means unrestricted; otherwise UNKNOWN (TrackSource 0) must be allowed.
*/
export function canPublishSoundboard(
perm:
| { canPublish?: boolean; canPublishSources?: readonly number[] }
| undefined,
): boolean {
if (!perm) return true;
if (perm.canPublish === false) return false;
const sources = perm.canPublishSources ?? [];
return sources.length === 0 || sources.includes(0);
}
export function startLotusAudioInject(vm: CallViewModel): () => void { export function startLotusAudioInject(vm: CallViewModel): () => void {
const w = widget; const w = widget;
if (!w) return () => undefined; if (!w) return () => undefined;
@@ -116,6 +132,19 @@ export function startLotusAudioInject(vm: CallViewModel): () => void {
return; return;
} }
// [EC #47] Clips publish as an Unknown-source track. Audio-only rooms get
// a token limited to the microphone source, where LiveKit refuses that
// publish *after* we replied; say so up front instead of failing silently.
if (
rooms.some((r) => !canPublishSoundboard(r.localParticipant.permissions))
) {
w.api.transport.reply(ev.detail, {
played: false,
reason: "not_permitted",
});
return;
}
w.api.transport.reply(ev.detail, {}); w.api.transport.reply(ev.detail, {});
void playInjectedClip(clip, volume, rooms, activeClips).catch((e) => void playInjectedClip(clip, volume, rooms, activeClips).catch((e) =>
logger.warn("[lotus] inject_audio failed", e), logger.warn("[lotus] inject_audio failed", e),
+30
View File
@@ -83,6 +83,36 @@ test("[lotus #28] safeImageUrl only accepts the pinned decoration CDN origin (or
stop(); stop();
}); });
test("[matrix #22] both the new decoration host and the old Nextcloud one are accepted", () => {
const stop = startLotusDecorations();
const { result } = renderHook(() => useLotusDecoration("@alice:example.org"));
pushDecorations({
"@alice:example.org":
"https://chat.lotusguild.org/decorations/joystick.png",
});
expect(result.current).toBe(
"https://chat.lotusguild.org/decorations/joystick.png",
);
pushDecorations({
"@alice:example.org":
"https://drive.lotusguild.org/public.php/dav/files/x/cinny-decorations/joystick.png",
});
expect(result.current).toBe(
"https://drive.lotusguild.org/public.php/dav/files/x/cinny-decorations/joystick.png",
);
// A look-alike subdomain is a different origin.
pushDecorations({
"@alice:example.org":
"https://chat.lotusguild.org.evil.example/joystick.png",
});
expect(result.current).toBeUndefined();
stop();
});
test("[lotus #17] the roster survives a handler remount within the same page session", () => { test("[lotus #17] the roster survives a handler remount within the same page session", () => {
const stop1 = startLotusDecorations(); const stop1 = startLotusDecorations();
pushDecorations({ pushDecorations({
+4
View File
@@ -45,7 +45,11 @@ export function useLotusDecoration(userId: string): string | undefined {
// to the actual decoration CDN origin(s) — cinny's `DECORATION_CDN` // to the actual decoration CDN origin(s) — cinny's `DECORATION_CDN`
// (`avatarDecorations.ts`) — plus `blob:`, which EC itself may use for local // (`avatarDecorations.ts`) — plus `blob:`, which EC itself may use for local
// previews. Exported so a future CDN move is a one-line edit here. // previews. Exported so a future CDN move is a one-line edit here.
//
// matrix #22: decorations moved off Nextcloud to chat.lotusguild.org/decorations
// (first entry). drive.lotusguild.org stays until no host build points there.
export const ALLOWED_DECORATION_ORIGINS: readonly string[] = [ export const ALLOWED_DECORATION_ORIGINS: readonly string[] = [
"https://chat.lotusguild.org",
"https://drive.lotusguild.org", "https://drive.lotusguild.org",
]; ];
+12 -1
View File
@@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { MicLevelQuantizer } from "./lotusMicLevel"; import { MicLevelQuantizer, sameRooms } from "./lotusMicLevel";
describe("MicLevelQuantizer", () => { describe("MicLevelQuantizer", () => {
it("maps RMS to 0–3 bars", () => { it("maps RMS to 0–3 bars", () => {
@@ -35,3 +35,14 @@ describe("MicLevelQuantizer", () => {
expect(q.push(0)).toBe(0); expect(q.push(0)).toBe(0);
}); });
}); });
describe("sameRooms (EC #45)", () => {
it("compares rooms by identity and order", () => {
const a = {};
const b = {};
expect(sameRooms([a, b], [a, b])).toBe(true);
expect(sameRooms([a], [a, b])).toBe(false);
expect(sameRooms([a, b], [b, a])).toBe(false);
expect(sameRooms([{}], [{}])).toBe(false);
});
});
+11 -2
View File
@@ -46,6 +46,10 @@ const micPublication = (
: null; : null;
}; };
/** Pure: the same LiveKit rooms, in the same order (by identity). */
export const sameRooms = <T>(a: readonly T[], b: readonly T[]): boolean =>
a.length === b.length && a.every((r, i) => r === b[i]);
const samplers = new WeakMap< const samplers = new WeakMap<
CallViewModel, CallViewModel,
Observable<LocalMicSample | null> Observable<LocalMicSample | null>
@@ -62,10 +66,15 @@ export function observeLocalMicSample$(
const cached = samplers.get(vm); const cached = samplers.get(vm);
if (cached) return cached; if (cached) return cached;
const sampler$ = vm.allConnections$.pipe( const sampler$ = vm.allConnections$.pipe(
map((data) => data.getConnections().map((c) => c.livekitRoom)),
// [EC #45] allConnections$ re-emits far more often than the set of
// LiveKit rooms changes; restarting the tap each time closed the
// AudioContext ~1×/s and emitted null, which reset the muted-speech
// gate so the "You're muted" nudge could never fire.
distinctUntilChanged(sameRooms),
switchMap( switchMap(
(data) => (rooms) =>
new Observable<LocalMicSample | null>((subscriber) => { new Observable<LocalMicSample | null>((subscriber) => {
const rooms = data.getConnections().map((c) => c.livekitRoom);
let ctx: AudioContext | null = null; let ctx: AudioContext | null = null;
let clone: MediaStreamTrack | null = null; let clone: MediaStreamTrack | null = null;
let timer: ReturnType<typeof setInterval> | undefined; let timer: ReturnType<typeof setInterval> | undefined;
+26
View File
@@ -13,6 +13,7 @@ import {
type ReactNode, type ReactNode,
type SVGAttributes, type SVGAttributes,
useCallback, useCallback,
useEffect,
} from "react"; } from "react";
import { Trans, useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { import {
@@ -24,6 +25,7 @@ import {
import { Button } from "@vector-im/compound-web"; import { Button } from "@vector-im/compound-web";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { MatrixError } from "matrix-js-sdk"; import { MatrixError } from "matrix-js-sdk";
import { type IWidgetApiRequest } from "matrix-widget-api";
import { import {
ConnectionLostError, ConnectionLostError,
@@ -38,6 +40,7 @@ import { FullScreenView } from "../FullScreenView.tsx";
import { ErrorView } from "../ErrorView.tsx"; import { ErrorView } from "../ErrorView.tsx";
import { type WidgetHelpers } from "../widget.ts"; import { type WidgetHelpers } from "../widget.ts";
import styles from "../ErrorView.module.css"; import styles from "../ErrorView.module.css";
import { LotusWidgetActions, lotusSendToHost } from "../lotus/lotusWidget";
export type CallErrorRecoveryAction = "reconnect"; // | "retry" ; export type CallErrorRecoveryAction = "reconnect"; // | "retry" ;
@@ -74,6 +77,29 @@ const ErrorPage: FC<ErrorPageProps> = ({
icon = ErrorSolidIcon; icon = ErrorSolidIcon;
} }
// [cinny #318] Tell the host the call dropped (it kept showing the call as
// joined), and let its call bar press Reconnect for us.
const recoverable =
error instanceof ConnectionLostError ||
error instanceof LivekitConnectionError ||
error instanceof PeerConnectionTimeoutError;
useEffect(() => {
lotusSendToHost(LotusWidgetActions.CallError, {
code: error.code,
recoverable,
});
const w = widget;
const onReconnect = (ev: CustomEvent<IWidgetApiRequest>): void => {
w?.api.transport.reply(ev.detail, {});
if (recoverable) void recoveryActionHandler("reconnect");
};
w?.lazyActions?.on(LotusWidgetActions.Reconnect, onReconnect);
return (): void => {
w?.lazyActions?.off(LotusWidgetActions.Reconnect, onReconnect);
lotusSendToHost(LotusWidgetActions.CallError, { code: null });
};
}, [error.code, recoverable, recoveryActionHandler, widget]);
const actions: { label: string; onClick: () => void }[] = []; const actions: { label: string; onClick: () => void }[] = [];
if (error instanceof ConnectionLostError) { if (error instanceof ConnectionLostError) {
actions.push({ actions.push({
@@ -868,16 +868,19 @@ export function enterRTCSession(
}; };
} }
// Calculates `maximumNetworkErrorRetryCount`. The connection is failed if EITHER: // Calculates `maximumNetworkErrorRetryCount`: enough retries to outlast the
// - The /sync loop is unresponsive for > `gracePeriod` ms, or // server's delayed-leave window (see [lotus #46] below).
// - A delayed leave event is emitted (after `leaveDelay` ms period).
// Note: Use leaveDelay >> gracePeriod for delegated leave events.
const gracePeriod = Config.get().sync_disconnect_grace_period_ms; const gracePeriod = Config.get().sync_disconnect_grace_period_ms;
const leaveDelay = matrixRtcSessionConfig?.delayed_leave_event_delay_ms; const leaveDelay = matrixRtcSessionConfig?.delayed_leave_event_delay_ms;
const retryInterval = matrixRtcSessionConfig?.network_error_retry_ms; const retryInterval = matrixRtcSessionConfig?.network_error_retry_ms;
// Math.min is used to account for the respective worst case: /sync not available or leave event emitted. // [lotus #46] Keep retrying for as long as the homeserver itself would keep
const maxWaitTime = Math.min(gracePeriod, leaveDelay); // our membership: until its delayed leave fires (`leaveDelay`). Capping at
// the 10 s sync grace period made a ~20–35 s homeserver stall end everyone's
// call ("Connection lost") even with a 60 s server-side leave delay. The
// embedded call has no /sync loop of its own, so the grace period doesn't
// describe anything it can observe.
const maxWaitTime = Math.max(gracePeriod, leaveDelay);
const maximumNetworkErrorRetryCount = const maximumNetworkErrorRetryCount =
Math.ceil(maxWaitTime / retryInterval) + 1; Math.ceil(maxWaitTime / retryInterval) + 1;