Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07e1506dd8 |
@@ -34,6 +34,7 @@ describe("LotusWidgetActions", () => {
|
||||
LotusWidgetActions.SetHotkeys,
|
||||
LotusWidgetActions.SetFrameScreenshare,
|
||||
LotusWidgetActions.PromptScreenshare,
|
||||
LotusWidgetActions.Reconnect,
|
||||
];
|
||||
|
||||
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.Hotkey);
|
||||
expect(LOTUS_TO_WIDGET_ACTIONS).not.toContain(LotusWidgetActions.CallError);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -116,6 +116,14 @@ export enum LotusWidgetActions {
|
||||
* only when it changes (≤ 10 Hz); 0 while muted or with no mic.
|
||||
*/
|
||||
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`. */
|
||||
@@ -133,4 +141,5 @@ export const LOTUS_TO_WIDGET_ACTIONS: LotusWidgetActions[] = [
|
||||
LotusWidgetActions.SetHotkeys,
|
||||
LotusWidgetActions.SetFrameScreenshare,
|
||||
LotusWidgetActions.PromptScreenshare,
|
||||
LotusWidgetActions.Reconnect,
|
||||
];
|
||||
|
||||
@@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { MicLevelQuantizer, sameRooms } from "./lotusMicLevel";
|
||||
import { MicLevelQuantizer } from "./lotusMicLevel";
|
||||
|
||||
describe("MicLevelQuantizer", () => {
|
||||
it("maps RMS to 0–3 bars", () => {
|
||||
@@ -35,14 +35,3 @@ describe("MicLevelQuantizer", () => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,10 +46,6 @@ const micPublication = (
|
||||
: 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<
|
||||
CallViewModel,
|
||||
Observable<LocalMicSample | null>
|
||||
@@ -66,15 +62,10 @@ export function observeLocalMicSample$(
|
||||
const cached = samplers.get(vm);
|
||||
if (cached) return cached;
|
||||
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(
|
||||
(rooms) =>
|
||||
(data) =>
|
||||
new Observable<LocalMicSample | null>((subscriber) => {
|
||||
const rooms = data.getConnections().map((c) => c.livekitRoom);
|
||||
let ctx: AudioContext | null = null;
|
||||
let clone: MediaStreamTrack | null = null;
|
||||
let timer: ReturnType<typeof setInterval> | undefined;
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
type ReactNode,
|
||||
type SVGAttributes,
|
||||
useCallback,
|
||||
useEffect,
|
||||
} from "react";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import {
|
||||
@@ -24,6 +25,7 @@ import {
|
||||
import { Button } from "@vector-im/compound-web";
|
||||
import { logger } from "matrix-js-sdk/lib/logger";
|
||||
import { MatrixError } from "matrix-js-sdk";
|
||||
import { type IWidgetApiRequest } from "matrix-widget-api";
|
||||
|
||||
import {
|
||||
ConnectionLostError,
|
||||
@@ -38,6 +40,7 @@ import { FullScreenView } from "../FullScreenView.tsx";
|
||||
import { ErrorView } from "../ErrorView.tsx";
|
||||
import { type WidgetHelpers } from "../widget.ts";
|
||||
import styles from "../ErrorView.module.css";
|
||||
import { LotusWidgetActions, lotusSendToHost } from "../lotus/lotusWidget";
|
||||
|
||||
export type CallErrorRecoveryAction = "reconnect"; // | "retry" ;
|
||||
|
||||
@@ -74,6 +77,29 @@ const ErrorPage: FC<ErrorPageProps> = ({
|
||||
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 }[] = [];
|
||||
if (error instanceof ConnectionLostError) {
|
||||
actions.push({
|
||||
|
||||
Reference in New Issue
Block a user