/* Copyright 2022-2024 New Vector Ltd. SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ import { type ChangeEvent, type FC, type ReactNode, useCallback, useEffect, useMemo, useId, useState, } from "react"; import { useTranslation } from "react-i18next"; import { UNSTABLE_MSC4354_STICKY_EVENTS, type MatrixClient, } from "matrix-js-sdk"; import { logger } from "matrix-js-sdk/lib/logger"; import { EditInPlace, ErrorMessage, Root as Form, Heading, HelpMessage, InlineField, Label, RadioControl, Separator, } from "@vector-im/compound-web"; import { type Room as LivekitRoom } from "livekit-client"; import { FieldRow, InputField } from "../input/Input"; import { Config } from "../config/Config"; import { type Setting, useSetting, duplicateTiles as duplicateTilesSetting, debugTileLayout as debugTileLayoutSetting, showConnectionStats as showConnectionStatsSetting, muteAllAudio as muteAllAudioSetting, alwaysShowIphoneEarpiece as alwaysShowIphoneEarpieceSetting, matrixRTCMode as matrixRTCModeSetting, customLivekitUrl as customLivekitUrlSetting, advancedScreenShare as advancedScreenShareSetting, screenShareResolution as screenShareResolutionSetting, screenShareFramerate as screenShareFramerateSetting, screenShareBitrate as screenShareBitrateSetting, screenShareCodec as screenShareCodecSetting, advancedCamera as advancedCameraSetting, cameraResolution as cameraResolutionSetting, cameraFramerate as cameraFramerateSetting, cameraBitrate as cameraBitrateSetting, cameraCodec as cameraCodecSetting, echoCancellationSetting, noiseSuppressionSetting, autoGainControlSetting, type VideoCodec, enableExtendedLivekitLogs as enableExtendedLivekitLogsSetting, } from "./settings"; import { MatrixRTCMode } from "../config/ConfigOptions"; import styles from "./DeveloperSettingsTab.module.css"; import settingsStyles from "./SettingsModal.module.css"; import { Slider } from "../Slider"; import { useUrlParams } from "../UrlParams"; import { getSFUConfigWithOpenID } from "../livekit/openIDSFU"; import { useBehavior } from "../useBehavior"; import { type ViewModel } from "../state/ViewModel.ts"; /** * The state of MatrixRTC's media key rotation. */ export interface KeyRotationInfo { /** Whether the call is large enough that MatrixRTC has stopped rotating the media key. */ suppressed: boolean; participantCount: number; } /** * The Snapshot combines all fields the developer settings tab needs from the * surrounding call. Everything else in this tab is read from the settings store * or the environment directly. */ export interface DeveloperSettingsSnapshot { /** The media key rotation state, or `null` when we are not in a call. */ keyRotation: KeyRotationInfo | null; } /** * Shows whether the call is large enough that MatrixRTC has stopped rotating the media key. */ const KeyRotationStatus: FC<{ info: KeyRotationInfo }> = ({ info }) => (
Media key rotation:{" "} {info.suppressed ? `suppressed, participant limit reached (${info.participantCount} participants)` : `active (${info.participantCount} participants)`}
); interface Props { client: MatrixClient; roomId?: string; livekitRooms?: { room: LivekitRoom; url: string; isLocal?: boolean; livekitAlias?: string; }[]; env: ImportMetaEnv; vm: ViewModel{t( "settings.audio_processing_description", "Changes apply on next call join.", )}
{t("developer_mode.hostname", { hostname: window.location.hostname || "unknown", })}
{t("version", { productName: import.meta.env.VITE_PRODUCT_NAME || "Element Call", version: import.meta.env.VITE_APP_VERSION || "dev", })}
{t("developer_mode.crypto_version", { version: client.getCrypto()?.getVersion() || "unknown", })}
{t("developer_mode.matrix_id", { id: client.getUserId() || "unknown", })}
{t("developer_mode.device_id", { id: client.getDeviceId() || "unknown", })}
{keyRotation !== null &&Your deployment overrides the mode.
} {livekitRooms?.map((livekitRoom) => (LivekitAlias: {livekitRoom.livekitAlias}
connectionState (wont hot reload): {livekitRoom.room.state}
{livekitRoom.isLocal &&ws-url: {localSfuUrl?.href}
}{t("developer_mode.livekit_server_info")}( {livekitRoom.isLocal ? "local" : "remote"})
{livekitRoom.room.serverInfo
? JSON.stringify(livekitRoom.room.serverInfo, null, 2)
: "undefined"}
{livekitRoom.room.metadata}
Local Participant
{livekitRoom.room.localParticipant.identity}
Remote Participants
{t("developer_mode.environment_variables")}
{JSON.stringify(env, null, 2)}
{t("developer_mode.url_params")}
{JSON.stringify(urlParams, null, 2)}
>
);
};