CI / Build & Quality Checks (pull_request) Successful in 4m12s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 10s
CI / Playwright smoke (e2e) (pull_request) Successful in 11m58s
When the homeserver, voice calls or sign-in break, or maintenance is under way, say so in the app — driven by the Kuma status page (isitup.lotusguild.org/status/matrix), managed from Kuma's UI. The client asks Kuma directly (not via our servers) so it still hears "the server is down" when our servers can't tell it. - config.json `statusPages`, keyed by homeserver: users of other servers never contact Kuma. - utils/kumaStatus.ts (pure, unit-tested): parse Kuma 2.x's public JSON; a group is down when any monitor fails two checks in a row (down+down or pending+down); maintenance = windows under way; announcements = incidents. One strip at a time: server down (connection lost AND Kuma confirms) > server having problems > maintenance > calls down > announcement; sign-in problems on the login screen only. - Wording about the user's own connection: "Connection lost … our status checks say the server is up, so it may be your internet connection" ONLY when Kuma checked the server after this client's connection dropped and it passed; a stale "up" (Kuma needs a minute or two to notice an outage) keeps the plain "Connection Lost!". - useServerStatus: polls only while visible; 5 min, 60 s while something is wrong or the connection is lost, at once when it drops; backoff; any failure = no banner (Kuma being unreachable never looks like Matrix being down); GET only, no cookies. - UI in the existing banner slot and style (ContainerColor/Line like the sync and clock banners); Details expands; dismiss for calls-down and announcements (an edited announcement comes back); calls-down note above Join; phone: one line + Details. Needs the CSP connect-src to allow https://isitup.lotusguild.org (matrix repo) before it can fetch in production; until then it fails quiet. Tests: 15 unit tests (live page layout, two-check rule, any-monitor rule, unknown/garbage, UTC beat times, stale-vs-fresh "up", priorities, login vs client, maintenance, announcements + dismiss/edit); e2e (fixtures for Kuma): calls-down strip + dismiss across reload, other homeservers make no requests, Kuma 500 → nothing, lost connection + Kuma down → critical strip instead of "Connection Lost", + fresh "up" → "may be your connection", + stale "up" → plain "Connection Lost". Unit 1315, Playwright 26 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
125 lines
4.5 KiB
TypeScript
125 lines
4.5 KiB
TypeScript
import React, { useCallback, useEffect, useState } from 'react';
|
|
import { Box, Button, color, Icon, Icons, Spinner, Text } from 'folds';
|
|
import { SequenceCard } from '../../components/sequence-card';
|
|
import * as css from './styles.css';
|
|
import { ChatButton, ControlDivider, MicrophoneButton, SoundButton, VideoButton } from './Controls';
|
|
import { useIsDirectRoom, useRoom } from '../../hooks/useRoom';
|
|
import { useCallEmbed, useCallJoined, useCallStart } from '../../hooks/useCallEmbed';
|
|
import { useCallPreferences } from '../../state/hooks/callPreferences';
|
|
import { useSetting } from '../../state/hooks/settings';
|
|
import { settingsAtom } from '../../state/settings';
|
|
import { useCallsDown } from '../server-status/ServerStatusBanner';
|
|
|
|
type MediaPermState = 'granted' | 'denied' | 'prompt' | 'unknown';
|
|
|
|
function useMediaPermissions(): MediaPermState {
|
|
const [state, setState] = useState<MediaPermState>('unknown');
|
|
|
|
useEffect(() => {
|
|
if (!navigator.permissions) {
|
|
setState('unknown');
|
|
return undefined;
|
|
}
|
|
let cancelled = false;
|
|
let permStatus: PermissionStatus | undefined;
|
|
navigator.permissions
|
|
.query({ name: 'microphone' as unknown as PermissionDescriptor['name'] })
|
|
.then((result) => {
|
|
if (cancelled) return;
|
|
permStatus = result;
|
|
setState(result.state as MediaPermState);
|
|
result.onchange = () => {
|
|
if (!cancelled) setState(result.state as MediaPermState);
|
|
};
|
|
})
|
|
.catch(() => {
|
|
if (!cancelled) setState('unknown');
|
|
});
|
|
// Detach the onchange handler on unmount so it can't setState afterward (and
|
|
// so the PermissionStatus doesn't retain the callback).
|
|
return () => {
|
|
cancelled = true;
|
|
if (permStatus) permStatus.onchange = null;
|
|
};
|
|
}, []);
|
|
|
|
return state;
|
|
}
|
|
|
|
type PrescreenControlsProps = {
|
|
canJoin?: boolean;
|
|
};
|
|
export function PrescreenControls({ canJoin }: PrescreenControlsProps) {
|
|
const room = useRoom();
|
|
const callEmbed = useCallEmbed();
|
|
const callJoined = useCallJoined(callEmbed);
|
|
const direct = useIsDirectRoom();
|
|
|
|
const inOtherCall = callEmbed && callEmbed.roomId !== room.roomId;
|
|
|
|
const startCall = useCallStart(direct);
|
|
const joining = callEmbed?.roomId === room.roomId && !callJoined;
|
|
|
|
const micPermission = useMediaPermissions();
|
|
const micDenied = micPermission === 'denied';
|
|
const callsDown = useCallsDown();
|
|
|
|
const disabled = inOtherCall || !canJoin || micDenied;
|
|
|
|
const { microphone, video, sound, toggleMicrophone, toggleVideo, toggleSound } =
|
|
useCallPreferences();
|
|
const [cameraOnJoin] = useSetting(settingsAtom, 'cameraOnJoin');
|
|
|
|
const handleMicrophoneToggle = useCallback(async () => toggleMicrophone(), [toggleMicrophone]);
|
|
const handleVideoToggle = useCallback(async () => toggleVideo(), [toggleVideo]);
|
|
|
|
return (
|
|
<SequenceCard
|
|
className={css.ControlCard}
|
|
variant="SurfaceVariant"
|
|
gap="400"
|
|
radii="500"
|
|
alignItems="Center"
|
|
justifyContent="SpaceBetween"
|
|
wrap="Wrap"
|
|
>
|
|
<Box shrink="No" alignItems="Inherit" justifyContent="SpaceBetween" gap="200">
|
|
<MicrophoneButton enabled={microphone} onToggle={handleMicrophoneToggle} />
|
|
<SoundButton enabled={sound} onToggle={toggleSound} />
|
|
</Box>
|
|
<ControlDivider />
|
|
<Box shrink="No" alignItems="Inherit" justifyContent="SpaceBetween" gap="200">
|
|
<VideoButton enabled={video} onToggle={handleVideoToggle} disabled={!cameraOnJoin} />
|
|
<ChatButton />
|
|
</Box>
|
|
<Box grow="Yes" direction="Column" gap="200">
|
|
{callsDown && (
|
|
<Text size="T200" style={{ color: color.Warning.Main, textAlign: 'center' }}>
|
|
Voice calls are down right now, so joining may fail.
|
|
</Text>
|
|
)}
|
|
{micDenied && (
|
|
<Text size="T200" style={{ color: color.Critical.Main, textAlign: 'center' }}>
|
|
Microphone access is blocked. Enable it in your browser settings to join.
|
|
</Text>
|
|
)}
|
|
<Button
|
|
variant={disabled ? 'Secondary' : 'Success'}
|
|
fill={disabled ? 'Soft' : 'Solid'}
|
|
onClick={() => startCall(room, { microphone, video, sound })}
|
|
disabled={disabled || joining}
|
|
before={
|
|
joining ? (
|
|
<Spinner variant="Success" fill="Solid" size="200" />
|
|
) : (
|
|
<Icon src={Icons.Phone} size="200" filled />
|
|
)
|
|
}
|
|
>
|
|
<Text size="B400">Join</Text>
|
|
</Button>
|
|
</Box>
|
|
</SequenceCard>
|
|
);
|
|
}
|