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.

fix(calls): open call settings from split buttons on click (#8674)

Eric Hayesd496a5add61c
diff --git a/apps/web/src/features/channel/Call/CallControls/CallControlBar.tsx b/apps/web/src/features/channel/Call/CallControls/CallControlBar.tsx
index 62bdd048cd..da3370de12 100644
--- a/apps/web/src/features/channel/Call/CallControls/CallControlBar.tsx
+++ b/apps/web/src/features/channel/Call/CallControls/CallControlBar.tsx
@@ -1,54 +1,62 @@
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';
+import { Button, ButtonGroup, Dropdown } from '@ui';
+import { createSignal, type JSX, Show } from 'solid-js';
-export function CallControlButton(props: {
+/**
+ * A media toggle split from its settings menu: the left half turns the device
+ * on or off, the caret opens its menu on click.
+ */
+function MediaSplitButton(props: {
label: string;
- pressed?: boolean;
+ toggleLabel: string;
+ menuLabel: string;
+ on: boolean;
disabled?: boolean;
- danger?: boolean;
- class?: string;
- onClick: () => void;
+ onToggle: () => void;
+ icon: JSX.Element;
children: JSX.Element;
}) {
+ const [open, setOpen] = createSignal(false);
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-10 @sm:size-12 ${props.class ?? ''}`}
- >
- {props.children}
- </Button>
+ <Dropdown placement="top-start" open={open()} onOpenChange={setOpen}>
+ <ButtonGroup size="icon-lg" label={props.label}>
+ <Button
+ label={props.toggleLabel}
+ tooltipPlacement="top"
+ aria-pressed={props.on}
+ disabled={props.disabled}
+ onClick={props.onToggle}
+ >
+ {props.icon}
+ </Button>
+ <ButtonGroup.Divider />
+ <Dropdown.Trigger
+ variant="ghost"
+ size="icon-lg"
+ label={props.menuLabel}
+ tooltipPlacement="top"
+ tooltipDisabled={open()}
+ class="w-6"
+ >
+ <CaretUp
+ class="size-3 transition-transform duration-200 ease-out motion-reduce:transition-none"
+ classList={{ 'rotate-180': open() }}
+ />
+ </Dropdown.Trigger>
+ </ButtonGroup>
+ <Dropdown.Content class="w-72 max-w-[calc(100vw-2rem)]">
+ {props.children}
+ </Dropdown.Content>
+ </Dropdown>
);
}
-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;
@@ -58,270 +66,67 @@ export function CallControlBar(props: {
onToggleVideo: () => void;
onToggleScreen: () => void;
onLeave: () => void;
- menuOpen: boolean;
- audioSettings: JSX.Element;
- videoSettings: JSX.Element;
- backgroundActive: boolean;
- backgroundDisabled: boolean;
- onToggleBackground: () => void;
- backgroundSettings: JSX.Element;
+ /** Dropdown items for microphone, speaker, and audio processing. */
+ audioMenu: JSX.Element;
+ /** Dropdown items for the camera and its background effect. */
+ videoMenu: 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 rounded-full border border-edge-muted bg-control"
- onPointerEnter={(event) => preview(group.kind, event)}
- onPointerLeave={cancelIntent}
- >
- <CallControlButton
- class="rounded-r-none"
- label={group.toggleLabel}
- pressed={group.active}
- disabled={props.disabled || group.disabled}
- onClick={group.onToggle}
- >
- {group.children}
- </CallControlButton>
- <Button
- size="icon-md"
- tooltipDisabled
- variant="ghost"
- 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-10 w-6 rounded-l-none border-l-edge-muted @sm:h-12 @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 bg-menu-glass text-ink glass">
- <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 data-call-controls class="@container relative z-20 w-full max-w-xl">
<div class="mx-auto flex w-fit max-w-full flex-wrap items-center justify-center gap-1 rounded-xl bg-menu-glass p-1.5 text-ink glass @sm:gap-2">
- <MediaGroup
- kind="audio"
- active={!props.audioMuted}
- label="Microphone controls"
+ <MediaSplitButton
+ label="Microphone"
toggleLabel={
props.audioMuted ? 'Unmute microphone' : 'Mute microphone'
}
+ menuLabel="Audio settings"
+ on={!props.audioMuted}
+ disabled={props.disabled}
onToggle={props.onToggleAudio}
+ icon={
+ <Show when={props.audioMuted} fallback={<Microphone />}>
+ <MicrophoneSlash />
+ </Show>
+ }
>
- <Show when={props.audioMuted} fallback={<Microphone />}>
- <MicrophoneSlash />
- </Show>
- </MediaGroup>
- <MediaGroup
- kind="video"
- active={!props.videoMuted}
- label="Camera controls"
+ {props.audioMenu}
+ </MediaSplitButton>
+ <MediaSplitButton
+ label="Camera"
toggleLabel={props.videoMuted ? 'Turn on camera' : 'Turn off camera'}
+ menuLabel="Video settings"
+ on={!props.videoMuted}
+ disabled={props.disabled}
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'
+ icon={
+ <Show when={props.videoMuted} fallback={<VideoCamera />}>
+ <VideoCameraSlash />
+ </Show>
}
- onToggle={props.onToggleBackground}
>
- <Image />
- </MediaGroup>
- <CallControlButton
+ {props.videoMenu}
+ </MediaSplitButton>
+ <Button
+ size="icon-lg"
+ variant="outline"
label={props.screenSharing ? 'Stop sharing screen' : 'Share screen'}
- pressed={props.screenSharing}
+ tooltipPlacement="top"
+ aria-pressed={props.screenSharing}
disabled={props.disabled}
onClick={props.onToggleScreen}
>
<Screencast />
- </CallControlButton>
- <CallControlButton label="Leave call" danger onClick={props.onLeave}>
+ </Button>
+ <Button
+ size="icon-lg"
+ variant="danger"
+ label="Leave call"
+ tooltipPlacement="top"
+ onClick={props.onLeave}
+ >
<PhoneDisconnect />
- </CallControlButton>
+ </Button>
</div>
<Show when={props.error}>
<p
diff --git a/apps/web/src/features/channel/Call/CallControls/CallMediaControls.tsx b/apps/web/src/features/channel/Call/CallControls/CallMediaControls.tsx
index 61333347a8..2c2fcfd8d1 100644
--- a/apps/web/src/features/channel/Call/CallControls/CallMediaControls.tsx
+++ b/apps/web/src/features/channel/Call/CallControls/CallMediaControls.tsx
@@ -1,13 +1,13 @@
-import { MediaBackgroundPicker } from '@core/component/media/media-background-picker';
-import { MediaDevicePicker } from '@core/component/media/media-device-picker';
+import { BlurIcon } from '@core/component/media/media-background-picker';
+import { MediaDeviceRadioItems } from '@core/component/media/media-device-picker';
import type { BackgroundEffect } from '@core/media/background-effect';
import { readBackgroundImage } from '@core/media/read-background-image';
import { fireAndForget } from '@core/util/fireAndForget';
-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 Image from '@phosphor/image.svg';
+import Prohibit from '@phosphor/prohibit.svg';
+import Upload from '@phosphor/upload-simple.svg';
+import { Dropdown } from '@ui';
+import { createSignal, type JSX, onCleanup, Show } from 'solid-js';
import type { CallState } from '../CallContext';
import { CallControlBar } from './CallControlBar';
@@ -35,15 +35,22 @@ export type CallMediaControlsState = Pick<
| 'setBackgroundEffect'
>;
+type BackgroundChoice = 'none' | 'light' | 'heavy' | 'image';
+
+function backgroundChoice(effect: BackgroundEffect): BackgroundChoice {
+ if (effect.type === 'blur')
+ return effect.intensity === 'light' ? 'light' : 'heavy';
+ return effect.type;
+}
+
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 upload: HTMLInputElement | undefined;
let disposed = false;
onCleanup(() => {
disposed = true;
@@ -62,6 +69,9 @@ export function CallMediaControls(props: {
);
}
}
+ const fire = (action: () => void | Promise<void>) =>
+ fireAndForget(run(action), 'channel-call');
+
async function applyBackground(effect: BackgroundEffect | File) {
if (applyingBackground()) return;
setApplyingBackground(true);
@@ -74,128 +84,181 @@ export function CallMediaControls(props: {
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) await call.setBackgroundEffect(next);
});
if (!disposed) setApplyingBackground(false);
}
+ async function selectBackground(value: string) {
+ if (value === 'none') await applyBackground({ type: 'none' });
+ else if (value === 'light' || value === 'heavy')
+ await applyBackground({ type: 'blur', intensity: value });
+ }
+
+ const backgroundDisabled = () => call.isConnecting() || applyingBackground();
return (
- <CallControlBar
- disabled={call.isConnecting()}
- audioMuted={call.isAudioMuted()}
- videoMuted={call.isVideoMuted()}
- screenSharing={call.isScreenSharing()}
- onToggleAudio={() => fireAndForget(run(call.toggleAudio), 'channel-call')}
- onToggleVideo={() => fireAndForget(run(call.toggleVideo), 'channel-call')}
- onToggleScreen={() =>
- fireAndForget(run(call.toggleScreenShare), 'channel-call')
- }
- onLeave={() => fireAndForget(run(props.onLeave), 'channel-call')}
- 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) =>
- fireAndForget(
- run(() => call.switchAudioInput(id || 'default')),
- 'channel-call'
- )
- }
- />
- <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) =>
- fireAndForget(
- run(() => call.switchAudioOutput(id || 'default')),
- 'channel-call'
- )
- }
- />
- </div>
- <button
- type="button"
- role="checkbox"
- aria-checked={call.isNoiseSuppressed()}
- disabled={call.isConnecting()}
- onClick={() =>
- fireAndForget(run(call.toggleNoiseSuppression), 'channel-call')
- }
- 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) =>
- fireAndForget(
- run(() =>
- call.switchVideoInput(
- id || call.videoInputDevices()[0]?.deviceId || ''
- )
- ),
- 'channel-call'
- )
- }
- />
- }
- backgroundActive={call.backgroundEffect().type !== 'none'}
- backgroundDisabled={applyingBackground()}
- onToggleBackground={() =>
- fireAndForget(
- applyBackground(
- call.backgroundEffect().type === 'none'
- ? lastBackground
- : { type: 'none' }
- ),
- 'channel-call'
- )
- }
- backgroundSettings={
- <MediaBackgroundPicker
- effect={call.backgroundEffect()}
- placement="top-end"
- onOpenChange={setMenuOpen}
- disabled={call.isConnecting()}
- uploading={applyingBackground()}
- onSelect={(effect) =>
- fireAndForget(applyBackground(effect), 'channel-call')
- }
- onUpload={(file) =>
- fireAndForget(applyBackground(file), 'channel-call')
- }
- />
- }
- />
+ <>
+ <CallControlBar
+ disabled={call.isConnecting()}
+ audioMuted={call.isAudioMuted()}
+ videoMuted={call.isVideoMuted()}
+ screenSharing={call.isScreenSharing()}
+ onToggleAudio={() => fire(call.toggleAudio)}
+ onToggleVideo={() => fire(call.toggleVideo)}
+ onToggleScreen={() => fire(call.toggleScreenShare)}
+ onLeave={() => fire(props.onLeave)}
+ error={error()}
+ audioMenu={
+ <>
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>Microphone</Dropdown.GroupLabel>
+ <MediaDeviceRadioItems
+ label="Microphone"
+ devices={call.audioInputDevices()}
+ selected={call.activeAudioInputDeviceId() ?? ''}
+ disabled={call.isConnecting()}
+ onSelect={(id) =>
+ fire(() => call.switchAudioInput(id || 'default'))
+ }
+ />
+ </Dropdown.Group>
+ <Show when={'setSinkId' in HTMLMediaElement.prototype}>
+ <Dropdown.Separator />
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>Speaker</Dropdown.GroupLabel>
+ <MediaDeviceRadioItems
+ label="Speaker"
+ devices={call.audioOutputDevices()}
+ selected={call.activeAudioOutputDeviceId() ?? ''}
+ disabled={call.isConnecting()}
+ onSelect={(id) =>
+ fire(() => call.switchAudioOutput(id || 'default'))
+ }
+ />
+ </Dropdown.Group>
+ </Show>
+ <Dropdown.Separator />
+ <Dropdown.Group>
+ <Dropdown.CheckboxItem
+ checked={call.isNoiseSuppressed()}
+ disabled={call.isConnecting()}
+ closeOnSelect={false}
+ onChange={() => fire(call.toggleNoiseSuppression)}
+ >
+ Noise suppression
+ </Dropdown.CheckboxItem>
+ </Dropdown.Group>
+ </>
+ }
+ videoMenu={
+ <>
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>Camera</Dropdown.GroupLabel>
+ <MediaDeviceRadioItems
+ label="Camera"
+ devices={call.videoInputDevices()}
+ selected={call.activeVideoInputDeviceId() ?? ''}
+ disabled={call.isConnecting()}
+ onSelect={(id) =>
+ fire(() =>
+ call.switchVideoInput(
+ id || call.videoInputDevices()[0]?.deviceId || ''
+ )
+ )
+ }
+ />
+ </Dropdown.Group>
+ <Dropdown.Separator />
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>Background</Dropdown.GroupLabel>
+ <div class="grid grid-cols-4 gap-1">
+ <Dropdown.RadioGroup
+ class="contents"
+ value={backgroundChoice(call.backgroundEffect())}
+ onChange={(value) =>
+ fireAndForget(selectBackground(value), 'channel-call')
+ }
+ >
+ <BackgroundTile
+ value="none"
+ label="None"
+ disabled={backgroundDisabled()}
+ >
+ <Prohibit class="size-4" />
+ </BackgroundTile>
+ <BackgroundTile
+ value="light"
+ label="Light blur"
+ caption="Light"
+ disabled={backgroundDisabled()}
+ >
+ <BlurIcon />
+ </BackgroundTile>
+ <BackgroundTile
+ value="heavy"
+ label="Strong blur"
+ caption="Strong"
+ disabled={backgroundDisabled()}
+ >
+ <BlurIcon strong />
+ </BackgroundTile>
+ <Show when={call.backgroundEffect().type === 'image'}>
+ <BackgroundTile
+ value="image"
+ label="Custom image"
+ caption="Custom"
+ >
+ <Image class="size-4" />
+ </BackgroundTile>
+ </Show>
+ </Dropdown.RadioGroup>
+ <Dropdown.Item
+ disabled={backgroundDisabled()}
+ onSelect={() => upload?.click()}
+ class="aspect-[4/3] flex-col justify-center gap-1 border border-dashed border-edge-muted p-1 text-xs text-ink-muted"
+ >
+ <Upload class="size-4" />
+ <span>{applyingBackground() ? 'Loading…' : 'Upload'}</span>
+ </Dropdown.Item>
+ </div>
+ </Dropdown.Group>
+ </>
+ }
+ />
+ <input
+ ref={upload}
+ 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) fireAndForget(applyBackground(file), 'channel-call');
+ }}
+ />
+ </>
+ );
+}
+
+/** One background choice as a small tile; `caption` shortens the visible name. */
+function BackgroundTile(props: {
+ value: BackgroundChoice;
+ label: string;
+ caption?: string;
+ disabled?: boolean;
+ children: JSX.Element;
+}) {
+ return (
+ <Dropdown.RadioItem
+ value={props.value}
+ disabled={props.disabled}
+ class="aspect-[4/3] flex-col justify-center gap-1 border border-edge-muted p-1 text-center text-xs text-ink-muted data-checked:overlay-active data-checked:text-ink"
+ >
+ {props.children}
+ <Dropdown.ItemLabel class="sr-only">{props.label}</Dropdown.ItemLabel>
+ <span aria-hidden="true">{props.caption ?? props.label}</span>
+ </Dropdown.RadioItem>
);
}
diff --git a/apps/web/src/features/channel/Call/CallOverlay.tsx b/apps/web/src/features/channel/Call/CallOverlay.tsx
index 3abfb24825..ebe79d1853 100644
--- a/apps/web/src/features/channel/Call/CallOverlay.tsx
+++ b/apps/web/src/features/channel/Call/CallOverlay.tsx
@@ -468,13 +468,16 @@ export function CallOverlay(props: {
<div
class="grid w-full items-center gap-2 px-2"
classList={{
- 'grid-cols-[minmax(3.5rem,1fr)_minmax(0,36rem)_minmax(3.5rem,1fr)]':
+ 'grid-cols-[minmax(3.5rem,1fr)_minmax(0,36rem)_minmax(3.5rem,1fr)] @max-[500px]/call:grid-cols-[minmax(0,1fr)_auto]':
canChat(),
'grid-cols-[minmax(0,1fr)_minmax(0,36rem)_minmax(0,1fr)]':
!canChat(),
}}
>
- <div class="col-start-2 flex min-w-0 justify-center">
+ <div
+ class="col-start-2 flex min-w-0 justify-center"
+ classList={{ '@max-[500px]/call:col-start-1': canChat() }}
+ >
<CallControls onLeave={props.onLeave} />
</div>
<Show when={canChat()}>
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
index dfb8f2b9d4..1e7e82b9fe 100644
--- a/apps/web/src/features/channel/Call/tests/call-controls.test.tsx
+++ b/apps/web/src/features/channel/Call/tests/call-controls.test.tsx
@@ -1,141 +1,116 @@
/** @vitest-environment jsdom */
-import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
-import { createSignal, type JSX } from 'solid-js';
+import type { BackgroundEffect } from '@core/media/background-effect';
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
-import { CallControlBar } from '../CallControls/CallControlBar';
+import {
+ CallMediaControls,
+ type CallMediaControlsState,
+} from '../CallControls/CallMediaControls';
-vi.mock('@ui', async () => ({
- ...(await import('../../../../components/ui/components/Button')),
- Tooltip: (props: { children: JSX.Element }) => props.children,
-}));
+afterEach(cleanup);
-afterEach(() => {
- cleanup();
- vi.useRealTimers();
-});
+const device = (deviceId: string, label: string) =>
+ ({ deviceId, label }) as MediaDeviceInfo;
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 };
+ const [audioMuted, setAudioMuted] = createSignal(false);
+ const [background, setBackground] = createSignal<BackgroundEffect>({
+ type: 'none',
+ });
+ const media = {
+ isConnecting: () => false,
+ isAudioMuted: audioMuted,
+ isVideoMuted: () => false,
+ isScreenSharing: () => false,
+ toggleAudio: vi.fn(async () => {
+ setAudioMuted(!audioMuted());
+ }),
+ toggleVideo: vi.fn(async () => {}),
+ toggleScreenShare: vi.fn(async () => {}),
+ audioInputDevices: () => [device('mic-1', 'Desk microphone')],
+ audioOutputDevices: () => [],
+ videoInputDevices: () => [device('cam-1', 'Desk camera')],
+ activeAudioInputDeviceId: () => null,
+ activeAudioOutputDeviceId: () => null,
+ activeVideoInputDeviceId: () => 'cam-1',
+ switchAudioInput: vi.fn(async () => {}),
+ switchAudioOutput: vi.fn(async () => {}),
+ switchVideoInput: vi.fn(async () => {}),
+ isNoiseSuppressed: () => true,
+ toggleNoiseSuppression: vi.fn(async () => {}),
+ backgroundEffect: background,
+ setBackgroundEffect: vi.fn(async (effect: BackgroundEffect) => {
+ setBackground(effect);
+ }),
+ } satisfies CallMediaControlsState;
+ const leave = vi.fn();
+ render(() => <CallMediaControls media={media} onLeave={leave} />);
+ return { media, 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();
- });
+async function openMenu(name: string) {
+ const trigger = screen.getByRole('button', { name });
+ trigger.focus();
+ fireEvent.keyDown(trigger, { key: 'ArrowDown' });
+ await screen.findByRole('menu');
+ return trigger;
+}
- 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();
- });
+async function choose(role: string, name: string) {
+ const item = await screen.findByRole(role, { name });
+ item.focus();
+ fireEvent.keyDown(item, { key: 'Enter' });
+}
- 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();
+describe('call controls', () => {
+ it('toggles the microphone without opening its settings', () => {
+ const { media } = setup();
+ const toggle = screen.getByRole('button', { name: 'Mute microphone' });
+ fireEvent.pointerEnter(toggle);
+ fireEvent.click(toggle);
+ expect(media.toggleAudio).toHaveBeenCalledOnce();
+ expect(screen.queryByRole('menu')).toBeNull();
+ expect(
+ screen
+ .getByRole('button', { name: 'Unmute microphone' })
+ .getAttribute('aria-pressed')
+ ).toBe('false');
});
- 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('opens audio settings from the caret and switches the microphone', async () => {
+ const { media } = setup();
+ const caret = await openMenu('Audio settings');
+ expect(caret.getAttribute('aria-expanded')).toBe('true');
+ await choose('menuitemradio', 'Desk microphone');
+ expect(media.switchAudioInput).toHaveBeenCalledWith('mic-1');
});
- 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);
+ it('keeps background effects in the video settings', async () => {
+ const { media } = setup();
+ await openMenu('Video settings');
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);
+ screen
+ .getByRole('menuitemradio', { name: 'Desk camera' })
+ .getAttribute('aria-checked')
+ ).toBe('true');
+ await choose('menuitemradio', 'Strong blur');
+ await waitFor(() =>
+ expect(media.setBackgroundEffect).toHaveBeenCalledWith({
+ type: 'blur',
+ intensity: 'heavy',
+ })
+ );
});
- 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();
+ it('leaves the call', () => {
+ const { leave } = setup();
fireEvent.click(screen.getByRole('button', { name: 'Leave call' }));
expect(leave).toHaveBeenCalledOnce();
});
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
index 9502be45f5..2b182f0632 100644
--- a/apps/web/src/lib/core/component/media/media-device-picker.tsx
+++ b/apps/web/src/lib/core/component/media/media-device-picker.tsx
@@ -2,10 +2,44 @@ import CaretDown from '@phosphor/caret-down.svg';
import { Dropdown, SingleSelectCheck, Tooltip } from '@ui';
import { For, type JSX } from 'solid-js';
+type MediaDevices = ReadonlyArray<Pick<MediaDeviceInfo, 'deviceId' | 'label'>>;
+
+/** A device kind's radio rows; `selected` '' is the system default. */
+export function MediaDeviceRadioItems(props: {
+ label: string;
+ devices: MediaDevices;
+ selected: string;
+ disabled?: boolean;
+ onSelect: (id: string) => void;
+}) {
+ return (
+ <Dropdown.RadioGroup value={props.selected} onChange={props.onSelect}>
+ <Dropdown.RadioItem closeOnSelect value="" disabled={props.disabled}>
+ <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}
+ disabled={props.disabled}
+ >
+ <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>
+ );
+}
+
export function MediaDevicePicker(props: {
label: string;
icon: JSX.Element;
- devices: ReadonlyArray<Pick<MediaDeviceInfo, 'deviceId' | 'label'>>;
+ devices: MediaDevices;
selected: string;
placement?: 'top-start' | 'bottom-start' | 'top-end' | 'bottom-end';
onOpenChange?: (open: boolean) => void;
@@ -48,24 +82,12 @@ export function MediaDevicePicker(props: {
<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>
+ <MediaDeviceRadioItems
+ label={props.label}
+ devices={props.devices}
+ selected={props.selected}
+ onSelect={props.onSelect}
+ />
</Dropdown.Content>
</Dropdown>
);
diff --git a/docs/agent-guide/calls.md b/docs/agent-guide/calls.md
index baaad00794..89a61599c8 100644
--- a/docs/agent-guide/calls.md
+++ b/docs/agent-guide/calls.md
@@ -171,18 +171,14 @@ 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. The toolbar and settings panels use Macro's
-shared glass surface in both light and dark themes.
-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.
+Join-preview and in-call controls use the standard Macro icon buttons. In a
+call, the microphone and camera are split buttons (`ButtonGroup`): the left half
+toggles the device (pressed while on), and the caret opens a settings menu above
+the toolbar on click only; hovering opens nothing. **Audio settings** lists
+microphones, speakers (when the browser can choose one), and noise suppression.
+**Video settings** lists cameras and the background effects as tiles: None,
+Light blur, Strong blur, a selected custom image, and Upload. Screen share and
+Leave call are separate buttons. Click outside or press Escape to close a menu.
The controls also work by keyboard and touch.
### Browser call diagnostics