Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(calls): improve settings (#7035)

Eric Hayesf706d6528fd0
diff --git a/apps/web/src/features/channel/Call/CallContext.tsx b/apps/web/src/features/channel/Call/CallContext.tsx
index 86daab0a40..e22a04bc1e 100644
--- a/apps/web/src/features/channel/Call/CallContext.tsx
+++ b/apps/web/src/features/channel/Call/CallContext.tsx
@@ -1,6 +1,10 @@
import { analytics } from '@app/lib/analytics';
import { useChannelsContext } from '@core/context/channels';
import { useUserId } from '@core/context/user';
+import {
+ type BackgroundEffect,
+ backgroundProcessorOptions,
+} from '@core/media/background-effect';
import type { KrispNoiseFilter } from '@livekit/krisp-noise-filter';
import type { BackgroundProcessorWrapper } from '@livekit/track-processors';
import {
@@ -76,18 +80,11 @@ export type MediaDeviceInfo = {
kind: MediaDeviceKind;
};
-export type BlurIntensity = 'light' | 'medium' | 'heavy';
-
-export type BackgroundEffect =
- | { type: 'none' }
- | { type: 'blur'; intensity: BlurIntensity }
- | { type: 'image'; id: string; path: string };
-
-export const BLUR_RADIUS: Record<BlurIntensity, number> = {
- light: 5,
- medium: 10,
- heavy: 20,
-};
+export type {
+ BackgroundEffect,
+ BlurIntensity,
+} from '@core/media/background-effect';
+export { BLUR_RADIUS } from '@core/media/background-effect';
type ImageBackgroundEffect = Extract<BackgroundEffect, { type: 'image' }>;
@@ -757,13 +754,7 @@ function createCallState() {
const camTrack = camPub?.track as LocalTrack | undefined;
if (!isLiveLocalTrack(camTrack)) return true;
- const processorOptions =
- effect.type === 'blur'
- ? {
- mode: 'background-blur' as const,
- blurRadius: BLUR_RADIUS[effect.intensity],
- }
- : { mode: 'virtual-background' as const, imagePath: effect.path };
+ const processorOptions = backgroundProcessorOptions(effect);
try {
if (room() !== r || !isLiveLocalTrack(camTrack)) return true;
@@ -1132,7 +1123,9 @@ function createCallState() {
source === 'microphone'
? new livekit.LocalAudioTrack(
mediaStreamTrack,
- currentMicrophoneCaptureOptions() as MediaTrackConstraints,
+ currentMicrophoneCaptureOptions(
+ store.activeAudioInputDeviceId
+ ) as MediaTrackConstraints,
false
)
: new livekit.LocalVideoTrack(
@@ -1142,16 +1135,58 @@ function createCallState() {
);
track.source =
LK_TRACK_SOURCE[source === 'microphone' ? 'Microphone' : 'Camera'];
+ await publishPreparedTrack(targetRoom, track);
+ }
+
+ /** Attach the selected background before any camera frames are published. */
+ async function publishPreparedTrack(targetRoom: Room, track: LocalTrack) {
+ let processor:
+ | ReturnType<
+ typeof import('@livekit/track-processors').BackgroundProcessor
+ >
+ | undefined;
try {
+ if (
+ track.source === LK_TRACK_SOURCE.Camera &&
+ store.backgroundEffect.type !== 'none'
+ ) {
+ const { BackgroundProcessor, supportsBackgroundProcessors } =
+ await import('@livekit/track-processors');
+ if (!supportsBackgroundProcessors())
+ throw new Error('Background effects are unavailable');
+ processor = BackgroundProcessor(
+ backgroundProcessorOptions(store.backgroundEffect)
+ );
+ await track.setProcessor(processor);
+ }
+ if (room() !== targetRoom) {
+ track.stop();
+ return;
+ }
await targetRoom.localParticipant.publishTrack(track, {
source: track.source,
});
+ if (processor && room() === targetRoom) setBlurProcessor(processor);
} catch (error) {
track.stop();
throw error;
}
}
+ async function enableInitialCamera(targetRoom: Room) {
+ const deviceId = store.activeVideoInputDeviceId;
+ const capture = deviceId ? { deviceId: { exact: deviceId } } : undefined;
+ if (store.backgroundEffect.type === 'none') {
+ await targetRoom.localParticipant.setCameraEnabled(true, capture);
+ return;
+ }
+ const livekit = getLivekit();
+ if (!livekit) throw new Error('LiveKit is not loaded');
+ const track = await livekit.createLocalVideoTrack(capture);
+ track.source = LK_TRACK_SOURCE.Camera;
+ await publishPreparedTrack(targetRoom, track);
+ }
+
/** Reuse the prejoin track, falling back to device capture if it fails. */
async function enablePrejoinOrDevice(
targetRoom: Room,
@@ -1165,6 +1200,8 @@ function createCallState() {
return;
} catch (e) {
console.error(`failed to publish prejoin ${source} track`, e);
+ if (source === 'camera' && store.backgroundEffect.type !== 'none')
+ throw e;
}
}
prejoinTrack?.stop();
@@ -1209,7 +1246,7 @@ function createCallState() {
() =>
targetRoom.localParticipant.setMicrophoneEnabled(
true,
- currentMicrophoneCaptureOptions()
+ currentMicrophoneCaptureOptions(store.activeAudioInputDeviceId)
)
);
}
@@ -1237,13 +1274,11 @@ function createCallState() {
if (!store.isVideoMuted) {
try {
await enablePrejoinOrDevice(targetRoom, 'camera', claim('camera'), () =>
- targetRoom.localParticipant.setCameraEnabled(true)
+ enableInitialCamera(targetRoom)
);
if (!isCurrentMediaSetup(targetRoom, setupVersion)) return;
if (store.isVideoMuted) {
await targetRoom.localParticipant.setCameraEnabled(false);
- } else {
- await ensureBackgroundEffectOnCameraTrack(targetRoom, true);
}
} catch (error) {
console.error('failed to enable camera', error);
@@ -1317,6 +1352,25 @@ function createCallState() {
setInitialMediaState: (preferences) => {
setStore('isAudioMuted', preferences?.microphoneEnabled === false);
setStore('isVideoMuted', preferences?.cameraEnabled !== true);
+ if (preferences?.microphoneDeviceId !== undefined)
+ setStore(
+ 'activeAudioInputDeviceId',
+ preferences.microphoneDeviceId || null
+ );
+ if (preferences?.cameraDeviceId !== undefined)
+ setStore(
+ 'activeVideoInputDeviceId',
+ preferences.cameraDeviceId || null
+ );
+ if (preferences?.speakerDeviceId !== undefined)
+ setStore(
+ 'activeAudioOutputDeviceId',
+ preferences.speakerDeviceId || null
+ );
+ if (preferences?.backgroundEffect) {
+ setStore('backgroundEffect', preferences.backgroundEffect);
+ setPersistedBackgroundEffect(preferences.backgroundEffect);
+ }
},
setRemoteParticipants: (participants) => {
setStore('remoteParticipants', participants);
diff --git a/apps/web/src/features/channel/Call/CallControls/CallControlBar.tsx b/apps/web/src/features/channel/Call/CallControls/CallControlBar.tsx
new file mode 100644
index 0000000000..4544fa56bd
--- /dev/null
+++ b/apps/web/src/features/channel/Call/CallControls/CallControlBar.tsx
@@ -0,0 +1,334 @@
+import CaretUp from '@phosphor/caret-up.svg';
+import Image from '@phosphor/image.svg';
+import Microphone from '@phosphor/microphone.svg';
+import MicrophoneSlash from '@phosphor/microphone-slash.svg';
+import PhoneDisconnect from '@phosphor/phone-disconnect.svg';
+import Screencast from '@phosphor/screencast.svg';
+import VideoCamera from '@phosphor/video-camera.svg';
+import VideoCameraSlash from '@phosphor/video-camera-slash.svg';
+import { Button } from '@ui';
+import {
+ createSignal,
+ createUniqueId,
+ type JSX,
+ onCleanup,
+ onMount,
+ Show,
+} from 'solid-js';
+
+export function CallControlButton(props: {
+ label: string;
+ pressed?: boolean;
+ disabled?: boolean;
+ danger?: boolean;
+ onClick: () => void;
+ children: JSX.Element;
+}) {
+ return (
+ <Button
+ size="icon-lg"
+ variant={props.danger ? 'danger' : 'ghost'}
+ label={props.label}
+ tooltipPlacement="top"
+ aria-pressed={props.pressed}
+ disabled={props.disabled}
+ onClick={props.onClick}
+ class="size-12"
+ >
+ {props.children}
+ </Button>
+ );
+}
+
+type SettingsSection = 'audio' | 'video' | 'background';
+const settingsLabels: Record<SettingsSection, string> = {
+ audio: 'Audio settings',
+ video: 'Camera settings',
+ background: 'Background settings',
+};
+
+/** Settings grow upward without moving the controls or resizing participant tiles. */
+export function CallControlBar(props: {
+ disabled: boolean;
+ audioMuted: boolean;
+ videoMuted: boolean;
+ screenSharing: boolean;
+ onToggleAudio: () => void;
+ onToggleVideo: () => void;
+ onToggleScreen: () => void;
+ onLeave: () => void;
+ menuOpen: boolean;
+ audioSettings: JSX.Element;
+ videoSettings: JSX.Element;
+ backgroundActive: boolean;
+ backgroundDisabled: boolean;
+ onToggleBackground: () => void;
+ backgroundSettings: JSX.Element;
+ error?: string;
+}) {
+ const [section, setSection] = createSignal<SettingsSection>();
+ const [pinned, setPinned] = createSignal(false);
+ const [lastSection, setLastSection] = createSignal<SettingsSection>('audio');
+ const displayedSection = () => section() ?? lastSection();
+ const id = createUniqueId();
+ let root!: HTMLDivElement;
+ let timer: ReturnType<typeof setTimeout> | undefined;
+ let intentTimer: ReturnType<typeof setTimeout> | undefined;
+ const cancelIntent = () => clearTimeout(intentTimer);
+ const open = (next: SettingsSection) => {
+ cancelIntent();
+ setLastSection(next);
+ setSection(next);
+ };
+ const cancelClose = () => clearTimeout(timer);
+ const close = () => {
+ cancelIntent();
+ cancelClose();
+ setSection(undefined);
+ setPinned(false);
+ };
+ const scheduleClose = () => {
+ cancelIntent();
+ cancelClose();
+ timer = setTimeout(() => {
+ if (
+ !pinned() &&
+ !props.menuOpen &&
+ !root.contains(document.activeElement)
+ )
+ close();
+ }, 320);
+ };
+ const preview = (next: SettingsSection, event: PointerEvent) => {
+ cancelClose();
+ cancelIntent();
+ if (event.pointerType === 'mouse' && !pinned() && !props.menuOpen)
+ intentTimer = setTimeout(() => open(next), 140);
+ };
+ const toggle = (next: SettingsSection) => {
+ cancelIntent();
+ cancelClose();
+ if (section() === next && pinned()) close();
+ else {
+ open(next);
+ setPinned(true);
+ }
+ };
+ onMount(() => {
+ const dismiss = (event: PointerEvent) => {
+ if (
+ !props.menuOpen &&
+ event.target instanceof Node &&
+ !root.contains(event.target)
+ )
+ close();
+ };
+ document.addEventListener('pointerdown', dismiss);
+ onCleanup(() => document.removeEventListener('pointerdown', dismiss));
+ });
+ onCleanup(() => {
+ cancelClose();
+ cancelIntent();
+ });
+
+ function MediaGroup(group: {
+ kind: SettingsSection;
+ active: boolean;
+ label: string;
+ toggleLabel: string;
+ disabled?: boolean;
+ onToggle: () => void;
+ children: JSX.Element;
+ }) {
+ const expanded = () => section() === group.kind;
+ return (
+ <div
+ role="group"
+ aria-label={group.label}
+ class="flex items-center gap-0.5"
+ onPointerEnter={(event) => preview(group.kind, event)}
+ onPointerLeave={cancelIntent}
+ >
+ <CallControlButton
+ label={group.toggleLabel}
+ pressed={group.active}
+ disabled={props.disabled || group.disabled}
+ onClick={group.onToggle}
+ >
+ {group.children}
+ </CallControlButton>
+ <Button
+ size="icon-md"
+ tooltipDisabled
+ variant="plain"
+ aria-label={settingsLabels[group.kind]}
+ aria-expanded={expanded()}
+ aria-controls={expanded() ? id : undefined}
+ onClick={(event) => {
+ toggle(group.kind);
+ if (event.detail === 0 && section() === group.kind) {
+ root
+ .querySelector<HTMLButtonElement>(
+ '[data-settings-active="true"] button:not(:disabled)'
+ )
+ ?.focus();
+ }
+ }}
+ class="h-12 w-6 @sm:w-8"
+ >
+ <CaretUp
+ class="size-4 transition-transform duration-200 ease-out motion-reduce:transition-none"
+ classList={{ 'rotate-180': expanded() }}
+ />
+ </Button>
+ </div>
+ );
+ }
+
+ return (
+ <div
+ ref={root}
+ data-call-controls
+ class="@container relative z-20 w-full max-w-xl"
+ onPointerEnter={cancelClose}
+ onPointerLeave={scheduleClose}
+ onFocusOut={scheduleClose}
+ onKeyDown={(event) => {
+ if (event.key === 'Escape' && !props.menuOpen) {
+ const active = section();
+ if (!active) return;
+ event.preventDefault();
+ root
+ .querySelector<HTMLButtonElement>(
+ `button[aria-label="${settingsLabels[active]}"]`
+ )
+ ?.focus();
+ close();
+ }
+ }}
+ >
+ <div
+ id={id}
+ role="region"
+ aria-label={settingsLabels[displayedSection()]}
+ aria-hidden={!section()}
+ inert={!section()}
+ data-state={section() ? 'open' : 'closed'}
+ class="absolute inset-x-0 bottom-full pb-2 transition-[opacity,translate,visibility] duration-200 ease-out motion-reduce:transition-none"
+ classList={{
+ 'visible translate-y-0 opacity-100': !!section(),
+ 'invisible translate-y-2 opacity-0 pointer-events-none': !section(),
+ }}
+ onPointerEnter={() => {
+ cancelClose();
+ cancelIntent();
+ }}
+ >
+ <div class="rounded-xl border border-edge-muted bg-panel shadow-md">
+ <div
+ aria-hidden={displayedSection() !== 'audio'}
+ inert={displayedSection() !== 'audio'}
+ data-settings-active={displayedSection() === 'audio'}
+ class="grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none"
+ classList={{
+ 'grid-rows-[1fr] opacity-100': displayedSection() === 'audio',
+ 'grid-rows-[0fr] opacity-0': displayedSection() !== 'audio',
+ }}
+ >
+ <div class="min-h-0 overflow-hidden">
+ <div class="p-3">{props.audioSettings}</div>
+ </div>
+ </div>
+ <div
+ aria-hidden={displayedSection() !== 'video'}
+ inert={displayedSection() !== 'video'}
+ data-settings-active={displayedSection() === 'video'}
+ class="grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none"
+ classList={{
+ 'grid-rows-[1fr] opacity-100': displayedSection() === 'video',
+ 'grid-rows-[0fr] opacity-0': displayedSection() !== 'video',
+ }}
+ >
+ <div class="min-h-0 overflow-hidden">
+ <div class="p-3">{props.videoSettings}</div>
+ </div>
+ </div>
+ <div
+ aria-hidden={displayedSection() !== 'background'}
+ inert={displayedSection() !== 'background'}
+ data-settings-active={displayedSection() === 'background'}
+ class="grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none"
+ classList={{
+ 'grid-rows-[1fr] opacity-100':
+ displayedSection() === 'background',
+ 'grid-rows-[0fr] opacity-0': displayedSection() !== 'background',
+ }}
+ >
+ <div class="min-h-0 overflow-hidden">
+ <div class="p-3">{props.backgroundSettings}</div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="mx-auto flex w-fit max-w-full flex-wrap items-center justify-center gap-1 rounded-xl border border-edge-muted bg-panel p-1.5 shadow-sm @sm:gap-2">
+ <MediaGroup
+ kind="audio"
+ active={!props.audioMuted}
+ label="Microphone controls"
+ toggleLabel={
+ props.audioMuted ? 'Unmute microphone' : 'Mute microphone'
+ }
+ onToggle={props.onToggleAudio}
+ >
+ <Show when={props.audioMuted} fallback={<Microphone />}>
+ <MicrophoneSlash />
+ </Show>
+ </MediaGroup>
+ <MediaGroup
+ kind="video"
+ active={!props.videoMuted}
+ label="Camera controls"
+ toggleLabel={props.videoMuted ? 'Turn on camera' : 'Turn off camera'}
+ onToggle={props.onToggleVideo}
+ >
+ <Show when={props.videoMuted} fallback={<VideoCamera />}>
+ <VideoCameraSlash />
+ </Show>
+ </MediaGroup>
+ <MediaGroup
+ kind="background"
+ active={props.backgroundActive}
+ disabled={props.backgroundDisabled}
+ label="Background controls"
+ toggleLabel={
+ props.backgroundActive
+ ? 'Turn off background'
+ : 'Turn on background'
+ }
+ onToggle={props.onToggleBackground}
+ >
+ <Image />
+ </MediaGroup>
+ <CallControlButton
+ label={props.screenSharing ? 'Stop sharing screen' : 'Share screen'}
+ pressed={props.screenSharing}
+ disabled={props.disabled}
+ onClick={props.onToggleScreen}
+ >
+ <Screencast />
+ </CallControlButton>
+ <CallControlButton label="Leave call" danger onClick={props.onLeave}>
+ <PhoneDisconnect />
+ </CallControlButton>
+ </div>
+ <Show when={props.error}>
+ <p
+ role="alert"
+ class="absolute inset-x-0 top-full rounded-lg bg-panel p-2 text-center text-xs text-failure"
+ >
+ {props.error}
+ </p>
+ </Show>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/channel/Call/CallControls/CallControls.tsx b/apps/web/src/features/channel/Call/CallControls/CallControls.tsx
index ef638c1998..8f901c2ba2 100644
--- a/apps/web/src/features/channel/Call/CallControls/CallControls.tsx
+++ b/apps/web/src/features/channel/Call/CallControls/CallControls.tsx
@@ -27,7 +27,7 @@ export function CallControls(props: CallControlsProps) {
const nativeCall = useMaybeNativeCallState();
return (
- <Show when={() => readWhen(props.when) && !nativeCall?.snapshot()}>
+ <Show when={readWhen(props.when) && !nativeCall?.snapshot()}>
<Show
when={props.variant === 'panel-small'}
fallback={<CallControlsDefaultAndPanelRow onLeave={props.onLeave} />}
diff --git a/apps/web/src/features/channel/Call/CallControls/CallControlsDefaultAndPanelRow.tsx b/apps/web/src/features/channel/Call/CallControls/CallControlsDefaultAndPanelRow.tsx
index 824bf91a80..9697bc6324 100644
--- a/apps/web/src/features/channel/Call/CallControls/CallControlsDefaultAndPanelRow.tsx
+++ b/apps/web/src/features/channel/Call/CallControls/CallControlsDefaultAndPanelRow.tsx
@@ -1,290 +1,8 @@
-import { DropdownMenu } from '@kobalte/core/dropdown-menu';
-import Gear from '@phosphor/gear.svg';
-import Microphone from '@phosphor/microphone.svg';
-import MicrophoneSlash from '@phosphor/microphone-slash.svg';
-import PhoneDisconnect from '@phosphor/phone-disconnect.svg';
-import Screencast from '@phosphor/screencast.svg';
-import VideoCamera from '@phosphor/video-camera.svg';
-import VideoCameraSlash from '@phosphor/video-camera-slash.svg';
-import { Button, Dropdown, SingleSelectCheck, Tooltip } from '@ui';
-import { For, type JSX, Show } from 'solid-js';
-import { BACKGROUND_IMAGES, useCallContext } from '../CallContext';
-import { CallDeviceList } from '../CallDeviceList';
+import { useCallContext } from '../CallContext';
+import { CallMediaControls } from './CallMediaControls';
-export type CallControlsDefaultAndPanelRowProps = {
+export function CallControlsDefaultAndPanelRow(props: {
onLeave: () => void | Promise<void>;
-};
-
-// Mirrors @livekit/track-processors' supportsBackgroundProcessors() so this
-// menu can render without statically importing heavy processor bundles.
-function isBackgroundBlurSupported(): boolean {
- if (typeof window === 'undefined') return false;
- if (
- !('OffscreenCanvas' in window) ||
- !('VideoFrame' in window) ||
- !('createImageBitmap' in window)
- ) {
- return false;
- }
- try {
- if (!document.createElement('canvas').getContext('webgl2')) return false;
- } catch {
- return false;
- }
- const hasStreamProcessor =
- 'MediaStreamTrackProcessor' in window &&
- 'MediaStreamTrackGenerator' in window;
- const hasFallback =
- typeof HTMLCanvasElement !== 'undefined' &&
- 'captureStream' in HTMLCanvasElement.prototype;
- return hasStreamProcessor || hasFallback;
-}
-
-function BackgroundEffectSelector() {
- const callCtx = useCallContext();
-
- const currentEffectValue = () => {
- const effect = callCtx.backgroundEffect();
- if (effect.type === 'none') return 'none';
- if (effect.type === 'blur') return `blur-${effect.intensity}`;
- return `image-${effect.id}`;
- };
-
- const handleChange = (value: string) => {
- if (value === 'none') {
- callCtx.setBackgroundEffect({ type: 'none' });
- return;
- }
-
- if (value.startsWith('blur-')) {
- const intensity = value.replace('blur-', '') as
- | 'light'
- | 'medium'
- | 'heavy';
-
- callCtx.setBackgroundEffect({ type: 'blur', intensity });
- return;
- }
-
- if (value.startsWith('image-')) {
- const id = value.replace('image-', '');
- const bg = BACKGROUND_IMAGES.find((b) => b.id === id);
-
- if (!bg) return;
-
- callCtx.setBackgroundEffect({
- type: 'image',
- id: bg.id,
- path: bg.path,
- });
- }
- };
-
- return (
- <>
- <Dropdown.Group>
- <Dropdown.GroupLabel>Background</Dropdown.GroupLabel>
- <Dropdown.Item
- closeOnSelect={false}
- onSelect={() => handleChange('none')}
- >
- <span class="flex-1 truncate">None</span>
- <SingleSelectCheck active={currentEffectValue() === 'none'} />
- </Dropdown.Item>
- </Dropdown.Group>
- <Dropdown.Group>
- <Dropdown.GroupLabel>Blur</Dropdown.GroupLabel>
- <For each={['light', 'medium', 'heavy'] as const}>
- {(intensity) => {
- const value = `blur-${intensity}`;
- const label = intensity[0]!.toUpperCase() + intensity.slice(1);
- return (
- <Dropdown.Item
- closeOnSelect={false}
- onSelect={() => handleChange(value)}
- >
- <span class="flex-1 truncate">{label}</span>
- <SingleSelectCheck active={currentEffectValue() === value} />
- </Dropdown.Item>
- );
- }}
- </For>
- </Dropdown.Group>
- <Show when={BACKGROUND_IMAGES.length}>
- <Dropdown.Group>
- <Dropdown.GroupLabel>Image</Dropdown.GroupLabel>
- <For each={BACKGROUND_IMAGES}>
- {(bg) => {
- const value = `image-${bg.id}`;
- return (
- <Dropdown.Item
- closeOnSelect={false}
- onSelect={() => handleChange(value)}
- >
- <span class="flex-1 truncate">{bg.label}</span>
- <SingleSelectCheck active={currentEffectValue() === value} />
- </Dropdown.Item>
- );
- }}
- </For>
- </Dropdown.Group>
- </Show>
- </>
- );
-}
-
-function Cell(props: { children: JSX.Element }) {
- return <div class="flex items-center p-1">{props.children}</div>;
-}
-
-/**
- * Mic / camera / screen-share / settings / hang-up arranged as a single
- * rounded card with hairline dividers — matches the in-call sidebar panel
- * styling. Each cell holds a plain ghost `Button`, so the hover stays
- * contained inside the button rather than filling the cell to the dividers.
- */
-export function CallControlsDefaultAndPanelRow(
- props: CallControlsDefaultAndPanelRowProps
-) {
- const callCtx = useCallContext();
- const isConnecting = () => callCtx.isConnecting();
-
- async function handleLeave() {
- try {
- await props.onLeave();
- } catch (error) {
- console.error('Failed to leave call', error);
- }
- }
-
- return (
- <div class="inline-flex items-center overflow-hidden rounded-lg border border-ink-muted/[0.08] bg-ink-muted/[0.025] divide-x divide-ink-muted/[0.08]">
- <Cell>
- <Tooltip label="Toggle microphone" placement="top">
- <Button
- size="icon-sm"
- onClick={() => void callCtx.toggleAudio()}
- disabled={isConnecting()}
- aria-label={
- callCtx.isAudioMuted() ? 'Unmute microphone' : 'Mute microphone'
- }
- aria-pressed={!callCtx.isAudioMuted()}
- >
- <Show when={!callCtx.isAudioMuted()} fallback={<MicrophoneSlash />}>
- <Microphone />
- </Show>
- </Button>
- </Tooltip>
- </Cell>
-
- <Cell>
- <Tooltip label="Toggle video" placement="top">
- <Button
- size="icon-sm"
- onClick={() => void callCtx.toggleVideo()}
- disabled={isConnecting()}
- aria-label={
- callCtx.isVideoMuted() ? 'Turn on camera' : 'Turn off camera'
- }
- aria-pressed={!callCtx.isVideoMuted()}
- >
- <Show
- when={!callCtx.isVideoMuted()}
- fallback={<VideoCameraSlash />}
- >
- <VideoCamera />
- </Show>
- </Button>
- </Tooltip>
- </Cell>
-
- <Cell>
- <Tooltip label="Screen share" placement="top">
- <Button
- size="icon-sm"
- onClick={() => void callCtx.toggleScreenShare()}
- disabled={isConnecting()}
- aria-label={
- callCtx.isScreenSharing() ? 'Stop sharing screen' : 'Share screen'
- }
- aria-pressed={callCtx.isScreenSharing()}
- >
- <Screencast />
- </Button>
- </Tooltip>
- </Cell>
-
- <Cell>
- <Dropdown placement="top" gutter={6}>
- <Tooltip label="Settings" placement="top">
- <DropdownMenu.Trigger
- as={Button}
- size="icon-sm"
- disabled={isConnecting()}
- aria-label="Call settings"
- >
- <Gear />
- </DropdownMenu.Trigger>
- </Tooltip>
- <Dropdown.Content class="min-w-56">
- <Dropdown.Group>
- <CallDeviceList
- label="Microphone"
- devices={callCtx.audioInputDevices()}
- activeDeviceId={callCtx.activeAudioInputDeviceId()}
- onSelect={(id) => callCtx.switchAudioInput(id)}
- />
- </Dropdown.Group>
- <Show when={callCtx.audioOutputDevices().length > 0}>
- <Dropdown.Group>
- <CallDeviceList
- label="Speaker"
- devices={callCtx.audioOutputDevices()}
- activeDeviceId={callCtx.activeAudioOutputDeviceId()}
- onSelect={(id) => callCtx.switchAudioOutput(id)}
- />
- </Dropdown.Group>
- </Show>
- <Dropdown.Group>
- <CallDeviceList
- label="Camera"
- devices={callCtx.videoInputDevices()}
- activeDeviceId={callCtx.activeVideoInputDeviceId()}
- onSelect={(id) => callCtx.switchVideoInput(id)}
- />
- </Dropdown.Group>
- <Dropdown.Group>
- <Dropdown.GroupLabel>Audio processing</Dropdown.GroupLabel>
- <Dropdown.Item
- closeOnSelect={false}
- onSelect={() => void callCtx.toggleNoiseSuppression()}
- >
- <span class="flex-1 truncate">Noise suppression</span>
- <SingleSelectCheck
- active={callCtx.noiseSuppressionMode() !== 'off'}
- />
- </Dropdown.Item>
- </Dropdown.Group>
- <Show when={isBackgroundBlurSupported()}>
- <BackgroundEffectSelector />
- </Show>
- </Dropdown.Content>
- </Dropdown>
- </Cell>
-
- <Cell>
- <Tooltip label="Leave call" placement="top">
- <Button
- size="icon-sm"
- class="text-failure not-disabled:hover:text-failure not-disabled:hover:bg-failure/10"
- onClick={handleLeave}
- disabled={isConnecting()}
- aria-label="Leave call"
- >
- <PhoneDisconnect />
- </Button>
- </Tooltip>
- </Cell>
- </div>
- );
+}) {
+ return <CallMediaControls media={useCallContext()} onLeave={props.onLeave} />;
}
diff --git a/apps/web/src/features/channel/Call/CallControls/CallMediaControls.tsx b/apps/web/src/features/channel/Call/CallControls/CallMediaControls.tsx
new file mode 100644
index 0000000000..4105d90248
--- /dev/null
+++ b/apps/web/src/features/channel/Call/CallControls/CallMediaControls.tsx
@@ -0,0 +1,180 @@
+import { MediaBackgroundPicker } from '@core/component/media/media-background-picker';
+import { MediaDevicePicker } from '@core/component/media/media-device-picker';
+import type { BackgroundEffect } from '@core/media/background-effect';
+import { readBackgroundImage } from '@core/media/read-background-image';
+import Microphone from '@phosphor/microphone.svg';
+import SpeakerHigh from '@phosphor/speaker-high.svg';
+import VideoCamera from '@phosphor/video-camera.svg';
+import { InlineCheckbox } from '@ui';
+import { createSignal, onCleanup } from 'solid-js';
+import type { CallState } from '../CallContext';
+import { CallControlBar } from './CallControlBar';
+
+export type CallMediaControlsState = Pick<
+ CallState,
+ | 'isConnecting'
+ | 'isAudioMuted'
+ | 'isVideoMuted'
+ | 'isScreenSharing'
+ | 'toggleAudio'
+ | 'toggleVideo'
+ | 'toggleScreenShare'
+ | 'audioInputDevices'
+ | 'audioOutputDevices'
+ | 'videoInputDevices'
+ | 'activeAudioInputDeviceId'
+ | 'activeAudioOutputDeviceId'
+ | 'activeVideoInputDeviceId'
+ | 'switchAudioInput'
+ | 'switchAudioOutput'
+ | 'switchVideoInput'
+ | 'isNoiseSuppressed'
+ | 'toggleNoiseSuppression'
+ | 'backgroundEffect'
+ | 'setBackgroundEffect'
+>;
+
+export function CallMediaControls(props: {
+ media: CallMediaControlsState;
+ onLeave: () => void | Promise<void>;
+}) {
+ const call = props.media;
+ const [menuOpen, setMenuOpen] = createSignal(false);
+ const [applyingBackground, setApplyingBackground] = createSignal(false);
+ const [error, setError] = createSignal<string>();
+ let lastBackground: BackgroundEffect = { type: 'blur', intensity: 'heavy' };
+ let disposed = false;
+ onCleanup(() => {
+ disposed = true;
+ });
+
+ async function run(action: () => void | Promise<void>) {
+ setError(undefined);
+ try {
+ await action();
+ } catch (error) {
+ if (!disposed)
+ setError(
+ error instanceof Error
+ ? error.message
+ : 'Could not update call settings.'
+ );
+ }
+ }
+ async function applyBackground(effect: BackgroundEffect | File) {
+ if (applyingBackground()) return;
+ setApplyingBackground(true);
+ await run(async () => {
+ const next =
+ effect instanceof File
+ ? {
+ type: 'image' as const,
+ id: 'custom',
+ path: await readBackgroundImage(effect),
+ }
+ : effect;
+ if (!disposed) {
+ const current = call.backgroundEffect();
+ if (current.type !== 'none') lastBackground = current;
+ await call.setBackgroundEffect(next);
+ if (next.type !== 'none') lastBackground = next;
+ }
+ });
+ if (!disposed) setApplyingBackground(false);
+ }
+
+ return (
+ <CallControlBar
+ disabled={call.isConnecting()}
+ audioMuted={call.isAudioMuted()}
+ videoMuted={call.isVideoMuted()}
+ screenSharing={call.isScreenSharing()}
+ onToggleAudio={() => void run(call.toggleAudio)}
+ onToggleVideo={() => void run(call.toggleVideo)}
+ onToggleScreen={() => void run(call.toggleScreenShare)}
+ onLeave={() => void run(props.onLeave)}
+ menuOpen={menuOpen()}
+ error={error()}
+ audioSettings={
+ <div class="flex flex-col gap-3">
+ <div class="grid grid-cols-1 gap-2 @sm:grid-cols-2">
+ <MediaDevicePicker
+ label="Microphone"
+ icon={<Microphone class="size-4 shrink-0" />}
+ devices={call.audioInputDevices()}
+ selected={call.activeAudioInputDeviceId() ?? ''}
+ placement="top-start"
+ onOpenChange={setMenuOpen}
+ disabled={call.isConnecting()}
+ onSelect={(id) =>
+ void run(() => call.switchAudioInput(id || 'default'))
+ }
+ />
+ <MediaDevicePicker
+ label="Speaker"
+ icon={<SpeakerHigh class="size-4 shrink-0" />}
+ devices={call.audioOutputDevices()}
+ selected={call.activeAudioOutputDeviceId() ?? ''}
+ placement="top-end"
+ onOpenChange={setMenuOpen}
+ unsupported={!('setSinkId' in HTMLMediaElement.prototype)}
+ disabled={call.isConnecting()}
+ onSelect={(id) =>
+ void run(() => call.switchAudioOutput(id || 'default'))
+ }
+ />
+ </div>
+ <button
+ type="button"
+ role="checkbox"
+ aria-checked={call.isNoiseSuppressed()}
+ disabled={call.isConnecting()}
+ onClick={() => void run(call.toggleNoiseSuppression)}
+ class="flex min-h-8 items-center gap-2 self-start rounded-lg px-2 text-sm text-ink-muted hover:bg-hover focus-visible:outline-2 focus-visible:outline-accent disabled:opacity-50"
+ >
+ <InlineCheckbox checked={call.isNoiseSuppressed()} />
+ Noise suppression
+ </button>
+ </div>
+ }
+ videoSettings={
+ <MediaDevicePicker
+ label="Camera"
+ icon={<VideoCamera class="size-4 shrink-0" />}
+ devices={call.videoInputDevices()}
+ selected={call.activeVideoInputDeviceId() ?? ''}
+ placement="top-start"
+ onOpenChange={setMenuOpen}
+ disabled={call.isConnecting()}
+ onSelect={(id) =>
+ void run(() =>
+ call.switchVideoInput(
+ id || call.videoInputDevices()[0]?.deviceId || ''
+ )
+ )
+ }
+ />
+ }
+ backgroundActive={call.backgroundEffect().type !== 'none'}
+ backgroundDisabled={applyingBackground()}
+ onToggleBackground={() =>
+ void applyBackground(
+ call.backgroundEffect().type === 'none'
+ ? lastBackground
+ : { type: 'none' }
+ )
+ }
+ backgroundSettings={
+ <MediaBackgroundPicker
+ effect={call.backgroundEffect()}
+ placement="top-end"
+ onOpenChange={setMenuOpen}
+ disabled={call.isConnecting()}
+ uploading={applyingBackground()}
+ onSelect={(effect) => void applyBackground(effect)}
+ onUpload={(file) => void applyBackground(file)}
+ />
+ }
+ />
+ );
+}
diff --git a/apps/web/src/features/channel/Call/CallOverlay.tsx b/apps/web/src/features/channel/Call/CallOverlay.tsx
index 95213f3b93..9fbdcdc4e1 100644
--- a/apps/web/src/features/channel/Call/CallOverlay.tsx
+++ b/apps/web/src/features/channel/Call/CallOverlay.tsx
@@ -350,10 +350,8 @@ export function CallOverlay(props: {
</Show>
</div>
- {/* Controls bar — soup-notification vocabulary. Share toggle is an
- icon button (with optional inline label), active state = subtle
- accent tint. No chunky toggle switch. */}
- <div class="flex items-center py-2 relative justify-center">
+ {/* Settings expand over the tiles; sharing stays clear of the controls. */}
+ <div class="flex flex-col items-center gap-2 py-3 relative">
<Show
when={
callCtx.activeChannelId() !== null &&
@@ -376,7 +374,7 @@ export function CallOverlay(props: {
role="checkbox"
aria-checked={sharedWithTeam()}
class={cn(
- 'absolute left-0 inline-flex items-center gap-2 rounded-md h-7 px-2.5 text-xs select-none',
+ 'order-1 inline-flex items-center gap-2 rounded-md h-7 px-2.5 text-xs select-none',
'border border-ink-muted/[0.08] bg-ink-muted/[0.025]',
'text-ink-muted/70 hover:text-ink hover:bg-ink-muted/[0.06]',
sharedWithTeam() && 'text-ink',
diff --git a/apps/web/src/features/channel/Call/CallSessionController.ts b/apps/web/src/features/channel/Call/CallSessionController.ts
index a411175341..68341d6a32 100644
--- a/apps/web/src/features/channel/Call/CallSessionController.ts
+++ b/apps/web/src/features/channel/Call/CallSessionController.ts
@@ -1,3 +1,4 @@
+import type { BackgroundEffect } from '@core/media/background-effect';
import type { CallTokenResponse } from '@service-call/client';
import type { NativeCallState } from './native-call-state';
import {
@@ -32,6 +33,10 @@ export type CallSessionConnectMetadata = {
channelTitle?: string | null;
microphoneEnabled?: boolean;
cameraEnabled?: boolean;
+ microphoneDeviceId?: string;
+ cameraDeviceId?: string;
+ speakerDeviceId?: string;
+ backgroundEffect?: BackgroundEffect;
/** Session-owned tracks: reuse without prompting again, or stop if unused. */
localTracks?: CallPrejoinTracks;
/** Public meeting pages use the browser media controls on every platform. */
diff --git a/apps/web/src/features/channel/Call/InCallPanel/InCallPanelView.tsx b/apps/web/src/features/channel/Call/InCallPanel/InCallPanelView.tsx
index ecf4d5b191..3b0d18c6ef 100644
--- a/apps/web/src/features/channel/Call/InCallPanel/InCallPanelView.tsx
+++ b/apps/web/src/features/channel/Call/InCallPanel/InCallPanelView.tsx
@@ -145,7 +145,7 @@ export const InCallPanel: Component<InCallPanelProps> = (props) => {
<section
data-in-call-panel
aria-label="In call"
- class="relative isolate overflow-hidden rounded-lg border border-ink-muted/[0.08] bg-ink-muted/[0.025] divide-y divide-ink-muted/[0.08]"
+ class="relative isolate rounded-lg border border-ink-muted/[0.08] bg-ink-muted/[0.025] divide-y divide-ink-muted/[0.08]"
>
{/* Header — soup notification vocabulary: muted label, accent pulse,
share affordance is a single icon button (no chunky toggle switch).
diff --git a/apps/web/src/features/channel/Call/LivekitJsCallController.ts b/apps/web/src/features/channel/Call/LivekitJsCallController.ts
index 12ca41e154..bfe4772533 100644
--- a/apps/web/src/features/channel/Call/LivekitJsCallController.ts
+++ b/apps/web/src/features/channel/Call/LivekitJsCallController.ts
@@ -197,7 +197,18 @@ export function createLivekitJsCallController(
}
const targetRoom = new Room({
- audioCaptureDefaults: options.currentMicrophoneCaptureOptions(),
+ audioCaptureDefaults: {
+ ...options.currentMicrophoneCaptureOptions(),
+ ...(preferences?.microphoneDeviceId
+ ? { deviceId: { exact: preferences.microphoneDeviceId } }
+ : {}),
+ },
+ videoCaptureDefaults: preferences?.cameraDeviceId
+ ? { deviceId: { exact: preferences.cameraDeviceId } }
+ : undefined,
+ audioOutput: preferences?.speakerDeviceId
+ ? { deviceId: preferences.speakerDeviceId }
+ : undefined,
publishDefaults: {
// Noise-suppressed audio has a near-silent noise floor, which makes
// Opus DTX (on by default) misread quiet speech onsets as silence and
diff --git a/apps/web/src/features/channel/Call/tests/call-controls.test.tsx b/apps/web/src/features/channel/Call/tests/call-controls.test.tsx
new file mode 100644
index 0000000000..dfb8f2b9d4
--- /dev/null
+++ b/apps/web/src/features/channel/Call/tests/call-controls.test.tsx
@@ -0,0 +1,142 @@
+/** @vitest-environment jsdom */
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { createSignal, type JSX } from 'solid-js';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { CallControlBar } from '../CallControls/CallControlBar';
+
+vi.mock('@ui', async () => ({
+ ...(await import('../../../../components/ui/components/Button')),
+ Tooltip: (props: { children: JSX.Element }) => props.children,
+}));
+
+afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+});
+
+function setup() {
+ const [menuOpen, setMenuOpen] = createSignal(false);
+ const toggleAudio = vi.fn(),
+ leave = vi.fn(),
+ toggleBackground = vi.fn();
+ const { container } = render(() => (
+ <CallControlBar
+ disabled={false}
+ audioMuted={false}
+ videoMuted={false}
+ screenSharing={false}
+ menuOpen={menuOpen()}
+ onToggleAudio={toggleAudio}
+ onToggleVideo={() => {}}
+ onToggleScreen={() => {}}
+ onLeave={leave}
+ audioSettings={<button type="button">Microphone device</button>}
+ videoSettings={<button type="button">Camera device</button>}
+ backgroundActive={false}
+ backgroundDisabled={false}
+ onToggleBackground={toggleBackground}
+ backgroundSettings={<button type="button">Background picker</button>}
+ />
+ ));
+ const bar = container.querySelector('[data-call-controls]')!;
+ const hover = (element: Element) =>
+ fireEvent(
+ element,
+ Object.assign(new Event('pointerenter', { bubbles: false }), {
+ pointerType: 'mouse',
+ })
+ );
+ return { bar, hover, setMenuOpen, toggleAudio, toggleBackground, leave };
+}
+
+describe('call controls', () => {
+ it('previews settings on hover, keeps them while a device menu is open, and closes after leaving', () => {
+ vi.useFakeTimers();
+ const { bar, hover, setMenuOpen } = setup();
+ hover(screen.getByRole('group', { name: 'Microphone controls' }));
+ expect(screen.queryByRole('region')).toBeNull();
+ vi.advanceTimersByTime(150);
+ expect(screen.getByRole('region', { name: 'Audio settings' })).toBeTruthy();
+ setMenuOpen(true);
+ fireEvent.pointerLeave(bar);
+ vi.advanceTimersByTime(350);
+ expect(screen.getByRole('region')).toBeTruthy();
+ setMenuOpen(false);
+ fireEvent.pointerLeave(bar);
+ vi.advanceTimersByTime(350);
+ expect(screen.queryByRole('region')).toBeNull();
+ });
+
+ it('ignores a quick pass over a control and cancels a close when the pointer returns', () => {
+ vi.useFakeTimers();
+ const { bar, hover } = setup();
+ const group = screen.getByRole('group', { name: 'Microphone controls' });
+ hover(group);
+ vi.advanceTimersByTime(70);
+ fireEvent.pointerLeave(group);
+ vi.advanceTimersByTime(200);
+ expect(screen.queryByRole('region')).toBeNull();
+ hover(group);
+ vi.advanceTimersByTime(150);
+ fireEvent.pointerLeave(bar);
+ vi.advanceTimersByTime(200);
+ hover(bar);
+ vi.advanceTimersByTime(200);
+ expect(screen.getByRole('region')).toBeTruthy();
+ });
+
+ it('pins settings by click and dismisses on an outside pointer', () => {
+ vi.useFakeTimers();
+ const { bar } = setup();
+ fireEvent.click(screen.getByRole('button', { name: 'Audio settings' }));
+ fireEvent.pointerLeave(bar);
+ vi.advanceTimersByTime(350);
+ expect(screen.getByRole('region')).toBeTruthy();
+ fireEvent.pointerDown(document.body);
+ expect(screen.queryByRole('region')).toBeNull();
+ });
+
+ it('returns keyboard focus to the disclosure when Escape closes settings', () => {
+ setup();
+ const disclosure = screen.getByRole('button', { name: 'Camera settings' });
+ fireEvent.click(disclosure);
+ const device = screen.getByRole('button', { name: 'Camera device' });
+ expect(document.activeElement).toBe(device);
+ fireEvent.keyDown(device, { key: 'Escape' });
+ expect(screen.queryByRole('region')).toBeNull();
+ expect(document.activeElement).toBe(disclosure);
+ });
+
+ it('previews backgrounds with the shared hover delay and toggles the effect independently', () => {
+ vi.useFakeTimers();
+ const { hover, toggleBackground } = setup();
+ fireEvent.click(screen.getByRole('button', { name: 'Turn on background' }));
+ expect(toggleBackground).toHaveBeenCalledOnce();
+ expect(screen.queryByRole('region')).toBeNull();
+ hover(screen.getByRole('group', { name: 'Background controls' }));
+ vi.advanceTimersByTime(70);
+ expect(screen.queryByRole('region')).toBeNull();
+ vi.advanceTimersByTime(80);
+ expect(
+ screen.getByRole('region', { name: 'Background settings' })
+ ).toBeTruthy();
+ const disclosure = screen.getByRole('button', {
+ name: 'Background settings',
+ });
+ fireEvent.click(disclosure);
+ const picker = screen.getByRole('button', { name: 'Background picker' });
+ expect(document.activeElement).toBe(picker);
+ fireEvent.keyDown(picker, { key: 'Escape' });
+ expect(screen.queryByRole('region')).toBeNull();
+ expect(document.activeElement).toBe(disclosure);
+ });
+
+ it('keeps media actions independent from the settings disclosures', () => {
+ const { toggleAudio, leave } = setup();
+ fireEvent.click(screen.getByRole('button', { name: 'Mute microphone' }));
+ expect(toggleAudio).toHaveBeenCalledOnce();
+ expect(screen.queryByRole('region')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Leave call' }));
+ expect(leave).toHaveBeenCalledOnce();
+ });
+});
diff --git a/apps/web/src/features/channel/Call/tests/livekit-js-call-controller.test.ts b/apps/web/src/features/channel/Call/tests/livekit-js-call-controller.test.ts
index 2bfb669195..f48940c6ea 100644
--- a/apps/web/src/features/channel/Call/tests/livekit-js-call-controller.test.ts
+++ b/apps/web/src/features/channel/Call/tests/livekit-js-call-controller.test.ts
@@ -1,11 +1,15 @@
import type { CallTokenResponse } from '@service-call/client';
-import type { Room } from 'livekit-client';
+import type { Room, RoomOptions } from 'livekit-client';
import { beforeEach, describe, expect, it, vi } from 'vitest';
+const roomOptions = vi.fn();
const connectRoom = vi.fn<() => Promise<void>>();
vi.mock('livekit-client', () => ({
Room: class {
+ constructor(options: RoomOptions) {
+ roomOptions(options);
+ }
remoteParticipants = new Map();
on() {}
removeAllListeners() {}
@@ -38,6 +42,7 @@ function track() {
function setup(state?: { connectionState: string; room?: Room }) {
let room: Room | null = state?.room ?? null;
+ const setInitialMediaState = vi.fn();
const finishLocalMediaSetup = vi.fn(async () => undefined);
const controller = createLivekitJsCallController({
room: () => room,
@@ -60,14 +65,14 @@ function setup(state?: { connectionState: string; room?: Room }) {
setConnectionState: () => undefined,
setActiveCall: () => undefined,
setDuplicateConnectCallId: () => undefined,
- setInitialMediaState: () => undefined,
+ setInitialMediaState,
setRemoteParticipants: () => undefined,
clearOptimisticJoin: () => undefined,
bumpTrackVersion: () => undefined,
bumpSpeakerVersion: () => undefined,
setScreenSharing: () => undefined,
});
- return { controller, finishLocalMediaSetup };
+ return { controller, finishLocalMediaSetup, setInitialMediaState };
}
describe('livekit call controller prejoin tracks', () => {
@@ -76,6 +81,25 @@ describe('livekit call controller prejoin tracks', () => {
connectRoom.mockResolvedValue(undefined);
});
+ it('carries selected devices and background into the connected room', async () => {
+ const { controller, setInitialMediaState } = setup();
+ const preferences = {
+ microphoneDeviceId: 'mic-2',
+ cameraDeviceId: 'camera-2',
+ speakerDeviceId: 'speaker-2',
+ backgroundEffect: { type: 'blur' as const, intensity: 'medium' as const },
+ };
+ await controller.connect(token, preferences);
+ expect(roomOptions).toHaveBeenLastCalledWith(
+ expect.objectContaining({
+ audioCaptureDefaults: { deviceId: { exact: 'mic-2' } },
+ videoCaptureDefaults: { deviceId: { exact: 'camera-2' } },
+ audioOutput: { deviceId: 'speaker-2' },
+ })
+ );
+ expect(setInitialMediaState).toHaveBeenCalledWith(preferences);
+ });
+
it('hands prejoin tracks to media setup instead of stopping them', async () => {
const { controller, finishLocalMediaSetup } = setup();
const localTracks = { microphone: track(), camera: track() };
diff --git a/apps/web/src/features/meetings/browser/meeting-media.ts b/apps/web/src/features/meetings/browser/meeting-media.ts
new file mode 100644
index 0000000000..1640f8462a
--- /dev/null
+++ b/apps/web/src/features/meetings/browser/meeting-media.ts
@@ -0,0 +1,42 @@
+import { backgroundProcessorOptions } from '@core/media/background-effect';
+import type { MeetingMediaAccess } from '../primitives/meeting-media';
+
+/** Preview processors own a clone, so disposal never stops the join track. */
+export const browserMeetingMedia: MeetingMediaAccess = {
+ request: (constraints) => navigator.mediaDevices.getUserMedia(constraints),
+ enumerate: () => navigator.mediaDevices.enumerateDevices(),
+ onDeviceChange: (refresh) => {
+ navigator.mediaDevices?.addEventListener('devicechange', refresh);
+ return () =>
+ navigator.mediaDevices?.removeEventListener('devicechange', refresh);
+ },
+ canSelectSpeaker: () => 'setSinkId' in HTMLMediaElement.prototype,
+ processBackground: async (track, effect) => {
+ const [
+ { LocalVideoTrack },
+ { BackgroundProcessor, supportsBackgroundProcessors },
+ ] = await Promise.all([
+ import('livekit-client'),
+ import('@livekit/track-processors'),
+ ]);
+ if (!supportsBackgroundProcessors())
+ throw new Error('Background effects aren’t supported in this browser.');
+ const camera = new LocalVideoTrack(
+ track.clone(),
+ track.getConstraints(),
+ false
+ );
+ try {
+ await camera.setProcessor(
+ BackgroundProcessor(backgroundProcessorOptions(effect))
+ );
+ return {
+ stream: new MediaStream([camera.mediaStreamTrack]),
+ dispose: () => camera.stop(),
+ };
+ } catch (error) {
+ camera.stop();
+ throw error;
+ }
+ },
+};
diff --git a/apps/web/src/features/meetings/components/meeting-participants.test.tsx b/apps/web/src/features/meetings/components/meeting-participants.test.tsx
new file mode 100644
index 0000000000..b254dd5983
--- /dev/null
+++ b/apps/web/src/features/meetings/components/meeting-participants.test.tsx
@@ -0,0 +1,40 @@
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { afterEach, expect, it } from 'vitest';
+import {
+ MeetingParticipants,
+ type MeetingParticipantsState,
+} from './meeting-participants';
+
+afterEach(cleanup);
+
+it('updates connected names and distinguishes an empty room from a failed lookup', () => {
+ const [state, setState] = createSignal<MeetingParticipantsState>({
+ kind: 'loading',
+ });
+ render(() => <MeetingParticipants state={state()} />);
+ expect(screen.getByText('Checking who’s here…')).toBeTruthy();
+ expect(screen.queryByText('No one else is here yet')).toBeNull();
+ setState({
+ kind: 'ready',
+ participants: [
+ { displayName: 'Alex Rivera', avatarUrl: null },
+ { displayName: 'Sam Chen', avatarUrl: null },
+ ],
+ });
+ expect(screen.getByText('2 people in this call')).toBeTruthy();
+ expect(screen.getByText('Alex Rivera, Sam Chen')).toBeTruthy();
+ setState({
+ kind: 'ready',
+ participants: [{ displayName: 'Sam Chen', avatarUrl: null }],
+ });
+ expect(screen.getByText('1 person in this call')).toBeTruthy();
+ expect(screen.queryByText('Alex Rivera, Sam Chen')).toBeNull();
+ setState({ kind: 'ready', participants: [] });
+ expect(screen.getByText('No one else is here yet')).toBeTruthy();
+ setState({ kind: 'unavailable' });
+ expect(screen.queryByText('No one else is here yet')).toBeNull();
+ expect(
+ screen.getByText('Couldn’t load participants. You can still join.')
+ ).toBeTruthy();
+});
diff --git a/apps/web/src/features/meetings/components/meeting-participants.tsx b/apps/web/src/features/meetings/components/meeting-participants.tsx
new file mode 100644
index 0000000000..65edcb3ce1
--- /dev/null
+++ b/apps/web/src/features/meetings/components/meeting-participants.tsx
@@ -0,0 +1,78 @@
+import { Avatar, Tooltip } from '@ui';
+import { For, Match, Switch } from 'solid-js';
+
+export type MeetingParticipantsState =
+ | { kind: 'loading' }
+ | { kind: 'unavailable' }
+ | {
+ kind: 'ready';
+ participants: readonly {
+ displayName: string;
+ avatarUrl: string | null;
+ }[];
+ };
+
+/** A fixed-height preview keeps roster refreshes from moving the join controls. */
+export function MeetingParticipants(props: {
+ state: MeetingParticipantsState;
+}) {
+ const participants = () =>
+ props.state.kind === 'ready' ? props.state.participants : [];
+ const names = () =>
+ participants()
+ .map((person) => person.displayName)
+ .join(', ');
+ return (
+ <section
+ aria-label="People in this call"
+ class="flex h-16 min-w-0 items-center gap-3"
+ aria-live="polite"
+ >
+ <Switch>
+ <Match when={props.state.kind === 'loading'}>
+ <p class="text-sm text-ink-muted">Checking who’s here…</p>
+ </Match>
+ <Match when={props.state.kind === 'unavailable'}>
+ <p class="text-sm text-ink-muted">
+ Couldn’t load participants. You can still join.
+ </p>
+ </Match>
+ <Match when={participants().length === 0}>
+ <p class="text-sm text-ink-muted">No one else is here yet</p>
+ </Match>
+ <Match when={participants().length > 0}>
+ <div class="flex shrink-0 -space-x-2" aria-hidden="true">
+ <For each={participants().slice(0, 3)}>
+ {(person) => (
+ <Avatar
+ size="lg"
+ class="size-9 border-2 border-surface bg-accent-bg text-accent"
+ >
+ <Avatar.Image src={person.avatarUrl ?? ''} alt="" />
+ <Avatar.Fallback>
+ {person.displayName
+ .trim()
+ .split(/\s+/)
+ .slice(0, 2)
+ .map((word) => word[0])
+ .join('')
+ .toUpperCase()}
+ </Avatar.Fallback>
+ </Avatar>
+ )}
+ </For>
+ </div>
+ <div class="min-w-0">
+ <p class="text-sm font-medium">
+ {participants().length}{' '}
+ {participants().length === 1 ? 'person' : 'people'} in this call
+ </p>
+ <Tooltip label={names()}>
+ <p class="truncate text-sm text-ink-muted">{names()}</p>
+ </Tooltip>
+ </div>
+ </Match>
+ </Switch>
+ </section>
+ );
+}
diff --git a/apps/web/src/features/meetings/context/meeting-session.ts b/apps/web/src/features/meetings/context/meeting-session.ts
index 09ee8d6464..7c9547c4fe 100644
--- a/apps/web/src/features/meetings/context/meeting-session.ts
+++ b/apps/web/src/features/meetings/context/meeting-session.ts
@@ -1,3 +1,4 @@
+import type { BackgroundEffect } from '@core/media/background-effect';
import type { Accessor } from 'solid-js';
import type { MeetingSessionLifecycle } from './meeting-session-lifecycle';
@@ -20,6 +21,10 @@ export type MeetingLocalTracks = {
export type MeetingMediaPreferences = {
microphoneEnabled: boolean;
cameraEnabled: boolean;
+ microphoneDeviceId?: string;
+ cameraDeviceId?: string;
+ speakerDeviceId?: string;
+ backgroundEffect?: BackgroundEffect;
/** Owned by `connect` once passed; the session stops them on early exits. */
localTracks?: MeetingLocalTracks;
};
diff --git a/apps/web/src/features/meetings/meeting-route.tsx b/apps/web/src/features/meetings/meeting-route.tsx
index 82c0526a69..30eb1db4fa 100644
--- a/apps/web/src/features/meetings/meeting-route.tsx
+++ b/apps/web/src/features/meetings/meeting-route.tsx
@@ -3,6 +3,7 @@ import { CallOverlay } from '@channel/Call/CallOverlay';
import { getMeetingUrl } from '@channel/Call/call-link';
import { UserIcon } from '@core/component/UserIcon';
import { useAuthor, useIsAuthenticated, useUserId } from '@core/context/user';
+import { readBackgroundImage } from '@core/media/read-background-image';
import { useCallRecordQuery } from '@queries/call/call';
import {
leaveMeeting,
@@ -12,6 +13,7 @@ import {
} from '@queries/call/meetings';
import { useLocation, useNavigate, useSearchParams } from '@solidjs/router';
import { Show } from 'solid-js';
+import { browserMeetingMedia } from './browser/meeting-media';
import type { MeetingPageState } from './context/meeting-session';
import { useMeetingSessionLifecycle } from './context/meeting-session-lifecycle';
import { MeetingPage } from './views/meeting-page';
@@ -64,10 +66,9 @@ export function MeetingRouteContent(props: {
source={source}
onCallStateChange={props.onCallStateChange}
onLeave={props.onLeave}
- mediaAccess={{
- request: (constraints) =>
- navigator.mediaDevices.getUserMedia(constraints),
- }}
+ mediaAccess={browserMeetingMedia}
+ initialBackground={call.backgroundEffect()}
+ readBackgroundImage={readBackgroundImage}
authenticated={authenticated}
author={author}
avatar={
diff --git a/apps/web/src/features/meetings/new-meeting-route.tsx b/apps/web/src/features/meetings/new-meeting-route.tsx
index c9d447464a..2a4b050be4 100644
--- a/apps/web/src/features/meetings/new-meeting-route.tsx
+++ b/apps/web/src/features/meetings/new-meeting-route.tsx
@@ -3,6 +3,7 @@ import { CallOverlay } from '@channel/Call/CallOverlay';
import { getMeetingUrl } from '@channel/Call/call-link';
import { UserIcon } from '@core/component/UserIcon';
import { useAuthor, useIsAuthenticated, useUserId } from '@core/context/user';
+import { readBackgroundImage } from '@core/media/read-background-image';
import { idToDisplayName } from '@core/user/util';
import { useCallRecordQuery } from '@queries/call/call';
import {
@@ -16,6 +17,7 @@ import {
import { useNavigate } from '@solidjs/router';
import { Button } from '@ui';
import { Show, Suspense } from 'solid-js';
+import { browserMeetingMedia } from './browser/meeting-media';
import type { MeetingPageState } from './context/meeting-session';
import { useMeetingSessionLifecycle } from './context/meeting-session-lifecycle';
import { createNewMeeting } from './primitives/new-meeting';
@@ -82,10 +84,9 @@ function NewMeetingSetup(props: {
showTooltip={false}
/>
}
- mediaAccess={{
- request: (constraints) =>
- navigator.mediaDevices.getUserMedia(constraints),
- }}
+ mediaAccess={browserMeetingMedia}
+ initialBackground={call.backgroundEffect()}
+ readBackgroundImage={readBackgroundImage}
startCall
url={url()}
onCopy={async () => {
diff --git a/apps/web/src/features/meetings/primitives/meeting-media.test.ts b/apps/web/src/features/meetings/primitives/meeting-media.test.ts
index 1ac7bbb0ce..e0632a9787 100644
--- a/apps/web/src/features/meetings/primitives/meeting-media.test.ts
+++ b/apps/web/src/features/meetings/primitives/meeting-media.test.ts
@@ -142,3 +142,149 @@ describe('prejoin media', () => {
}
);
});
+
+describe('prejoin device and background settings', () => {
+ beforeEach(stubMediaStream);
+
+ it('selects devices without opening disabled inputs and captures the selected device when enabled', async () => {
+ const { request, tracks } = fakeMediaAccess();
+ const { media, dispose } = setup(request);
+ try {
+ await media.prepare();
+ media.selectDevice('camera', 'camera-2');
+ media.selectDevice('speaker', 'speaker-2');
+ expect(request).toHaveBeenCalledTimes(1);
+ media.setCameraEnabled(true);
+ await vi.waitFor(() => expect(media.video()).toBeDefined());
+ expect(request).toHaveBeenLastCalledWith({
+ audio: false,
+ video: expect.objectContaining({ deviceId: { exact: 'camera-2' } }),
+ });
+ media.selectDevice('microphone', 'mic-2');
+ await vi.waitFor(() => expect(media.pending()).toBe(false));
+ expect(tracks[0].stop).toHaveBeenCalledOnce();
+ expect(request).toHaveBeenLastCalledWith({
+ audio: { deviceId: { exact: 'mic-2' } },
+ video: false,
+ });
+ expect(media.selectedDevices().speaker).toBe('speaker-2');
+ } finally {
+ dispose();
+ }
+ });
+
+ it('keeps the selected camera when retrying unsupported resolution constraints', async () => {
+ const camera = fakeTrack('video');
+ const request = vi
+ .fn()
+ .mockRejectedValueOnce(
+ new DOMException('Resolution', 'OverconstrainedError')
+ )
+ .mockResolvedValueOnce(withTracks(camera));
+ const { media, dispose } = setup(request);
+ try {
+ media.selectDevice('camera', 'camera-2');
+ media.setCameraEnabled(true);
+ await vi.waitFor(() => expect(media.video()).toBeDefined());
+ expect(request).toHaveBeenLastCalledWith({
+ audio: false,
+ video: { deviceId: { exact: 'camera-2' } },
+ });
+ } finally {
+ dispose();
+ }
+ });
+
+ it('disposes the processed preview while handing off the live raw camera and retaining the effect', async () => {
+ const { request, tracks } = fakeMediaAccess();
+ const previewTrack = fakeTrack('video');
+ const stream = withTracks(previewTrack);
+ const stopPreview = vi.fn();
+ const processBackground = vi.fn(async () => ({
+ stream,
+ dispose: stopPreview,
+ }));
+ const { media, dispose } = createRoot((dispose) => ({
+ media: createMeetingMedia({ request, processBackground }),
+ dispose,
+ }));
+ try {
+ media.setBackgroundEffect({ type: 'blur', intensity: 'medium' });
+ media.setCameraEnabled(true);
+ await vi.waitFor(() => expect(media.video()).toBe(stream));
+ const camera = tracks[0];
+ expect(processBackground).toHaveBeenCalledWith(camera, {
+ type: 'blur',
+ intensity: 'medium',
+ });
+ expect(media.handoff()).toEqual({ camera });
+ expect(stopPreview).toHaveBeenCalledOnce();
+ expect(camera.stop).not.toHaveBeenCalled();
+ expect(media.backgroundEffect()).toEqual({
+ type: 'blur',
+ intensity: 'medium',
+ });
+ } finally {
+ dispose();
+ }
+ });
+
+ it('never exposes raw video when a requested background fails', async () => {
+ const { request, tracks } = fakeMediaAccess();
+ const { media, dispose } = createRoot((dispose) => ({
+ media: createMeetingMedia({
+ request,
+ processBackground: async () => {
+ throw new Error('unsupported');
+ },
+ }),
+ dispose,
+ }));
+ try {
+ media.setBackgroundEffect({ type: 'blur', intensity: 'light' });
+ media.setCameraEnabled(true);
+ await vi.waitFor(() => expect(media.backgroundError()).toBeDefined());
+ expect(media.video()).toBeUndefined();
+ expect(media.cameraEnabled()).toBe(false);
+ expect(media.pending()).toBe(false);
+ expect(tracks[0].stop).toHaveBeenCalledOnce();
+ expect(media.handoff()).toBeUndefined();
+ media.setBackgroundEffect({ type: 'none' });
+ media.setCameraEnabled(true);
+ await vi.waitFor(() => expect(media.video()).toBeDefined());
+ expect(media.backgroundError()).toBeUndefined();
+ } finally {
+ dispose();
+ }
+ });
+
+ it('discards an effect that finishes after the camera was turned off', async () => {
+ const { request } = fakeMediaAccess();
+ const stopPreview = vi.fn();
+ let resolve!: (value: { stream: MediaStream; dispose: () => void }) => void;
+ const processBackground = vi.fn(
+ () =>
+ new Promise<{ stream: MediaStream; dispose: () => void }>((done) => {
+ resolve = done;
+ })
+ );
+ const { media, dispose } = createRoot((dispose) => ({
+ media: createMeetingMedia({ request, processBackground }),
+ dispose,
+ }));
+ try {
+ media.setBackgroundEffect({ type: 'blur', intensity: 'heavy' });
+ media.setCameraEnabled(true);
+ await vi.waitFor(() => expect(processBackground).toHaveBeenCalledOnce());
+ expect(media.video()).toBeUndefined();
+ expect(media.pending()).toBe(true);
+ media.setCameraEnabled(false);
+ resolve({ stream: withTracks(fakeTrack('video')), dispose: stopPreview });
+ await vi.waitFor(() => expect(stopPreview).toHaveBeenCalledOnce());
+ expect(media.video()).toBeUndefined();
+ expect(media.pending()).toBe(false);
+ } finally {
+ dispose();
+ }
+ });
+});
diff --git a/apps/web/src/features/meetings/primitives/meeting-media.ts b/apps/web/src/features/meetings/primitives/meeting-media.ts
index 58c194b9b9..981eb1f416 100644
--- a/apps/web/src/features/meetings/primitives/meeting-media.ts
+++ b/apps/web/src/features/meetings/primitives/meeting-media.ts
@@ -1,8 +1,19 @@
+import type { BackgroundEffect } from '@core/media/background-effect';
import { createSignal, onCleanup } from 'solid-js';
import type { MeetingLocalTracks } from '../context/meeting-session';
export type MeetingMediaAccess = {
request: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
+ enumerate?: () => Promise<MediaDeviceInfo[]>;
+ onDeviceChange?: (refresh: () => void) => () => void;
+ canSelectSpeaker?: () => boolean;
+ processBackground?: (
+ track: MediaStreamTrack,
+ effect: BackgroundEffect
+ ) => Promise<{
+ stream: MediaStream;
+ dispose: () => void;
+ }>;
};
// Match LiveKit's capture quality when publishing preview tracks.
@@ -47,7 +58,10 @@ function mediaErrorMessage(device: 'microphone' | 'camera', error: unknown) {
}
/** Hand preview tracks to the call without reopening devices; release all others. */
-export function createMeetingMedia(access?: MeetingMediaAccess) {
+export function createMeetingMedia(
+ access?: MeetingMediaAccess,
+ initialBackground: BackgroundEffect = { type: 'none' }
+) {
type Device = 'microphone' | 'camera';
const devices: Device[] = ['microphone', 'camera'];
const [microphoneEnabled, setMicrophone] = createSignal(true);
@@ -58,6 +72,27 @@ export function createMeetingMedia(access?: MeetingMediaAccess) {
camera: false,
});
const [errors, setErrors] = createSignal<Partial<Record<Device, string>>>({});
+ const [availableDevices, setAvailableDevices] = createSignal<
+ MediaDeviceInfo[]
+ >([]);
+ const [selectedDevices, setSelectedDevices] = createSignal({
+ microphone: '',
+ camera: '',
+ speaker: '',
+ });
+ const [deviceError, setDeviceError] = createSignal<string>();
+ const [backgroundEffect, setBackground] = createSignal<BackgroundEffect>(
+ initialBackground.type === 'blur' &&
+ initialBackground.intensity === 'medium'
+ ? { type: 'blur', intensity: 'heavy' }
+ : initialBackground
+ );
+ const [backgroundPending, setBackgroundPending] = createSignal(false);
+ const [backgroundError, setBackgroundError] = createSignal<string>();
+ let preview: { dispose: () => void } | undefined;
+ let previewGeneration = 0;
+ let enumerationGeneration = 0;
+ let watchingDevices: (() => void) | undefined;
const streams: Partial<Record<Device, MediaStream>> = {};
const generations = { microphone: 0, camera: 0 };
let disposed = false;
@@ -72,23 +107,119 @@ export function createMeetingMedia(access?: MeetingMediaAccess) {
generations[device]++;
streams[device]?.getTracks().forEach((track) => track.stop());
delete streams[device];
- if (device === 'camera') setVideo(undefined);
+ if (device === 'camera') {
+ previewGeneration++;
+ preview?.dispose();
+ preview = undefined;
+ setVideo(undefined);
+ setBackgroundPending(false);
+ }
setDevicePending(device, false);
};
+ async function refreshDevices() {
+ if (!access?.enumerate || disposed) return;
+ const generation = ++enumerationGeneration;
+ try {
+ const devices = await access.enumerate();
+ if (disposed || generation !== enumerationGeneration) return;
+ setAvailableDevices(devices);
+ setDeviceError(undefined);
+ } catch {
+ if (!disposed && generation === enumerationGeneration)
+ setDeviceError(
+ 'Could not list your devices. Check browser permissions and try again.'
+ );
+ }
+ }
+ async function updatePreview() {
+ const generation = ++previewGeneration;
+ preview?.dispose();
+ preview = undefined;
+ setBackgroundError(undefined);
+ setBackgroundPending(false);
+ const stream = streams.camera;
+ const track = stream?.getVideoTracks()[0];
+ if (!track || !cameraEnabled()) {
+ setVideo(undefined);
+ return;
+ }
+ const effect = backgroundEffect();
+ if (effect.type === 'none') {
+ setVideo(stream);
+ return;
+ }
+ setVideo(undefined);
+ setBackgroundPending(true);
+ try {
+ if (!access?.processBackground)
+ throw new Error('Background effects are unavailable.');
+ const processed = await access.processBackground(track, effect);
+ if (disposed || generation !== previewGeneration) {
+ processed.dispose();
+ return;
+ }
+ preview = processed;
+ setVideo(processed.stream);
+ } catch (error) {
+ if (disposed || generation !== previewGeneration) return;
+ console.warn('[meeting] background preview failed', error);
+ setBackgroundError(
+ 'Couldn’t apply the background. Your camera is off. Choose another background or None, then turn the camera on to retry.'
+ );
+ setCamera(false);
+ stop('camera');
+ } finally {
+ if (!disposed && generation === previewGeneration)
+ setBackgroundPending(false);
+ }
+ }
const accept = (device: Device, stream: MediaStream) => {
streams[device] = stream;
- if (device === 'camera') setVideo(stream);
+ const track = stream.getTracks()[0];
+ const deviceId = track?.getSettings?.().deviceId;
+ if (deviceId)
+ setSelectedDevices((current) => ({ ...current, [device]: deviceId }));
+ track?.addEventListener?.('ended', () => {
+ if (streams[device] !== stream) return;
+ setEnabled(device, false);
+ stop(device);
+ setErrors((current) => ({
+ ...current,
+ [device]: `${device === 'camera' ? 'Camera' : 'Microphone'} disconnected. Select a device and turn it on to retry.`,
+ }));
+ void refreshDevices();
+ });
+ if (device === 'camera') void updatePreview();
+ };
+ const captureConstraints = (device: Device) => {
+ const deviceId = selectedDevices()[device];
+ const selection = deviceId ? { deviceId: { exact: deviceId } } : {};
+ return device === 'camera'
+ ? { ...CAMERA_CONSTRAINTS, ...selection }
+ : deviceId
+ ? selection
+ : true;
};
/** A camera that can't meet the preferred capture falls back to any mode. */
async function open(device: Device) {
if (!access) throw new Error('Media access is unavailable');
if (device === 'microphone')
- return access.request({ audio: true, video: false });
+ return access.request({
+ audio: captureConstraints(device),
+ video: false,
+ });
try {
- return await access.request({ audio: false, video: CAMERA_CONSTRAINTS });
+ return await access.request({
+ audio: false,
+ video: captureConstraints(device),
+ });
} catch (error) {
if (errorName(error) !== 'OverconstrainedError') throw error;
- return access.request({ audio: false, video: true });
+ const deviceId = selectedDevices().camera;
+ return access.request({
+ audio: false,
+ video: deviceId ? { deviceId: { exact: deviceId } } : true,
+ });
}
}
async function request(device: Device) {
@@ -104,6 +235,7 @@ export function createMeetingMedia(access?: MeetingMediaAccess) {
return;
}
accept(device, stream);
+ void refreshDevices();
} catch (error) {
if (disposed || generations[device] !== generation) return;
console.warn(`[meeting] ${device} request failed`, error);
@@ -131,7 +263,10 @@ export function createMeetingMedia(access?: MeetingMediaAccess) {
setErrors({});
let stream: MediaStream;
try {
- stream = await access.request({ audio: true, video: CAMERA_CONSTRAINTS });
+ stream = await access.request({
+ audio: captureConstraints('microphone'),
+ video: captureConstraints('camera'),
+ });
} catch {
return devices.filter(isCurrent);
} finally {
@@ -162,6 +297,9 @@ export function createMeetingMedia(access?: MeetingMediaAccess) {
};
const release = () => {
preparation++;
+ enumerationGeneration++;
+ watchingDevices?.();
+ watchingDevices = undefined;
devices.forEach(stop);
};
onCleanup(() => {
@@ -172,17 +310,39 @@ export function createMeetingMedia(access?: MeetingMediaAccess) {
microphoneEnabled,
cameraEnabled,
video,
- pending: () => pending().microphone || pending().camera,
+ backgroundEffect,
+ backgroundPending,
+ backgroundError,
+ setBackgroundEffect: (effect: BackgroundEffect) => {
+ setBackground(effect);
+ void updatePreview();
+ },
+ availableDevices,
+ selectedDevices,
+ deviceError,
+ canSelectSpeaker: () => access?.canSelectSpeaker?.() ?? false,
+ refreshDevices,
+ selectDevice: (device: Device | 'speaker', deviceId: string) => {
+ setSelectedDevices((current) => ({ ...current, [device]: deviceId }));
+ if (device !== 'speaker' && enabled(device)) void request(device);
+ },
+ cameraError: () => errors().camera,
+ microphoneError: () => errors().microphone,
+ pending: () =>
+ pending().microphone || pending().camera || backgroundPending(),
errors: () =>
Object.values(errors()).filter((message): message is string =>
Boolean(message)
),
prepare: async () => {
const current = ++preparation;
+ watchingDevices ??= access?.onDeviceChange?.(() => void refreshDevices());
+ void refreshDevices();
for (const device of await requestTogether(current)) {
if (disposed || current !== preparation) return;
await request(device);
}
+ if (!disposed && current === preparation) void refreshDevices();
},
setMicrophoneEnabled: (value: boolean) => toggle('microphone', value),
setCameraEnabled: (value: boolean) => toggle('camera', value),
diff --git a/apps/web/src/features/meetings/views/meeting-media-setup.tsx b/apps/web/src/features/meetings/views/meeting-media-setup.tsx
new file mode 100644
index 0000000000..29cfdca6af
--- /dev/null
+++ b/apps/web/src/features/meetings/views/meeting-media-setup.tsx
@@ -0,0 +1,250 @@
+import { MediaBackgroundPicker } from '@core/component/media/media-background-picker';
+import { MediaDevicePicker } from '@core/component/media/media-device-picker';
+import type { BackgroundEffect } from '@core/media/background-effect';
+import Image from '@phosphor/image.svg';
+import Microphone from '@phosphor/microphone.svg';
+import MicrophoneSlash from '@phosphor/microphone-slash.svg';
+import Speaker from '@phosphor/speaker-high.svg';
+import VideoCamera from '@phosphor/video-camera.svg';
+import VideoCameraSlash from '@phosphor/video-camera-slash.svg';
+import Warning from '@phosphor/warning-circle.svg';
+import { Button } from '@ui';
+import {
+ children,
+ createEffect,
+ createSignal,
+ For,
+ type JSX,
+ onCleanup,
+ Show,
+} from 'solid-js';
+import type { createMeetingMedia } from '../primitives/meeting-media';
+
+export function MeetingMediaSetup(props: {
+ media: ReturnType<typeof createMeetingMedia>;
+ name: string;
+ avatar?: JSX.Element;
+ disabled?: boolean;
+ readBackgroundImage?: (file: File) => Promise<string>;
+ onUploading: (uploading: boolean) => void;
+}) {
+ const media = props.media;
+ const avatar = children(() => props.avatar);
+ const [uploading, setUploading] = createSignal(false);
+ const [uploadError, setUploadError] = createSignal<string>();
+ let lastBackground: BackgroundEffect = { type: 'blur', intensity: 'heavy' };
+ let disposed = false;
+ onCleanup(() => {
+ disposed = true;
+ });
+ let video: HTMLVideoElement | undefined;
+ createEffect(() => {
+ if (video) video.srcObject = media.video() ?? null;
+ });
+ const selectBackground = (effect: BackgroundEffect) => {
+ setUploadError(undefined);
+ const current = media.backgroundEffect();
+ if (current.type !== 'none') lastBackground = current;
+ if (effect.type !== 'none') lastBackground = effect;
+ media.setBackgroundEffect(effect);
+ };
+ async function upload(file: File) {
+ if (!props.readBackgroundImage) return;
+ setUploading(true);
+ props.onUploading(true);
+ setUploadError(undefined);
+ try {
+ const path = await props.readBackgroundImage(file);
+ if (!disposed) selectBackground({ type: 'image', id: 'custom', path });
+ } catch (error) {
+ if (!disposed)
+ setUploadError(
+ error instanceof Error ? error.message : 'Could not read this image.'
+ );
+ } finally {
+ if (!disposed) {
+ setUploading(false);
+ props.onUploading(false);
+ }
+ }
+ }
+ const previewError = () => media.backgroundError() || media.cameraError();
+ return (
+ <section aria-label="Audio and video setup" class="min-w-0">
+ <div class="relative aspect-video overflow-hidden rounded-2xl bg-panel text-ink light-mode:bg-ink light-mode:text-page">
+ <video
+ ref={video}
+ autoplay
+ muted
+ playsinline
+ aria-label="Camera preview"
+ class="absolute inset-0 h-full w-full object-cover -scale-x-100"
+ classList={{ hidden: !media.video() }}
+ />
+ <span
+ class="absolute top-4 left-5 z-10 max-w-[calc(100%-2.5rem)] truncate text-sm font-medium"
+ title={props.name}
+ >
+ {props.name || 'You'}
+ </span>
+ <Show when={!media.video()}>
+ <div class="absolute inset-x-5 top-10 bottom-20 flex flex-col items-center justify-center gap-3 text-center">
+ <Show
+ when={!previewError()}
+ fallback={
+ <>
+ <Warning class="size-7 shrink-0 text-warning" />
+ <p role="alert" class="max-w-sm text-sm">
+ {media.backgroundError()
+ ? 'Background unavailable'
+ : 'Camera unavailable'}
+ </p>
+ </>
+ }
+ >
+ <Show
+ when={!media.backgroundPending()}
+ fallback={
+ <p role="status" class="text-sm">
+ Applying background…
+ </p>
+ }
+ >
+ <div class="flex size-16 items-center justify-center overflow-hidden rounded-full bg-accent/20 text-2xl font-medium text-accent sm:size-20">
+ <Show
+ when={avatar()}
+ fallback={props.name.charAt(0).toUpperCase() || 'Y'}
+ >
+ {avatar()}
+ </Show>
+ </div>
+ <p class="text-sm">Camera is off</p>
+ </Show>
+ </Show>
+ </div>
+ </Show>
+ <div class="absolute inset-x-0 bottom-4 flex justify-center">
+ <div class="flex items-center gap-1 rounded-xl border border-edge-muted bg-panel p-1 shadow-sm">
+ <Button
+ size="icon-lg"
+ class="size-12"
+ label={
+ media.microphoneEnabled()
+ ? 'Turn off microphone'
+ : 'Turn on microphone'
+ }
+ tooltipPlacement="top"
+ disabled={props.disabled}
+ aria-pressed={media.microphoneEnabled()}
+ onClick={() =>
+ media.setMicrophoneEnabled(!media.microphoneEnabled())
+ }
+ >
+ <Show
+ when={media.microphoneEnabled()}
+ fallback={<MicrophoneSlash />}
+ >
+ <Microphone />
+ </Show>
+ </Button>
+ <Button
+ size="icon-lg"
+ class="size-12"
+ label={
+ media.cameraEnabled() ? 'Turn off camera' : 'Turn on camera'
+ }
+ tooltipPlacement="top"
+ disabled={props.disabled}
+ aria-pressed={media.cameraEnabled()}
+ onClick={() => media.setCameraEnabled(!media.cameraEnabled())}
+ >
+ <Show
+ when={media.cameraEnabled()}
+ fallback={<VideoCameraSlash />}
+ >
+ <VideoCamera />
+ </Show>
+ </Button>
+ <Button
+ size="icon-lg"
+ class="size-12"
+ disabled={props.disabled || uploading()}
+ label={
+ media.backgroundEffect().type === 'none'
+ ? 'Turn on background'
+ : 'Turn off background'
+ }
+ tooltipPlacement="top"
+ aria-pressed={media.backgroundEffect().type !== 'none'}
+ onClick={() =>
+ selectBackground(
+ media.backgroundEffect().type === 'none'
+ ? lastBackground
+ : { type: 'none' }
+ )
+ }
+ >
+ <Image />
+ </Button>
+ </div>
+ </div>
+ </div>
+ <div class="mt-4 grid grid-cols-2 gap-2 xl:grid-cols-4">
+ <MediaDevicePicker
+ label="Microphone"
+ icon={<Microphone class="size-4 shrink-0" />}
+ devices={media
+ .availableDevices()
+ .filter((device) => device.kind === 'audioinput')}
+ selected={media.selectedDevices().microphone}
+ disabled={props.disabled}
+ onSelect={(id) => media.selectDevice('microphone', id)}
+ />
+ <MediaDevicePicker
+ label="Speaker"
+ icon={<Speaker class="size-4 shrink-0" />}
+ devices={media
+ .availableDevices()
+ .filter((device) => device.kind === 'audiooutput')}
+ selected={media.selectedDevices().speaker}
+ disabled={props.disabled}
+ unsupported={!media.canSelectSpeaker()}
+ onSelect={(id) => media.selectDevice('speaker', id)}
+ />
+ <MediaDevicePicker
+ label="Camera"
+ icon={<VideoCamera class="size-4 shrink-0" />}
+ devices={media
+ .availableDevices()
+ .filter((device) => device.kind === 'videoinput')}
+ selected={media.selectedDevices().camera}
+ disabled={props.disabled}
+ onSelect={(id) => media.selectDevice('camera', id)}
+ />
+ <MediaBackgroundPicker
+ effect={media.backgroundEffect()}
+ disabled={props.disabled}
+ uploading={uploading()}
+ onSelect={selectBackground}
+ onUpload={
+ props.readBackgroundImage ? (file) => void upload(file) : undefined
+ }
+ />
+ </div>
+ <For
+ each={[
+ ...media.errors(),
+ media.backgroundError(),
+ media.deviceError(),
+ uploadError(),
+ ].filter(Boolean)}
+ >
+ {(error) => (
+ <p role="alert" class="mt-3 text-sm text-failure">
+ {error}
+ </p>
+ )}
+ </For>
+ </section>
+ );
+}
diff --git a/apps/web/src/features/meetings/views/meeting-page.tsx b/apps/web/src/features/meetings/views/meeting-page.tsx
index ca5e9d7f10..b9b2485af8 100644
--- a/apps/web/src/features/meetings/views/meeting-page.tsx
+++ b/apps/web/src/features/meetings/views/meeting-page.tsx
@@ -1,13 +1,12 @@
+import type { BackgroundEffect } from '@core/media/background-effect';
import ArrowLeft from '@phosphor/arrow-left.svg';
import Phone from '@phosphor/phone-call.svg';
-import { Button, ToggleSwitch } from '@ui';
+import { Button } from '@ui';
import {
type Accessor,
batch,
- children,
createEffect,
createSignal,
- For,
type JSX,
Match,
on,
@@ -16,6 +15,10 @@ import {
} from 'solid-js';
import { MeetingCallHeading } from '../components/meeting-call-heading';
import { MeetingCopyButton } from '../components/meeting-copy-button';
+import {
+ MeetingParticipants,
+ type MeetingParticipantsState,
+} from '../components/meeting-participants';
import type {
MeetingPageState,
MeetingSessionCapabilities,
@@ -25,14 +28,18 @@ import {
type MeetingMediaAccess,
} from '../primitives/meeting-media';
import { createMeetingSession } from '../primitives/meeting-session';
+import { MeetingMediaSetup } from './meeting-media-setup';
export function MeetingPage(props: {
source: Accessor<MeetingPageState>;
session: MeetingSessionCapabilities;
mediaAccess?: MeetingMediaAccess;
+ initialBackground?: BackgroundEffect;
+ readBackgroundImage?: (file: File) => Promise<string>;
authenticated: Accessor<boolean | undefined>;
author: Accessor<string>;
avatar?: JSX.Element;
+ participants?: MeetingParticipantsState;
startCall?: boolean;
url?: string;
onCopy: () => Promise<void>;
@@ -47,11 +54,11 @@ export function MeetingPage(props: {
onSignIn?: () => void;
renderCall: (onLeave: () => void, name: Accessor<string>) => JSX.Element;
}) {
- const avatar = children(() => props.avatar);
const session = createMeetingSession(props.session);
const [name, setName] = createSignal('');
const [leaving, setLeaving] = createSignal(false);
- const media = createMeetingMedia(props.mediaAccess);
+ const media = createMeetingMedia(props.mediaAccess, props.initialBackground);
+ const [uploadingBackground, setUploadingBackground] = createSignal(false);
const ready = () => {
const state = props.source();
return state.kind === 'ready' ? state : undefined;
@@ -82,18 +89,18 @@ export function MeetingPage(props: {
}
)
);
- let videoElement: HTMLVideoElement | undefined;
- createEffect(() => {
- const stream = media.video();
- if (videoElement) videoElement.srcObject = stream ?? null;
- });
const join = () => {
- if (membersOnly() || leaving() || media.pending()) return;
+ if (membersOnly() || leaving() || media.pending() || uploadingBackground())
+ return;
// The call publishes the preview tracks rather than re-opening the
// devices, so the waiting room is the only place permission is asked.
return session.join(props.authenticated() ? undefined : name(), {
microphoneEnabled: media.microphoneEnabled(),
cameraEnabled: media.cameraEnabled(),
+ microphoneDeviceId: media.selectedDevices().microphone,
+ cameraDeviceId: media.selectedDevices().camera,
+ speakerDeviceId: media.selectedDevices().speaker,
+ backgroundEffect: media.backgroundEffect(),
localTracks: media.handoff(),
});
};
@@ -188,32 +195,15 @@ export function MeetingPage(props: {
</div>
</Match>
<Match when={ready()}>
- <div class="m-auto grid w-full max-w-4xl gap-8 py-6 md:grid-cols-2 md:items-center">
- <div class="flex aspect-video flex-col items-center justify-center gap-5 rounded-2xl border border-edge-muted bg-message px-6">
- <video
- ref={videoElement}
- autoplay
- muted
- playsinline
- aria-label="Camera preview"
- class="max-h-full w-full rounded-xl object-cover -scale-x-100"
- classList={{ hidden: !media.video() }}
- />
- <Show when={!media.video()}>
- <div class="flex size-24 items-center justify-center rounded-full bg-accent/10 text-4xl font-medium text-accent">
- <Show
- when={avatar()}
- fallback={
- displayName().charAt(0).toUpperCase() || (
- <Phone class="size-10" />
- )
- }
- >
- {avatar()}
- </Show>
- </div>
- </Show>
- </div>
+ <div class="m-auto grid w-full max-w-6xl gap-8 py-6 md:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)] md:items-center">
+ <MeetingMediaSetup
+ media={media}
+ name={displayName()}
+ avatar={props.avatar}
+ disabled={session.joining()}
+ readBackgroundImage={props.readBackgroundImage}
+ onUploading={setUploadingBackground}
+ />
<form
class="flex flex-col gap-5"
onSubmit={(event) => {
@@ -245,6 +235,9 @@ export function MeetingPage(props: {
</Show>
</div>
</div>
+ <Show when={props.participants}>
+ {(state) => <MeetingParticipants state={state()} />}
+ </Show>
<Show
when={!props.authenticated()}
fallback={
@@ -267,31 +260,6 @@ export function MeetingPage(props: {
/>
</label>
</Show>
- <div class="flex flex-wrap items-center gap-6">
- <ToggleSwitch
- checked={media.microphoneEnabled()}
- disabled={session.joining()}
- onChange={media.setMicrophoneEnabled}
- size="sm"
- label="Microphone"
- labelClass="whitespace-nowrap text-xs text-ink-muted"
- />
- <ToggleSwitch
- checked={media.cameraEnabled()}
- disabled={session.joining()}
- onChange={media.setCameraEnabled}
- size="sm"
- label="Camera"
- labelClass="whitespace-nowrap text-xs text-ink-muted"
- />
- </div>
- <For each={media.errors()}>
- {(error) => (
- <p role="alert" class="text-sm text-failure">
- {error} You can still join with it off.
- </p>
- )}
- </For>
<Show when={session.error()}>
<p role="alert" class="text-sm text-failure">
{session.error()}
@@ -308,11 +276,12 @@ export function MeetingPage(props: {
<Button
variant="ghost"
size="lg"
- class="bg-hover text-ink not-touch:not-disabled:hover:bg-active focus-visible:outline-2 focus-visible:outline-accent"
+ class="w-full bg-hover text-ink not-touch:not-disabled:hover:bg-active focus-visible:outline-2 focus-visible:outline-accent"
type="submit"
disabled={
session.joining() ||
media.pending() ||
+ uploadingBackground() ||
(!props.authenticated() && !name().trim())
}
>
@@ -327,20 +296,10 @@ export function MeetingPage(props: {
? 'Start call'
: 'Join call'}
</Button>
- <Show when={session.joining()}>
- <Button type="button" onClick={() => void session.leave()}>
- Cancel
- </Button>
- </Show>
<p class="text-xs text-ink-muted">
Calls are recorded and transcribed for the organizer and Macro
participants.
</p>
- <Show when={props.url}>
- {(url) => (
- <MeetingCopyButton url={url()} onCopy={props.onCopy} />
- )}
- </Show>
</form>
</div>
</Match>
diff --git a/apps/web/src/lib/core/component/media/media-background-picker.tsx b/apps/web/src/lib/core/component/media/media-background-picker.tsx
new file mode 100644
index 0000000000..a0bfb6c110
--- /dev/null
+++ b/apps/web/src/lib/core/component/media/media-background-picker.tsx
@@ -0,0 +1,148 @@
+import type { BackgroundEffect } from '@core/media/background-effect';
+import CaretDown from '@phosphor/caret-down.svg';
+import Image from '@phosphor/image.svg';
+import Prohibit from '@phosphor/prohibit.svg';
+import Upload from '@phosphor/upload-simple.svg';
+import { Dropdown, SingleSelectCheck } from '@ui';
+import { For, type JSX, Show } from 'solid-js';
+
+export function BlurIcon(props: { strong?: boolean }) {
+ const count = () => (props.strong ? 5 : 3);
+ const dots = () =>
+ Array.from({ length: count() ** 2 }, (_, index) => ({
+ x: 4 + (index % count()) * (16 / (count() - 1)),
+ y: 4 + Math.floor(index / count()) * (16 / (count() - 1)),
+ }));
+ return (
+ <svg
+ viewBox="0 0 24 24"
+ class="size-4 shrink-0"
+ fill="currentColor"
+ aria-hidden="true"
+ >
+ <For each={dots()}>
+ {(dot) => <circle cx={dot.x} cy={dot.y} r="1.2" />}
+ </For>
+ </svg>
+ );
+}
+
+export function MediaBackgroundPicker(props: {
+ effect: BackgroundEffect;
+ trigger?: JSX.Element;
+ placement?: 'top-start' | 'bottom-start' | 'top-end' | 'bottom-end';
+ onOpenChange?: (open: boolean) => void;
+ disabled?: boolean;
+ uploading?: boolean;
+ onSelect: (effect: BackgroundEffect) => void;
+ onUpload?: (file: File) => void;
+}) {
+ let input: HTMLInputElement | undefined;
+ const selected = () =>
+ props.effect.type === 'blur'
+ ? props.effect.intensity === 'light'
+ ? 'light'
+ : 'heavy'
+ : props.effect.type;
+ const select = (value: string) => {
+ if (value === 'none') props.onSelect({ type: 'none' });
+ else if (value === 'light' || value === 'heavy')
+ props.onSelect({ type: 'blur', intensity: value });
+ };
+ return (
+ <>
+ <Dropdown
+ placement={props.placement ?? 'bottom-end'}
+ onOpenChange={props.onOpenChange}
+ >
+ <Show
+ keyed
+ when={props.trigger}
+ fallback={
+ <Dropdown.Trigger
+ disabled={props.disabled || props.uploading}
+ size="lg"
+ fullWidth
+ class="min-w-0 text-sm"
+ >
+ <Image class="size-4 shrink-0" />
+ <span class="flex-1 text-left">Backgrounds</span>
+ <CaretDown class="size-3 shrink-0" />
+ </Dropdown.Trigger>
+ }
+ >
+ {(trigger) => trigger}
+ </Show>
+ <Dropdown.Content class="min-w-48">
+ <Dropdown.RadioGroup value={selected()} onChange={select}>
+ <Dropdown.RadioItem
+ value="none"
+ closeOnSelect
+ disabled={props.disabled || props.uploading}
+ >
+ <Prohibit class="size-4" />
+ <span class="flex-1">None</span>
+ <SingleSelectCheck active={selected() === 'none'} />
+ </Dropdown.RadioItem>
+ <Dropdown.RadioItem
+ value="light"
+ closeOnSelect
+ disabled={props.disabled || props.uploading}
+ >
+ <BlurIcon />
+ <span class="flex-1">Light blur</span>
+ <SingleSelectCheck active={selected() === 'light'} />
+ </Dropdown.RadioItem>
+ <Dropdown.RadioItem
+ value="heavy"
+ closeOnSelect
+ disabled={props.disabled || props.uploading}
+ >
+ <BlurIcon strong />
+ <span class="flex-1">Strong blur</span>
+ <SingleSelectCheck active={selected() === 'heavy'} />
+ </Dropdown.RadioItem>
+ <Show when={props.effect.type === 'image'}>
+ <Dropdown.RadioItem
+ value="image"
+ closeOnSelect
+ disabled={props.disabled || props.uploading}
+ >
+ <Image class="size-4" />
+ <span class="flex-1">Custom background</span>
+ <SingleSelectCheck active />
+ </Dropdown.RadioItem>
+ </Show>
+ </Dropdown.RadioGroup>
+ <Show when={props.onUpload}>
+ <Dropdown.Separator />
+ <Dropdown.Item
+ disabled={props.disabled || props.uploading}
+ onSelect={() => input?.click()}
+ >
+ <Upload class="size-4" />
+ <span>
+ {props.uploading ? 'Loading image…' : 'Upload an image'}
+ </span>
+ </Dropdown.Item>
+ </Show>
+ </Dropdown.Content>
+ </Dropdown>
+ <Show when={props.onUpload}>
+ <input
+ ref={input}
+ type="file"
+ accept="image/jpeg,image/png,image/webp"
+ aria-label="Upload background image"
+ class="sr-only"
+ tabindex={-1}
+ onChange={(event) => {
+ const file = event.currentTarget.files?.[0];
+ event.currentTarget.value = '';
+ if (file) props.onUpload?.(file);
+ }}
+ />
+ </Show>
+ </>
+ );
+}
diff --git a/apps/web/src/lib/core/component/media/media-device-picker.tsx b/apps/web/src/lib/core/component/media/media-device-picker.tsx
new file mode 100644
index 0000000000..9502be45f5
--- /dev/null
+++ b/apps/web/src/lib/core/component/media/media-device-picker.tsx
@@ -0,0 +1,72 @@
+import CaretDown from '@phosphor/caret-down.svg';
+import { Dropdown, SingleSelectCheck, Tooltip } from '@ui';
+import { For, type JSX } from 'solid-js';
+
+export function MediaDevicePicker(props: {
+ label: string;
+ icon: JSX.Element;
+ devices: ReadonlyArray<Pick<MediaDeviceInfo, 'deviceId' | 'label'>>;
+ selected: string;
+ placement?: 'top-start' | 'bottom-start' | 'top-end' | 'bottom-end';
+ onOpenChange?: (open: boolean) => void;
+ disabled?: boolean;
+ unsupported?: boolean;
+ onSelect: (id: string) => void;
+}) {
+ const selectedLabel = () =>
+ props.devices.find((device) => device.deviceId === props.selected)?.label ||
+ 'System default';
+ return (
+ <Dropdown
+ placement={props.placement ?? 'bottom-start'}
+ onOpenChange={props.onOpenChange}
+ >
+ <Tooltip
+ placement="top"
+ label={
+ props.unsupported
+ ? 'Your browser uses the system’s speaker selection'
+ : `${props.label}: ${selectedLabel()}`
+ }
+ class="w-full min-w-0"
+ >
+ <Dropdown.Trigger
+ disabled={props.disabled || props.unsupported}
+ aria-label={`${props.label}: ${selectedLabel()}`}
+ size="lg"
+ fullWidth
+ class="min-w-0 text-sm"
+ >
+ {props.icon}
+ <span class="min-w-0 flex-1 truncate text-left">
+ {selectedLabel()}
+ </span>
+ <CaretDown class="size-3 shrink-0" />
+ </Dropdown.Trigger>
+ </Tooltip>
+ <Dropdown.Content class="max-w-80">
+ <div class="px-2 py-1 text-xs font-medium text-ink-muted">
+ {props.label}
+ </div>
+ <Dropdown.RadioGroup value={props.selected} onChange={props.onSelect}>
+ <Dropdown.RadioItem closeOnSelect value="">
+ <span class="flex-1">System default</span>
+ <SingleSelectCheck active={!props.selected} />
+ </Dropdown.RadioItem>
+ <For each={props.devices.filter((device) => device.deviceId !== '')}>
+ {(device, index) => (
+ <Dropdown.RadioItem closeOnSelect value={device.deviceId}>
+ <span class="min-w-0 flex-1 truncate">
+ {device.label || `${props.label} ${index() + 1}`}
+ </span>
+ <SingleSelectCheck
+ active={props.selected === device.deviceId}
+ />
+ </Dropdown.RadioItem>
+ )}
+ </For>
+ </Dropdown.RadioGroup>
+ </Dropdown.Content>
+ </Dropdown>
+ );
+}
diff --git a/apps/web/src/lib/core/media/background-effect.ts b/apps/web/src/lib/core/media/background-effect.ts
new file mode 100644
index 0000000000..9788c4709b
--- /dev/null
+++ b/apps/web/src/lib/core/media/background-effect.ts
@@ -0,0 +1,22 @@
+/** Camera effects shared by the waiting room and connected calls. */
+export type BlurIntensity = 'light' | 'medium' | 'heavy';
+export type BackgroundEffect =
+ | { type: 'none' }
+ | { type: 'blur'; intensity: BlurIntensity }
+ | { type: 'image'; id: string; path: string };
+
+export const BLUR_RADIUS: Record<BlurIntensity, number> = {
+ light: 5,
+ medium: 10,
+ heavy: 20,
+};
+
+export function backgroundProcessorOptions(effect: BackgroundEffect) {
+ if (effect.type === 'none') return { mode: 'disabled' as const };
+ if (effect.type === 'blur')
+ return {
+ mode: 'background-blur' as const,
+ blurRadius: BLUR_RADIUS[effect.intensity],
+ };
+ return { mode: 'virtual-background' as const, imagePath: effect.path };
+}
diff --git a/apps/web/src/lib/core/media/read-background-image.ts b/apps/web/src/lib/core/media/read-background-image.ts
new file mode 100644
index 0000000000..aa5d9a4aab
--- /dev/null
+++ b/apps/web/src/lib/core/media/read-background-image.ts
@@ -0,0 +1,20 @@
+/** Bound custom images before storing the same background preference as calls. */
+export async function readBackgroundImage(file: File): Promise<string> {
+ if (!['image/jpeg', 'image/png', 'image/webp'].includes(file.type))
+ throw new Error('Choose a JPG, PNG, or WebP image.');
+ if (file.size > 10 * 1024 * 1024)
+ throw new Error('Choose an image smaller than 10 MB.');
+ const image = await createImageBitmap(file);
+ try {
+ const scale = Math.min(1, 1280 / image.width, 720 / image.height);
+ const canvas = document.createElement('canvas');
+ canvas.width = Math.max(1, Math.round(image.width * scale));
+ canvas.height = Math.max(1, Math.round(image.height * scale));
+ const context = canvas.getContext('2d');
+ if (!context) throw new Error('Could not read this image.');
+ context.drawImage(image, 0, 0, canvas.width, canvas.height);
+ return canvas.toDataURL('image/jpeg', 0.8);
+ } finally {
+ image.close();
+ }
+}
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 3044f2e8a6..68a8c83510 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1048,6 +1048,9 @@ Guests enter `Your name`, choose their microphone and camera preferences, and
press `Join call`. Setup requests device
permissions and previews video locally; sharing starts only after joining.
Permission denial leaves the affected device off and still allows joining.
+The preview and full-width join button retain their size while joining.
+Copying the meeting URL is available after joining, in the in-call header.
+
The creator presses `Start call`; invitees press `Join call`. Loading the page or
completing authentication never joins automatically, including old `?join=true`
URLs. `Back to Macro` exits setup.
@@ -1070,13 +1073,33 @@ call without gaining access to the channel.
The join screen, in-call participant tiles, and incoming direct-call badges use
profile pictures; initials are the fallback when no photo is available.
-The join screen uses small switches for Microphone and Camera. Join and
-`Copy Meeting Url` use gray buttons; the copy action includes a copy icon.
-The in-call header uses the same copy button and shows the current local time
-before the call name. Owners can click the name to rename it, then Save or press
-Enter; Cancel or Escape discards the edit. Guests and other participants see a
+The join screen has microphone, camera, and background effects buttons over the
+preview, with pill selectors below for microphone, speaker, camera, and
+backgrounds. The background button over the preview toggles the selected effect
+off and back on; when no effect has been selected, it enables Strong blur.
+Backgrounds use a simple menu with None, Light blur, Strong blur, and image upload
+(JPG, PNG, or WebP, up to 10 MB). Dot icons distinguish the two blur strengths.
+Selected devices and backgrounds carry into the call; unsupported browsers use
+the system speaker. If a background cannot be applied, the camera stays off
+until the user retries or chooses None. The screen uses a gray join
+button. The in-call header has a gray `Copy Meeting Url` button with a copy icon
+and shows the current local time before the call name. Owners can click the name
+to rename it, then Save or press Enter; Cancel or Escape discards the edit. Guests and other participants see a
read-only name.
+Join-preview and in-call controls use the standard Macro icon buttons. Pause
+over the microphone, camera, or background group to reveal an animated settings popover
+above the call toolbar; click its caret to keep it open. Brief pointer passes
+do not open settings, and moving into the popover keeps it open. Settings
+respect reduced-motion preferences.
+Audio settings include microphone, speaker, and noise suppression. Camera
+settings include the camera selector. Clicking the background icon toggles the
+selected effect off/on, restoring the last blur strength or image (Strong blur
+by default). Its hover panel contains the same None, Light blur, Strong blur,
+and image-upload menu as the join screen; the caret pins this panel for keyboard
+and touch access. Click outside or press Escape to close the settings.
+The controls also work by keyboard and touch.
+
### Sharing a call
A channel call's **Share** dialog has a `Team access` control (None or View) for the same canonical