Fix unnecessary livekit support checks (#1099)

<!-- Please read
https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before
submitting your pull request -->

### Description

<!-- Please include a summary of the change. Please also include
relevant motivation and context. List any dependencies that are required
for this change. -->

Allows users without livekit backends setup to join existing calls again

#### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings

### AI disclosure:

- [ ] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [ ] Fully AI generated (explain what all the generated code does in
moderate detail).
<!-- Write any explanation required here, but do not generate the
explanation using AI!! You must prove you understand what the code in
this PR does. -->
This commit is contained in:
7w1 authored and GitHub committed 2026-07-16 22:37:10 -05:00
commit 7b60c45ec5
7 files changed
+26 -48

No files matched your search

@@ -0,0 +1,5 @@
---
default: patch
---
Allow users without a locally configured LiveKit focus to join calls started by others.
+5 -24
View File
@@ -3,13 +3,11 @@ import type { Room } from '$types/matrix-sdk';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { IncomingCallInternal } from './IncomingCallModal';
const { navigateRoomMock, sendRtcDeclineMock, webRtcSupportedMock, livekitSupportedMock } =
vi.hoisted(() => ({
navigateRoomMock: vi.fn<(roomId: string) => void>(),
sendRtcDeclineMock: vi.fn<(roomId: string, eventId: string) => Promise<void>>(),
webRtcSupportedMock: vi.fn<() => boolean>(),
livekitSupportedMock: vi.fn<() => boolean>(),
}));
const { navigateRoomMock, sendRtcDeclineMock, webRtcSupportedMock } = vi.hoisted(() => ({
navigateRoomMock: vi.fn<(roomId: string) => void>(),
sendRtcDeclineMock: vi.fn<(roomId: string, eventId: string) => Promise<void>>(),
webRtcSupportedMock: vi.fn<() => boolean>(),
}));
vi.mock('$hooks/useMatrixClient', () => ({
useMatrixClient: () => ({
@@ -19,10 +17,6 @@ vi.mock('$hooks/useMatrixClient', () => ({
}),
}));
vi.mock('$hooks/useLivekitSupport', () => ({
useLivekitSupport: () => livekitSupportedMock(),
}));
vi.mock('$hooks/useCallEmbed', () => ({
useCallEmbed: () => undefined,
}));
@@ -101,7 +95,6 @@ describe('IncomingCallInternal', () => {
navigateRoomMock.mockReset();
sendRtcDeclineMock.mockReset().mockResolvedValue(undefined);
webRtcSupportedMock.mockReset().mockReturnValue(true);
livekitSupportedMock.mockReset().mockReturnValue(true);
});
it('closes the modal when decline is pressed', async () => {
@@ -152,16 +145,4 @@ describe('IncomingCallInternal', () => {
});
expect(sendRtcDeclineMock).not.toHaveBeenCalled();
});
it('shows homeserver capability issues and blocks answer when LiveKit is unavailable', () => {
livekitSupportedMock.mockReturnValue(false);
const onClose = vi.fn<() => void>();
render(<IncomingCallInternal room={room} incomingCall={incomingCall} onClose={onClose} />);
expect(
screen.getByText(/homeserver does not expose a livekit call focus/i)
).toBeInTheDocument();
expect(screen.getByRole('button', { name: /answer voice call/i })).toBeDisabled();
expect(screen.getByText(/homeserver call focus is unavailable/i)).toBeInTheDocument();
});
});
+1 -4
View File
@@ -16,7 +16,6 @@ import {
import { useMemo, type KeyboardEvent as ReactKeyboardEvent } from 'react';
import type { Room } from '$types/matrix-sdk';
import { useMatrixClient } from '$hooks/useMatrixClient';
import { useLivekitSupport } from '$hooks/useLivekitSupport';
import { useRoomName } from '$hooks/useRoomMeta';
import { useCallEmbed } from '$hooks/useCallEmbed';
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
@@ -63,7 +62,6 @@ export function IncomingCallInternal({ room, incomingCall, onClose }: IncomingCa
const screenSize = useScreenSizeContext();
const compact = screenSize === ScreenSize.Mobile;
const roomName = useRoomName(room);
const livekitSupported = useLivekitSupport();
const callEmbed = useCallEmbed();
const { navigateRoom } = useRoomNavigate();
const roomAvatarUrl = getRoomAvatarUrl(mx, room, 96);
@@ -93,11 +91,10 @@ export function IncomingCallInternal({ room, incomingCall, onClose }: IncomingCa
() =>
getIncomingCallBlockers({
canUseWebRTC,
livekitSupported,
hasCallMemberPermission,
inAnotherCall,
}),
[canUseWebRTC, livekitSupported, hasCallMemberPermission, inAnotherCall]
[canUseWebRTC, hasCallMemberPermission, inAnotherCall]
);
const canAnswer = capabilityIssues.length === 0;
+4 -3
View File
@@ -12,6 +12,7 @@ import * as css from './styles.css';
import { CallMemberRenderer } from './CallMemberCard';
import { PrescreenControls } from './PrescreenControls';
import { callEmbedAtom, callEmbedStartErrorAtom } from '$state/callEmbed';
import { canJoinCall } from './callStartCapabilities';
function LivekitServerMissingMessage() {
return (
@@ -42,12 +43,12 @@ function JoinMessage({
return <WebRTCMissingError />;
}
if (hasParticipant) return null;
if (livekitSupported === false) {
return <LivekitServerMissingMessage />;
}
if (hasParticipant) return null;
return (
<Text style={{ margin: 'auto' }} size="L400" align="Center">
Voice chat&apos;s empty - be the first to hop in!
@@ -96,7 +97,7 @@ function CallPrescreen() {
? 'Call setup failed because required call capabilities were rejected.'
: 'Call setup failed while preparing the embedded call app.';
const canJoin = callStartCapabilities.canStart;
const canJoin = canJoinCall(callStartCapabilities, hasParticipant);
return (
<Scroll variant="Surface" hideTrack>
@@ -18,6 +18,16 @@ export type CallStartCapabilities = {
inAnotherCall: boolean;
};
export const canJoinCall = (
capabilities: CallStartCapabilities,
hasParticipant: boolean
): boolean =>
capabilities.canStart ||
(hasParticipant &&
capabilities.webRTCSupported &&
capabilities.hasCallMemberPermission &&
!capabilities.inAnotherCall);
type EvaluateCallStartCapabilitiesInput = {
room: Room;
myUserId: string;
@@ -6,7 +6,6 @@ describe('getIncomingCallBlockers', () => {
expect(
getIncomingCallBlockers({
canUseWebRTC: true,
livekitSupported: true,
hasCallMemberPermission: true,
inAnotherCall: false,
})
@@ -16,16 +15,10 @@ describe('getIncomingCallBlockers', () => {
it('returns blockers in priority order', () => {
const issues = getIncomingCallBlockers({
canUseWebRTC: false,
livekitSupported: false,
hasCallMemberPermission: false,
inAnotherCall: true,
});
expect(issues.map((issue) => issue.id)).toEqual([
'webrtc',
'livekit',
'permission',
'another_call',
]);
expect(issues.map((issue) => issue.id)).toEqual(['webrtc', 'permission', 'another_call']);
});
});
@@ -6,14 +6,12 @@ export type IncomingCallBlocker = {
export type IncomingCallBlockerInput = {
canUseWebRTC: boolean;
livekitSupported: boolean;
hasCallMemberPermission: boolean;
inAnotherCall: boolean;
};
export const getIncomingCallBlockers = ({
canUseWebRTC,
livekitSupported,
hasCallMemberPermission,
inAnotherCall,
}: IncomingCallBlockerInput): IncomingCallBlocker[] => {
@@ -26,13 +24,6 @@ export const getIncomingCallBlockers = ({
shortReason: 'WebRTC is unavailable in this browser.',
});
}
if (!livekitSupported) {
issues.push({
id: 'livekit',
message: 'Your homeserver does not expose a LiveKit call focus.',
shortReason: 'Homeserver call focus is unavailable.',
});
}
if (!hasCallMemberPermission) {
issues.push({
id: 'permission',