Compare commits

..
Author SHA1 Message Date
Johannes Marbach 068d968aab Stop depending on pull_request_target 2026-12-03 15:18:21 +01:00
Johannes Marbach 965e77be36 Merge pull request #4555 from element-hq/renovate/element-web
Update ghcr.io/element-hq/element-web:develop Docker digest to a9fba6e
2026-12-03 08:39:00 +01:00
renovate[bot] 3818c34c3b Update ghcr.io/element-hq/element-web:develop Docker digest to a9fba6e 2026-12-03 03:18:47 +00:00
Robin b7374c4906 Merge pull request #4553 from element-hq/renovate/compound
Update dependency @vector-im/compound-web to v10.7.0
2026-12-02 17:09:20 -05:00
Robin 2100b93f5b Exclude our own packages from Renovate's minimum release age policy 2026-12-02 16:59:09 -05:00
renovate[bot] a62d3f4dd9 Update dependency @vector-im/compound-web to v10.7.0 2026-12-02 21:55:07 +00:00
Timo ab8340e3c2 Fall back to compat mode even if the config is configured for 2.0 (#4528)
* Fall back to compat mode even if the config is configured for 2.0 if not
supported

This prohibts showing an error screen when using a deployment with a
config for 2.0 in combination with a HS that does not support sticky.

* Add comment to document CORS issue
2026-12-02 10:34:23 +00:00
Timo 32e35fdfc8 Merge pull request #4539 from element-hq/toger5/fix-js-sdk-entry-point-guard
Skip "two js-sdk guard" for the component build
2026-12-02 11:17:35 +01:00
TimoandElementBot 6dede3a678 Apply suggestion from @ElementBot
Co-authored-by: ElementBot <110224175+ElementBot@users.noreply.github.com>
2026-12-02 10:55:33 +01:00
renovate[bot] 8ebf54159a Update ghcr.io/element-hq/element-web:develop Docker digest to a781033 (#4543)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-02 02:23:49 +00:00
Robin 60f5c90bb5 Merge pull request #4542 from element-hq/robin/no-npx
Don't use npx for translation update scripts
2026-12-01 15:33:52 -05:00
Robin f2549a0e17 Don't use npx for translation update scripts
This could cause CI to use a different version of i18next-cli when checking the translation files.
2026-12-01 12:27:02 -05:00
TimoandJohannes Marbach 3f933c1077 Update component/guestJsSdk.ts
Co-authored-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2026-12-01 17:03:28 +01:00
Johannes Marbach 2872857be6 Merge pull request #4508 from element-hq/johannes/bump-jsdom
Bump jsdom and remove outdated overrides
2026-12-01 16:25:04 +01:00
Johannes Marbach 6888727328 Merge branch 'main' into johannes/bump-jsdom 2026-12-01 16:15:23 +01:00
Timo K. 474b27d362 A bare import "matrix-js-sdk" now resolves to
matrix-js-sdk/lib/matrix.js instead of browser-index.js. That file has
 the same API but no guard, and it doesn't point the component's crypto
 store at the host's matrix-js-sdk:crypto IndexedDB or overwrite
 globalThis.matrixcs.
2026-12-01 16:09:46 +01:00
Johannes Marbach 33ba54e8bd Merge pull request #4537 from element-hq/renovate/all-minor-patch
Update all non-major dependencies
2026-12-01 09:13:41 +01:00
renovate[bot] c682a9970c Update ghcr.io/element-hq/element-web:develop Docker digest to 01b0026 (#4536)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-01 01:26:19 +00:00
renovate[bot] acd0fd524e Update all non-major dependencies 2026-12-01 01:20:31 +00:00
Robin 36b0e41269 Merge pull request #4481 from element-hq/robin/popover
Create generic popover component
2026-11-30 14:21:44 -05:00
Johannes Marbach e2a5fd94ce Bump jsdom and remove outdated overrides 2026-11-25 12:58:04 +01:00
22 changed files with 1168 additions and 1079 deletions
+2 -10
View File
@@ -1,22 +1,14 @@
name: Prevent blocked
on:
# zizmor: ignore[dangerous-triggers]
# Reason: This workflow does not checkout code or use secrets.
# It only reads labels to set a failure status on the PR.
pull_request_target:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
permissions:
pull-requests: read
# Required to fail the check on the PR
statuses: write
permissions: {}
jobs:
prevent-blocked:
name: Prevent blocked
runs-on: ubuntu-24.04
permissions:
pull-requests: read
steps:
- name: Add notice
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
+2 -7
View File
@@ -1,15 +1,10 @@
name: PR changelog label
on:
# zizmor: ignore[dangerous-triggers]
# This is safe because we do not use actions/checkout or execute untrusted code.
# Using pull_request_target is necessary to allow status writes for PRs from forks.
pull_request_target:
pull_request:
types: [labeled, unlabeled, opened, synchronize]
permissions:
pull-requests: read
statuses: write
permissions: {}
jobs:
pr-changelog-label:
Binary file not shown.
+41
View File
@@ -0,0 +1,41 @@
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
/**
* The js-sdk for the component: the package's own entry points
* (`lib/index.js`, `lib/browser-index.js`) throw when the host's copy has
* already loaded one, and `browser-index` also writes the host's globals.
* `lib/matrix` is the same API without either. The client this exports
* refuses the few calls that would collide with the host's js-sdk: a sync
* loop, crypto, and the IndexedDB stores both would open by the same name.
*/
import { IndexedDBStore, MatrixClient } from "matrix-js-sdk/lib/matrix";
function refuse<C extends { prototype: object }>(
cls: C,
name: string,
methods: (keyof C["prototype"] & string)[],
): void {
for (const method of methods)
Object.defineProperty(cls.prototype, method, {
value() {
throw new Error(
`${name}.${method} is not available in the Element Call component: the host's client does this`,
);
},
});
}
refuse(MatrixClient, "MatrixClient", [
"startClient",
"initRustCrypto",
"clearStores",
]);
refuse(IndexedDBStore, "IndexedDBStore", ["startup"]);
export * from "matrix-js-sdk/lib/matrix";
+2 -1
View File
@@ -34,7 +34,8 @@
"./style.css": "./dist/element-call.css"
},
"sideEffects": [
"*.css"
"*.css",
"./guestJsSdk.ts"
],
"scripts": {
"prepare": "cd .. && pnpm install --frozen-lockfile && pnpm build:component"
+2 -2
View File
@@ -19,10 +19,10 @@ services:
- ./backend/playwright_homeserver-othersite.yaml:/data/cfg/homeserver.yaml:Z
element-web:
# Pin to a SHA so that upstream cannot break our tests. Renovate handles regular updates.
image: ghcr.io/element-hq/element-web:develop@sha256:9ed1f2140ce855b8e599bf4b16f9be47c3295738989574efbb0b8f0e159c5de7
image: ghcr.io/element-hq/element-web:develop@sha256:a9fba6e7ea9a32f62bc1459fcdad790662476ff1b2bcebc62fe47e5cf51e3932
element-web-1:
# Pin to a SHA so that upstream cannot break our tests. Renovate handles regular updates.
image: ghcr.io/element-hq/element-web:develop@sha256:9ed1f2140ce855b8e599bf4b16f9be47c3295738989574efbb0b8f0e159c5de7
image: ghcr.io/element-hq/element-web:develop@sha256:a9fba6e7ea9a32f62bc1459fcdad790662476ff1b2bcebc62fe47e5cf51e3932
volumes:
# The other site opens the embedded package under test in place of the
# copy its image bundles (the first site opens the dev server's app.
+4 -4
View File
@@ -39,8 +39,8 @@
"lint:knip": "knip",
"lint:externals": "node scripts/check-component-externals.mjs",
"lint:types": "tsc",
"i18n": "npx i18next-cli extract",
"i18n:check": "npx i18next-cli extract --ci",
"i18n": "i18next-cli extract",
"i18n:check": "i18next-cli extract --ci",
"test": "vitest",
"test:storybook": "vitest --project=storybook",
"test:unit": "vitest --project=unit",
@@ -106,7 +106,7 @@
"i18next": "^26.0.0",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-cli": "^1.61.0",
"jsdom": "^26.0.0",
"jsdom": "^31.0.0",
"knip": "^5.86.0",
"livekit-client": "^2.18.1",
"lodash-es": "^4.17.21",
@@ -115,7 +115,7 @@
"matrix-widget-api": "^1.18.0",
"node-stdlib-browser": "^1.3.1",
"normalize.css": "^8.0.1",
"oxfmt": "^0.79.0",
"oxfmt": "^0.80.0",
"oxlint": "^1.70.0",
"oxlint-tsgolint": "^0.25.0",
"pako": "^3.0.3",
+896 -1003
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -28,8 +28,8 @@ overrides:
# - https://github.com/advisories/GHSA-7r86-cg39-jmmj
# - https://github.com/advisories/GHSA-23c5-xmqv-rm74
"minimatch": "^11.0.0"
# Security fix: https://github.com/element-hq/element-call/security/dependabot/109
"glob": "^10.5.0"
# The v8 line is deprecated.
"eslint": "^9.0.0"
# Security fix: https://github.com/advisories/GHSA-6pq8-jhm2-2vcw
"qs": ">=6.16.1"
# Security fix: https://github.com/advisories/GHSA-2883-xcg3-v3hh
+4 -2
View File
@@ -28,12 +28,14 @@
{
"groupName": "matrix-widget-api",
"matchDepNames": ["matrix-widget-api"],
"extends": ["schedule:weekly"]
"extends": ["schedule:weekly"],
"minimumReleaseAge": null
},
{
"groupName": "Compound",
"matchPackageNames": ["@vector-im/compound-{/,}**"],
"extends": ["schedule:weekly"]
"extends": ["schedule:weekly"],
"minimumReleaseAge": null
},
{
"groupName": "LiveKit client",
+11 -11
View File
@@ -6,18 +6,18 @@ Please see LICENSE in the repository root for full details.
*/
/**
* Checks the component build's output for what a host must not be handed.
* Checks the component build's output for things we do not want to end up in the
* component target.
*
* A library build inlines every asset it meets as a data URL unless the import
* says otherwise, and does so silently: one import without `no-inline` and the
* module grows by the asset, encoded a third larger, that every host then
* downloads and parses before the first call. MediaPipe's runtime alone is
* 11 MB. A reference to a file by an absolute path is just as silent and
* breaks at runtime instead, since a host serves the module from wherever it
* likes. And the standalone app's client store worker, which carries a copy of
* the Matrix SDK and its crypto, has no business in a package whose host
* supplies the client: the bundler emits it on loading its import, used or
* not (see src/utils/initClient.ts). This fails the build on each of those.
* A library build inlines every asset it needs as a data URL unless the import
* says otherwise: if one adds an import without `no-inline` the
* module grows by the asset (due to encoding a third larger than the original file)
* that every host then downloads and parses before the first call.
* MediaPipe's runtime alone is 11 MB, so it should not be inlined.
* The standalone app's client store worker, which carries a copy of the Matrix SDK
* and its crypto, is also not needed in a package whose host supplies the client:
* the bundler packages if it is imported, even if not used (see src/utils/initClient.ts).
* The script makes sure, the build fails on each of those issues.
*/
import { existsSync } from "node:fs";
+1 -1
View File
@@ -61,7 +61,7 @@ exports[`the modal renders as a drawer in mobile viewports 1`] = `
/>
<h2
id="radix-_r_a_"
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;"
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; overflow-wrap: normal;"
>
My modal
</h2>
@@ -291,7 +291,7 @@ describe("MediaMuteAndSwitchButton", () => {
// After clicking, plannedSelection="mic2" but selectedOption is still "mic1",
// so mic2 should be in an activating state
screen.getByRole("menuitemradio", {
name: "Microphone 2 Activating…",
name: /^Microphone 2\s*Activating…$/,
checked: false,
});
+14 -11
View File
@@ -137,23 +137,24 @@ beforeEach(() => {
);
});
function createCallView(
async function createCallView(
hostBridge: HostBridge,
joined = true,
options: {
/** Wait for the host to say when to join, rather than joining at once. */
preload?: boolean;
} = {},
): {
): Promise<{
rtcSession: MatrixRTCSession;
getByText: ReturnType<typeof render>["getByText"];
} {
}> {
const client = {
...mockEmitter(),
getUser: () => null,
getUserId: () => localRtcMember.userId,
getDeviceId: () => localRtcMember.deviceId,
getRoom: (rId) => (rId === roomId ? room : null),
doesServerSupportUnstableFeature: vi.fn().mockResolvedValue(true),
} as Partial<MatrixClient> as MatrixClient;
const room = mockMatrixRoom({
relations: {
@@ -203,6 +204,8 @@ function createCallView(
</HostBridgeProvider>
</BrowserRouter>,
);
// Let the homeserver capability check resolve, which the call waits for
await act(flushPromises);
return {
getByText,
rtcSession: rtcSession.asMockedSession(),
@@ -211,7 +214,7 @@ function createCallView(
test.skip("CallView plays a leave sound asynchronously in SPA mode", async () => {
const user = userEvent.setup();
const { getByText, rtcSession } = createCallView(nullHostBridge);
const { getByText, rtcSession } = await createCallView(nullHostBridge);
const leaveButton = getByText("Leave");
await user.click(leaveButton);
expect(playSound).toHaveBeenCalledWith("left");
@@ -241,7 +244,7 @@ test.skip("CallView plays a leave sound synchronously in widget mode", async ()
soundDuration: {},
});
const { getByText, rtcSession } = createCallView(hostBridge);
const { getByText, rtcSession } = await createCallView(hostBridge);
const leaveButton = getByText("Leave");
await user.click(leaveButton);
await flushPromises();
@@ -274,7 +277,7 @@ test("Should ask the host to close when all other left and play a sound", async
soundDuration: {},
});
const { getByText } = createCallView(hostBridge);
const { getByText } = await createCallView(hostBridge);
const leaveButton = getByText("SimulateOtherLeft");
await user.click(leaveButton);
await flushPromises();
@@ -291,7 +294,7 @@ test("Waits for the host to say when to join, when preloaded", async () => {
const join$ = new Subject<HostRequest<JoinCallData>>();
const hostBridge: HostBridge = { ...nullHostBridge, join$ };
createCallView(hostBridge, false, { preload: true });
await createCallView(hostBridge, false, { preload: true });
await flushPromises();
// Past the lobby, but not in the call: the host has not asked yet
expect(screen.queryByText("Leave")).toBeNull();
@@ -316,7 +319,7 @@ test("Should not ask the host to close when auto leave due to error", async () =
close,
};
const { getByText } = createCallView(hostBridge);
const { getByText } = await createCallView(hostBridge);
const leaveButton = getByText("SimulateErrorLeft");
await user.click(leaveButton);
await flushPromises();
@@ -339,7 +342,7 @@ test.skip("CallView leaves the session when an error occurs", async () => {
);
});
const user = userEvent.setup();
const { rtcSession } = createCallView(nullHostBridge);
const { rtcSession } = await createCallView(nullHostBridge);
await user.click(screen.getByRole("button", { name: "Panic!" }));
screen.getByText("Something went wrong");
expect(leaveRTCSession).toHaveBeenCalledWith(
@@ -356,7 +359,7 @@ test.skip("CallView shows errors that occur during joining", async () => {
onTestFinished(() => {
enterRTCSession.mockReset();
});
createCallView(nullHostBridge, false);
await createCallView(nullHostBridge, false);
await user.click(screen.getByRole("button", { name: "Join call" }));
screen.getByText("Call is not supported");
});
@@ -378,7 +381,7 @@ test("user can reconnect after losing the connection", async () => {
},
);
const user = userEvent.setup();
createCallView(nullHostBridge, true);
await createCallView(nullHostBridge, true);
await user.click(screen.getByRole("button", { name: "LoseConnection" }));
await screen.findByText("Connection lost");
// Never joined, so there was no call to leave
+40 -2
View File
@@ -13,7 +13,12 @@ import {
useMemo,
useState,
} from "react";
import { type MatrixClient, JoinRule, type Room } from "matrix-js-sdk";
import {
type MatrixClient,
JoinRule,
type Room,
UNSTABLE_MSC4354_STICKY_EVENTS,
} from "matrix-js-sdk";
import {
Room as LivekitRoom,
isE2EESupported as isE2EESupportedBrowser,
@@ -166,7 +171,35 @@ export const CallView: FC<Props> = ({
return (): void => scope.end();
}, [backend, e2eeSystem, externalRtcSession]);
if (muteStates === null || slot === null) return null;
// Known before the call renders, so a join without a lobby picks the right
// Matrix RTC mode
const [stickyEventsSupported, setStickyEventsSupported] = useState<
boolean | null
>(null);
useEffect(() => {
let cancelled = false;
void backend
.doesServerSupportUnstableFeature(UNSTABLE_MSC4354_STICKY_EVENTS)
.catch((e) => {
// This will also fail in embedded mode if the HS does not
// set `Access-Control-Allow-Origin: *`:
// The page is loaded from a file url (origin=null) + widget api does not handle this
// -> a raw http request will be used -> CORS errors due to origin=null
// The conclusion is: matrix 2.0 mode will always fall back in widget mode on mobile.
// This is acceptable as we plan to not extend the widget api for full 2.0 mode support.
logger.warn("Failed to check if sticky events are supported", e);
return false;
})
.then((supported) => {
if (!cancelled) setStickyEventsSupported(supported);
});
return (): void => {
cancelled = true;
};
}, [backend]);
if (muteStates === null || slot === null || stickyEventsSupported === null)
return null;
return (
<LoadedCallView
@@ -180,6 +213,7 @@ export const CallView: FC<Props> = ({
joined={joined}
setJoined={setJoined}
muteStates={muteStates}
stickyEventsSupported={stickyEventsSupported}
/>
);
};
@@ -249,6 +283,8 @@ interface LoadedProps extends Omit<Props, "rtcSession" | "backend"> {
joined: boolean;
setJoined: (value: boolean) => void;
muteStates: MuteStates;
/** Whether the homeserver supports sticky events (MSC4354), which Matrix 2.0 needs. */
stickyEventsSupported: boolean;
}
/**
@@ -281,6 +317,7 @@ const LoadedCallView: FC<LoadedProps> = ({
joined,
setJoined,
muteStates,
stickyEventsSupported,
}) => {
// Used to thread through any errors that occur outside the error boundary
const [externalError, setExternalError] = useState<ElementCallError | null>(
@@ -619,6 +656,7 @@ const LoadedCallView: FC<LoadedProps> = ({
media={media}
muteStates={muteStates}
e2eeSystem={e2eeSystem}
stickyEventsSupported={stickyEventsSupported}
//otelGroupCallMembership={otelGroupCallMembership}
onShareClick={onShareClick}
/>
+37 -2
View File
@@ -7,6 +7,7 @@ Please see LICENSE in the repository root for full details.
*/
import {
afterEach,
beforeEach,
describe,
expect,
@@ -20,8 +21,10 @@ import { BrowserRouter } from "react-router-dom";
import { TooltipProvider } from "@vector-im/compound-web";
import userEvent from "@testing-library/user-event";
import { ActiveCall, InCallView } from "./InCallView";
import { ActiveCall, InCallView, rtcParticipationOptions } from "./InCallView";
import { getUrlParams } from "../UrlParams";
import {
mockConfig,
mockMediaDevices,
mockMuteStates,
mockRtcMembership,
@@ -43,7 +46,11 @@ import { ReactionsSenderProvider } from "../reactions/useReactionsSender";
import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement";
import { MemberAudioRenderer } from "../tracks/MemberAudioRenderer";
import type * as MatrixRTCSdk from "@element-hq/matrixrtc-sdk";
import { constant, type RTCSlot } from "@element-hq/matrixrtc-sdk";
import {
constant,
MatrixRTCMode,
type RTCSlot,
} from "@element-hq/matrixrtc-sdk";
import { MediaDevicesContext } from "../MediaDevicesContext";
import { type MediaDevices as ECMediaDevices } from "../state/MediaDevices";
import { AppBar } from "../AppBar";
@@ -246,6 +253,7 @@ function renderActiveCall(slot: RTCSlot): RenderResult {
onShareClick={null}
e2eeSystem={{ kind: E2eeType.NONE }}
media={fakeLocalMedia()}
stickyEventsSupported
onLeft={(): void => {}}
/>
</TooltipProvider>
@@ -255,6 +263,32 @@ function renderActiveCall(slot: RTCSlot): RenderResult {
);
}
describe("rtcParticipationOptions", () => {
const urlParams = getUrlParams("", "");
afterEach(() => vi.restoreAllMocks());
it("joins in Matrix 2.0 mode when the homeserver supports sticky events", () => {
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Matrix_2_0 });
expect(rtcParticipationOptions(urlParams, true).matrixRTCMode).toBe(
MatrixRTCMode.Matrix_2_0,
);
});
it("falls back to compatibility mode when the homeserver lacks sticky events", () => {
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Matrix_2_0 });
expect(rtcParticipationOptions(urlParams, false).matrixRTCMode).toBe(
MatrixRTCMode.Compatibility,
);
});
it("keeps compatibility mode when the homeserver lacks sticky events", () => {
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Compatibility });
expect(rtcParticipationOptions(urlParams, false).matrixRTCMode).toBe(
MatrixRTCMode.Compatibility,
);
});
});
describe("ActiveCall", () => {
it("creates the view models and renders the call", async () => {
const { findByTestId } = renderActiveCall(mockSlot());
@@ -315,6 +349,7 @@ describe("ActiveCall", () => {
onShareClick={null}
e2eeSystem={{ kind: E2eeType.NONE }}
media={fakeLocalMedia()}
stickyEventsSupported
onLeft={(): void => {}}
/>
</TooltipProvider>
+19 -8
View File
@@ -55,7 +55,7 @@ import { SpotlightTile } from "../tile/SpotlightTile";
import {
type EncryptionSystem,
type LocalMedia,
type MatrixRTCMode,
MatrixRTCMode,
} from "@element-hq/matrixrtc-sdk";
import { E2eeType } from "../e2ee/e2eeType";
import { makeGridLayout } from "../grid/GridLayout";
@@ -194,6 +194,8 @@ export interface ActiveCallProps extends Omit<
e2eeSystem: EncryptionSystem;
/** The tracks the lobby opened, for the join to publish. */
media: LocalMedia;
/** Whether the homeserver supports sticky events (MSC4354), which Matrix 2.0 needs. */
stickyEventsSupported: boolean;
// TODO refactor those reasons into an enum
onLeft: (
reason: "user" | "timeout" | "decline" | "allOthersLeft" | "error",
@@ -229,7 +231,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
const capture = captureSettings();
const rtcParticipation = props.slot.join({
...rtcParticipationOptions(urlParams),
...rtcParticipationOptions(urlParams, props.stickyEventsSupported),
// Without a lobby nothing was captured and the join captures itself
publish:
props.media.requests.length > 0
@@ -290,6 +292,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
backgroundEffectsState$,
props.client,
props.media,
props.stickyEventsSupported,
rootElement,
]);
@@ -867,16 +870,24 @@ export function captureSettings(): CaptureSettings {
*/
export function rtcParticipationOptions(
urlParams: ReturnType<typeof useUrlParams>,
stickyEventsSupported: boolean,
): Omit<RTCParticipationOptions, "publish"> {
const config = Config.get();
const session = config.matrix_rtc_session;
// matrix_rtc_mode in config.json overrides the user's Developer Settings
// choice. We merely sample the current mode here, so the user would need
// to manually rejoin to switch to a different one.
let matrixRTCMode =
(config.matrix_rtc_mode as MatrixRTCMode | undefined) ??
matrixRTCModeSetting.value$.value;
if (matrixRTCMode === MatrixRTCMode.Matrix_2_0 && !stickyEventsSupported) {
rootLogger.warn(
"Homeserver does not support sticky events (MSC4354), falling back from Matrix 2.0 to compatibility mode",
);
matrixRTCMode = MatrixRTCMode.Compatibility;
}
return {
// matrix_rtc_mode in config.json overrides the user's Developer Settings
// choice. We merely sample the current mode here, so the user would need
// to manually rejoin to switch to a different one.
matrixRTCMode:
(config.matrix_rtc_mode as MatrixRTCMode | undefined) ??
matrixRTCModeSetting.value$.value,
matrixRTCMode,
sendNotificationType: urlParams.sendNotificationType,
callIntent: urlParams.callIntent,
timings: {
@@ -108,7 +108,6 @@ exports[`InCallView > rendering > renders 1`] = `
</div>
<div
class="_fixedGrid_4e7ff8 _grid_b0d1cd"
style="inset-block-start: NaNpx;"
>
<div />
</div>
@@ -422,6 +422,54 @@ describe("DeveloperSettingsTab", () => {
expect(checkedValue).toBeChecked();
},
);
it("shows the compatibility fallback when matrix_2_0 is forced but the homeserver lacks sticky events", async () => {
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Matrix_2_0 });
const client = createMockMatrixClient();
vi.mocked(client.doesServerSupportUnstableFeature).mockResolvedValue(
false,
);
render(
<TooltipProvider>
<DeveloperSettingsTab
client={client}
env={{} as unknown as ImportMetaEnv}
vm={outOfCallDeveloperSettingsTabViewModel}
/>
</TooltipProvider>,
);
expect(
await screen.findByText(/calls fall back to compatibility mode/),
).toBeInTheDocument();
const radios = getModeRadios();
expect(radios.compatibility).toBeChecked();
expect(radios.matrix20).not.toBeChecked();
});
it("shows no fallback when matrix_2_0 is forced and the homeserver has sticky events", async () => {
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Matrix_2_0 });
const client = createMockMatrixClient();
render(
<TooltipProvider>
<DeveloperSettingsTab
client={client}
env={{} as unknown as ImportMetaEnv}
vm={outOfCallDeveloperSettingsTabViewModel}
/>
</TooltipProvider>,
);
await waitFor(() =>
expect(client.doesServerSupportUnstableFeature).toHaveBeenCalled(),
);
expect(
screen.queryByText(/calls fall back to compatibility mode/),
).toBeNull();
expect(getModeRadios().matrix20).toBeChecked();
});
});
describe("KeyRotationStatus", () => {
+20 -3
View File
@@ -146,7 +146,10 @@ export const DeveloperSettingsTab: FC<Props> = ({
debugTileLayoutSetting,
);
const [stickyEventsSupported, setStickyEventsSupported] = useState(false);
// null until the homeserver has answered
const [stickyEventsSupported, setStickyEventsSupported] = useState<
boolean | null
>(null);
useEffect(() => {
client
.doesServerSupportUnstableFeature(UNSTABLE_MSC4354_STICKY_EVENTS)
@@ -155,6 +158,8 @@ export const DeveloperSettingsTab: FC<Props> = ({
})
.catch((ex) => {
logger.warn("Failed to check if sticky events are supported", ex);
// As the call does
setStickyEventsSupported(false);
});
}, [client]);
@@ -170,7 +175,13 @@ export const DeveloperSettingsTab: FC<Props> = ({
| MatrixRTCMode
| undefined;
const matrixRTCModeForced = configMatrixRTCMode !== undefined;
const effectiveMatrixRTCMode = configMatrixRTCMode ?? matrixRTCMode;
// The call joins in compatibility mode instead, see `rtcParticipationOptions`
const stickyFallback =
configMatrixRTCMode === MatrixRTCMode.Matrix_2_0 &&
stickyEventsSupported === false;
const effectiveMatrixRTCMode = stickyFallback
? MatrixRTCMode.Compatibility
: (configMatrixRTCMode ?? matrixRTCMode);
const [showConnectionStats, setShowConnectionStats] = useSetting(
showConnectionStatsSetting,
@@ -569,6 +580,12 @@ export const DeveloperSettingsTab: FC<Props> = ({
{t("developer_mode.matrixRTCMode.title")}
</Heading>
{matrixRTCModeForced && <p>Your deployment overrides the mode.</p>}
{stickyFallback && (
<p>
Your homeserver does not support sticky events (MSC4354), so calls
fall back to compatibility mode.
</p>
)}
<Form>
<InlineField
name={matrixRTCModeRadioGroup}
@@ -592,7 +609,7 @@ export const DeveloperSettingsTab: FC<Props> = ({
<RadioControl
checked={effectiveMatrixRTCMode === MatrixRTCMode.Matrix_2_0}
value={MatrixRTCMode.Matrix_2_0}
disabled={matrixRTCModeForced || !stickyEventsSupported}
disabled={matrixRTCModeForced || stickyEventsSupported !== true}
onChange={onMatrixRTCModeChange}
/>
}
+7
View File
@@ -53,6 +53,13 @@ window.matchMedia = global.matchMedia = (): MediaQueryList =>
removeEventListener: () => {},
}) as Partial<MediaQueryList> as MediaQueryList;
// Disable animations. jsdom computes `animation-name` from our stylesheets but
// never runs an animation, so anything that waits for `animationend` before
// unmounting (Radix dialogs, for one) would stay mounted forever.
const noAnimations = document.createElement("style");
noAnimations.textContent = "* { animation: none !important; }";
document.head.appendChild(noAnimations);
// jsdom does no layout and has no ResizeObserver. The call view observes the
// size of its root element; this one reports nothing, so that element stays at
// whatever size jsdom says it is unless a test says otherwise.
+15 -8
View File
@@ -5,8 +5,9 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { defineConfig } from "vite";
import { defineConfig, mergeConfig } from "vite";
import { posix } from "node:path";
import { fileURLToPath } from "node:url";
import { vitePluginsConfig, withoutMatrixCrypto } from "./vite.config.ts";
import { scopeStylesToRoot } from "./component/build/scopeStylesToRoot.ts";
@@ -21,17 +22,23 @@ export default defineConfig(({ mode }) => {
return {
...base,
plugins: [...(base.plugins ?? []), withoutMatrixCrypto()],
resolve: {
...base.resolve,
alias: {
...base.resolve?.alias,
// mergeConfig appends to the base's aliases, whatever form they are in
resolve: mergeConfig(base.resolve ?? {}, {
alias: [
// react-i18next depends on the CommonJS `use-sync-external-store/shim`, whose
// `require("react")` cannot be bundled against an external React: rolldown leaves a
// `require` shim that throws in the browser. React 18+ provides `useSyncExternalStore`
// itself, so point the shim at React.
"use-sync-external-store/shim": "react",
},
},
{ find: "use-sync-external-store/shim", replacement: "react" },
// Only the bare name, not its subpaths: see component/guestJsSdk.ts
{
find: /^matrix-js-sdk$/,
replacement: fileURLToPath(
new URL("./component/guestJsSdk.ts", import.meta.url),
),
},
],
}),
// A library has no public directory to serve. Without this the build copies
// whatever is in `public` — including the developer's own config.json, which
// is not in the repository — into the output we would publish.