Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(calls): new styling, global call tracking, sidebar call panel, call fixes. Stacked PR (#2703)
Gary Acers9bcf9f4547e8
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsxindex d386444b87..226b6c39a2 100644--- a/js/app/packages/app/component/Root.tsx+++ b/js/app/packages/app/component/Root.tsx@@ -91,6 +91,7 @@ import {useAnalytics,} from '@app/component/analytics-context';import { PosthogProvider, usePosthog } from '@app/lib/analytics/posthog';+import { CallProvider } from '@channel/Call/CallContext';/** Syncs login cookie with auth state. Only updates on successful query (not errors/loading). */function useSyncLoginCookie() {@@ -444,28 +445,30 @@ export function Root() {<ConfiguredGlobalAppStateProvider><MutationUndoProvider><ChannelsContextProvider>- <QuickAccessProvider>- <SearchProvider>- <ChatAttachmentsInit />- <ReactiveFavicon />- <Title>{tabTitle()}</Title>- <Suspense>- <IsomorphicRouter- transformUrl={transformShortIdInUrlPathname}- root={Layout}- rootPreload={rootPreload}- base={ROUTER_BASE}- >- {{- path: '/',- component: TauriRouteListener,- children: ROUTES,- }}- </IsomorphicRouter>- </Suspense>- <ToastRegion />- </SearchProvider>- </QuickAccessProvider>+ <CallProvider>+ <QuickAccessProvider>+ <SearchProvider>+ <ChatAttachmentsInit />+ <ReactiveFavicon />+ <Title>{tabTitle()}</Title>+ <Suspense>+ <IsomorphicRouter+ transformUrl={transformShortIdInUrlPathname}+ root={Layout}+ rootPreload={rootPreload}+ base={ROUTER_BASE}+ >+ {{+ path: '/',+ component: TauriRouteListener,+ children: ROUTES,+ }}+ </IsomorphicRouter>+ </Suspense>+ <ToastRegion />+ </SearchProvider>+ </QuickAccessProvider>+ </CallProvider></ChannelsContextProvider></MutationUndoProvider></ConfiguredGlobalAppStateProvider>diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsxindex ce62ba6fe8..74b96c92be 100644--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx@@ -1,64 +1,65 @@-import { useAnalytics } from '@app/component/analytics-context';-import { ChannelsUnreadWidget } from '@app/component/app-sidebar/channels-unread-widget';+import { AnimatedUsersIcon } from '@macro-icons/wide/animating/users';+import { AnimatedGearIcon } from '@macro-icons/wide/animating/gear';import {- InviteModal,- setInviteModalOpen,-} from '@app/component/app-sidebar/invite-modal';-import { CommandState } from '@app/component/command';-import { gitBranch, setDevStatusBarOpen } from '@app/component/DevStatusBar';-import { createMenuOpen, setCreateMenuOpen } from '@app/component/Launcher';-import { useSplitLayout } from '@app/component/split-layout/layout';-import { GO_TO_COMMAND_SCOPE, GO_TO_LEADER_KEY } from '@app/constants/hotkeys';+ type Component,+ createMemo,+ createSignal,+ For,+ type JSX,+ onCleanup,+ Show,+} from 'solid-js';+import { Dynamic } from 'solid-js/web';+import { AnimatedStarIcon } from '@macro-icons/wide/animating/star';+import { AnimatedEmailIcon } from '@macro-icons/wide/animating/email';+import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';+import { AnimatedChannelIcon } from '@macro-icons/wide/animating/channel';+import { AnimatedFileMdIcon } from '@macro-icons/wide/animating/fileMd';+import { AnimatedFolderIcon } from '@macro-icons/wide/animating/folder';+import { AnimatedInboxIcon } from '@macro-icons/wide/animating/inbox';+import { AnimatedSearchIcon } from '@macro-icons/wide/animating/search';+import { AnimatedSidebarIcon } from '@macro-icons/wide/animating/sidebar';+import { AnimatedPlusIcon } from '@macro-icons/wide/animating/plus';+import { AnimatedNewSplitIcon } from '@macro-icons/wide/animating/newSplit';+import { AnimatedCommandIcon } from '@macro-icons/wide/animating/command';+import { useLocation } from '@solidjs/router';+import LogoIcon from '@macro-icons/macro-logo.svg';import {LIST_VIEW_ID,LIST_VIEW_PATHS,type ListView,} from '@app/constants/list-views';-import { useHotkeyInterceptor } from '@app/signal/hotkeyRoot';-import { globalSplitManager } from '@app/signal/splitLayout';-import { Hotkey } from '@core/component/Hotkey';-import { ContextMenuContent, MenuItem } from '@core/component/Menu';import { LabelAndHotKey } from '@core/component/Tooltip';-import { ENABLE_CALLS, LOCAL_ONLY } from '@core/constant/featureFlags';+import { createMenuOpen, setCreateMenuOpen } from '@app/component/Launcher';+import { CommandState } from '@app/component/command';+import { cn } from '@ui/utils/classname';+import { Button } from '@ui/components/Button';+import { useSplitLayout } from '@app/component/split-layout/layout';+import { ChannelsUnreadWidget } from '@app/component/app-sidebar/channels-unread-widget';+import { globalSplitManager } from '@app/signal/splitLayout';import { useSettingsState } from '@core/constant/SettingsState';+import type { ValidHotkey } from '@core/hotkey/types';import { registerHotkey } from '@core/hotkey/hotkeys';+import { GO_TO_COMMAND_SCOPE, GO_TO_LEADER_KEY } from '@app/constants/hotkeys';+import { debounce } from '@solid-primitives/scheduled';+import { Hotkey } from '@core/component/Hotkey';import { clearPressedKeys } from '@core/hotkey/state';-import { type HotkeyToken, TOKENS } from '@core/hotkey/tokens';-import type { ValidHotkey } from '@core/hotkey/types';import { activateClosestDOMScope } from '@core/hotkey/utils';-import BellIcon from '@icon/regular/bell.svg';-import TerminalIcon from '@icon/regular/terminal.svg';+import { type HotkeyToken, TOKENS } from '@core/hotkey/tokens';+import { ContextMenuContent, MenuItem } from '@core/component/Menu';import { ContextMenu } from '@kobalte/core/context-menu';-import LogoIcon from '@macro-icons/macro-logo.svg';+import { useAnalytics } from '@app/component/analytics-context';+import { useHotkeyInterceptor } from '@app/signal/hotkeyRoot';+import {+ InviteModal,+ setInviteModalOpen,+} from '@app/component/app-sidebar/invite-modal';+import { ENABLE_CALLS } from '@core/constant/featureFlags';import { AnimatedCallIcon } from '@macro-icons/wide/animating/call';-import { AnimatedChannelIcon } from '@macro-icons/wide/animating/channel';-import { AnimatedCommandIcon } from '@macro-icons/wide/animating/command';-import { AnimatedEmailIcon } from '@macro-icons/wide/animating/email';-import { AnimatedFileMdIcon } from '@macro-icons/wide/animating/fileMd';-import { AnimatedFolderIcon } from '@macro-icons/wide/animating/folder';-import { AnimatedGearIcon } from '@macro-icons/wide/animating/gear';-import { AnimatedInboxIcon } from '@macro-icons/wide/animating/inbox';-import { AnimatedNewSplitIcon } from '@macro-icons/wide/animating/newSplit';-import { AnimatedPlusIcon } from '@macro-icons/wide/animating/plus';-import { AnimatedSearchIcon } from '@macro-icons/wide/animating/search';-import { AnimatedSidebarIcon } from '@macro-icons/wide/animating/sidebar';-import { AnimatedStarIcon } from '@macro-icons/wide/animating/star';-import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';-import { AnimatedUsersIcon } from '@macro-icons/wide/animating/users';+import BellIcon from '@icon/regular/bell.svg';+import { useCallContextOptional } from '@channel/Call/CallContext';+import { InCallPanel } from '@channel/Call';import { useNotificationSettings } from '@notifications';-import { debounce } from '@solid-primitives/scheduled';-import { useLocation } from '@solidjs/router';-import { Button } from '@ui/components/Button';-import { cn } from '@ui/utils/classname';-import {- type Component,- createMemo,- createSignal,- For,- type JSX,- Show,-} from 'solid-js';-import { Dynamic } from 'solid-js/web';interface SidebarItem {id: ListView;@@ -133,6 +134,84 @@ export const SIDEBAR_LINKS = [export type SidebarState = 'hidden' | 'expanded' | 'slim';+/** Root sidebar `max-width` transition (see `SIDEBAR_MAX_WIDTH_TRANSITION_STYLE`). */+const SIDEBAR_MAX_WIDTH_TRANSITION_MS = 100;+const SIDEBAR_MAX_WIDTH_TRANSITION_STYLE = `max-width ease-in-out ${SIDEBAR_MAX_WIDTH_TRANSITION_MS}ms`;++/**+ * InCallPanel stays in slim layout until the sidebar shell finishes widening.+ * Uses `transitionend` on that element’s `max-width` (no timer on the happy path);+ * a short fallback timeout covers reduced-motion / no-op layout.+ */+function createInCallPanelSlimToggle(args: {+ initialSlim: boolean;+ parentOnOpenChange: (open: boolean) => void;+ getShell: () => HTMLDivElement | undefined;+}) {+ const [panelIsSlim, setPanelIsSlim] = createSignal(args.initialSlim);+ let shellEl: HTMLDivElement | undefined;+ let onMaxWidthEnd: ((e: TransitionEvent) => void) | undefined;+ let fallbackTimer: ReturnType<typeof setTimeout> | undefined;++ const detachExpandTracking = () => {+ const el = shellEl;+ const handler = onMaxWidthEnd;+ shellEl = undefined;+ onMaxWidthEnd = undefined;+ if (el && handler) {+ el.removeEventListener('transitionend', handler);+ }+ if (fallbackTimer !== undefined) {+ globalThis.clearTimeout(fallbackTimer);+ fallbackTimer = undefined;+ }+ };++ const finishExpand = () => {+ detachExpandTracking();+ setPanelIsSlim(false);+ };++ onCleanup(detachExpandTracking);++ return {+ panelIsSlim,+ handleSidebarOpenChange(open: boolean) {+ detachExpandTracking();++ if (!open) {+ setPanelIsSlim(true);+ args.parentOnOpenChange(open);+ return;+ }++ args.parentOnOpenChange(open);++ requestAnimationFrame(() => {+ const el = args.getShell();+ if (!el) {+ setPanelIsSlim(false);+ return;+ }++ const onEnd = (e: TransitionEvent) => {+ if (e.propertyName !== 'max-width' || e.target !== el) return;+ finishExpand();+ };++ shellEl = el;+ onMaxWidthEnd = onEnd;+ el.addEventListener('transitionend', onEnd);++ fallbackTimer = globalThis.setTimeout(+ finishExpand,+ SIDEBAR_MAX_WIDTH_TRANSITION_MS + 80+ );+ });+ },+ } as const;+}+type AppSidebarProps = {sidebarState?: SidebarState;onOpenChange: (open: boolean) => void;@@ -364,6 +443,7 @@ export const AppSidebar = (props: AppSidebarProps) => {const layout = useSplitLayout();const { toggleSettings } = useSettingsState();const notificationSettings = useNotificationSettings();+ const callCtx = useCallContextOptional();const showEnableNotifications = () =>notificationSettings.isSupported && notificationSettings.canPrompt();@@ -434,6 +514,14 @@ export const AppSidebar = (props: AppSidebarProps) => {const isExpanded = () => props.sidebarState === 'expanded';const isSlim = () => props.sidebarState === 'slim';++ let sidebarShell: HTMLDivElement | undefined;+ const { panelIsSlim, handleSidebarOpenChange } = createInCallPanelSlimToggle({+ initialSlim: isSlim(),+ parentOnOpenChange: props.onOpenChange,+ getShell: () => sidebarShell,+ });+const [sidebarBtnHovering, setSidebarBtnHovering] = createSignal(false);registerSidebarHotkeys({@@ -442,12 +530,15 @@ export const AppSidebar = (props: AppSidebarProps) => {setHotkeyVisible,resetHotkeysState,isSlim,- onOpenChange: props.onOpenChange,+ onOpenChange: handleSidebarOpenChange,openWithSplit: layout.openWithSplit,});return (<div+ ref={(el) => {+ sidebarShell = el ?? undefined;+ }}class={cn('group/sidebar h-full py-2 flex flex-col gap-0 mobile:absolute mobile:z-modal-content overflow-hidden',isExpanded() &&@@ -459,7 +550,7 @@ export const AppSidebar = (props: AppSidebarProps) => {)}data-expanded={isExpanded()}data-slim={isSlim()}- style={{ transition: 'max-width ease-in-out 100ms' }}+ style={{ transition: SIDEBAR_MAX_WIDTH_TRANSITION_STYLE }}><div class="flex items-center justify-between py-2 pl-2 pr-2 relative"><div class="flex items-center group/logo-area w-full">@@ -469,7 +560,7 @@ export const AppSidebar = (props: AppSidebarProps) => {<div class="grow shrink-10 min-w-0" /><Buttonclass="flex items-center justify-center rounded-xs p-0.5 px-2 bg-page [&_svg]:size-4"- onClick={() => props.onOpenChange(!isExpanded())}+ onClick={() => handleSidebarOpenChange(!isExpanded())}onMouseEnter={() => setSidebarBtnHovering(true)}onMouseLeave={() => setSidebarBtnHovering(false)}tooltip={@@ -526,11 +617,17 @@ export const AppSidebar = (props: AppSidebarProps) => {<ChannelsUnreadWidget sidebarState={props.sidebarState ?? 'expanded'} /></div>- <div class="px-2 mt-auto w-full">- <hr class="border-edge-muted mb-2" />+ <Show when={callCtx?.isInCall()}>+ <div class="px-2 mb-2 mt-auto" data-ui="in-call-panel">+ <InCallPanel isSlim={panelIsSlim} />+ </div>+ </Show>++ <div class={cn('px-2 w-full', !callCtx?.isInCall() && 'mt-auto')}>+ <hr class="border-edge-muted mb-[8px]" /></div>- <div class=" w-full px-2 flex flex-col">+ <div class="w-full px-2 flex flex-col"><Show when={showEnableNotifications()}><SidebarActionButtonlabel="Enable Notifications"@@ -539,7 +636,6 @@ export const AppSidebar = (props: AppSidebarProps) => {icon={() => <BellIcon class="size-4" />}/></Show>-<SidebarActionButtonlabel="Invite"isSlim={isSlim}@@ -571,15 +667,6 @@ export const AppSidebar = (props: AppSidebarProps) => {onClick={toggleSettings}icon={AnimatedGearIcon}/>-- <Show when={LOCAL_ONLY && gitBranch()}>- <SidebarActionButton- label="Dev Toolbar"- isSlim={isSlim}- onClick={() => setDevStatusBarOpen((v) => !v)}- icon={TerminalIcon}- />- </Show></div><InviteModal /></div>@@ -699,9 +786,12 @@ const SidebarLink = (props: SidebarLinkProps) => {<Dynamic component={props.icon} triggerAnimation={isHovering()} /></div></Show>- <span class="whitespace-nowrap group-data-[slim=true]/sidebar:invisible">- {props.label}- </span>++ <div class="flex items-center gap-1">+ <span class="whitespace-nowrap group-data-[slim=true]/sidebar:invisible">+ {props.label}+ </span>+ </div><Show when={isHovering() && !props.hotkeyVisible}><div class="group-data-[slim=true]/sidebar:invisible ml-auto">@@ -710,8 +800,7 @@ const SidebarLink = (props: SidebarLinkProps) => {<div class="text-xxs text-ink-extra-muted rounded-sm ml-auto border border-ink/5 px-1.5 py-0.5 -my-1"><Hotkey shortcut={GO_TO_LEADER_KEY} /></div>- then- <div class="text-xxs text-ink-extra-muted rounded-sm ml-auto border border-ink/5 px-1.5 py-0.5 -my-1">+ <div class="text-[0.625rem] text-ink-extra-muted rounded-sm ml-auto border border-ink/5 px-1.5 py-0.5 -my-1"><Hotkey shortcut={props.hotkey} /></div></Show>diff --git a/js/app/packages/block-call/component/CallBlockAdapter.tsx b/js/app/packages/block-call/component/CallBlockAdapter.tsxindex d26c77771c..902ef57269 100644--- a/js/app/packages/block-call/component/CallBlockAdapter.tsx+++ b/js/app/packages/block-call/component/CallBlockAdapter.tsx@@ -2,14 +2,9 @@ import { useBlockId } from '@core/block';import Unauthorized from '@core/component/AccessErrorViews/Unauthorized';import { MaybeResultError } from '@core/util/maybeResult';import { useCallRecordQuery } from '@queries/call/call';-import { createSignal, Match, Show, Switch } from 'solid-js';-import { CallTranscript } from './CallTranscript';-import type { CallRecord } from '@service-storage/generated/schemas/callRecord';-import { format } from 'date-fns';-import PhoneCallIcon from '@macro-icons/wide/call.svg';-import ChevronDownIcon from '@icon/regular/caret-down.svg?component-solid';-import { cn } from '@ui/utils/classname';-import { formatCallDuration } from '../utils';+import { Match, Switch } from 'solid-js';+import { CallRecordingBody } from './CallRecording/CallRecordingBody';+import { CallRecordingSplitHeaderLoading } from './CallRecording/CallRecordingSplitHeader';function isUnauthorized(error: Error | null): boolean {if (error instanceof MaybeResultError) {@@ -18,135 +13,41 @@ function isUnauthorized(error: Error | null): boolean {return false;}-function formatCallDate(dateStr: string): string {- return format(new Date(dateStr), 'MMM d, yyyy h:mm a');-}--function CallSummary(props: { summary: string }) {- const [expanded, setExpanded] = createSignal(true);- return (- <div class="px-4 py-3 border-b border-edge">- <button- type="button"- class="flex items-center gap-1.5 text-xs font-medium text-ink-muted hover:text-ink"- aria-expanded={expanded()}- onClick={() => setExpanded((prev) => !prev)}- >- <ChevronDownIcon- class={cn('w-3 h-3 transition-transform duration-100', {- 'rotate-180': expanded(),- '-rotate-90': !expanded(),- })}- />- <span>AI summary</span>- </button>- <Show when={expanded()}>- <div class="mt-2 text-sm text-ink whitespace-pre-wrap">- {props.summary}- </div>- </Show>- </div>- );-}--function CallHeader(props: { record: CallRecord }) {- return (- <div class="px-4 py-3 border-b border-edge shrink-0 flex items-center gap-3">- <PhoneCallIcon class="size-5 text-ink-muted shrink-0" />- <div class="flex flex-col min-w-0">- <h2 class="text-sm font-medium text-ink truncate">- {props.record.customName ?? props.record.channelName ?? 'Call'}- </h2>- <div class="flex items-center gap-2 text-xs text-ink-muted">- <Show when={props.record.endedAt}>- {(endedAt) => <span>{formatCallDate(endedAt())}</span>}- </Show>- <Show when={props.record.durationMs}>- {(ms) => (- <>- <span>·</span>- <span>{formatCallDuration(ms())}</span>- </>- )}- </Show>- <Show when={props.record.isActive}>- <span class="text-success font-medium">In progress</span>- </Show>- </div>- </div>- </div>- );-}-export function CallBlockAdapter() {const callId = useBlockId();const callRecord = useCallRecordQuery(() => callId);return (- <div class="h-full flex flex-col overflow-hidden">- <Show- when={callRecord.data}- fallback={- <div class="px-4 py-3 border-b border-edge shrink-0">- <h2 class="text-sm font-medium text-ink">Call Recording</h2>- </div>- }- >- {(data) => <CallHeader record={data()} />}- </Show>- <div class="flex-1 overflow-y-auto">- <Switch>- <Match when={callRecord.isLoading}>- <div class="flex items-center justify-center h-full text-ink-faint text-sm">+ <div class="h-full flex flex-col @container">+ <Switch>+ <Match when={callRecord.data}>+ {(data) => <CallRecordingBody data={data} />}+ </Match>+ <Match when={callRecord.isLoading}>+ <>+ <CallRecordingSplitHeaderLoading />+ <div class="flex flex-1 min-h-0 items-center justify-center text-sm text-ink-faint">Loading call...</div>- </Match>- <Match when={callRecord.isError && isUnauthorized(callRecord.error)}>- <Unauthorized />- </Match>- <Match when={callRecord.isError}>- <div class="flex items-center justify-center h-full text-failure text-sm">+ </>+ </Match>+ <Match when={callRecord.isError && isUnauthorized(callRecord.error)}>+ <>+ <CallRecordingSplitHeaderLoading />+ <div class="flex flex-1 min-h-0 overflow-hidden">+ <Unauthorized />+ </div>+ </>+ </Match>+ <Match when={callRecord.isError}>+ <>+ <CallRecordingSplitHeaderLoading />+ <div class="flex flex-1 min-h-0 items-center justify-center text-sm text-failure">Failed to load call recording.</div>- </Match>- <Match when={callRecord.data}>- {(data) => (- <>- <Show when={data().recordingUrl}>- {(url) => (- <div class="p-4 border-b border-edge flex justify-center">- <video- class="w-3/4 rounded"- controls- crossorigin="anonymous"- src={url()}- />- </div>- )}- </Show>- <Show when={data().summary}>- {(summary) => <CallSummary summary={summary()} />}- </Show>- <Show- when={data().transcript.length > 0}- fallback={- <Show when={!data().recordingUrl && !data().summary}>- <div class="flex items-center justify-center h-full text-ink-faint text-sm">- No recording or transcript available.- </div>- </Show>- }- >- <CallTranscript- transcript={data().transcript}- channelId={data().channelId}- />- </Show>- </>- )}- </Match>- </Switch>- </div>+ </>+ </Match>+ </Switch></div>);}diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingBody.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingBody.tsxnew file mode 100644index 0000000000..578c718061--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingBody.tsx@@ -0,0 +1,215 @@+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';+import type { Accessor } from 'solid-js';+import {+ createEffect,+ createMemo,+ createSignal,+ onCleanup,+ untrack,+} from 'solid-js';+import { cn } from '@ui/utils/classname';+import {+ getActiveTranscriptSequenceNum,+ sortTranscriptSegments,+} from '../transcript-playback';+import {+ CallRecordingMediaColumn,+ type CallRecordingTimeUpdateSource,+} from './CallRecordingMediaColumn';+import { CallRecordingMetaStrip } from './CallRecordingMetaStrip';+import { CallRecordingSplitHeader } from './CallRecordingSplitHeader';+import { CallRecordingTranscriptColumn } from './CallRecordingTranscriptColumn';+import {+ isCallRecordingStackedLayout,+ seekDedupeKey,+ shouldCoalesceSeekGenerationBump,+} from './call-recording-utils';++export function CallRecordingBody(props: { data: Accessor<CallRecord> }) {+ const record = props.data;+ const hasTranscripts = createMemo(() => record().transcript.length > 0);+ const [playbackSeconds, setPlaybackSeconds] = createSignal(0);+ const [allowFutureLead, setAllowFutureLead] = createSignal(true);+ const [videoRef, setVideoRef] = createSignal<HTMLVideoElement>();+ const [containerRef, setContainerRef] = createSignal<HTMLDivElement>();+ const [isStacked, setIsStacked] = createSignal(false);+ const sortedTranscript = createMemo(() =>+ sortTranscriptSegments(record().transcript)+ );++ const [transcriptOpen, setTranscriptOpen] = createSignal(true);+ const [participantsOpen, setParticipantsOpen] = createSignal(false);+ const [layoutDefaultsSeeded, setLayoutDefaultsSeeded] = createSignal(false);+ const [suppressWideParticipantsMotion, setSuppressWideParticipantsMotion] =+ createSignal(false);+ const [participantsContentRef, setParticipantsContentRef] =+ createSignal<HTMLDivElement>();+ const [participantsContentHeight, setParticipantsContentHeight] =+ createSignal(0);+ const [videoSeekGeneration, setVideoSeekGeneration] = createSignal(0);+ let lastVideoSeekBumpKey: string | null = null;+ let lastVideoSeekBumpAtMs = 0;+ let prevLayoutStacked: boolean | undefined;++ const bumpVideoSeekGeneration = (seconds: number) => {+ if (!Number.isFinite(seconds)) return;+ const key = seekDedupeKey(seconds);+ const now = performance.now();+ if (+ shouldCoalesceSeekGenerationBump(+ key,+ now,+ lastVideoSeekBumpKey,+ lastVideoSeekBumpAtMs+ )+ )+ return;+ lastVideoSeekBumpKey = key;+ lastVideoSeekBumpAtMs = now;+ setVideoSeekGeneration((n) => n + 1);+ };++ const activeSequenceNum = createMemo(() =>+ getActiveTranscriptSequenceNum(+ sortedTranscript(),+ playbackSeconds(),+ allowFutureLead()+ )+ );++ const handleTimeUpdate = (+ seconds: number,+ source: CallRecordingTimeUpdateSource+ ) => {+ setPlaybackSeconds(seconds);+ setAllowFutureLead(source === 'playback');+ if (source === 'seeked') bumpVideoSeekGeneration(seconds);+ };++ const seekToSeconds = (seconds: number) => {+ const video = videoRef();+ if (!video || !Number.isFinite(seconds)) return;+ const maxTime = Number.isFinite(video.duration) ? video.duration : seconds;+ const targetSeconds = Math.max(0, Math.min(seconds, maxTime));+ video.currentTime = targetSeconds;+ setPlaybackSeconds(targetSeconds);+ setAllowFutureLead(false);+ };++ const toggleTranscript = () => {+ setTranscriptOpen((open) => {+ const next = !open;+ if (next && isStacked()) setParticipantsOpen(false);+ return next;+ });+ };++ const toggleParticipants = () => {+ setParticipantsOpen((open) => {+ const next = !open;+ if (next && isStacked()) setTranscriptOpen(false);+ return next;+ });+ };++ createEffect(() => {+ const el = containerRef();+ if (!el) return;++ const updateLayout = () => {+ const stacked = isCallRecordingStackedLayout(el.clientWidth);+ setIsStacked(stacked);++ if (!layoutDefaultsSeeded()) {+ if (!stacked) setSuppressWideParticipantsMotion(true);+ setParticipantsOpen(!stacked);+ setLayoutDefaultsSeeded(true);+ prevLayoutStacked = stacked;+ queueMicrotask(() => setSuppressWideParticipantsMotion(false));+ return;+ }++ const prev = prevLayoutStacked;+ if (prev !== undefined && prev !== stacked) {+ if (stacked) {+ if (transcriptOpen() && participantsOpen())+ setParticipantsOpen(false);+ } else {+ setSuppressWideParticipantsMotion(true);+ setTranscriptOpen(hasTranscripts());+ setParticipantsOpen(true);+ queueMicrotask(() => setSuppressWideParticipantsMotion(false));+ }+ }++ prevLayoutStacked = stacked;+ };++ const observer = new ResizeObserver(updateLayout);+ observer.observe(el);+ untrack(() => updateLayout());+ onCleanup(() => observer.disconnect());+ });++ createEffect(() => {+ const el = participantsContentRef();+ if (!el) return;+ const updateHeight = () => setParticipantsContentHeight(el.scrollHeight);+ updateHeight();+ const observer = new ResizeObserver(updateHeight);+ observer.observe(el);+ onCleanup(() => observer.disconnect());+ });++ return (+ <>+ <CallRecordingSplitHeader record={record} />+ <CallRecordingMetaStrip+ record={record()}+ transcriptOpen={transcriptOpen()}+ participantsOpen={participantsOpen()}+ onToggleTranscript={toggleTranscript}+ onToggleParticipants={toggleParticipants}+ />+ <div+ ref={setContainerRef}+ class={cn(+ 'grid min-h-0 flex-1 overflow-hidden grid-cols-1',+ isStacked()+ ? 'grid-rows-1'+ : 'transition-[grid-template-columns] duration-300 linear grid-rows-1',+ !isStacked() &&+ (transcriptOpen()+ ? 'grid-cols-[minmax(0,6fr)_minmax(0,4fr)]'+ : 'grid-cols-[minmax(0,1fr)_minmax(0,0fr)]')+ )}+ >+ <div class="contents @[860px]:contents">+ <CallRecordingMediaColumn+ record={record}+ hasTranscripts={hasTranscripts}+ isStacked={isStacked}+ participantsOpen={participantsOpen}+ suppressWideParticipantsMotion={suppressWideParticipantsMotion}+ participantsContentHeight={participantsContentHeight}+ setParticipantsContentRef={setParticipantsContentRef}+ onTimeUpdate={handleTimeUpdate}+ setVideoRef={setVideoRef}+ />+ <CallRecordingTranscriptColumn+ record={record}+ hasTranscripts={hasTranscripts}+ isStacked={isStacked}+ transcriptOpen={transcriptOpen}+ participantsOpen={participantsOpen}+ activeSequenceNum={activeSequenceNum}+ videoSeekGeneration={videoSeekGeneration}+ onToggleTranscript={toggleTranscript}+ onToggleParticipants={toggleParticipants}+ onSeekToSeconds={seekToSeconds}+ />+ </div>+ </div>+ </>+ );+}diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingMediaColumn.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingMediaColumn.tsxnew file mode 100644index 0000000000..0bfc5fda67--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingMediaColumn.tsx@@ -0,0 +1,83 @@+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';+import type { Accessor, Setter } from 'solid-js';+import { Show } from 'solid-js';+import { cn } from '@ui/utils/classname';+import { CallRecordingParticipantsSection } from './CallRecordingParticipants';+import { CallRecordingVideo } from './CallRecordingVideo';++export type CallRecordingTimeUpdateSource = 'playback' | 'seeking' | 'seeked';++/** Left column: recording video, fallbacks, and wide-mode participants slide. */+export function CallRecordingMediaColumn(props: {+ record: Accessor<CallRecord>;+ hasTranscripts: Accessor<boolean>;+ isStacked: Accessor<boolean>;+ participantsOpen: Accessor<boolean>;+ suppressWideParticipantsMotion: Accessor<boolean>;+ participantsContentHeight: Accessor<number>;+ setParticipantsContentRef: Setter<HTMLDivElement | undefined>;+ onTimeUpdate: (+ seconds: number,+ source: CallRecordingTimeUpdateSource+ ) => void;+ setVideoRef: Setter<HTMLVideoElement | undefined>;+}) {+ return (+ <div class="flex min-h-0 min-w-0 flex-col overflow-hidden @[860px]:min-h-0 @[860px]:min-w-0 @[860px]:overflow-hidden">+ <Show when={props.record().recordingUrl}>+ {(url) => (+ <div class="min-h-0 flex-1 overflow-hidden">+ <CallRecordingVideo+ url={url()}+ onTimeUpdate={props.onTimeUpdate}+ setVideoRef={props.setVideoRef}+ />+ </div>+ )}+ </Show>+ <Show when={!props.record().recordingUrl}>+ <Show+ when={props.hasTranscripts()}+ fallback={+ <div class="flex min-h-0 flex-1 items-center justify-center px-4 text-center text-sm text-ink-faint">+ No recording or transcript available.+ </div>+ }+ >+ <div class="flex min-h-[120px] flex-1 items-center justify-center px-4 text-center text-sm text-ink-faint">+ No video recording for this call.+ </div>+ </Show>+ </Show>++ <div+ class={cn(+ 'overflow-hidden @[860px]:block',+ props.isStacked() ? 'hidden' : 'block',+ props.suppressWideParticipantsMotion()+ ? 'transition-none'+ : 'transition-[max-height] duration-300 ease-out'+ )}+ style={{+ 'max-height': props.participantsOpen()+ ? `${props.participantsContentHeight()}px`+ : '0px',+ }}+ >+ <div+ ref={props.setParticipantsContentRef}+ class={cn(+ props.suppressWideParticipantsMotion()+ ? 'transition-none'+ : 'transition-[transform,opacity] duration-300 ease-out will-change-transform',+ props.participantsOpen()+ ? 'translate-y-0 opacity-100'+ : 'translate-y-4 opacity-0 pointer-events-none'+ )}+ >+ <CallRecordingParticipantsSection record={props.record} />+ </div>+ </div>+ </div>+ );+}diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingMetaStrip.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingMetaStrip.tsxnew file mode 100644index 0000000000..5635185c87--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingMetaStrip.tsx@@ -0,0 +1,94 @@+import { formatCallDuration } from '../../utils';+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';+import Subtitles from '@phosphor-icons/core/assets/regular/subtitles.svg';+import SubtitlesSlash from '@phosphor-icons/core/assets/regular/subtitles-slash.svg';+import UserCircle from '@phosphor-icons/core/assets/regular/user-circle.svg';+import UserCircleMinus from '@phosphor-icons/core/assets/regular/user-circle-minus.svg';+import { cn } from '@ui/utils/classname';+import { format } from 'date-fns';+import { Show } from 'solid-js';+import {+ CALL_META_STRIP_TOGGLE_ACTIVE,+ CALL_META_STRIP_TOGGLE_IDLE,+} from './call-recording-utils';++function formatCallDate(dateStr: string): string {+ return format(new Date(dateStr), 'MMM d, yyyy h:mm a');+}++export function CallRecordingMetaStrip(props: {+ record: CallRecord;+ transcriptOpen: boolean;+ participantsOpen: boolean;+ onToggleTranscript: () => void;+ onToggleParticipants: () => void;+}) {+ return (+ <div class="flex shrink-0 items-center justify-between gap-3 border-b border-edge-muted/50 px-4 py-2">+ <div class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-ink-muted">+ <Show when={props.record.endedAt}>+ {(endedAt) => <span>{formatCallDate(endedAt())}</span>}+ </Show>+ <Show when={props.record.durationMs}>+ {(ms) => (+ <>+ <span>·</span>+ <span>{formatCallDuration(ms())}</span>+ </>+ )}+ </Show>+ <Show when={props.record.isActive}>+ <span class="text-success font-medium">In progress</span>+ </Show>+ </div>+ <div class="flex items-center gap-1.5">+ <button+ type="button"+ class={cn(+ 'shrink-0',+ props.transcriptOpen+ ? CALL_META_STRIP_TOGGLE_ACTIVE+ : CALL_META_STRIP_TOGGLE_IDLE+ )}+ aria-expanded={props.transcriptOpen}+ aria-label={+ props.transcriptOpen ? 'Hide transcript' : 'Show transcript'+ }+ title={props.transcriptOpen ? 'Hide transcript' : 'Show transcript'}+ onClick={() => props.onToggleTranscript()}+ >+ <Show when={props.transcriptOpen}>+ <Subtitles class="size-4 shrink-0" />+ </Show>+ <Show when={!props.transcriptOpen}>+ <SubtitlesSlash class="size-4 shrink-0" />+ </Show>+ </button>+ <button+ type="button"+ class={cn(+ 'shrink-0',+ props.participantsOpen+ ? CALL_META_STRIP_TOGGLE_ACTIVE+ : CALL_META_STRIP_TOGGLE_IDLE+ )}+ aria-expanded={props.participantsOpen}+ aria-label={+ props.participantsOpen ? 'Hide participants' : 'Show participants'+ }+ title={+ props.participantsOpen ? 'Hide participants' : 'Show participants'+ }+ onClick={() => props.onToggleParticipants()}+ >+ <Show when={props.participantsOpen}>+ <UserCircle class="size-4 shrink-0" />+ </Show>+ <Show when={!props.participantsOpen}>+ <UserCircleMinus class="size-4 shrink-0" />+ </Show>+ </button>+ </div>+ </div>+ );+}diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingParticipants.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingParticipants.tsxnew file mode 100644index 0000000000..074283fa51--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingParticipants.tsx@@ -0,0 +1,102 @@+import { useSplitLayout } from '@app/component/split-layout/layout';+import { UserIcon } from '@core/component/UserIcon';+import { idToEmail } from '@core/user';+import { isOk } from '@core/util/maybeResult';+import { ParticipantsEmptyState } from '@channel/Participants/ParticipantsEmptyState';+import { ParticipantsSearchInput } from '@channel/Participants/ParticipantsSearchInput';+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';+import { commsServiceClient } from '@service-comms/client';+import UsersThree from '@phosphor-icons/core/assets/regular/users-three.svg';+import type { Accessor } from 'solid-js';+import { For, Show, createMemo, createSignal } from 'solid-js';+import { CallRecordingSectionShell } from './CallRecordingSectionShell';+import { dedupeCallRecordingParticipants } from './call-recording-utils';++export function CallRecordingParticipantsSection(props: {+ record: Accessor<CallRecord>;+ withShell?: boolean;+ open?: boolean;+}) {+ const { replaceOrInsertSplit } = useSplitLayout();+ const [searchQuery, setSearchQuery] = createSignal('');+ const participants = createMemo(() =>+ dedupeCallRecordingParticipants(+ props.record().participants,+ props.record().createdBy+ )+ );+ const filteredParticipants = createMemo(() => {+ const query = searchQuery().trim().toLowerCase();+ if (query.length === 0) return participants();+ return participants().filter((participant) => {+ const email = idToEmail(participant.userId).toLowerCase();+ return (+ email.includes(query) ||+ participant.userId.toLowerCase().includes(query) ||+ participant.role.includes(query)+ );+ });+ });++ const openDirectMessage = async (participantId: string) => {+ const result = await commsServiceClient.getOrCreateDirectMessage({+ recipient_id: participantId,+ });+ const channelId = isOk(result) && result[1]?.channel_id;+ if (!channelId) return;+ replaceOrInsertSplit({+ type: 'channel',+ id: channelId,+ });+ };++ const body = (+ <div class="min-h-0 flex h-full flex-col gap-2 p-4 pt-3">+ <ParticipantsSearchInput value={searchQuery()} onInput={setSearchQuery} />+ <Show+ when={filteredParticipants().length > 0}+ fallback={<ParticipantsEmptyState searchQuery={searchQuery()} />}+ >+ <div class="min-h-0 flex-1 overflow-y-auto scrollbar-hidden">+ <div class="flex flex-col border-t border-edge-muted/50">+ <For each={filteredParticipants()}>+ {(participant) => (+ <button+ type="button"+ class="flex items-center gap-2 min-h-10 px-2 py-2 text-sm w-full border-b border-edge-muted/50 last:border-b-0 hover:bg-hover/30 text-left cursor-pointer"+ onClick={() => openDirectMessage(participant.userId)}+ >+ <div class="shrink-0">+ <UserIcon+ id={participant.userId}+ size="xs"+ isDeleted={false}+ />+ </div>+ <span class="font-semibold truncate flex-1 text-ink">+ {idToEmail(participant.userId)}+ </span>+ <span class="text-xs font-mono text-ink-extra-muted uppercase font-light shrink-0">+ {participant.role}+ </span>+ </button>+ )}+ </For>+ </div>+ </div>+ </Show>+ </div>+ );++ if (props.withShell === false) return body;++ return (+ <CallRecordingSectionShell+ title="Participants"+ icon={<UsersThree class="size-4 text-ink shrink-0" />}+ open={props.open}+ >+ {body}+ </CallRecordingSectionShell>+ );+}diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingSectionShell.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingSectionShell.tsxnew file mode 100644index 0000000000..94388f84ec--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingSectionShell.tsx@@ -0,0 +1,155 @@+import Eye from '@phosphor-icons/core/assets/regular/eye.svg';+import EyeSlash from '@phosphor-icons/core/assets/regular/eye-slash.svg';+import UserCircle from '@phosphor-icons/core/assets/regular/user-circle.svg';+import UserCircleMinus from '@phosphor-icons/core/assets/regular/user-circle-minus.svg';+import { cn } from '@ui/utils/classname';+import type { JSX } from 'solid-js';+import {+ Show,+ createEffect,+ createMemo,+ createSignal,+ onCleanup,+} from 'solid-js';++export function CallRecordingSectionShell(props: {+ title: string;+ icon: JSX.Element;+ children: JSX.Element;+ class?: string;+ open?: boolean;+ accordion?: boolean;+ /** Used only for stacked accordion mode: cap open height as a % of the viewport height. */+ accordionOpenMaxVh?: number;+ onToggle?: () => void;+ toggleIconOpen?: JSX.Element;+ toggleIconClosed?: JSX.Element;+ toggleLabelOpen?: string;+ toggleLabelClosed?: string;+}) {+ const isOpen = () => props.open ?? true;+ const [viewportResizeTick, setViewportResizeTick] = createSignal(0);++ const accordionOpenCapPx = createMemo(() => {+ viewportResizeTick();+ if (!props.accordion) return Number.POSITIVE_INFINITY;+ if (typeof window === 'undefined') return Number.POSITIVE_INFINITY;+ const vh = props.accordionOpenMaxVh ?? 45;+ return Math.max(0, (window.innerHeight * vh) / 100);+ });++ createEffect(() => {+ if (!props.accordion) return;+ const onResize = () => setViewportResizeTick((n) => n + 1);+ window.addEventListener('resize', onResize);+ onCleanup(() => window.removeEventListener('resize', onResize));+ });++ const toggleLabel = () =>+ isOpen()+ ? (props.toggleLabelOpen ?? `Hide ${props.title.toLowerCase()}`)+ : (props.toggleLabelClosed ?? `Show ${props.title.toLowerCase()}`);+ return (+ <div+ class={cn(+ 'min-h-0 overflow-hidden border-t border-edge-muted/50',+ props.class,+ props.accordion+ ? 'flex shrink-0 flex-col'+ : 'flex flex-col @[860px]:flex-1',+ !props.accordion && (isOpen() ? 'flex-1' : 'shrink-0')+ )}+ >+ <Show+ when={props.accordion && props.onToggle}+ fallback={+ <div class="isolate flex shrink-0 items-center gap-2 sticky top-0 bg-panel z-10 px-4 py-2 @[860px]:py-4 border-b border-edge-muted/50">+ {props.icon}+ <p class="font-semibold text-ink select-none text-sm shrink-0">+ {props.title}+ </p>+ <Show when={props.onToggle}>+ <button+ type="button"+ class="ml-auto shrink-0 rounded-xs border border-edge-muted/50 px-2 py-1 text-xs font-medium text-ink-muted cursor-pointer hover:bg-hover/30 hover:text-ink flex items-center gap-1.5 transition-colors"+ aria-expanded={props.open}+ aria-label={toggleLabel()}+ title={toggleLabel()}+ onClick={() => props.onToggle?.()}+ >+ <Show+ when={props.open}+ fallback={+ props.toggleIconClosed ?? (+ <UserCircleMinus class="size-4 shrink-0" />+ )+ }+ >+ {props.toggleIconOpen ?? (+ <UserCircle class="size-4 shrink-0" />+ )}+ </Show>+ </button>+ </Show>+ </div>+ }+ >+ <button+ type="button"+ class="isolate sticky top-0 z-10 flex w-full min-w-0 shrink-0 cursor-pointer items-center gap-2 border-b border-edge-muted/50 bg-panel px-4 py-2 text-left @[860px]:py-4 hover:bg-hover/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 focus-visible:ring-offset-0"+ aria-expanded={props.open}+ aria-label={toggleLabel()}+ title={toggleLabel()}+ onClick={() => props.onToggle?.()}+ >+ {props.icon}+ <p class="min-w-0 flex-1 font-semibold text-ink select-none text-sm truncate">+ {props.title}+ </p>+ <span class="ml-auto flex shrink-0 items-center text-ink-muted">+ <Show+ when={isOpen()}+ fallback={<EyeSlash class="size-4 shrink-0" />}+ >+ <Eye class="size-4 shrink-0" />+ </Show>+ </span>+ </button>+ </Show>+ <div+ class={cn(+ 'min-h-0 overflow-hidden',+ props.accordion+ ? cn(+ 'transition-[max-height] duration-300 ease-in-out',+ isOpen() ? '' : 'pointer-events-none'+ )+ : cn(+ 'transition-[max-height,transform,opacity] duration-300 ease-out @[860px]:transition-none @[860px]:max-h-none @[860px]:opacity-100 @[860px]:translate-y-0',+ isOpen()+ ? 'flex min-h-0 flex-1 flex-col max-h-[100dvh] translate-y-0 opacity-100 @[860px]:h-full @[860px]:max-h-none'+ : 'max-h-0 translate-y-2 opacity-0 pointer-events-none'+ )+ )}+ style={+ props.accordion+ ? {+ 'max-height': isOpen() ? `${accordionOpenCapPx()}px` : '0px',+ }+ : undefined+ }+ >+ <div+ class={cn(+ 'min-h-0 overflow-hidden',+ props.accordion+ ? 'flex h-full max-h-full flex-1 flex-col'+ : 'flex min-h-0 flex-1 flex-col @[860px]:h-full @[860px]:min-h-0'+ )}+ >+ {props.children}+ </div>+ </div>+ </div>+ );+}diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingSplitHeader.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingSplitHeader.tsxnew file mode 100644index 0000000000..f63db89509--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingSplitHeader.tsx@@ -0,0 +1,42 @@+import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';+import { StaticSplitLabel } from '@app/component/split-layout/components/SplitLabel';+import PhoneCallIcon from '@macro-icons/wide/call.svg';+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';+import type { Accessor } from 'solid-js';++export function CallRecordingSplitHeaderLoading() {+ return (+ <SplitHeaderLeft>+ <div class="h-full my-auto flex min-w-0 items-center justify-start gap-3">+ <div class="ph-no-capture z-3 relative flex h-full max-w-full min-w-0 shrink items-center gap-2">+ <StaticSplitLabel+ label="Call Recording"+ icon={+ <PhoneCallIcon class="size-4 touch:size-6 shrink-0 text-ink-muted" />+ }+ />+ </div>+ </div>+ </SplitHeaderLeft>+ );+}++export function CallRecordingSplitHeader(props: {+ record: Accessor<CallRecord>;+}) {+ const record = props.record;+ return (+ <SplitHeaderLeft>+ <div class="h-full my-auto flex min-w-0 items-center justify-start gap-3">+ <div class="ph-no-capture z-3 relative flex h-full max-w-full min-w-0 shrink items-center gap-2">+ <StaticSplitLabel+ label={record().channelName ?? 'Call'}+ icon={+ <PhoneCallIcon class="size-4 touch:size-6 shrink-0 text-ink-muted" />+ }+ />+ </div>+ </div>+ </SplitHeaderLeft>+ );+}diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingTranscriptColumn.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingTranscriptColumn.tsxnew file mode 100644index 0000000000..81eb4b4545--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingTranscriptColumn.tsx@@ -0,0 +1,87 @@+import Subtitles from '@phosphor-icons/core/assets/regular/subtitles.svg';+import UsersThree from '@phosphor-icons/core/assets/regular/users-three.svg';+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';+import type { Accessor } from 'solid-js';+import { Show } from 'solid-js';+import { cn } from '@ui/utils/classname';+import { CallTranscript } from '../CallTranscript';+import { CallRecordingParticipantsSection } from './CallRecordingParticipants';+import { CallRecordingSectionShell } from './CallRecordingSectionShell';++/** Right column: transcript shell + stacked participants accordion. */+export function CallRecordingTranscriptColumn(props: {+ record: Accessor<CallRecord>;+ hasTranscripts: Accessor<boolean>;+ isStacked: Accessor<boolean>;+ transcriptOpen: Accessor<boolean>;+ participantsOpen: Accessor<boolean>;+ activeSequenceNum: Accessor<number | null>;+ videoSeekGeneration: Accessor<number>;+ onToggleTranscript: () => void;+ onToggleParticipants: () => void;+ onSeekToSeconds: (seconds: number) => void;+}) {+ return (+ <div+ class={cn(+ 'relative min-h-0 min-w-0 overflow-hidden border-edge-muted/50',+ props.isStacked()+ ? 'flex min-h-0 min-w-0 flex-col'+ : 'flex min-h-0 min-w-0 flex-col border-t @[860px]:h-full @[860px]:min-h-0 @[860px]:border-t-0 @[860px]:border-l'+ )}+ >+ <Show+ when={props.hasTranscripts()}+ fallback={+ <div class="flex h-full min-h-0 w-full min-w-0 flex-1 items-center justify-center px-4 py-10 text-center text-sm text-ink-muted">+ No transcripts for this call.+ </div>+ }+ >+ <div+ class={cn(+ 'min-h-0 min-w-0 flex-1',+ props.isStacked()+ ? 'flex flex-col'+ : 'flex min-h-0 flex-1 flex-col @[860px]:h-full @[860px]:min-h-0 @[860px]:min-w-[40cqw]'+ )}+ >+ <CallRecordingSectionShell+ title="Transcript"+ icon={<Subtitles class="size-4 text-ink shrink-0" />}+ open={props.transcriptOpen()}+ accordion={props.isStacked()}+ accordionOpenMaxVh={52}+ onToggle={props.isStacked() ? props.onToggleTranscript : undefined}+ class={cn(!props.isStacked() && 'border-t-0')}+ >+ <CallTranscript+ transcript={props.record().transcript}+ channelId={props.record().channelId}+ activeSequenceNum={props.activeSequenceNum()}+ videoSeekGeneration={props.videoSeekGeneration()}+ onSeekToSeconds={props.onSeekToSeconds}+ hideHeader+ />+ </CallRecordingSectionShell>++ <Show when={props.isStacked()}>+ <CallRecordingSectionShell+ title="Participants"+ icon={<UsersThree class="size-4 text-ink shrink-0" />}+ open={props.participantsOpen()}+ accordion+ accordionOpenMaxVh={38}+ onToggle={props.onToggleParticipants}+ >+ <CallRecordingParticipantsSection+ record={props.record}+ withShell={false}+ />+ </CallRecordingSectionShell>+ </Show>+ </div>+ </Show>+ </div>+ );+}diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingVideo.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingVideo.tsxnew file mode 100644index 0000000000..4ac6c1c250--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingVideo.tsx@@ -0,0 +1,71 @@+import { createSignal, onCleanup } from 'solid-js';++export function CallRecordingVideo(props: {+ url: string;+ onTimeUpdate?: (+ seconds: number,+ source: 'playback' | 'seeking' | 'seeked'+ ) => void;+ setVideoRef?: (el: HTMLVideoElement) => void;+}) {+ const [isLoaded, setIsLoaded] = createSignal(false);+ let rafId: number | null = null;++ const stopTicking = () => {+ if (rafId !== null) {+ cancelAnimationFrame(rafId);+ rafId = null;+ }+ };++ const startTicking = (video: HTMLVideoElement) => {+ stopTicking();+ const tick = () => {+ props.onTimeUpdate?.(video.currentTime, 'playback');+ if (!video.paused && !video.ended) {+ rafId = requestAnimationFrame(tick);+ } else {+ rafId = null;+ }+ };+ rafId = requestAnimationFrame(tick);+ };+ onCleanup(stopTicking);++ return (+ <div class="p-4 h-full min-h-0 flex justify-center items-start overflow-hidden">+ <video+ ref={props.setVideoRef}+ class="max-w-full max-h-full rounded transition-opacity duration-200"+ classList={{ 'opacity-0': !isLoaded(), 'opacity-100': isLoaded() }}+ controls+ crossorigin="anonymous"+ src={props.url}+ onLoadedData={() => setIsLoaded(true)}+ onCanPlay={() => setIsLoaded(true)}+ onPlaying={(event) => {+ setIsLoaded(true);+ startTicking(event.currentTarget);+ }}+ onPlay={(event) => startTicking(event.currentTarget)}+ onPause={() => stopTicking()}+ onSeeking={(event) =>+ props.onTimeUpdate?.(event.currentTarget.currentTime, 'seeking')+ }+ onSeeked={(event) =>+ props.onTimeUpdate?.(event.currentTarget.currentTime, 'seeked')+ }+ onEnded={(event) => {+ stopTicking();+ props.onTimeUpdate?.(event.currentTarget.duration, 'playback');+ }}+ onTimeUpdate={(event) =>+ props.onTimeUpdate?.(event.currentTarget.currentTime, 'playback')+ }+ onLoadedMetadata={(event) =>+ props.onTimeUpdate?.(event.currentTarget.currentTime, 'playback')+ }+ />+ </div>+ );+}diff --git a/js/app/packages/block-call/component/CallRecording/call-recording-utils.ts b/js/app/packages/block-call/component/CallRecording/call-recording-utils.tsnew file mode 100644index 0000000000..387d3a98f3--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/call-recording-utils.ts@@ -0,0 +1,59 @@+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';++/** Matches `@container` / grid breakpoint in `CallBlockAdapter`. */+export const CALL_RECORDING_STACKED_BREAKPOINT_PX = 860;++export function isCallRecordingStackedLayout(clientWidth: number): boolean {+ return clientWidth < CALL_RECORDING_STACKED_BREAKPOINT_PX;+}++export type CallRecordingParticipantRow = {+ userId: string;+ joinedAt: string;+ role: 'organizer' | 'participant';+};++/**+ * Historic call records can list the same user more than once; keep earliest join+ * and label organizer from `createdBy`.+ */+export function dedupeCallRecordingParticipants(+ participants: CallRecord['participants'],+ createdBy: string+): CallRecordingParticipantRow[] {+ const unique = new Map<string, CallRecordingParticipantRow>();+ for (const participant of participants) {+ const prev = unique.get(participant.userId);+ if (!prev || participant.joinedAt < prev.joinedAt) {+ unique.set(participant.userId, {+ userId: participant.userId,+ joinedAt: participant.joinedAt,+ role: participant.userId === createdBy ? 'organizer' : 'participant',+ });+ }+ }+ return Array.from(unique.values()).sort((a, b) =>+ a.joinedAt.localeCompare(b.joinedAt)+ );+}++export function seekDedupeKey(seconds: number): string {+ return `${Math.round(seconds * 1000)}`;+}++export function shouldCoalesceSeekGenerationBump(+ key: string,+ nowMs: number,+ lastKey: string | null,+ lastAtMs: number,+ minIntervalMs = 45+): boolean {+ return key === lastKey && nowMs - lastAtMs < minIntervalMs;+}++/** Transcript / participants meta strip toggles when the panel is open (stacked or wide). */+export const CALL_META_STRIP_TOGGLE_ACTIVE =+ 'inline-flex items-center justify-center font-medium focus-visible:outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 bg-ink text-page not-disabled:hover:bg-ink/90 not-disabled:active:bg-ink/80 py-1 text-xs gap-1 rounded-xs [&_svg]:size-4 px-1 border border-transparent';++export const CALL_META_STRIP_TOGGLE_IDLE =+ 'flex shrink-0 items-center gap-1.5 rounded-xs border border-edge-muted/50 px-2 py-1.5 text-xs font-medium text-ink-muted cursor-pointer transition-colors hover:bg-hover/30 hover:text-ink focus-visible:outline-none';diff --git a/js/app/packages/block-call/component/CallTranscript.tsx b/js/app/packages/block-call/component/CallTranscript.tsxindex 858ff3e91c..5f7ddd26fc 100644--- a/js/app/packages/block-call/component/CallTranscript.tsx+++ b/js/app/packages/block-call/component/CallTranscript.tsx@@ -1,8 +1,22 @@import type { CallRecordTranscriptSegment } from '@service-storage/generated/schemas/callRecordTranscriptSegment';import type { ApiChannelMessage } from '@service-comms/client';+import Subtitles from '@phosphor-icons/core/assets/regular/subtitles.svg';import { Message } from '@channel/Message';import { Thread } from '@channel/Thread/Thread';-import { createMemo, For, Show } from 'solid-js';+import { CustomScrollbar } from '@core/component/CustomScrollbar';+import {+ createMemo,+ createSignal,+ createEffect,+ For,+ on,+ onCleanup,+ Show,+} from 'solid-js';+import {+ formatVideoTimestamp,+ getSegmentVideoSeconds,+} from './transcript-playback';// Match the channel message grouping window (5 minutes).const GROUPING_WINDOW_MS = 5 * 60 * 1000;@@ -44,13 +58,26 @@ function segmentToApiChannelMessage(function TranscriptSegmentRow(props: {segment: CallRecordTranscriptSegment;channelId: string;+ isActive: boolean;+ timelineStartMs: number | null;+ onSeekToSeconds?: (seconds: number) => void;}) {- const message = createMemo(() =>- segmentToApiChannelMessage(props.segment, props.channelId)+ const message = segmentToApiChannelMessage(props.segment, props.channelId);+ const videoTimestamp = getSegmentVideoSeconds(+ props.segment,+ props.timelineStartMs);return (- <Thread.Row message={message()}>- <Message.Root message={message()}>+ <Thread.Row message={message}>+ <Message.Root+ message={message}+ highlighted={props.isActive}+ selected={props.isActive}+ class="cursor-pointer"+ onClick={() => {+ if (videoTimestamp !== null) props.onSeekToSeconds?.(videoTimestamp);+ }}+ ><Message.Layout class="pt-(--regular-message-padding-t)"><Message.Slot placement="icon"><Message.SenderIcon />@@ -60,7 +87,14 @@ function TranscriptSegmentRow(props: {class="flex items-center gap-1 min-w-0"><Message.SenderName />- <Message.Timestamp class="ml-auto" />+ <span class="ml-auto text-xs text-ink-muted tabular-nums">+ <Show+ when={videoTimestamp !== null}+ fallback={<Message.Timestamp />}+ >+ {formatVideoTimestamp(videoTimestamp ?? 0)}+ </Show>+ </span></Message.Slot><Message.Slot placement="content"><div class="whitespace-pre-wrap wrap-break-word text-sm">@@ -76,13 +110,26 @@ function TranscriptSegmentRow(props: {function GroupedTranscriptSegmentRow(props: {segment: CallRecordTranscriptSegment;channelId: string;+ isActive: boolean;+ timelineStartMs: number | null;+ onSeekToSeconds?: (seconds: number) => void;}) {- const message = createMemo(() =>- segmentToApiChannelMessage(props.segment, props.channelId)+ const message = segmentToApiChannelMessage(props.segment, props.channelId);+ const videoTimestamp = getSegmentVideoSeconds(+ props.segment,+ props.timelineStartMs);return (- <Thread.Row message={message()}>- <Message.Root message={message()}>+ <Thread.Row message={message}>+ <Message.Root+ message={message}+ highlighted={props.isActive}+ selected={props.isActive}+ class="cursor-pointer"+ onClick={() => {+ if (videoTimestamp !== null) props.onSeekToSeconds?.(videoTimestamp);+ }}+ ><Message.Layout><Message.Slot placement="icon"><Message.SenderIcon hidden />@@ -101,37 +148,259 @@ function GroupedTranscriptSegmentRow(props: {export function CallTranscript(props: {transcript: CallRecordTranscriptSegment[];channelId: string;+ activeSequenceNum?: number | null;+ /** Bumps when the user seeks via the native video controls (deduped in CallBlockAdapter). */+ videoSeekGeneration?: number;+ onSeekToSeconds?: (seconds: number) => void;+ hideHeader?: boolean;}) {- const items = createMemo<SegmentItem[]>(() => {+ const [scrollRef, setScrollRef] = createSignal<HTMLElement>();+ const [syncToVideoTime, setSyncToVideoTime] = createSignal(true);+ const [isActiveRowInView, setIsActiveRowInView] = createSignal(true);+ const rowRefs = new Map<number, HTMLDivElement>();+ let ignoreScrollUntil = 0;++ const transcriptMeta = createMemo(() => {const sorted = [...props.transcript].sort((a, b) => a.sequenceNum - b.sequenceNum);- return sorted.map((segment, index) => ({+ const items: SegmentItem[] = sorted.map((segment, index) => ({segment,groupedWithPrevious: shouldGroupWithPrevious(segment, sorted[index - 1]),}));+ if (sorted.length === 0) return { items, timelineStartMs: null };++ const firstStartMs = new Date(sorted[0].startedAt).getTime();+ return {+ items,+ timelineStartMs: Number.isFinite(firstStartMs) ? firstStartMs : null,+ };+ });++ const scrollActiveIntoView = (+ behavior: ScrollBehavior = 'smooth',+ opts?: { mode?: 'auto' | 'force' }+ ) => {+ const activeSequenceNum = props.activeSequenceNum;+ if (activeSequenceNum === null || activeSequenceNum === undefined) return;++ const container = scrollRef();+ const row = rowRefs.get(activeSequenceNum);+ if (!container || !row) return;++ const containerRect = container.getBoundingClientRect();+ const rowRect = row.getBoundingClientRect();+ const mode = opts?.mode ?? 'auto';++ if (mode === 'auto') {+ const isAbove = rowRect.top < containerRect.top;+ const isBelow = rowRect.bottom > containerRect.bottom;+ if (!isAbove && !isBelow) return;+ }++ const targetScrollTop =+ container.scrollTop ++ (rowRect.top - containerRect.top) -+ container.clientHeight / 2 ++ row.clientHeight / 2;++ ignoreScrollUntil = performance.now() + 350;+ container.scrollTo({+ top: Math.max(0, targetScrollTop),+ behavior,+ });+ };++ const updateActiveRowVisibility = () => {+ const activeSequenceNum = props.activeSequenceNum;+ if (activeSequenceNum === null || activeSequenceNum === undefined) {+ setIsActiveRowInView(true);+ return;+ }++ const container = scrollRef();+ const row = rowRefs.get(activeSequenceNum);+ if (!container || !row) {+ setIsActiveRowInView(false);+ return;+ }++ const containerRect = container.getBoundingClientRect();+ const rowRect = row.getBoundingClientRect();+ const intersects =+ rowRect.bottom > containerRect.top && rowRect.top < containerRect.bottom;+ setIsActiveRowInView(intersects);+ };++ const onTranscriptViewportResize = () => {+ updateActiveRowVisibility();++ // If we're following video time, keep the active row placed sensibly after layout changes.+ if (syncToVideoTime()) {+ scrollActiveIntoView('auto');+ updateActiveRowVisibility();+ return;+ }++ // If the user has disabled follow-scroll, don't fight them — unless the active row is now+ // fully scrolled out of view due to a viewport resize, in which case recover visibility.+ if (!isActiveRowInView()) {+ scrollActiveIntoView('auto');+ updateActiveRowVisibility();+ }+ };++ /** Avoid double `scrollActiveIntoView` when seek bumps `videoSeekGeneration` and active line updates in the same flush. */+ let suppressFollowScrollAfterSeek = false;++ createEffect(+ on(+ () => props.videoSeekGeneration ?? 0,+ (gen, prev) => {+ if (prev === undefined) {+ updateActiveRowVisibility();+ return;+ }+ if (gen !== prev) {+ suppressFollowScrollAfterSeek = true;+ queueMicrotask(() => {+ suppressFollowScrollAfterSeek = false;+ });+ setSyncToVideoTime(true);+ scrollActiveIntoView('smooth', { mode: 'force' });+ updateActiveRowVisibility();+ }+ }+ )+ );++ createEffect(() => {+ void props.activeSequenceNum;+ void syncToVideoTime();+ void scrollRef();++ if (suppressFollowScrollAfterSeek) {+ updateActiveRowVisibility();+ return;+ }++ if (syncToVideoTime()) {+ scrollActiveIntoView();+ }+ updateActiveRowVisibility();+ });++ createEffect(() => {+ const el = scrollRef();+ if (!el) return;++ let rafId = 0;+ const schedule = () => {+ if (rafId) cancelAnimationFrame(rafId);+ rafId = requestAnimationFrame(() => {+ rafId = 0;+ onTranscriptViewportResize();+ });+ };++ schedule();+ const observer = new ResizeObserver(schedule);+ observer.observe(el);+ onCleanup(() => {+ observer.disconnect();+ if (rafId) cancelAnimationFrame(rafId);+ });});return (- <div class="flex flex-col py-2">- <For each={items()}>- {(item) => (- <Show- when={item.groupedWithPrevious}- fallback={- <TranscriptSegmentRow- segment={item.segment}- channelId={props.channelId}- />- }- >- <GroupedTranscriptSegmentRow- segment={item.segment}- channelId={props.channelId}- />+ <div class="relative flex h-full min-h-0 flex-col overflow-hidden">+ <div class="relative flex flex-1 min-h-0 flex-col">+ <div+ ref={setScrollRef}+ class="h-full min-h-0 flex-1 overflow-y-auto scrollbar-hidden"+ onWheel={() => setSyncToVideoTime(false)}+ onTouchMove={() => setSyncToVideoTime(false)}+ onScroll={() => {+ if (performance.now() < ignoreScrollUntil) return;+ updateActiveRowVisibility();+ }}+ >+ <Show when={!props.hideHeader}>+ <div class="isolate flex items-center gap-2 sticky top-0 bg-panel z-10 px-4 py-2 @[860px]:py-4 border-b border-edge-muted/50">+ <Subtitles class="size-4 text-ink shrink-0" />+ <p class="font-semibold text-ink select-none text-sm shrink-0">+ Transcript+ </p>+ </div></Show>- )}- </For>++ <div class="flex flex-col p-4 pt-0">+ <For each={transcriptMeta().items}>+ {(item) => (+ <Show+ when={item.groupedWithPrevious}+ fallback={+ <div+ ref={(el) => rowRefs.set(item.segment.sequenceNum, el)}+ >+ <TranscriptSegmentRow+ segment={item.segment}+ channelId={props.channelId}+ isActive={+ item.segment.sequenceNum === props.activeSequenceNum+ }+ timelineStartMs={transcriptMeta().timelineStartMs}+ onSeekToSeconds={props.onSeekToSeconds}+ />+ </div>+ }+ >+ <div ref={(el) => rowRefs.set(item.segment.sequenceNum, el)}>+ <GroupedTranscriptSegmentRow+ segment={item.segment}+ channelId={props.channelId}+ isActive={+ item.segment.sequenceNum === props.activeSequenceNum+ }+ timelineStartMs={transcriptMeta().timelineStartMs}+ onSeekToSeconds={props.onSeekToSeconds}+ />+ </div>+ </Show>+ )}+ </For>+ </div>+ </div>+ </div>+ <Show+ when={+ !syncToVideoTime() &&+ !isActiveRowInView() &&+ props.activeSequenceNum !== null &&+ props.activeSequenceNum !== undefined+ }+ >+ <div+ class="absolute bottom-0 right-px left-px px-2 pb-2 flex justify-center pointer-events-none z-20"+ style={{+ 'background-image':+ 'linear-gradient(transparent, var(--color-panel) 85%)',+ }}+ >+ <button+ type="button"+ class="pointer-events-auto isolate overflow-hidden relative bg-panel border border-accent/30 flex h-8 px-2 items-center justify-center text-xs font-mono uppercase font-medium leading-5 whitespace-nowrap cursor-pointer text-accent before:absolute before:inset-0 before:bg-accent/10 hover:before:bg-accent/20 before:content-[''] before:transition-colors"+ onClick={() => {+ setSyncToVideoTime(true);+ scrollActiveIntoView('smooth');+ setIsActiveRowInView(true);+ }}+ >+ <span class="relative z-1">Sync to video time</span>+ </button>+ </div>+ </Show>+ <CustomScrollbar scrollContainer={scrollRef} /></div>);}diff --git a/js/app/packages/block-call/component/transcript-playback.ts b/js/app/packages/block-call/component/transcript-playback.tsnew file mode 100644index 0000000000..7dc284d471--- /dev/null+++ b/js/app/packages/block-call/component/transcript-playback.ts@@ -0,0 +1,65 @@+import type { CallRecordTranscriptSegment } from '@service-storage/generated/schemas/callRecordTranscriptSegment';++export function sortTranscriptSegments(+ transcript: CallRecordTranscriptSegment[]+): CallRecordTranscriptSegment[] {+ return [...transcript].sort((a, b) => a.sequenceNum - b.sequenceNum);+}++export function getActiveTranscriptSequenceNum(+ sortedTranscript: CallRecordTranscriptSegment[],+ playbackSeconds: number,+ allowFutureLead = true+): number | null {+ if (sortedTranscript.length === 0 || playbackSeconds < 0) return null;+ const firstStartMs = new Date(sortedTranscript[0].startedAt).getTime();+ if (!Number.isFinite(firstStartMs)) return null;++ // Bias slightly earlier so short segments feel responsive.+ const ACTIVE_LEAD_MS = 250;+ const rawTimelineMs = firstStartMs + playbackSeconds * 1000;+ if (rawTimelineMs < firstStartMs) return null;+ const currentTimelineMs = allowFutureLead+ ? rawTimelineMs + ACTIVE_LEAD_MS+ : rawTimelineMs;++ let activeSequenceNum: number | null = null;+ for (let i = 0; i < sortedTranscript.length; i += 1) {+ const currentStartMs = new Date(sortedTranscript[i].startedAt).getTime();+ if (!Number.isFinite(currentStartMs)) continue;++ // Use the latest segment whose start is <= playback time.+ // This handles close/identical timestamps without skipping rows.+ if (+ currentTimelineMs >= currentStartMs &&+ rawTimelineMs >= currentStartMs+ ) {+ activeSequenceNum = sortedTranscript[i].sequenceNum;+ } else {+ break;+ }+ }++ return activeSequenceNum;+}++export function formatVideoTimestamp(totalSeconds: number): string {+ const clamped = Math.max(0, Math.floor(totalSeconds));+ const hours = Math.floor(clamped / 3600);+ const minutes = Math.floor((clamped % 3600) / 60);+ const seconds = clamped % 60;+ if (hours > 0) {+ return `${hours}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;+ }+ return `${minutes}:${String(seconds).padStart(2, '0')}`;+}++export function getSegmentVideoSeconds(+ segment: CallRecordTranscriptSegment,+ timelineStartMs: number | null+): number | null {+ if (timelineStartMs === null) return null;+ const segmentStartMs = new Date(segment.startedAt).getTime();+ if (!Number.isFinite(segmentStartMs)) return null;+ return Math.max(0, (segmentStartMs - timelineStartMs) / 1000);+}diff --git a/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx b/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsxindex b098db5a9a..5bd611a45d 100644--- a/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx+++ b/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx@@ -10,11 +10,21 @@ import {} from '@channel/Channel/ChannelTabContext';import {isJoinCallRequested,+ isOpenCallTabRequested,URL_PARAMS as CHANNEL_URL_PARAMS,} from '@channel/Channel/link';import { useBlockId } from '@core/block';import { EntityPermissionsGate } from '@core/component/EntityPermissionsGate';-import { createSignal, Match, onMount, Show, Suspense, Switch } from 'solid-js';+import {+ createComputed,+ createSignal,+ Match,+ onCleanup,+ onMount,+ Show,+ Suspense,+ Switch,+} from 'solid-js';import { useSearchParams } from '@solidjs/router';import { blockHandleSignal } from '@core/signal/load';import { createMethodRegistration } from '@core/orchestrator';@@ -32,13 +42,12 @@ import {import { ChannelAttachmentsTab } from '@channel/Attachments/ChannelAttachmentsTab';import { ChannelParticipantsTab } from '@channel/Participants/ChannelParticipantsTab';import {- CallAudioSink,CallEventSync,- CallProvider,ChannelCallAutoJoin,ChannelCallButton,ChannelCallTab,useCall,+ useCallContextOptional,} from '@channel/Call';import { ENABLE_CALLS } from '@core/constant/featureFlags';import {@@ -53,6 +62,7 @@ type ChannelTargetMessageParams = {[URL_PARAMS.message]?: string;[URL_PARAMS.thread]?: string;[CHANNEL_URL_PARAMS.joinCall]?: string;+ [CHANNEL_URL_PARAMS.openCallTab]?: string;};export type BlockChannelProps = ChannelTargetMessageParams;@@ -151,11 +161,40 @@ export function NewChannelBlockAdapter(props: BlockChannelProps) {(isJoinCallRequested(props[CHANNEL_URL_PARAMS.joinCall]) ||isJoinCallRequested(searchParams[CHANNEL_URL_PARAMS.joinCall]));- const [activeTab, setActiveTab] = createSignal<ChannelTabId>(- wantsJoinCall ? 'call' : DEFAULT_CHANNEL_TAB+ const callCtx = useCallContextOptional();+ const hasActiveCallHere =+ callCtx?.isInCall() && callCtx.activeChannelId() === channelId;++ const [activeTab, setActiveTabInternal] = createSignal<ChannelTabId>(+ wantsJoinCall || hasActiveCallHere ? 'call' : DEFAULT_CHANNEL_TAB);const [pendingJoinCall, setPendingJoinCall] = createSignal(wantsJoinCall);+ /** Set when `<NewChannel>` mounts (Messages tab only); used for goToMessage. */+ const messagesChannelHandle: { current?: ChannelHandle } = {};++ const setActiveTab = (tab: ChannelTabId) => {+ if (tab !== 'messages') {+ messagesChannelHandle.current = undefined;+ }+ setActiveTabInternal(tab);+ };++ // CallContext: which channel has the Call tab selected (for isCallPage(), etc.).+ // `createComputed` (not `createEffect`) so this runs before paint and matches+ // `activeTab` on the first frame (e.g. deep-link opens on Call tab).+ createComputed(() => {+ if (isPreview || !callCtx) return;+ const tab = activeTab();+ callCtx.syncCallPageTab(channelId, tab === 'call');+ });++ // Nav away unmounts this block without switching tabs first — clear stale ownership.+ onCleanup(() => {+ if (isPreview || !callCtx) return;+ callCtx.syncCallPageTab(channelId, false);+ });+// Clear the URL param after consuming it so a reload doesn't re-trigger// the join if the user has since left the call.onMount(() => {@@ -188,6 +227,33 @@ export function NewChannelBlockAdapter(props: BlockChannelProps) {};};+ // Register on the block always — `goToLocationFromParams` used to live only+ // inside `onChannelReady` (Messages tab), so open-call from Attachments/etc. was a no-op.+ createMethodRegistration(blockHandle, {+ goToLocationFromParams: async (params: ChannelTargetMessageParams) => {+ if (isOpenCallTabRequested(params[CHANNEL_URL_PARAMS.openCallTab])) {+ setActiveTab('call');+ return;+ }++ const { targetMessageId, targetMessageReplyId } =+ convertTargetMessage(params);++ if (targetMessageId && messagesChannelHandle.current) {+ setActiveTab(DEFAULT_CHANNEL_TAB);+ await messagesChannelHandle.current.goToMessage(+ targetMessageId,+ targetMessageReplyId+ );+ }++ if (isJoinCallRequested(params[CHANNEL_URL_PARAMS.joinCall])) {+ setActiveTab('call');+ setPendingJoinCall(true);+ }+ },+ });+const initialTargetMessageParams = (): ChannelTargetMessageParams => {const hasPropsTarget =props[URL_PARAMS.message] !== undefined ||@@ -211,69 +277,44 @@ export function NewChannelBlockAdapter(props: BlockChannelProps) {};const onChannelReady = (handle: ChannelHandle) => {- createMethodRegistration(blockHandle, {- goToLocationFromParams: async (params: ChannelTargetMessageParams) => {- const { targetMessageId, targetMessageReplyId } =- convertTargetMessage(params);-- if (targetMessageId && handle) {- setActiveTab(DEFAULT_CHANNEL_TAB);- handle.goToMessage(targetMessageId, targetMessageReplyId);- }-- if (isJoinCallRequested(params[CHANNEL_URL_PARAMS.joinCall])) {- // Flip to the call tab eagerly so the user sees the "Joining- // call…" placeholder instead of whatever tab they were on.- setActiveTab('call');- setPendingJoinCall(true);- }- },- });+ messagesChannelHandle.current = handle;};return (<EntityPermissionsGate entityType="channel" entityId={channelId}>- <CallProvider>- <CallEventSync />- <ChannelTabProvider activeTab={activeTab} setActiveTab={setActiveTab}>- <ChannelCallAutoJoin- channelId={channelId}- pendingJoinCall={pendingJoinCall}- onHandled={() => setPendingJoinCall(false)}- />- <div class="h-full flex flex-col px-2 mobile:px-0">- {/*- Mounted above <Switch> so remote call audio keeps playing when- the user switches from the Call tab to Messages / Attachments /- Participants. See CallAudioSink for details.- */}- <CallAudioSink />- <Switch>- <Match when={activeTab() === 'messages'}>- <NewChannel- channelId={channelId}- onHandleReady={onChannelReady}- autofocus={!isPreview}- {...convertTargetMessage(initialTargetMessageParams())}- />- </Match>- <Match when={activeTab() === 'attachments'}>- <ChannelAttachmentsTab channelId={channelId} />- </Match>- <Match when={activeTab() === 'participants'}>- <ChannelParticipantsTab channelId={channelId} />- </Match>- <Match when={activeTab() === 'call'}>- <ChannelCallTab- channelId={channelId}- pendingJoin={pendingJoinCall}- />- </Match>- </Switch>- <NewTop channelId={channelId} />- </div>- </ChannelTabProvider>- </CallProvider>+ <CallEventSync />+ <ChannelTabProvider activeTab={activeTab} setActiveTab={setActiveTab}>+ <ChannelCallAutoJoin+ channelId={channelId}+ pendingJoinCall={pendingJoinCall}+ onHandled={() => setPendingJoinCall(false)}+ />+ <div class="h-full flex flex-col px-2 mobile:px-0">+ <Switch>+ <Match when={activeTab() === 'messages'}>+ <NewChannel+ channelId={channelId}+ onHandleReady={onChannelReady}+ autofocus={!isPreview}+ {...convertTargetMessage(initialTargetMessageParams())}+ />+ </Match>+ <Match when={activeTab() === 'attachments'}>+ <ChannelAttachmentsTab channelId={channelId} />+ </Match>+ <Match when={activeTab() === 'participants'}>+ <ChannelParticipantsTab channelId={channelId} />+ </Match>+ <Match when={activeTab() === 'call'}>+ <ChannelCallTab+ channelId={channelId}+ pendingJoin={pendingJoinCall}+ />+ </Match>+ </Switch>+ <NewTop channelId={channelId} />+ </div>+ </ChannelTabProvider></EntityPermissionsGate>);}diff --git a/js/app/packages/channel/Call/CallContext.tsx b/js/app/packages/channel/Call/CallContext.tsxindex a278d85daf..131c788261 100644--- a/js/app/packages/channel/Call/CallContext.tsx+++ b/js/app/packages/channel/Call/CallContext.tsx@@ -23,6 +23,7 @@ import {import { createStore } from 'solid-js/store';import { makePersisted } from '@solid-primitives/storage';import type { CallTokenResponse } from '@service-call/client';+import { CallAudioSink } from './CallAudioSink';export type CallParticipantInfo = {identity: string;@@ -119,6 +120,10 @@ type CallStoreState = {activeAudioOutputDeviceId: string | null;activeVideoInputDeviceId: string | null;isNoiseSuppressed: boolean;+ optimisticJoinChannelId: string | null;+ joinError: string | null;+ /** Which channel block has the Call tab selected (synced from channel UI). */+ callPageChannelId: string | null;backgroundEffect: BackgroundEffect;// Mirrors the call's `share_with_team` flag. Defaults to true to match the// server-side default for newly-created calls; synced from the toggle@@ -143,6 +148,9 @@ const initialState: CallStoreState = {activeAudioOutputDeviceId: null,activeVideoInputDeviceId: null,isNoiseSuppressed: false,+ optimisticJoinChannelId: null,+ joinError: null,+ callPageChannelId: null,backgroundEffect: { type: 'none' },isSharedWithTeam: true,};@@ -238,6 +246,29 @@ export type CallState = {isNoiseSuppressed: () => boolean;/** Toggle mic noise suppression on/off */toggleNoiseSuppression: () => Promise<void>;+ /** Begin an optimistic join to a channel */+ beginOptimisticJoin: (channelId: string) => void;+ /** Rollback an optimistic join to a channel */+ rollbackOptimisticJoin: () => void;+ /** Whether we're in the optimistic join window */+ isConnecting: () => boolean;+ /** Error message from a failed join attempt */+ joinError: () => string | null;+ /** Set the join error message */+ setJoinError: (error: string | null) => void;+ /**+ * Which channel has the Call tab focused in a channel split. `null` when no+ * channel block reports the Call tab.+ */+ callPageChannelId: () => string | null;+ /**+ * Channel blocks call this when the tab strip changes.+ */+ syncCallPageTab: (channelId: string, isCallTab: boolean) => void;+ /**+ * True when the active call and call-page channel match.+ */+ isCallPage: () => boolean;/** Current background effect (none, blur, or image) */backgroundEffect: () => BackgroundEffect;/** Set the background effect (blur with intensity or image background) */@@ -430,8 +461,12 @@ function createCallState() {}function resetState() {+ // Preserve joinError across room teardown — LiveKit can emit Disconnected+ // when the network drops or reconnects; wiping joinError would hide the+ // "Try again" UI while the user is still not in the call (empty ChannelCallTab).setStore({...initialState,+ joinError: store.joinError,backgroundEffect: persistedBackgroundEffect(),isNoiseSuppressed: persistedNoiseSuppressionPref(),});@@ -447,8 +482,11 @@ function createCallState() {r.on(RoomEvent.TrackSubscribed, bumpTrackVersion);r.on(RoomEvent.TrackUnsubscribed, bumpTrackVersion);+ r.on(RoomEvent.TrackPublished, bumpTrackVersion);+ r.on(RoomEvent.TrackUnpublished, bumpTrackVersion);r.on(RoomEvent.TrackMuted, bumpTrackVersion);r.on(RoomEvent.TrackUnmuted, bumpTrackVersion);+ r.on(RoomEvent.LocalTrackPublished, bumpTrackVersion);r.on(RoomEvent.ActiveSpeakersChanged, () => {setStore('speakerVersion', (v) => v + 1);@@ -663,6 +701,9 @@ function createCallState() {try {await targetRoom.connect(tokenResponse.serverUrl, tokenResponse.token);+ // Real connection established — optimistic flag no longer needed+ setStore('optimisticJoinChannelId', null);+ setStore('joinError', null);} catch (e) {console.error('failed to connect to LiveKit room', e);destroyRoom();@@ -800,6 +841,30 @@ function createCallState() {}}+ // --- optimistic join ---++ function beginOptimisticJoin(channelId: string) {+ // Do not clear joinError here — retries should keep the error panel visible+ // with `isJoining` until LiveKit connects (see useCall join mutation).+ setStore('optimisticJoinChannelId', channelId);+ }++ function rollbackOptimisticJoin() {+ setStore('optimisticJoinChannelId', null);+ }++ function setJoinError(error: string | null) {+ setStore('joinError', error);+ }++ function syncCallPageTab(channelId: string, isCallTab: boolean) {+ if (isCallTab) {+ setStore('callPageChannelId', channelId);+ } else if (store.callPageChannelId === channelId) {+ setStore('callPageChannelId', null);+ }+ }+async function setBackgroundEffect(effect: BackgroundEffect) {const prevEffect = store.backgroundEffect;setStore('backgroundEffect', effect);@@ -850,8 +915,11 @@ function createCallState() {// readonly stateroom,connectionState: () => store.connectionState,- isInCall: () => store.connectionState === ConnectionState.Connected,- activeChannelId: () => store.activeChannelId,+ isInCall: () =>+ store.connectionState === ConnectionState.Connected ||+ store.optimisticJoinChannelId !== null,+ activeChannelId: () =>+ store.activeChannelId ?? store.optimisticJoinChannelId,activeCallId: () => store.activeCallId,remoteParticipants: () => store.remoteParticipants,trackVersion: () => store.trackVersion,@@ -874,6 +942,7 @@ function createCallState() {activeAudioInputDeviceId: () => store.activeAudioInputDeviceId,activeAudioOutputDeviceId: () => store.activeAudioOutputDeviceId,activeVideoInputDeviceId: () => store.activeVideoInputDeviceId,+ isConnecting: () => store.optimisticJoinChannelId !== null,// mutationsconnect,@@ -886,6 +955,20 @@ function createCallState() {switchVideoInput,isNoiseSuppressed: () => store.isNoiseSuppressed,toggleNoiseSuppression,+ beginOptimisticJoin,+ rollbackOptimisticJoin,+ joinError: () => store.joinError,+ setJoinError,+ callPageChannelId: () => store.callPageChannelId,+ syncCallPageTab,+ isCallPage: () => {+ store.callPageChannelId;+ store.activeChannelId;+ store.optimisticJoinChannelId;+ const page = store.callPageChannelId;+ const active = store.activeChannelId ?? store.optimisticJoinChannelId;+ return page !== null && active !== null && page === active;+ },backgroundEffect: () => store.backgroundEffect,setBackgroundEffect,isSharedWithTeam: () => store.isSharedWithTeam,@@ -899,6 +982,9 @@ export function CallProvider(props: ParentProps) {const state = createCallState();return (- <CallContext.Provider value={state}>{props.children}</CallContext.Provider>+ <CallContext.Provider value={state}>+ {props.children}+ <CallAudioSink />+ </CallContext.Provider>);}diff --git a/js/app/packages/channel/Call/CallControls/CallControlButton.tsx b/js/app/packages/channel/Call/CallControls/CallControlButton.tsxnew file mode 100644index 0000000000..0c77da6adb--- /dev/null+++ b/js/app/packages/channel/Call/CallControls/CallControlButton.tsx@@ -0,0 +1,95 @@+import {+ createMemo,+ createSignal,+ splitProps,+ type Component,+ type JSX,+} from 'solid-js';+import { cn } from '@ui/utils/classname';+import type { OverrideComponentProps } from '@kobalte/core';++export type CallControlButtonSize = 'sm' | 'md';+export type CallControlButtonVariant = 'default' | 'active' | 'danger';++export const callControlButtonStyles = {+ base: 'flex items-center justify-center cursor-pointer outline outline-transarent bg-transparent transition-colors',++ size: {+ sm: 'w-6 h-6 rounded-md',+ md: 'w-10 h-10 rounded-lg',+ },++ variant: {+ default: 'text-ink outline-edge-muted hover:bg-edge/20',+ active: 'text-success outline-success bg-success/25 hover:bg-success/20',+ danger: 'text-failure outline-failure/50 hover:bg-failure hover:text-ink',+ },+};++export type CallControlButtonProps = OverrideComponentProps<+ 'button',+ {+ onClick: () => Promise<void> | void;+ active?: boolean;+ danger?: boolean;+ variant?: CallControlButtonVariant;+ children?: JSX.Element;+ disabled?: boolean;+ size?: CallControlButtonSize;+ class?: string;+ }+>;++export const CallControlButton: Component<CallControlButtonProps> = (props) => {+ const [local, others] = splitProps(props, [+ 'active',+ 'danger',+ 'variant',+ 'size',+ 'onClick',+ 'disabled',+ 'class',+ 'children',+ ]);++ const [isPending, setIsPending] = createSignal(false);+ const interactionDisabled = createMemo(() => isPending() || !!local.disabled);++ const handleClick = async () => {+ if (interactionDisabled()) return;+ setIsPending(true);+ try {+ await local.onClick();+ } catch (e) {+ console.error('ControlButton action failed', e);+ } finally {+ setIsPending(false);+ }+ };++ const size = () => local.size ?? 'md';++ const variant = (): CallControlButtonVariant => {+ if (local.variant) return local.variant;+ if (local.danger) return 'danger';+ if (local.active) return 'active';+ return 'default';+ };++ return (+ <button+ onClick={handleClick}+ disabled={interactionDisabled()}+ class={cn(+ callControlButtonStyles.base,+ callControlButtonStyles.size[size()],+ callControlButtonStyles.variant[variant()],+ interactionDisabled() && 'pointer-events-none opacity-50',+ local.class+ )}+ {...others}+ >+ {local.children}+ </button>+ );+};diff --git a/js/app/packages/channel/Call/CallControls/CallControlButtonWithDropdown.tsx b/js/app/packages/channel/Call/CallControls/CallControlButtonWithDropdown.tsxnew file mode 100644index 0000000000..0a948ea144--- /dev/null+++ b/js/app/packages/channel/Call/CallControls/CallControlButtonWithDropdown.tsx@@ -0,0 +1,87 @@+import { DropdownMenu } from '@kobalte/core/dropdown-menu';+import { DropdownMenuContent } from '@core/component/Menu';+import CaretDown from '@icon/regular/caret-down.svg';+import { createMemo, Show, type JSX } from 'solid-js';+import { cn } from '@ui/utils/classname';+import {+ CallControlButton,+ callControlButtonStyles,+ type CallControlButtonSize,+} from './CallControlButton';++export function CallControlButtonWithDropdown(props: {+ onClick: () => Promise<void> | void;+ active?: boolean;+ danger?: boolean;+ children?: JSX.Element;+ dropdownContent: () => JSX.Element;+ disabled?: boolean;+ size?: CallControlButtonSize;+}) {+ const interactionDisabled = createMemo(() => !!props.disabled);++ const handleClick = () => {+ if (interactionDisabled()) return;+ props.onClick();+ };++ const size = () => props.size ?? 'md';+ const isMd = () => size() === 'md';+ const isSm = () => size() === 'sm';++ return (+ <div+ class={cn(+ 'isolate flex items-center transition-colors',+ isMd() &&+ cn(+ 'rounded-lg p-1 gap-1 outline outline-edge-muted',+ props.active && callControlButtonStyles.variant.active,+ interactionDisabled() && 'pointer-events-none opacity-50'+ ),+ isSm() &&+ cn(+ 'bg-transparent p-0.5 shadow-none outline-none',+ interactionDisabled() && 'pointer-events-none opacity-50'+ )+ )}+ >+ <CallControlButton+ onClick={handleClick}+ disabled={interactionDisabled()}+ active={props.active}+ danger={props.danger}+ size={props.size}+ class={cn('outline-0 bg-transparent', isMd() && 'h-8')}+ >+ {props.children}+ </CallControlButton>++ <Show when={!isSm()}>+ <div class="w-px h-8 bg-ink/20 pointer-events-none" />+ </Show>++ <DropdownMenu>+ <DropdownMenu.Trigger+ as={CallControlButton}+ active={props.active}+ danger={props.danger}+ size={props.size}+ class={cn(+ 'outline-0 bg-transparent w-auto px-1 rounded-md',+ isMd() && 'h-8'+ )}+ >+ <CaretDown+ class={isSm() ? 'w-2.5 h-2.5 shrink-0' : 'w-3 h-3 shrink-0'}+ />+ </DropdownMenu.Trigger>+ <DropdownMenu.Portal>+ <DropdownMenuContent class="mb-2" width="lg">+ {props.dropdownContent()}+ </DropdownMenuContent>+ </DropdownMenu.Portal>+ </DropdownMenu>+ </div>+ );+}diff --git a/js/app/packages/channel/Call/CallControls/CallControls.tsx b/js/app/packages/channel/Call/CallControls/CallControls.tsxnew file mode 100644index 0000000000..a422c1affe--- /dev/null+++ b/js/app/packages/channel/Call/CallControls/CallControls.tsx@@ -0,0 +1,51 @@+import { Match, Show, Switch, mergeProps, type Accessor } from 'solid-js';+import type { CallControlButtonSize } from './CallControlButton';+import { CallControlsDefaultAndPanelRow } from './CallControlsDefaultAndPanelRow';+import { CallControlsPanelSmallRow } from './CallControlsPanelSmallRow';++export type CallControlsVariant = 'default' | 'panel' | 'panel-small';++export type CallControlsProps = {+ /** Leave / hang up — parent supplies tab switch, `leaveCall()`, etc. */+ onLeave: () => void | Promise<void>;+ variant?: CallControlsVariant;+ when?: boolean | Accessor<boolean>;+};++function readWhen(when: boolean | Accessor<boolean> | undefined): boolean {+ if (when === undefined) return true;+ return typeof when === 'function' ? when() : when;+}++/**+ * Mic / camera / screen / leave wired to `useCallContext()`. Single place for+ * control markup so Call overlay and sidebar InCall panel stay in sync.+ */+export function CallControls(rawProps: CallControlsProps) {+ const props = mergeProps(+ { variant: 'default' as CallControlsVariant },+ rawProps+ );++ const variant = () => props.variant ?? 'default';++ const buttonSize = (): CallControlButtonSize =>+ variant() === 'default' ? 'md' : 'sm';++ return (+ <Show when={() => readWhen(props.when)}>+ <Switch+ fallback={+ <CallControlsDefaultAndPanelRow+ size={buttonSize}+ onLeave={props.onLeave}+ />+ }+ >+ <Match when={variant() === 'panel-small'}>+ <CallControlsPanelSmallRow onLeave={props.onLeave} />+ </Match>+ </Switch>+ </Show>+ );+}diff --git a/js/app/packages/channel/Call/CallControls/CallControlsDefaultAndPanelRow.tsx b/js/app/packages/channel/Call/CallControls/CallControlsDefaultAndPanelRow.tsxnew file mode 100644index 0000000000..f7466b8467--- /dev/null+++ b/js/app/packages/channel/Call/CallControls/CallControlsDefaultAndPanelRow.tsx@@ -0,0 +1,270 @@+import { DropdownMenu } from '@kobalte/core/dropdown-menu';+import Microphone from '@icon/regular/microphone.svg';+import MicrophoneSlash from '@icon/regular/microphone-slash.svg';+import Screencast from '@icon/regular/screencast.svg';+import PhoneDisconnect from '@macro-icons/wide/call-disconnect.svg';+import VideoCamera from '@icon/regular/video-camera.svg';+import VideoCameraSlash from '@icon/regular/video-camera-slash.svg';+import Users from '@icon/regular/users.svg';+import { useToggleShareWithTeamMutation } from '@queries/call/call';+import { For, Show, type Accessor } from 'solid-js';+import { cn } from '@ui/utils/classname';+import {+ GroupLabel,+ MenuGroup,+ MenuItem,+ MenuSeparator,+} from '@core/component/Menu';+import {+ CallControlButton,+ type CallControlButtonSize,+} from './CallControlButton';+import { CallControlButtonWithDropdown } from './CallControlButtonWithDropdown';+import { CallDeviceList } from '../CallDeviceList';+import { BACKGROUND_IMAGES, useCallContext } from '../CallContext';++export type CallControlsDefaultAndPanelRowProps = {+ size: Accessor<CallControlButtonSize>;+ class?: string;+ 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 (+ <DropdownMenu.RadioGroup+ class="w-full"+ value={currentEffectValue()}+ onChange={handleChange}+ >+ <MenuGroup>+ <GroupLabel>Background</GroupLabel>+ <MenuItem+ text="None"+ selectorType="radio"+ value="none"+ groupValue={currentEffectValue()}+ />+ </MenuGroup>+ <MenuGroup>+ <GroupLabel>Blur</GroupLabel>+ <MenuItem+ text="Light"+ selectorType="radio"+ value="blur-light"+ groupValue={currentEffectValue()}+ />+ <MenuItem+ text="Medium"+ selectorType="radio"+ value="blur-medium"+ groupValue={currentEffectValue()}+ />+ <MenuItem+ text="Heavy"+ selectorType="radio"+ value="blur-heavy"+ groupValue={currentEffectValue()}+ />+ </MenuGroup>+ <Show when={BACKGROUND_IMAGES.length}>+ <MenuGroup>+ <GroupLabel>Image</GroupLabel>+ <For each={BACKGROUND_IMAGES}>+ {(bg) => (+ <MenuItem+ text={bg.label}+ selectorType="radio"+ value={`image-${bg.id}`}+ groupValue={currentEffectValue()}+ />+ )}+ </For>+ </MenuGroup>+ </Show>+ </DropdownMenu.RadioGroup>+ );+}++export function CallControlsDefaultAndPanelRow(+ props: CallControlsDefaultAndPanelRowProps+) {+ const callCtx = useCallContext();+ const isConnecting = () => callCtx.isConnecting();+ const size = () => props.size();+ const iconClass = () => (size() === 'sm' ? 'w-4 h-4' : 'w-5 h-5');+ const toggleShareWithTeam = useToggleShareWithTeamMutation();++ const handleToggleShareWithTeam = async () => {+ const callId = callCtx.activeCallId();+ if (!callId) return;+ const newValue = await toggleShareWithTeam.mutateAsync(callId);+ callCtx.setSharedWithTeam(newValue);+ };++ return (+ <div+ data-call-controls+ class={cn(+ 'flex flex-row flex-wrap items-center',+ size() === 'md' && 'justify-center gap-3',+ size() === 'sm' && 'justify-around gap-0 py-1',+ props.class+ )}+ >+ <CallControlButtonWithDropdown+ size={size()}+ onClick={() => callCtx.toggleAudio()}+ active={!callCtx.isAudioMuted()}+ disabled={isConnecting()}+ dropdownContent={() => (+ <>+ <CallDeviceList+ label="Microphone"+ devices={callCtx.audioInputDevices()}+ activeDeviceId={callCtx.activeAudioInputDeviceId()}+ onSelect={(id) => callCtx.switchAudioInput(id)}+ />+ <Show when={callCtx.audioOutputDevices().length > 0}>+ <MenuSeparator />+ <CallDeviceList+ label="Speaker"+ devices={callCtx.audioOutputDevices()}+ activeDeviceId={callCtx.activeAudioOutputDeviceId()}+ onSelect={(id) => callCtx.switchAudioOutput(id)}+ />+ </Show>+ </>+ )}+ >+ <Show+ when={!callCtx.isAudioMuted()}+ fallback={<MicrophoneSlash class={iconClass()} />}+ >+ <Microphone class={iconClass()} />+ </Show>+ </CallControlButtonWithDropdown>++ <CallControlButtonWithDropdown+ size={size()}+ onClick={() => callCtx.toggleVideo()}+ active={!callCtx.isVideoMuted()}+ disabled={isConnecting()}+ dropdownContent={() => (+ <>+ <CallDeviceList+ label="Camera"+ devices={callCtx.videoInputDevices()}+ activeDeviceId={callCtx.activeVideoInputDeviceId()}+ onSelect={(id) => callCtx.switchVideoInput(id)}+ />+ <Show when={isBackgroundBlurSupported()}>+ <MenuSeparator />+ <BackgroundEffectSelector />+ </Show>+ </>+ )}+ >+ <Show+ when={!callCtx.isVideoMuted()}+ fallback={<VideoCameraSlash class={iconClass()} />}+ >+ <VideoCamera class={iconClass()} />+ </Show>+ </CallControlButtonWithDropdown>++ <CallControlButton+ class="border-0"+ size={size()}+ onClick={() => callCtx.toggleScreenShare()}+ active={callCtx.isScreenSharing()}+ disabled={isConnecting()}+ >+ <Screencast class={iconClass()} />+ </CallControlButton>++ <CallControlButton+ class="border-0"+ size={size()}+ onClick={handleToggleShareWithTeam}+ active={callCtx.isSharedWithTeam()}+ disabled={isConnecting()}+ >+ <Users class={iconClass()} />+ </CallControlButton>++ <CallControlButton+ class="border-0"+ size={size()}+ onClick={props.onLeave}+ disabled={isConnecting()}+ danger+ >+ <PhoneDisconnect class={iconClass()} />+ </CallControlButton>+ </div>+ );+}diff --git a/js/app/packages/channel/Call/CallControls/CallControlsPanelSmallRow.tsx b/js/app/packages/channel/Call/CallControls/CallControlsPanelSmallRow.tsxnew file mode 100644index 0000000000..0565cbc776--- /dev/null+++ b/js/app/packages/channel/Call/CallControls/CallControlsPanelSmallRow.tsx@@ -0,0 +1,275 @@+import { DropdownMenu } from '@kobalte/core/dropdown-menu';+import { DropdownMenuContent, MENU_ITEM_CLASS } from '@core/component/Menu';+import CheckIcon from '@icon/bold/check-bold.svg';+import Microphone from '@icon/regular/microphone.svg';+import MicrophoneSlash from '@icon/regular/microphone-slash.svg';+import Screencast from '@icon/regular/screencast.svg';+import PhoneDisconnect from '@macro-icons/wide/call-disconnect.svg';+import Users from '@icon/regular/users.svg';+import VideoCamera from '@icon/regular/video-camera.svg';+import VideoCameraSlash from '@icon/regular/video-camera-slash.svg';+import VideoConference from '@icon/regular/video-conference.svg';+import { useToggleShareWithTeamMutation } from '@queries/call/call';+import { For, Show } from 'solid-js';+import { cn } from '@ui/utils/classname';+import { useCallContext } from '../CallContext';++const menuStyles = {+ item: cn(+ MENU_ITEM_CLASS,+ 'cursor-pointer hover:bg-hover hover-transition-bg'+ ),+ groupLabel: cn(MENU_ITEM_CLASS, 'text-xs text-accent'),+};++const panelSmallIconClass = 'w-4 h-4';++export type CallControlsPanelSmallRowProps = {+ class?: string;+ onLeave: () => void | Promise<void>;+};++export function CallControlsPanelSmallRow(+ props: CallControlsPanelSmallRowProps+) {+ const callCtx = useCallContext();+ const isConnecting = () => callCtx.isConnecting();+ const toggleShareWithTeam = useToggleShareWithTeamMutation();++ const handleToggleShareWithTeam = async () => {+ const callId = callCtx.activeCallId();+ if (!callId) return;+ const newValue = await toggleShareWithTeam.mutateAsync(callId);+ callCtx.setSharedWithTeam(newValue);+ };++ return (+ <div+ data-call-controls+ data-call-controls-panel-small+ class={cn(+ 'flex flex-row flex-wrap items-center justify-center gap-0.5',+ props.class+ )}+ >+ <DropdownMenu placement="top-start" gutter={4}>+ <DropdownMenu.Trigger+ as="button"+ type="button"+ disabled={isConnecting()}+ class={cn(+ 'flex items-center justify-center w-4 h-4 shrink-0 rounded-md border-0 bg-transparent transition-colors',+ isConnecting() &&+ 'opacity-50 pointer-events-none cursor-not-allowed',+ !isConnecting() &&+ (!callCtx.isAudioMuted() ||+ !callCtx.isVideoMuted() ||+ callCtx.isScreenSharing())+ ? 'text-accent-2'+ : 'text-ink',+ !isConnecting() && 'hover:bg-ink/5 cursor-pointer'+ )}+ aria-label="Call options"+ >+ <VideoConference class={panelSmallIconClass} />+ </DropdownMenu.Trigger>++ <DropdownMenu.Portal>+ <DropdownMenuContent class="mb-2 z-modal" width="lg">+ <DropdownMenu.Item+ class={menuStyles.item}+ closeOnSelect={false}+ onSelect={() => void callCtx.toggleAudio()}+ >+ <div class="flex min-w-0 flex-1 items-center gap-2">+ <Show+ when={!callCtx.isAudioMuted()}+ fallback={<MicrophoneSlash class="h-4 w-4 shrink-0" />}+ >+ <Microphone class="h-4 w-4 shrink-0" />+ </Show>+ <span class="min-w-0 flex-1">+ {callCtx.isAudioMuted()+ ? 'Unmute microphone'+ : 'Mute microphone'}+ </span>+ </div>+ </DropdownMenu.Item>++ <DropdownMenu.Separator class="my-1 w-full border-t border-edge" />++ <DropdownMenu.Group>+ <DropdownMenu.GroupLabel class={menuStyles.groupLabel}>+ Microphone+ </DropdownMenu.GroupLabel>++ <For each={callCtx.audioInputDevices()}>+ {(device) => (+ <DropdownMenu.Item+ class={menuStyles.item}+ closeOnSelect={false}+ onSelect={() =>+ void callCtx.switchAudioInput(device.deviceId)+ }+ >+ <div class="flex min-w-0 flex-1 items-baseline gap-2">+ <span class="min-w-0 flex-1">{device.label}</span>+ <span class="inline-flex w-3 shrink-0 justify-center">+ <Show+ when={+ callCtx.activeAudioInputDeviceId() ===+ device.deviceId+ }+ >+ <CheckIcon class="h-3 w-3 text-accent" />+ </Show>+ </span>+ </div>+ </DropdownMenu.Item>+ )}+ </For>+ </DropdownMenu.Group>++ <Show when={callCtx.audioOutputDevices().length > 0}>+ <DropdownMenu.Separator class="my-1 w-full border-t border-edge" />+ <DropdownMenu.Group>+ <DropdownMenu.GroupLabel class={menuStyles.groupLabel}>+ Speaker+ </DropdownMenu.GroupLabel>+ <For each={callCtx.audioOutputDevices()}>+ {(device) => (+ <DropdownMenu.Item+ class={menuStyles.item}+ closeOnSelect={false}+ onSelect={() =>+ void callCtx.switchAudioOutput(device.deviceId)+ }+ >+ <div class="flex min-w-0 flex-1 items-baseline gap-2">+ <span class="min-w-0 flex-1">{device.label}</span>+ <span class="inline-flex w-3 shrink-0 justify-center">+ <Show+ when={+ callCtx.activeAudioOutputDeviceId() ===+ device.deviceId+ }+ >+ <CheckIcon class="h-3 w-3 text-accent" />+ </Show>+ </span>+ </div>+ </DropdownMenu.Item>+ )}+ </For>+ </DropdownMenu.Group>+ </Show>++ <DropdownMenu.Separator class="my-1 w-full border-t border-edge" />++ <DropdownMenu.Item+ class={menuStyles.item}+ closeOnSelect={false}+ onSelect={() => void callCtx.toggleVideo()}+ >+ <div class="flex min-w-0 flex-1 items-center gap-2">+ <Show+ when={!callCtx.isVideoMuted()}+ fallback={<VideoCameraSlash class="h-4 w-4 shrink-0" />}+ >+ <VideoCamera class="h-4 w-4 shrink-0" />+ </Show>+ <span class="min-w-0 flex-1">+ {callCtx.isVideoMuted()+ ? 'Turn camera on'+ : 'Turn camera off'}+ </span>+ </div>+ </DropdownMenu.Item>++ <DropdownMenu.Separator class="my-1 w-full border-t border-edge" />++ <DropdownMenu.Group class="w-full">+ <DropdownMenu.GroupLabel class={menuStyles.groupLabel}>+ Camera+ </DropdownMenu.GroupLabel>+ <For each={callCtx.videoInputDevices()}>+ {(device) => (+ <DropdownMenu.Item+ class={menuStyles.item}+ closeOnSelect={false}+ onSelect={() =>+ void callCtx.switchVideoInput(device.deviceId)+ }+ >+ <div class="flex min-w-0 flex-1 items-baseline gap-2">+ <span class="min-w-0 flex-1">{device.label}</span>+ <span class="inline-flex w-3 shrink-0 justify-center">+ <Show+ when={+ callCtx.activeVideoInputDeviceId() ===+ device.deviceId+ }+ >+ <CheckIcon class="h-3 w-3 text-accent" />+ </Show>+ </span>+ </div>+ </DropdownMenu.Item>+ )}+ </For>+ </DropdownMenu.Group>++ <DropdownMenu.Separator class="my-1 w-full border-t border-edge" />++ <DropdownMenu.Item+ class={menuStyles.item}+ closeOnSelect={false}+ onSelect={() => void callCtx.toggleScreenShare()}+ >+ <div class="flex min-w-0 flex-1 items-center gap-2">+ <Screencast class="h-4 w-4 shrink-0" />+ <span class="min-w-0 flex-1">+ {callCtx.isScreenSharing()+ ? 'Stop sharing screen'+ : 'Share screen'}+ </span>+ </div>+ </DropdownMenu.Item>++ <DropdownMenu.Separator class="my-1 w-full border-t border-edge" />++ <DropdownMenu.Item+ class={menuStyles.item}+ closeOnSelect={false}+ onSelect={() => void handleToggleShareWithTeam()}+ >+ <div class="flex min-w-0 flex-1 items-center gap-2">+ <Users class="h-4 w-4 shrink-0" />+ <span class="min-w-0 flex-1">+ {callCtx.isSharedWithTeam()+ ? 'Shared with team'+ : 'Share with team'}+ </span>+ </div>+ </DropdownMenu.Item>++ <DropdownMenu.Separator class="my-1 w-full border-t border-edge" />++ <DropdownMenu.Item+ class={cn(+ MENU_ITEM_CLASS,+ 'cursor-pointer text-failure hover:bg-failure/10 hover-transition-bg'+ )}+ onSelect={() => void props.onLeave()}+ >+ <div class="flex min-w-0 flex-1 items-center gap-2">+ <PhoneDisconnect class="h-4 w-4 shrink-0" />+ <span class="min-w-0 flex-1">Leave call</span>+ </div>+ </DropdownMenu.Item>+ </DropdownMenuContent>+ </DropdownMenu.Portal>+ </DropdownMenu>+ </div>+ );+}diff --git a/js/app/packages/channel/Call/CallDeviceList.tsx b/js/app/packages/channel/Call/CallDeviceList.tsxnew file mode 100644index 0000000000..4a86c5916b--- /dev/null+++ b/js/app/packages/channel/Call/CallDeviceList.tsx@@ -0,0 +1,47 @@+import { DropdownMenu } from '@kobalte/core/dropdown-menu';+import { MENU_ITEM_CLASS } from '@core/component/Menu';+import CheckIcon from '@icon/bold/check-bold.svg';+import { For, Show } from 'solid-js';+import type { MediaDeviceInfo } from './CallContext';+import { cn } from '@ui/utils/classname';++const deviceRadioRowClass =+ 'flex min-w-0 items-center gap-2 w-full py-1 pl-2 pr-2 text-sm font-medium rounded-xs cursor-pointer hover:bg-hover hover-transition-bg focus-bracket';++/** Device picker rows for use inside `DropdownMenu` + `DropdownMenuContent` only. */+export function CallDeviceList(props: {+ label: string;+ devices: MediaDeviceInfo[];+ activeDeviceId: string | null;+ onSelect: (deviceId: string) => void;+}) {+ return (+ <DropdownMenu.Group class="w-full">+ <DropdownMenu.GroupLabel+ class={`${MENU_ITEM_CLASS} text-xs! text-accent`}+ >+ {props.label}+ </DropdownMenu.GroupLabel>+ <DropdownMenu.RadioGroup+ value={props.activeDeviceId ?? ''}+ onChange={(value) => props.onSelect(value)}+ >+ <For each={props.devices}>+ {(device) => (+ <DropdownMenu.RadioItem+ value={device.deviceId}+ class={cn(deviceRadioRowClass, 'w-full items-baseline')}+ >+ <div class="min-w-0 flex-1">{device.label}</div>+ <span class="inline-flex w-3 shrink-0 justify-center">+ <Show when={props.activeDeviceId === device.deviceId}>+ <CheckIcon class="h-3 w-3 text-accent" />+ </Show>+ </span>+ </DropdownMenu.RadioItem>+ )}+ </For>+ </DropdownMenu.RadioGroup>+ </DropdownMenu.Group>+ );+}diff --git a/js/app/packages/channel/Call/CallOverlay.tsx b/js/app/packages/channel/Call/CallOverlay.tsxindex 96fc78a903..e527b2f873 100644--- a/js/app/packages/channel/Call/CallOverlay.tsx+++ b/js/app/packages/channel/Call/CallOverlay.tsx@@ -1,59 +1,45 @@import { Track, type RemoteParticipant } from 'livekit-client';-import { For, Show, createSignal, type Component, type JSX } from 'solid-js';+import { For, Show, type JSXElement } from 'solid-js';import { cn } from '@ui/utils/classname';import { TrackView } from './TrackView';-import PhoneDisconnect from '@macro-icons/wide/call-disconnect.svg';-import Microphone from '@macro-icons/wide/microphone.svg';-import MicrophoneSlash from '@macro-icons/wide/microphone-slash.svg';-import VideoCamera from '@macro-icons/wide/video.svg';-import VideoCameraSlash from '@macro-icons/wide/video-slash.svg';-import Screencast from '@macro-icons/wide/screencast.svg';-import Users from '@macro-icons/wide/users.svg';-import CaretDown from '@icon/regular/caret-down.svg';-import { useToggleShareWithTeamMutation } from '@queries/call/call';-import { DropdownMenu } from '@kobalte/core/dropdown-menu';-import {- DropdownMenuContent,- MenuItem,- MenuGroup,- GroupLabel,- MenuSeparator,-} from '@core/component/Menu';-import { Tooltip } from '@core/component/Tooltip';import { tryMacroId, useDisplayName } from '@core/user';-import {- useCallContext,- type MediaDeviceInfo,- BACKGROUND_IMAGES,-} from './CallContext';+import { useCallContext } from './CallContext';+import { CallControls } from './CallControls/CallControls';-// Mirrors @livekit/track-processors' supportsBackgroundProcessors() =-// BackgroundProcessor.isSupported && ProcessorWrapper.isSupported. Kept local so the-// toggle renders without statically importing the WASM/MediaPipe-bearing package.-function isBackgroundBlurSupported(): boolean {- if (typeof window === 'undefined') return false;- // BackgroundProcessor.isSupported: OffscreenCanvas, VideoFrame, createImageBitmap, WebGL2.- if (- !('OffscreenCanvas' in window) ||- !('VideoFrame' in window) ||- !('createImageBitmap' in window)- ) {- return false;- }- try {- if (!document.createElement('canvas').getContext('webgl2')) return false;- } catch {- return false;- }- // ProcessorWrapper.isSupported: modern MediaStreamTrackProcessor API OR canvas- // captureStream() fallback (Firefox 126+).- const hasStreamProcessor =- 'MediaStreamTrackProcessor' in window &&- 'MediaStreamTrackGenerator' in window;- const hasFallback =- typeof HTMLCanvasElement !== 'undefined' &&- 'captureStream' in HTMLCanvasElement.prototype;- return hasStreamProcessor || hasFallback;+function VideoTag(props: {+ children: JSXElement;+ class?: string;+ variant?: 'default' | 'truncated';+}) {+ return (+ <div+ class={cn(+ 'absolute bottom-1 left-1 px-1.5 py-0.5 rounded bg-surface-0/70 text-ink text-xs',+ props.variant === 'truncated' ? 'truncate max-w-[80%]' : '',+ props.class+ )}+ >+ {props.children}+ </div>+ );+}++function ParticipantTileWrapper(props: {+ isSpeaking: boolean;+ children: JSXElement;+ isConnecting?: boolean;+}) {+ return (+ <div+ class="relative flex items-center justify-center rounded-lg overflow-hidden bg-surface-2 min-h-[120px]"+ classList={{+ 'ring-inset ring-2 ring-accent-2': props.isSpeaking,+ 'animate-pulse': props.isConnecting,+ }}+ >+ {props.children}+ </div>+ );}function ParticipantTile(props: { participant: RemoteParticipant }) {@@ -70,15 +56,11 @@ function ParticipantTile(props: { participant: RemoteParticipant }) {const isSpeaking = () => callCtx.isParticipantSpeaking(props.participant);return (- <div- class="relative flex items-center justify-center rounded-lg overflow-hidden bg-surface-2 min-h-[120px]"- classList={{ 'ring-2 ring-accent-2': isSpeaking() }}- >- {/* Remote mic audio is attached by <CallAudioSink /> so playback survives tab switches. */}+ <ParticipantTileWrapper isSpeaking={isSpeaking()}><Showwhen={cameraTrack()}fallback={- <div class="flex items-center justify-center w-full h-full p-4">+ <div class="flex items-center justify-center w-full h-full p-4 ring-2 ring-accent-2"><div class="w-12 h-12 rounded-full bg-surface-3 flex items-center justify-center text-ink-muted text-lg font-medium">{displayName().charAt(0).toUpperCase()}</div>@@ -87,234 +69,9 @@ function ParticipantTile(props: { participant: RemoteParticipant }) {><TrackView track={cameraTrack()} /></Show>- <div class="absolute bottom-1 left-1 px-1.5 py-0.5 rounded bg-surface-0/70 text-ink text-xs truncate max-w-[80%]">- {displayName()}- </div>- </div>- );-}--const ControlButton: Component<{- onClick: () => Promise<void> | void;- active?: boolean;- danger?: boolean;- children?: JSX.Element;-}> = (props) => {- const [isPending, setIsPending] = createSignal(false);- const handleClick = async () => {- if (isPending()) return;- setIsPending(true);- try {- await props.onClick();- } catch (e) {- console.error('ControlButton action failed', e);- } finally {- setIsPending(false);- }- };-- return (- <button- onClick={handleClick}- disabled={isPending()}- class="w-10 h-10 rounded-full flex items-center justify-center transition-colors"- classList={{- 'opacity-50 cursor-not-allowed': isPending(),- 'bg-failure text-panel hover:bg-failure/80':- props.danger && !isPending(),- 'bg-surface-2 text-ink hover:bg-surface-3':- !props.danger && !props.active && !isPending(),- 'bg-accent-2 text-panel hover:bg-accent-3':- !props.danger && props.active && !isPending(),- }}- >- {props.children}- </button>- );-};--/**- * A call control button with a small dropdown chevron for device selection.- * Similar to Google Meet's mic/camera buttons with a dropdown arrow.- */-function ControlButtonWithDropdown(props: {- onClick: () => Promise<void> | void;- active?: boolean;- children?: JSX.Element;- dropdownContent: JSX.Element;-}) {- const [isPending, setIsPending] = createSignal(false);-- const handleClick = async () => {- if (isPending()) return;- setIsPending(true);- try {- await props.onClick();- } catch (e) {- console.error('ControlButton action failed', e);- } finally {- setIsPending(false);- }- };-- return (- <div class="relative flex items-center">- <button- onClick={handleClick}- disabled={isPending()}- class="w-10 h-10 rounded-l-full flex items-center justify-center transition-colors"- classList={{- 'opacity-50 cursor-not-allowed': isPending(),- 'bg-surface-2 text-ink hover:bg-surface-3':- !props.active && !isPending(),- 'bg-accent-2 text-panel hover:bg-accent-3':- props.active && !isPending(),- }}- >- {props.children}- </button>- <DropdownMenu>- <DropdownMenu.Trigger- class="h-10 w-5 rounded-r-full flex items-center justify-center transition-colors border-l"- classList={{- 'bg-surface-2 text-ink hover:bg-surface-3 border-surface-3':- !props.active,- 'bg-accent-2 text-panel hover:bg-accent-3 border-accent-3':- props.active,- }}- >- <CaretDown class="w-3 h-3" />- </DropdownMenu.Trigger>- <DropdownMenu.Portal>- <DropdownMenuContent class="mb-2" width="lg">- {props.dropdownContent}- </DropdownMenuContent>- </DropdownMenu.Portal>- </DropdownMenu>- </div>- );-}--function DeviceList(props: {- label: string;- devices: MediaDeviceInfo[];- activeDeviceId: string | null;- onSelect: (deviceId: string) => void;-}) {- return (- <MenuGroup>- <GroupLabel>{props.label}</GroupLabel>- <DropdownMenu.RadioGroup- value={props.activeDeviceId ?? ''}- onChange={(value) => props.onSelect(value)}- >- <For each={props.devices}>- {(device) => (- <MenuItem- text={device.label}- selectorType="radio"- value={device.deviceId}- groupValue={props.activeDeviceId ?? ''}- />- )}- </For>- </DropdownMenu.RadioGroup>- </MenuGroup>- );-}--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 (- <DropdownMenu.RadioGroup- value={currentEffectValue()}- onChange={handleChange}- >- <MenuGroup>- <GroupLabel>Background</GroupLabel>- <MenuItem- text="None"- selectorType="radio"- value="none"- groupValue={currentEffectValue()}- />- </MenuGroup>- <MenuGroup>- <GroupLabel>Blur</GroupLabel>- <MenuItem- text="Light"- selectorType="radio"- value="blur-light"- groupValue={currentEffectValue()}- />- <MenuItem- text="Medium"- selectorType="radio"- value="blur-medium"- groupValue={currentEffectValue()}- />- <MenuItem- text="Heavy"- selectorType="radio"- value="blur-heavy"- groupValue={currentEffectValue()}- />- </MenuGroup>- <Show when={BACKGROUND_IMAGES.length}>- <MenuGroup>- <GroupLabel>Image</GroupLabel>- <For each={BACKGROUND_IMAGES}>- {(bg) => (- <MenuItem- text={bg.label}- selectorType="radio"- value={`image-${bg.id}`}- groupValue={currentEffectValue()}- />- )}- </For>- </MenuGroup>- </Show>- </DropdownMenu.RadioGroup>+ <VideoTag variant="truncated">{displayName()}</VideoTag>+ </ParticipantTileWrapper>);}@@ -329,25 +86,17 @@ function ScreenShareTile(props: { participant: RemoteParticipant }) {};return (- <div class="relative flex items-center justify-center rounded-lg overflow-hidden bg-surface-2">+ <div class="relative w-full h-full flex items-center justify-center rounded-lg overflow-hidden bg-surface-2"><TrackView track={screenTrack()} fit="contain" />- <div class="absolute bottom-1 left-1 px-1.5 py-0.5 rounded bg-surface-0/70 text-ink text-xs truncate max-w-[80%]">- {displayName()}'s screen- </div>++ <VideoTag variant="truncated">{displayName()}'s screen</VideoTag></div>);}export function CallOverlay(props: { onLeave: () => void }) {const callCtx = useCallContext();- const toggleShareWithTeam = useToggleShareWithTeamMutation();-- const handleToggleShareWithTeam = async () => {- const callId = callCtx.activeCallId();- if (!callId) return;- const newValue = await toggleShareWithTeam.mutateAsync(callId);- callCtx.setSharedWithTeam(newValue);- };+ const isConnecting = () => callCtx.isConnecting();const participants = () =>Array.from(callCtx.remoteParticipants().values()).filter((p) => !p.isAgent);@@ -373,7 +122,7 @@ export function CallOverlay(props: { onLeave: () => void }) {callCtx.trackVersion();return participants().filter((p) => {const pub = p.getTrackPublication(Track.Source.ScreenShare);- return pub?.isSubscribed && !pub.isMuted;+ return !!pub?.track && pub.isSubscribed && !pub.isMuted;});};@@ -388,17 +137,16 @@ export function CallOverlay(props: { onLeave: () => void }) {};return (- <div class="flex flex-col h-full bg-surface-0">+ <div class="flex flex-col h-full">{/* Screen share area */}<Show when={hasAnyScreenShare()}>- <div class="flex-1 min-h-0 p-2">+ <div class="flex-1 min-h-0 pt-2"><div class="h-full rounded-lg overflow-hidden bg-surface-2 flex items-center justify-center"><Show when={callCtx.isScreenSharing()}><div class="relative w-full h-full"><TrackView track={localScreenTrack()} fit="contain" />- <div class="absolute bottom-1 left-1 px-1.5 py-0.5 rounded bg-surface-0/70 text-ink text-xs">- Your screen- </div>++ <VideoTag>Your screen</VideoTag></div></Show><For each={remoteScreenShares()}>@@ -410,21 +158,15 @@ export function CallOverlay(props: { onLeave: () => void }) {{/* Participants grid */}<div- class={cn(- 'grid gap-2 p-2 auto-rows-fr overflow-hidden',- hasAnyScreenShare() ? 'h-[140px] shrink-0' : 'flex-1 min-h-0',- gridCols()- )}+ class={`${hasAnyScreenShare() ? 'h-[180px] shrink-0' : 'flex-1 min-h-0'} grid ${gridCols()} gap-2 py-2 auto-rows-fr overflow-hidden`}>{/* Local participant */}- <div- class="relative flex items-center justify-center rounded-lg overflow-hidden bg-surface-2 min-h-[120px]"- classList={{- 'ring-2 ring-accent-2': isLocalSpeaking(),- }}+ <ParticipantTileWrapper+ isSpeaking={isLocalSpeaking()}+ isConnecting={isConnecting()}><Show- when={!callCtx.isVideoMuted()}+ when={!isConnecting() && !callCtx.isVideoMuted()}fallback={<div class="flex items-center justify-center w-full h-full p-4"><div class="w-12 h-12 rounded-full bg-surface-3 flex items-center justify-center text-ink-muted text-lg font-medium">@@ -435,10 +177,13 @@ export function CallOverlay(props: { onLeave: () => void }) {><TrackView track={localVideoTrack()} mirror /></Show>- <div class="absolute bottom-1 left-1 px-1.5 py-0.5 rounded bg-surface-0/70 text-ink text-xs">- You- </div>- </div>++ <Show when={isConnecting()} fallback={<VideoTag>You</VideoTag>}>+ <div class="absolute bottom-1 left-1 px-1.5 py-0.5 rounded bg-surface-0/70 text-ink-muted text-xs">+ Connecting...+ </div>+ </Show>+ </ParticipantTileWrapper><For each={participants()}>{(participant) => <ParticipantTile participant={participant} />}@@ -446,94 +191,8 @@ export function CallOverlay(props: { onLeave: () => void }) {</div>{/* Controls bar */}- <div class="flex items-center justify-center gap-3 p-3 bg-surface-1 border-t border-edge">- <ControlButtonWithDropdown- onClick={() => callCtx.toggleAudio()}- active={!callCtx.isAudioMuted()}- dropdownContent={- <>- <DeviceList- label="Microphone"- devices={callCtx.audioInputDevices()}- activeDeviceId={callCtx.activeAudioInputDeviceId()}- onSelect={(id) => callCtx.switchAudioInput(id)}- />- <Show when={callCtx.audioOutputDevices().length > 0}>- <MenuSeparator />- <DeviceList- label="Speaker"- devices={callCtx.audioOutputDevices()}- activeDeviceId={callCtx.activeAudioOutputDeviceId()}- onSelect={(id) => callCtx.switchAudioOutput(id)}- />- </Show>- <MenuSeparator />- <MenuGroup>- <GroupLabel>Effects</GroupLabel>- <MenuItem- text="Noise suppression"- selectorType="checkbox"- checked={callCtx.isNoiseSuppressed()}- closeOnSelect={false}- onClick={() => callCtx.toggleNoiseSuppression()}- />- </MenuGroup>- </>- }- >- <Show- when={!callCtx.isAudioMuted()}- fallback={<MicrophoneSlash class="w-5 h-5" />}- >- <Microphone class="w-5 h-5" />- </Show>- </ControlButtonWithDropdown>-- <ControlButtonWithDropdown- onClick={() => callCtx.toggleVideo()}- active={!callCtx.isVideoMuted()}- dropdownContent={- <>- <DeviceList- label="Camera"- devices={callCtx.videoInputDevices()}- activeDeviceId={callCtx.activeVideoInputDeviceId()}- onSelect={(id) => callCtx.switchVideoInput(id)}- />- <Show when={isBackgroundBlurSupported()}>- <MenuSeparator />- <BackgroundEffectSelector />- </Show>- </>- }- >- <Show- when={!callCtx.isVideoMuted()}- fallback={<VideoCameraSlash class="w-5 h-5" />}- >- <VideoCamera class="w-5 h-5" />- </Show>- </ControlButtonWithDropdown>-- <ControlButton- onClick={() => callCtx.toggleScreenShare()}- active={callCtx.isScreenSharing()}- >- <Screencast class="w-5 h-5" />- </ControlButton>-- <Tooltip tooltip={<span class="text-xs">Toggle share with team</span>}>- <ControlButton- onClick={handleToggleShareWithTeam}- active={callCtx.isSharedWithTeam()}- >- <Users class="w-5 h-5" />- </ControlButton>- </Tooltip>-- <ControlButton onClick={props.onLeave} danger>- <PhoneDisconnect class="w-5 h-5" />- </ControlButton>+ <div class="flex items-center justify-center p-3 pt-1 bg-surface-1">+ <CallControls onLeave={props.onLeave} /></div></div>);diff --git a/js/app/packages/channel/Call/ChannelCallAutoJoin.tsx b/js/app/packages/channel/Call/ChannelCallAutoJoin.tsxindex 3893878329..2a29ef2f46 100644--- a/js/app/packages/channel/Call/ChannelCallAutoJoin.tsx+++ b/js/app/packages/channel/Call/ChannelCallAutoJoin.tsx@@ -2,7 +2,7 @@ import { type Accessor, createEffect, untrack } from 'solid-js';import { ENABLE_CALLS } from '@core/constant/featureFlags';import { DEFAULT_CHANNEL_TAB } from '@channel/Channel/channel-tabs';import { useChannelTab } from '@channel/Channel/ChannelTabContext';-import { useCall } from './useCall';+import { useCall } from './use-call';/*** Auto-joins the call for this channel whenever `pendingJoinCall` flips todiff --git a/js/app/packages/channel/Call/ChannelCallButton.tsx b/js/app/packages/channel/Call/ChannelCallButton.tsxindex c4364df454..a6ab2875a2 100644--- a/js/app/packages/channel/Call/ChannelCallButton.tsx+++ b/js/app/packages/channel/Call/ChannelCallButton.tsx@@ -5,7 +5,7 @@ import { Button } from '@ui/components/Button';import PhoneIcon from '@macro-icons/wide/call.svg';import PhoneDisconnectIcon from '@macro-icons/wide/call-disconnect.svg';import { useActiveCallQuery } from '@queries/call/call';-import { useCall } from './useCall';+import { useCall } from './use-call';import { isTouchDevice } from '@core/mobile/isTouchDevice';export function ChannelCallButton(props: { channelId: string }) {@@ -19,7 +19,7 @@ export function ChannelCallButton(props: { channelId: string }) {const isCallInProgress = () => !!activeCallQuery.data;const isHighlighted = () => call.isInThisChannel() || isCallInProgress();- const isPending = () => call.isJoining() || call.isLeaving();+ const isPending = () => call.isLeaving();const tooltip = () => {if (call.isInThisChannel()) return 'Leave Call';@@ -28,7 +28,8 @@ export function ChannelCallButton(props: { channelId: string }) {};const handleClick = async () => {- if (isPending()) return;+ if (call.isJoining() || call.isLeaving()) return;+try {if (call.isInThisChannel()) {await call.leaveCall();diff --git a/js/app/packages/channel/Call/ChannelCallTab.tsx b/js/app/packages/channel/Call/ChannelCallTab.tsxindex d54bae3a56..225a781c6d 100644--- a/js/app/packages/channel/Call/ChannelCallTab.tsx+++ b/js/app/packages/channel/Call/ChannelCallTab.tsx@@ -1,5 +1,7 @@-import { type Accessor, Show } from 'solid-js';-import { useCall } from './useCall';+import { type Accessor, Match, Show, Switch } from 'solid-js';+import { DEFAULT_CHANNEL_TAB } from '@channel/Channel/channel-tabs';+import { useChannelTab } from '@channel/Channel/ChannelTabContext';+import { useCall } from './use-call';import { CallOverlay } from './CallOverlay';export function ChannelCallTab(props: {@@ -12,22 +14,66 @@ export function ChannelCallTab(props: {*/pendingJoin?: Accessor<boolean>;}) {- const call = useCall(() => props.channelId);- const showJoining = () =>- call.isJoining() || (props.pendingJoin?.() ?? false);+ const { setActiveTab } = useChannelTab();++ // Match ChannelCallButton / ChannelCallAutoJoin so leaving from the+ // overlay (or disconnect) switches back to Messages — not only when+ // the join was initiated from the header button.+ const call = useCall(() => props.channelId, {+ onJoin: () => setActiveTab('call'),+ onLeave: () => setActiveTab(DEFAULT_CHANNEL_TAB),+ });++ const handleRetry = async () => {+ try {+ await call.joinCall();+ } catch {+ // joinError is set inside useCall join mutation onError+ }+ };return (- <Show- when={call.isInThisChannel()}+ <Switchfallback={- <Show when={showJoining()}>- <div class="flex size-full items-center justify-center text-ink-muted">- Joining call…- </div>- </Show>+ <div class="flex size-full flex-col items-center justify-center gap-3 text-ink-muted px-4">+ <p class="text-center text-sm">You’re not in this call yet.</p>+ <button+ type="button"+ onClick={() => void call.joinCall()}+ disabled={call.isJoining()}+ class="rounded-lg bg-surface-2 px-4 py-2 text-sm text-ink hover:bg-surface-3 transition-colors disabled:opacity-50 disabled:pointer-events-none"+ >+ {call.isJoining() ? 'Connecting…' : 'Join call'}+ </button>+ </div>}>- <CallOverlay onLeave={call.leaveCall} />- </Show>+ <Match when={call.isInThisChannel() && !call.joinError()}>+ <CallOverlay onLeave={call.leaveCall} />+ </Match>+ <Match when={call.joinError()}>+ <div class="flex size-full flex-col items-center justify-center gap-3 text-ink-muted px-4">+ <p class="text-center">{call.joinError()}</p>+ <Show when={call.isJoining()}>+ <p class="text-xs text-ink-extra-muted animate-pulse">+ Connecting…+ </p>+ </Show>+ <button+ type="button"+ onClick={handleRetry}+ disabled={call.isJoining()}+ class="rounded-lg bg-surface-2 px-4 py-2 text-sm text-ink hover:bg-surface-3 transition-colors disabled:opacity-50 disabled:pointer-events-none"+ >+ Try again+ </button>+ </div>+ </Match>+ <Match when={props.pendingJoin?.()}>+ <div class="flex size-full items-center justify-center text-ink-muted">+ Joining call...+ </div>+ </Match>+ </Switch>);}diff --git a/js/app/packages/channel/Call/InCallPanel/InCallAvatarPlaceholder.tsx b/js/app/packages/channel/Call/InCallPanel/InCallAvatarPlaceholder.tsxnew file mode 100644index 0000000000..7196263fee--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/InCallAvatarPlaceholder.tsx@@ -0,0 +1,54 @@+import User from '@phosphor-icons/core/regular/user.svg?component-solid';+import DotsThree from '@icon/regular/dots-three.svg';+import { Show, type Component } from 'solid-js';+import type { UserIconProps } from '@core/component/UserIcon';+import { cn } from '@ui/utils/classname';++export function inCallAvatarPlaceholderClasses(size: UserIconProps['size']) {+ const s = size ?? 'md';+ const container = cn(+ 'flex shrink-0 items-center justify-center rounded-full bg-ink-extra-muted text-panel leading-none',+ s === 'xs' && 'size-4',+ s === 'sm' && 'size-6',+ s === 'md' && 'size-8',+ s === 'lg' && 'size-10',+ s === 'xl' && 'size-25',+ s === 'fill' && 'size-8 w-full h-full'+ );+ const icon = cn(+ s === 'xs' && 'w-2 h-2',+ s === 'sm' && 'w-3 h-3',+ s === 'md' && 'w-4 h-4',+ s === 'lg' && 'w-5 h-5',+ s === 'xl' && 'w-16 h-16',+ s === 'fill' && 'w-4 h-4'+ );+ return { container, icon };+}++export const InCallAvatarPlaceholderShell: Component<{+ size?: UserIconProps['size'];+ variant?: 'placeholder' | 'view-more';+}> = (props) => {+ const classes = () => inCallAvatarPlaceholderClasses(props.size);+ return (+ <div+ class={cn(+ classes().container,+ props.variant === 'view-more' &&+ 'bg-transparent border-2 border-accent/70 rounded-full'+ )}+ >+ <Show when={props.variant === 'placeholder'}>+ <User class={cn(classes().icon, 'block')} aria-hidden />+ </Show>++ <Show when={props.variant === 'view-more'}>+ <DotsThree+ class="block h-6 w-6 bg-transparent text-accent"+ aria-hidden+ />+ </Show>+ </div>+ );+};diff --git a/js/app/packages/channel/Call/InCallPanel/InCallPanelView.tsx b/js/app/packages/channel/Call/InCallPanel/InCallPanelView.tsxnew file mode 100644index 0000000000..f5e00c1780--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/InCallPanelView.tsx@@ -0,0 +1,207 @@+import { Show, createMemo, type Component } from 'solid-js';+import type { CallControlsVariant } from '../CallControls/CallControls';+import { StackedAvatarsRow } from '@core/component/StackedAvatarsRow';+import ArrowsOut from '@icon/regular/arrows-out.svg';+import { CallControls } from '../CallControls/CallControls';+import { openChannelCallTab } from '../open-channel-call-tab';+import {+ IN_CALL_ROSTER_CARD_CLASS,+ InCallParticipantsListPopover,+ InCallRosterListSection,+} from './InCallParticipantsListPopover';+import { profilePictureIdForMember } from './profile-picture-id-for-member';+import type { InCallPanelProps } from '../InCallPanel/types';+import { useInCallPanel } from './use-in-call-panel';+import {+ IN_CALL_LOCAL_STRIP_PENDING_ID,+ IN_CALL_STRIP_IMAGE_SIZE,+ InCallStripAvatarImage,+ type InCallStripImage,+} from './InCallStripAvatarImage';+import { cn } from '@ui/utils/classname';++export const InCallPanel: Component<InCallPanelProps> = (props) => {+ const panel = useInCallPanel({+ channelId: props.channelId,+ onLeaveCall: props.onLeaveCall,+ onJoinCall: props.onJoinCall,+ });++ /** Memo so `props.isSlim` (boolean or accessor) always drives updates. */+ const isSlimLayout = createMemo((): boolean => {+ const v = props.isSlim;+ return typeof v === 'function' ? v() : v;+ });+ const slim = () => isSlimLayout();++ const showCallLabel = createMemo(() => !isSlimLayout());++ const onCallPage = createMemo(() => panel.callCtx.isCallPage());++ const showHeaderPulse = createMemo(+ () => !isSlimLayout() || (isSlimLayout() && onCallPage())+ );++ const orderedMembers = createMemo(() => [+ ...panel.visibleMembers(),+ ...panel.overflowMembers(),+ ]);++ /** Full roster order for the in-call avatar strip. */+ const stripStackEach = createMemo((): InCallStripImage[] => {+ if (!panel.isActive()) return [];+ const out: InCallStripImage[] = [];+ for (const member of orderedMembers()) {+ if (member.kind === 'local') {+ const id = profilePictureIdForMember(panel, member);+ if (id) {+ out.push({ userId: id, stripMemberKind: 'local' });+ } else {+ out.push({+ userId: IN_CALL_LOCAL_STRIP_PENDING_ID,+ stripMemberKind: 'local',+ stripLocalPending: true,+ });+ }+ continue;+ }+ const id = profilePictureIdForMember(panel, member);+ if (!id) continue;+ const name = member.participant.name?.trim();+ out.push({+ userId: id,+ stripMemberKind: 'remote',+ ...(name ? { tooltip: name } : {}),+ });+ }+ return out;+ });++ const controlsVariant = createMemo(+ (): CallControlsVariant => (slim() ? 'panel-small' : 'panel')+ );++ const showExpandToFullCall = createMemo(() => !onCallPage());++ const headerRowClass = createMemo(() =>+ cn(+ 'py-1 px-2 border-b border-edge-muted bg-accent/5 rounded-t-lg flex items-center gap-1 min-w-0 w-full',+ !slim() || showExpandToFullCall()+ ? 'justify-between gap-0'+ : 'justify-center'+ )+ );++ return (+ <Show when={() => panel.isActive()}>+ <section+ data-in-call-panel+ aria-label="In call"+ class="relative isolate overflow-hidden rounded-lg border border-edge-muted"+ >+ <div class={headerRowClass()}>+ <div+ class={cn(+ 'flex min-w-0 shrink-0 items-center gap-0.5',+ slim() && !showExpandToFullCall() && 'p-1'+ )}+ >+ <Show when={showHeaderPulse()}>+ <span+ class={cn(+ 'size-1.5 shrink-0 rounded-full bg-accent animate-pulse',+ showCallLabel() && 'mr-1'+ )}+ />+ </Show>++ <Show when={showCallLabel()}>+ <span class="text-sm text-accent truncate">Call</span>+ </Show>+ </div>++ <Show when={showExpandToFullCall()}>+ <button+ type="button"+ class={cn(+ 'shrink-0 transition-colors cursor-pointer hover:bg-accent/30 outline-0 outline-accent/50 hover:outline-1 hover-transition-outline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-edge-muted',+ slim() && 'animate-pulse hover:outline-0'+ )}+ title="Open full call view"+ aria-label="Open full call view"+ onClick={() => {+ const id = panel.callCtx.activeChannelId();+ if (id) void openChannelCallTab(id);+ }}+ >+ <ArrowsOut+ class={cn('text-accent', slim() ? 'h-3.5 w-3.5' : 'h-4 w-4')}+ />+ </button>+ </Show>+ </div>++ <div+ class={cn(+ 'px-2 py-3 bg-panel rounded-b-lg w-full',+ slim() && 'px-2 pt-2 pb-1 flex flex-col items-center gap-2'+ )}+ >+ <div+ class={cn(+ 'flex flex-row items-center leading-none min-w-0 w-full',+ slim() ? 'justify-center' : 'justify-between'+ )}+ data-in-call-panel-avatars+ >+ <Show when={!slim()}>+ <StackedAvatarsRow<InCallStripImage>+ class="w-full min-w-0"+ distribute="fill"+ each={stripStackEach}+ max={6}+ size={IN_CALL_STRIP_IMAGE_SIZE}+ defaultEmptyUserPlaceholder+ overflowChipClass="bg-edge-muted"+ overflowTooltipContent={(close) => (+ <div class={IN_CALL_ROSTER_CARD_CLASS}>+ <InCallRosterListSection+ panel={panel}+ members={orderedMembers()}+ onClose={() => close()}+ allowOpenDm={false}+ />+ </div>+ )}+ >+ {(image) => (+ <InCallStripAvatarImage+ image={image}+ trackCall={() => panel.callCtx.trackVersion()}+ />+ )}+ </StackedAvatarsRow>+ </Show>++ <Show when={slim()}>+ <InCallParticipantsListPopover panel={panel} />+ </Show>+ </div>+ </div>++ <div+ class={cn(+ !slim() && 'bg-panel border-t border-edge-muted',+ slim() && 'px-2 pt-1 pb-2'+ )}+ >+ <CallControls+ variant={controlsVariant()}+ when={props.showCallControls}+ onLeave={() => panel.controls.leaveCall()}+ />+ </div>+ </section>+ </Show>+ );+};diff --git a/js/app/packages/channel/Call/InCallPanel/InCallParticipantAvatar.tsx b/js/app/packages/channel/Call/InCallPanel/InCallParticipantAvatar.tsxnew file mode 100644index 0000000000..9f0c4be116--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/InCallParticipantAvatar.tsx@@ -0,0 +1,51 @@+import { type Accessor, Show } from 'solid-js';+import { tryMacroId, type MacroId as MacroIdType } from '@core/user';+import { UserIcon } from '@core/component/UserIcon';+import type { UserIconProps } from '@core/component/UserIcon';+import type { InCallPanelMember, UseInCallPanelResult } from './types';+import { profilePictureIdForMember } from './profile-picture-id-for-member';+import { InCallAvatarPlaceholderShell } from './InCallAvatarPlaceholder';++/**+ * Renders `UserIcon` once LiveKit identity is available; until then shows the+ * generic silhouette. `ProfilePicture` inside `UserIcon` handles letter vs photo.+ */+export function InCallParticipantAvatar(props: {+ panel: UseInCallPanelResult;+ member: InCallPanelMember;+ size?: UserIconProps['size'];+}) {+ const rawIdentity = () =>+ profilePictureIdForMember(props.panel, props.member);++ const size = () => props.size ?? 'md';++ const userIconId = (raw: string): MacroIdType => {+ const t = raw.trim();+ return (tryMacroId(t) ?? t) as MacroIdType;+ };++ return (+ <Show+ when={rawIdentity}+ keyed+ fallback={<InCallAvatarPlaceholderShell size={size()} />}+ >+ {(raw) => {+ const id =+ typeof raw === 'function'+ ? (raw as Accessor<string | undefined>)()+ : raw;+ if (!id) return <InCallAvatarPlaceholderShell size={size()} />;+ return (+ <UserIcon+ id={userIconId(id)}+ size={size()}+ suppressClick+ showTooltip={false}+ />+ );+ }}+ </Show>+ );+}diff --git a/js/app/packages/channel/Call/InCallPanel/InCallParticipantsListPopover.tsx b/js/app/packages/channel/Call/InCallPanel/InCallParticipantsListPopover.tsxnew file mode 100644index 0000000000..76a5c8ab14--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/InCallParticipantsListPopover.tsx@@ -0,0 +1,173 @@+import { Popover } from '@kobalte/core/popover';+import UserCircle from '@icon/regular/user-circle.svg';+import { For, Show, createMemo, createSignal } from 'solid-js';+import { tryMacroId, useDisplayName } from '@core/user';+import { toast } from '@core/component/Toast/Toast';+import { useSplitLayout } from '@app/component/split-layout/layout';+import { useGetOrCreateDirectMessageMutation } from '@queries/channel/get-or-create-dm';+import type { InCallPanelMember, UseInCallPanelResult } from './types';+import { InCallParticipantAvatar } from './InCallParticipantAvatar';+import { profilePictureIdForMember } from './profile-picture-id-for-member';+import { cn } from '@ui/utils/classname';++/** Shared shell for “In this call” (popover content + +N tooltip). */+export const IN_CALL_ROSTER_CARD_CLASS =+ 'z-modal min-w-[12rem] max-w-[18rem] rounded-md border border-edge-muted bg-panel shadow-lg';++export function InCallRosterListSection(props: {+ panel: UseInCallPanelResult;+ members: InCallPanelMember[];+ onClose: () => void;+ allowOpenDm?: boolean;+}) {+ return (+ <>+ <div class="rounded-t-md border-b border-edge px-2 py-2.5 text-xs font-medium text-accent">+ In this call+ </div>+ <div class="max-h-64 overflow-y-auto p-1">+ <Show+ when={props.members.length > 0}+ fallback={+ <div class="px-2 py-2 text-sm text-ink-muted">Connecting…</div>+ }+ >+ <For each={props.members}>+ {(member) => (+ <InCallParticipantNameRow+ panel={props.panel}+ member={member}+ onClose={props.onClose}+ allowOpenDm={props.allowOpenDm}+ />+ )}+ </For>+ </Show>+ </div>+ </>+ );+}++export function InCallParticipantNameRow(props: {+ panel: UseInCallPanelResult;+ member: InCallPanelMember;+ onClose: () => void;+ /** When false, the row is display-only (no DM on click). Default true. */+ allowOpenDm?: boolean;+}) {+ const { replaceOrInsertSplit } = useSplitLayout();+ const getOrCreateDmMutation = useGetOrCreateDirectMessageMutation({+ onError: () => toast.failure('Could not open direct message'),+ });++ const raw = profilePictureIdForMember(props.panel, props.member);+ const [displayName] = useDisplayName(tryMacroId(raw ?? ''));+ const label = createMemo(() => {+ props.panel.callCtx.trackVersion();+ const r = profilePictureIdForMember(props.panel, props.member);+ return (+ displayName() ||+ r ||+ (props.member.kind === 'local' ? 'You' : 'Participant')+ );+ });++ const isRemote = () => props.member.kind === 'remote';+ const allowDm = () => props.allowOpenDm !== false;+ const isInteractive = () => isRemote() && allowDm();++ const openDm = () => {+ if (props.member.kind !== 'remote') return;+ const { identity } = props.member.participant;+ if (!identity.startsWith('macro|') || !identity.slice(6).includes('@'))+ return;+ getOrCreateDmMutation.mutate(+ { recipient_id: identity },+ {+ onSuccess: ({ channel_id }) => {+ props.onClose();+ replaceOrInsertSplit({ type: 'channel', id: channel_id });+ },+ }+ );+ };++ return (+ <div+ role={isInteractive() ? 'button' : undefined}+ tabIndex={isInteractive() ? 0 : undefined}+ onClick={isInteractive() ? openDm : undefined}+ onKeyDown={+ isInteractive() ? (e) => e.key === 'Enter' && void openDm() : undefined+ }+ class={cn(+ 'flex min-w-0 items-center gap-2 rounded-xs px-1 py-1',+ isInteractive() ? 'cursor-pointer hover:bg-hover' : 'cursor-default'+ )}+ >+ <InCallParticipantAvatar+ panel={props.panel}+ member={props.member}+ size="sm"+ />+ <span class="truncate text-sm text-ink">{label()}</span>+ <Show when={props.member.kind === 'local'}>+ <span class="ml-auto text-xs text-ink-muted shrink-0">You</span>+ </Show>+ </div>+ );+}++export type InCallParticipantsListPopoverProps = {+ panel: UseInCallPanelResult;+ class?: string;+};++/**+ * Slim in-call panel only: compact trigger opens the full roster (`InCallRosterListSection`).+ * Parent should render only when the panel is in slim layout.+ */+export function InCallParticipantsListPopover(+ props: InCallParticipantsListPopoverProps+) {+ const [open, setOpen] = createSignal(false);++ const members = createMemo(() => [+ ...props.panel.visibleMembers(),+ ...props.panel.overflowMembers(),+ ]);++ return (+ <Popover+ open={open()}+ onOpenChange={setOpen}+ placement="right-start"+ gutter={8}+ overflowPadding={8}+ >+ <Popover.Trigger+ as="button"+ type="button"+ class={cn(+ 'inline-flex items-center justify-center rounded-full bg-transparent p-0 transition-colors hover:bg-accent/15 cursor-pointer text-accent',+ props.class+ )}+ aria-haspopup="dialog"+ aria-expanded={open()}+ aria-label="Everyone in call"+ >+ <UserCircle class="block h-4 w-4" />+ </Popover.Trigger>++ <Popover.Portal>+ <Popover.Content class={IN_CALL_ROSTER_CARD_CLASS}>+ <InCallRosterListSection+ panel={props.panel}+ members={members()}+ onClose={() => setOpen(false)}+ />+ </Popover.Content>+ </Popover.Portal>+ </Popover>+ );+}diff --git a/js/app/packages/channel/Call/InCallPanel/InCallStripAvatarImage.tsx b/js/app/packages/channel/Call/InCallPanel/InCallStripAvatarImage.tsxnew file mode 100644index 0000000000..933b84a089--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/InCallStripAvatarImage.tsx@@ -0,0 +1,69 @@+import { Show, type Component } from 'solid-js';+import { tryMacroId, useDisplayName } from '@core/user';+import { Tooltip } from '@core/component/Tooltip';+import { UserIcon } from '@core/component/UserIcon';+import {+ StackedAvatarsDefaultEmptyPlaceholder,+ stackedAvatarInnerClass,+ type StackedAvatarInput,+ type StackedAvatarsSize,+} from '@core/component/StackedAvatarsRow';++/** Matches {@link UserIcon} `lg` (`size-10`) for the in-call strip. */+export const IN_CALL_STRIP_IMAGE_SIZE = 'lg' satisfies StackedAvatarsSize;++/** Stable id for the local slot before `room().localParticipant.identity` is available. */+export const IN_CALL_LOCAL_STRIP_PENDING_ID = '__in_call_local_pending__';++export type InCallStripImage = StackedAvatarInput & {+ stripMemberKind: 'local' | 'remote';+ /** Local participant: show ring placeholder until LiveKit identity is ready for `UserIcon`. */+ stripLocalPending?: boolean;+};++export const InCallStripAvatarImage: Component<{+ image: InCallStripImage;+ trackCall?: () => unknown;+}> = (props) => {+ const [displayName] = useDisplayName(+ props.image.stripLocalPending ? undefined : tryMacroId(props.image.userId)+ );++ const nameLabel = () => {+ props.trackCall?.();+ if (props.image.stripLocalPending) return 'You';+ const fromProfile = displayName()?.trim();+ if (fromProfile) return fromProfile;+ const liveKit = props.image.tooltip?.trim();+ if (liveKit) return liveKit;+ return (+ props.image.userId?.split('|').at(1)?.split('@')[0] ||+ (props.image.stripMemberKind === 'remote' ? 'Participant' : 'You')+ );+ };++ return (+ <Tooltip+ tooltip={<span class="wrap-break-word text-ink">{nameLabel()}</span>}+ >+ <Show+ when={props.image.stripLocalPending}+ fallback={+ <div class={stackedAvatarInnerClass(IN_CALL_STRIP_IMAGE_SIZE)}>+ <UserIcon+ id={props.image.userId}+ isDeleted={false}+ size="fill"+ showTooltip={false}+ suppressClick+ />+ </div>+ }+ >+ <StackedAvatarsDefaultEmptyPlaceholder+ size={IN_CALL_STRIP_IMAGE_SIZE}+ />+ </Show>+ </Tooltip>+ );+};diff --git a/js/app/packages/channel/Call/InCallPanel/in-call-panel-debug.ts b/js/app/packages/channel/Call/InCallPanel/in-call-panel-debug.tsnew file mode 100644index 0000000000..cf9bdf825a--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/in-call-panel-debug.ts@@ -0,0 +1,33 @@+import type { RemoteParticipant } from 'livekit-client';+import type { InCallPanelMember } from './types';++const QUERY_KEY = 'in_call_debug_extra';+/** Upper bound so absurd query values do not freeze the tab in dev. */+const MAX_EXTRAS = 500;++/**+ * Dev-only: append N fake remotes to the in-call roster for layout testing.+ * Add e.g. `?in_call_debug_extra=8` to the page URL (integer 1–500, clamped). No-op in prod builds.+ */+export function readInCallPanelDebugExtraRemoteCount(): number {+ if (!import.meta.env.DEV) return 0;+ if (typeof window === 'undefined') return 0;+ const raw = new URLSearchParams(window.location.search).get(QUERY_KEY);+ if (raw == null || raw === '') return 0;+ const n = Number.parseInt(raw, 10);+ if (!Number.isFinite(n) || n < 1) return 0;+ return Math.min(n, MAX_EXTRAS);+}++export function debugInCallExtraRemoteMembers(+ count: number+): InCallPanelMember[] {+ return Array.from({ length: count }, (_, i) => {+ const participant = {+ sid: `debug-mock-${i}`,+ identity: `debug-mock-participant-${i}`,+ isAgent: false,+ } as RemoteParticipant;+ return { kind: 'remote' as const, participant };+ });+}diff --git a/js/app/packages/channel/Call/InCallPanel/index.ts b/js/app/packages/channel/Call/InCallPanel/index.tsnew file mode 100644index 0000000000..8de30cf707--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/index.ts@@ -0,0 +1,18 @@+export { InCallPanel } from './InCallPanelView';+export { InCallParticipantsListPopover } from './InCallParticipantsListPopover';+export type { InCallParticipantsListPopoverProps } from './InCallParticipantsListPopover';+export { useInCallPanel } from './use-in-call-panel';+export {+ IN_CALL_PANEL_VISIBLE_AVATAR_COUNT,+ buildOrderedInCallMembers,+ buildVisibleAvatarSlots,+ splitInCallMembersForAvatars,+} from './members';+export type {+ InCallPanelMember,+ InCallVisibleAvatarSlot,+ InCallPanelControls,+ UseInCallPanelOptions,+ UseInCallPanelResult,+ InCallPanelProps,+} from './types';diff --git a/js/app/packages/channel/Call/InCallPanel/members.ts b/js/app/packages/channel/Call/InCallPanel/members.tsnew file mode 100644index 0000000000..7d6004ce79--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/members.ts@@ -0,0 +1,52 @@+import type { RemoteParticipant, Room } from 'livekit-client';+import type { InCallPanelMember, InCallVisibleAvatarSlot } from './types';++/** How many participant avatars show inline before the rest go in a dropdown. */+export const IN_CALL_PANEL_VISIBLE_AVATAR_COUNT = 3;++/** Non-slim panel: when there are more than this many people, show this many inline avatars plus the roster trigger. */+export const IN_CALL_PANEL_CROWDED_MEMBER_THRESHOLD = 5;+export const IN_CALL_PANEL_VISIBLE_AVATAR_COUNT_CROWDED = 4;++/**+ * Ordered list: local participant first, then non-agent remotes.+ * Empty when there is no room yet (e.g. still connecting).+ */+export function buildOrderedInCallMembers(+ room: Room | null,+ remoteParticipants: Map<string, RemoteParticipant>+): InCallPanelMember[] {+ if (!room) return [];+ const out: InCallPanelMember[] = [{ kind: 'local' }];+ for (const p of remoteParticipants.values()) {+ if (!p.isAgent) out.push({ kind: 'remote', participant: p });+ }+ return out;+}++export function splitInCallMembersForAvatars(+ members: InCallPanelMember[],+ visibleCount: number+): { visible: InCallPanelMember[]; overflow: InCallPanelMember[] } {+ return {+ visible: members.slice(0, visibleCount),+ overflow: members.slice(visibleCount),+ };+}++export function buildVisibleAvatarSlots(+ panelActive: boolean,+ members: InCallPanelMember[],+ visibleCount: number+): InCallVisibleAvatarSlot[] {+ if (!panelActive) return [];+ if (members.length === 0) {+ return [{ type: 'placeholder', key: 'connecting' }];+ }+ const slice = members.slice(0, visibleCount);+ return slice.map((member) => ({+ type: 'member',+ member,+ key: member.kind === 'local' ? 'local' : member.participant.sid,+ }));+}diff --git a/js/app/packages/channel/Call/InCallPanel/profile-picture-id-for-member.ts b/js/app/packages/channel/Call/InCallPanel/profile-picture-id-for-member.tsnew file mode 100644index 0000000000..d35ea38eee--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/profile-picture-id-for-member.ts@@ -0,0 +1,19 @@+import { tryMacroId } from '@core/user';+import type { InCallPanelMember, UseInCallPanelResult } from './types';++export function profilePictureIdForMember(+ panel: UseInCallPanelResult,+ member: InCallPanelMember+): string | undefined {+ // LiveKit mutates participant fields on stable object refs — `room()` alone+ // does not invalidate. Re-read when connection or participant/track state changes.+ panel.callCtx.connectionState();+ panel.callCtx.trackVersion();++ if (member.kind === 'local') {+ const identity = panel.callCtx.room()?.localParticipant.identity;+ if (!identity) return undefined;+ return tryMacroId(identity) ?? identity;+ }+ return tryMacroId(member.participant.identity) ?? member.participant.identity;+}diff --git a/js/app/packages/channel/Call/InCallPanel/types.ts b/js/app/packages/channel/Call/InCallPanel/types.tsnew file mode 100644index 0000000000..62d4fbc303--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/types.ts@@ -0,0 +1,62 @@+import type { RemoteParticipant } from 'livekit-client';+import type { Accessor } from 'solid-js';+import type { CallState } from '../CallContext';++export type InCallPanelMember =+ | { kind: 'local' }+ | { kind: 'remote'; participant: RemoteParticipant };++export type InCallVisibleAvatarSlot =+ | { type: 'member'; member: InCallPanelMember; key: string }+ | { type: 'placeholder'; key: string };++export type InCallPanelControls = {+ toggleAudio: () => Promise<void>;+ toggleVideo: () => Promise<void>;+ toggleScreenShare: () => Promise<void>;+ leaveCall: () => Promise<void>;+ switchAudioInput: CallState['switchAudioInput'];+ switchAudioOutput: CallState['switchAudioOutput'];+ switchVideoInput: CallState['switchVideoInput'];+};++export type UseInCallPanelOptions = {+ /**+ * When set, `isActive` is true only if the active call is for this channel.+ * Omit to treat any active call as active (sidebar-global).+ */+ channelId?: Accessor<string | undefined>;+ /** Same role as `useCall` `onLeave` (e.g. switch tab back to Messages). */+ onLeaveCall?: () => void;+ onJoinCall?: () => void;+};++export type UseInCallPanelResult = {+ /** Whether the panel should render (in a call, and optional channel filter). */+ isActive: () => boolean;+ /** Members shown as inline avatars. */+ visibleMembers: Accessor<InCallPanelMember[]>;+ /** One placeholder while connecting; otherwise up to visible cap members (no padding). */+ visibleAvatarSlots: Accessor<InCallVisibleAvatarSlot[]>;+ /** Members listed in the overflow dropdown. */+ overflowMembers: Accessor<InCallPanelMember[]>;+ isConnecting: CallState['isConnecting'];+ /** LiveKit + device state (read in your DOM). */+ callCtx: CallState;+ /** Join / leave orchestration for this channel. */+ controls: InCallPanelControls;+};++export type InCallPanelProps = {+ /** Plain boolean or accessor so sidebar width updates stay tracked in Solid. */+ isSlim: boolean | Accessor<boolean>;+ channelId?: Accessor<string | undefined>;+ onLeaveCall?: () => void;+ onJoinCall?: () => void;+ class?: string;+ /**+ * When false, the in-panel mic / camera / screen / leave row is hidden.+ * Omitted defaults to visible. Use an accessor to toggle reactively.+ */+ showCallControls?: boolean | Accessor<boolean>;+};diff --git a/js/app/packages/channel/Call/InCallPanel/use-in-call-panel.ts b/js/app/packages/channel/Call/InCallPanel/use-in-call-panel.tsnew file mode 100644index 0000000000..5edfe2ac54--- /dev/null+++ b/js/app/packages/channel/Call/InCallPanel/use-in-call-panel.ts@@ -0,0 +1,84 @@+import { createMemo } from 'solid-js';+import { useCall } from '../use-call';+import { useCallContext } from '../CallContext';+import type { UseInCallPanelOptions, UseInCallPanelResult } from './types';+import {+ debugInCallExtraRemoteMembers,+ readInCallPanelDebugExtraRemoteCount,+} from './in-call-panel-debug';+import {+ IN_CALL_PANEL_VISIBLE_AVATAR_COUNT,+ buildOrderedInCallMembers,+ buildVisibleAvatarSlots,+ splitInCallMembersForAvatars,+} from './members';++/**+ * Headless model for the in-call sidebar strip: participant split + the same+ * control surface as `CallOverlay` (mic / cam / screen / leave + device switches).+ *+ * Dev: `?in_call_debug_extra=8` appends fake remotes for crowded-roster UI (see `inCallPanelDebug.ts`;+ * values are clamped to a max in that module).+ */+export function useInCallPanel(+ options?: UseInCallPanelOptions+): UseInCallPanelResult {+ const callCtx = useCallContext();++ const resolvedChannelId = () =>+ options?.channelId?.() ?? callCtx.activeChannelId() ?? '';++ const call = useCall(resolvedChannelId, {+ onJoin: options?.onJoinCall,+ onLeave: options?.onLeaveCall,+ });++ const members = createMemo(() => {+ const real = buildOrderedInCallMembers(+ callCtx.room(),+ callCtx.remoteParticipants()+ );+ const extra = readInCallPanelDebugExtraRemoteCount();+ if (extra === 0) return real;+ return [...real, ...debugInCallExtraRemoteMembers(extra)];+ });++ const avatarSplit = createMemo(() =>+ splitInCallMembersForAvatars(members(), IN_CALL_PANEL_VISIBLE_AVATAR_COUNT)+ );++ const isActive = () => {+ if (!callCtx.isInCall()) return false;+ if (options?.channelId === undefined) return true;+ return callCtx.activeChannelId() === options.channelId();+ };++ const avatarSlotsRow = createMemo(() =>+ buildVisibleAvatarSlots(+ isActive(),+ members(),+ IN_CALL_PANEL_VISIBLE_AVATAR_COUNT+ )+ );++ const controls = {+ toggleAudio: () => callCtx.toggleAudio(),+ toggleVideo: () => callCtx.toggleVideo(),+ toggleScreenShare: () => callCtx.toggleScreenShare(),+ leaveCall: () => call.leaveCall(),+ switchAudioInput: (deviceId: string) => callCtx.switchAudioInput(deviceId),+ switchAudioOutput: (deviceId: string) =>+ callCtx.switchAudioOutput(deviceId),+ switchVideoInput: (deviceId: string) => callCtx.switchVideoInput(deviceId),+ };++ return {+ isActive,+ visibleMembers: () => avatarSplit().visible,+ visibleAvatarSlots: () => avatarSlotsRow(),+ overflowMembers: () => avatarSplit().overflow,+ isConnecting: callCtx.isConnecting,+ callCtx,+ controls,+ };+}diff --git a/js/app/packages/channel/Call/index.ts b/js/app/packages/channel/Call/index.tsindex d904f0593e..f92bb39975 100644--- a/js/app/packages/channel/Call/index.ts+++ b/js/app/packages/channel/Call/index.ts@@ -4,10 +4,38 @@ export {useCallContextOptional,} from './CallContext';export type { CallState } from './CallContext';-export { useCall } from './useCall';+export { useCall } from './use-call';export { CallOverlay } from './CallOverlay';+export { CallControls } from './CallControls/CallControls';+export type {+ CallControlsProps,+ CallControlsVariant,+} from './CallControls/CallControls';+export type {+ CallControlButtonSize,+ CallControlButtonVariant,+} from './CallControls/CallControlButton';export { CallAudioSink } from './CallAudioSink';export { ChannelCallButton } from './ChannelCallButton';export { ChannelCallTab } from './ChannelCallTab';export { ChannelCallAutoJoin } from './ChannelCallAutoJoin';export { CallEventSync } from './CallEventSync';+export { openChannelCallTab } from './open-channel-call-tab';+export {+ InCallPanel,+ InCallParticipantsListPopover,+ useInCallPanel,+ buildOrderedInCallMembers,+ buildVisibleAvatarSlots,+ splitInCallMembersForAvatars,+ IN_CALL_PANEL_VISIBLE_AVATAR_COUNT,+} from './InCallPanel';+export type {+ InCallPanelMember,+ InCallVisibleAvatarSlot,+ InCallPanelControls,+ UseInCallPanelOptions,+ UseInCallPanelResult,+ InCallPanelProps,+ InCallParticipantsListPopoverProps,+} from './InCallPanel';diff --git a/js/app/packages/channel/Call/open-channel-call-tab.ts b/js/app/packages/channel/Call/open-channel-call-tab.tsnew file mode 100644index 0000000000..7c20a621a6--- /dev/null+++ b/js/app/packages/channel/Call/open-channel-call-tab.ts@@ -0,0 +1,27 @@+import { globalSplitManager } from '@app/signal/splitLayout';+import { URL_PARAMS } from '@channel/Channel/link';++/**+ * Focuses the channel split (opens if needed) and switches to the Call tab+ * without triggering join-call flows.+ */+export async function openChannelCallTab(channelId: string): Promise<void> {+ const manager = globalSplitManager();+ if (!manager || !channelId) return;++ const existing = manager.getSplitByContent('channel', channelId);+ if (existing) {+ existing.activate();+ } else {+ manager.openWithSplit(+ { type: 'channel', id: channelId },+ { activate: true, referredFrom: 'sidebar' }+ );+ }++ const orchestrator = manager.getOrchestrator();+ const handle = await orchestrator.getBlockHandle(channelId, 'channel');+ await handle?.goToLocationFromParams({+ [URL_PARAMS.openCallTab]: 'true',+ });+}diff --git a/js/app/packages/channel/Call/use-call.ts b/js/app/packages/channel/Call/use-call.tsnew file mode 100644index 0000000000..35aedc0115--- /dev/null+++ b/js/app/packages/channel/Call/use-call.ts@@ -0,0 +1,169 @@+import { useLeaveCallMutation } from '@queries/call/call';+import { queryClient } from '@queries/client';+import { useMutation } from '@tanstack/solid-query';+import { callServiceClient } from '@service-call/client';+import { throwOnErr } from '@core/util/maybeResult';+import { RoomEvent } from 'livekit-client';+import { createSignal, onCleanup } from 'solid-js';+import { useCallContext } from './CallContext';++type UseCallOptions = {+ /** Called after successfully joining a call. */+ onJoin?: () => void;+ /** Called when the call ends for any reason (user leave, disconnect, kicked, etc.). */+ onLeave?: () => void;+};++type JoinCallContext = {+ channelId: string;+};++const JOIN_TIMEOUT_MS = 15_000;++/**+ * Hook that orchestrates joining/leaving calls by combining+ * the API mutations with the LiveKit room connection.+ *+ * Join is implemented as a single TanStack mutation so optimistic UI, timeout,+ * rollback, and server cleanup stay in onMutate / onError / onSuccess.+ */+export function useCall(channelId: () => string, options?: UseCallOptions) {+ const callCtx = useCallContext();+ const leaveMutation = useLeaveCallMutation();++ // Track the disconnect listener so we can swap it when the room changes.+ let cleanupDisconnectListener: (() => void) | null = null;++ function attachDisconnectListener() {+ cleanupDisconnectListener?.();+ cleanupDisconnectListener = null;++ const room = callCtx.room();+ if (!room) return;++ const handleDisconnect = () => options?.onLeave?.();+ room.on(RoomEvent.Disconnected, handleDisconnect);+ cleanupDisconnectListener = () =>+ room.off(RoomEvent.Disconnected, handleDisconnect);+ }++ // If the call is already active for this channel (e.g. the user navigated+ // away and came back), eagerly attach the disconnect listener so onLeave+ // fires when the call ends.+ if (callCtx.isInCall() && callCtx.activeChannelId() === channelId()) {+ attachDisconnectListener();+ }++ onCleanup(() => cleanupDisconnectListener?.());++ /** Cleared in `joinCall` `finally` + safety timer so Try again never stays disabled if TanStack pending glitches. */+ const [joinUiPending, setJoinUiPending] = createSignal(false);++ let cancelCurrentJoin: () => void = () => {};++ const joinCallMutation = useMutation(() => ({+ mutationFn: async (id: string) => {+ let cancelled = false;+ cancelCurrentJoin = () => {+ cancelled = true;+ };++ const doConnect = async () => {+ // Call the join API directly so a timed-out join attempt cannot leave+ // `useJoinCallMutation` stuck pending and block the next retry.+ const [tokenResponse] = await Promise.all([+ throwOnErr(() => callServiceClient.getOrCreateCall(id)),+ new Promise<void>((resolve) => setTimeout(resolve, 300)),+ ]);+ if (cancelled) return;+ await callCtx.connect(tokenResponse);+ };++ const timeout = new Promise<never>((_, reject) =>+ setTimeout(+ () => reject(new Error('Connection timed out')),+ JOIN_TIMEOUT_MS+ )+ );++ await Promise.race([doConnect(), timeout]);+ },+ onMutate: (id: string): JoinCallContext => {+ cancelCurrentJoin();+ callCtx.beginOptimisticJoin(id);+ options?.onJoin?.();+ return { channelId: id };+ },+ onSuccess: () => {+ void queryClient.invalidateQueries({ queryKey: ['call', 'active'] });+ attachDisconnectListener();+ },+ // Keep this handler synchronous: we undo the optimistic join and show the+ // error message right away. LiveKit disconnect and the server leave call+ // run in a fire-and-forget async block — on flaky networks those can take+ // forever, and if we awaited them here TanStack would keep the mutation+ // pending and the Try again button would stay stuck.+ onError: (_err, channelId: string, _ctx: JoinCallContext | undefined) => {+ cancelCurrentJoin();+ callCtx.rollbackOptimisticJoin();+ callCtx.setJoinError(+ 'Unable to join the call. Please check your connection.'+ );+ void (async () => {+ try {+ await callCtx.disconnect();+ } catch (e) {+ console.error('join error recovery: disconnect failed', e);+ }+ try {+ await leaveMutation.mutateAsync(channelId);+ } catch (e) {+ console.error('join error recovery: leave server state failed', e);+ }+ })();+ },+ }));++ const joinCall = async () => {+ setJoinUiPending(true);+ const safetyMs = JOIN_TIMEOUT_MS + 5_000;+ const safetyTimer = globalThis.setTimeout(+ () => setJoinUiPending(false),+ safetyMs+ );+ try {+ await joinCallMutation.mutateAsync(channelId());+ } finally {+ globalThis.clearTimeout(safetyTimer);+ setJoinUiPending(false);+ }+ };++ async function leaveCall() {+ const id = channelId();+ // Detach before disconnect so the RoomEvent.Disconnected handler+ // doesn't double-fire onLeave.+ cleanupDisconnectListener?.();+ cleanupDisconnectListener = null;+ try {+ await callCtx.disconnect();+ options?.onLeave?.();+ } finally {+ await leaveMutation.mutateAsync(id);+ }+ }++ return {+ joinCall,+ leaveCall,+ // Rely on `joinUiPending` (finally + safety timer) so the button is not+ // gated on `joinCallMutation.isPending`, which can stick true in edge cases.+ isJoining: () => joinUiPending(),+ isLeaving: () => leaveMutation.isPending,+ isInCall: callCtx.isInCall,+ isInThisChannel: () =>+ callCtx.isInCall() && callCtx.activeChannelId() === channelId(),+ joinError: callCtx.joinError,+ callCtx,+ };+}diff --git a/js/app/packages/channel/Call/useCall.ts b/js/app/packages/channel/Call/useCall.tsdeleted file mode 100644index f24a707125..0000000000--- a/js/app/packages/channel/Call/useCall.ts+++ /dev/null@@ -1,85 +0,0 @@-import { useJoinCallMutation, useLeaveCallMutation } from '@queries/call/call';-import { RoomEvent } from 'livekit-client';-import { onCleanup } from 'solid-js';-import { useCallContext } from './CallContext';--type UseCallOptions = {- /** Called after successfully joining a call. */- onJoin?: () => void;- /** Called when the call ends for any reason (user leave, disconnect, kicked, etc.). */- onLeave?: () => void;-};--/**- * Hook that orchestrates joining/leaving calls by combining- * the API mutations with the LiveKit room connection.- */-export function useCall(channelId: () => string, options?: UseCallOptions) {- const callCtx = useCallContext();- const joinMutation = useJoinCallMutation();- const leaveMutation = useLeaveCallMutation();-- // Track the disconnect listener so we can swap it when the room changes.- let cleanupDisconnectListener: (() => void) | null = null;-- function attachDisconnectListener() {- cleanupDisconnectListener?.();- cleanupDisconnectListener = null;-- const room = callCtx.room();- if (!room) return;-- const handleDisconnect = () => options?.onLeave?.();- room.on(RoomEvent.Disconnected, handleDisconnect);- cleanupDisconnectListener = () =>- room.off(RoomEvent.Disconnected, handleDisconnect);- }-- onCleanup(() => cleanupDisconnectListener?.());-- async function joinCall() {- const id = channelId();- const tokenResponse = await joinMutation.mutateAsync(id);- try {- await callCtx.connect(tokenResponse);- } catch (e) {- // Roll back the backend join so it doesn't think we're in the call- try {- await leaveMutation.mutateAsync(id);- } catch (leaveErr) {- console.error(- 'Failed to roll back join after connect failure',- leaveErr- );- }- throw e;- }- attachDisconnectListener();- options?.onJoin?.();- }-- async function leaveCall() {- const id = channelId();- // Detach before disconnect so the RoomEvent.Disconnected handler- // doesn't double-fire onLeave.- cleanupDisconnectListener?.();- cleanupDisconnectListener = null;- try {- await callCtx.disconnect();- options?.onLeave?.();- } finally {- await leaveMutation.mutateAsync(id);- }- }-- return {- joinCall,- leaveCall,- isJoining: () => joinMutation.isPending,- isLeaving: () => leaveMutation.isPending,- isInCall: callCtx.isInCall,- isInThisChannel: () =>- callCtx.isInCall() && callCtx.activeChannelId() === channelId(),- callCtx,- };-}diff --git a/js/app/packages/channel/Channel/link.ts b/js/app/packages/channel/Channel/link.tsindex e05346864d..2af5276725 100644--- a/js/app/packages/channel/Channel/link.ts+++ b/js/app/packages/channel/Channel/link.ts@@ -7,6 +7,8 @@ export const URL_PARAMS = {thread: 'channel_thread_id',message: 'channel_message_id',joinCall: 'join_call',+ /** Switch to the Call tab without starting a join (e.g. sidebar → full call UI). */+ openCallTab: 'open_call_tab',};export function getChannelParams(@@ -27,3 +29,8 @@ export function getChannelParams(export function isJoinCallRequested(value: unknown): boolean {return value === 'true' || value === true;}++/** True when we should only show the Call tab (already in / joining call). */+export function isOpenCallTabRequested(value: unknown): boolean {+ return value === 'true' || value === true;+}diff --git a/js/app/packages/channel/Thread/ThreadRow.tsx b/js/app/packages/channel/Thread/ThreadRow.tsxindex d80f74cde0..fbc9040958 100644--- a/js/app/packages/channel/Thread/ThreadRow.tsx+++ b/js/app/packages/channel/Thread/ThreadRow.tsx@@ -25,7 +25,7 @@ export function ThreadRow(props: ThreadRowProps) {createdAt={props.message.created_at}listMeta={props.listMeta}/>- <div class="relative">+ <div class="relative isolate"><ThreadRail newMessage={props.listMeta?.isNewMessage} />{props.children}</div>diff --git a/js/app/packages/core/component/StackedAvatarsRow.tsx b/js/app/packages/core/component/StackedAvatarsRow.tsxnew file mode 100644index 0000000000..5cb2824fca--- /dev/null+++ b/js/app/packages/core/component/StackedAvatarsRow.tsx@@ -0,0 +1,411 @@+import User from '@phosphor-icons/core/regular/user.svg?component-solid';+import {+ For,+ Show,+ createEffect,+ createMemo,+ createSignal,+ onCleanup,+ type Accessor,+ type JSX,+} from 'solid-js';+import { Tooltip } from './Tooltip';+import type { UserIconProps } from './UserIcon';+import { cn } from '@ui/utils/classname';++/** Same keys as {@link UserIconProps} `size` (aligned ring + overlap + overflow chip). */+export type StackedAvatarsSize = NonNullable<UserIconProps['size']>;++/** `distribute="fill"`: face + chip footprint in px (matches Tailwind `size-*` at default rem). */+const AVATAR_DIAMETER_PX: Record<StackedAvatarsSize, number> = {+ xs: 16,+ sm: 24,+ md: 32,+ lg: 40,+ xl: 100,+ fill: 32,+};++/** Horizontal row shell: stacking context (`isolate`). */+export const STACKED_AVATARS_ROW_CLASS =+ 'flex items-center h-full shrink-0 w-fit isolate leading-none min-w-0';++export type StackedAvatarsOverflowContext<T = unknown> = {+ overflowItems: T[];+ overflowCount: number;+};++/**+ * Ring, overlap, and +N chip track {@link UserIcon} `sizeClasses().container` widths.+ * `fill` uses the md footprint (intrinsic fill still needs a sized parent for `UserIcon`).+ */+const STACK_STYLE: Record<+ StackedAvatarsSize,+ {+ overlap: string;+ overflowChip: string;+ overflowChipText: string;+ inner: string;+ /** Muted empty-slot user icon (same scale as in-call avatar placeholder shells). */+ defaultEmptyIcon: string;+ }+> = {+ xs: {+ overlap: '-mr-1.5',+ overflowChip:+ 'size-4 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',+ overflowChipText:+ 'text-[8px] font-semibold tabular-nums leading-none text-ink',+ inner:+ 'bg-panel size-4 rounded-full p-[1px] border-2 border-panel box-border',+ defaultEmptyIcon: 'w-2 h-2',+ },+ sm: {+ overlap: '-mr-2',+ overflowChip:+ 'size-6 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',+ overflowChipText:+ 'text-[10px] font-semibold tabular-nums leading-none text-ink',+ inner:+ 'bg-panel size-6 rounded-full p-[2px] border-2 border-panel box-border',+ defaultEmptyIcon: 'w-3 h-3',+ },+ md: {+ overlap: '-mr-3',+ overflowChip:+ 'size-8 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',+ overflowChipText:+ 'text-xs font-semibold tabular-nums leading-none text-ink',+ inner:+ 'bg-panel size-8 rounded-full p-[2px] border-2 border-panel box-border',+ defaultEmptyIcon: 'w-4 h-4',+ },+ lg: {+ overlap: '-mr-4',+ overflowChip:+ 'size-10 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',+ overflowChipText:+ 'text-sm font-semibold tabular-nums leading-none text-ink',+ inner:+ 'bg-panel size-10 rounded-full p-[2px] border-2 border-panel box-border',+ defaultEmptyIcon: 'w-5 h-5',+ },+ xl: {+ overlap: '-mr-10',+ overflowChip:+ 'size-25 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',+ overflowChipText:+ 'text-lg font-semibold tabular-nums leading-none text-ink',+ inner:+ 'bg-panel size-25 rounded-full p-[2px] border-2 border-panel box-border',+ defaultEmptyIcon: 'w-16 h-16',+ },+ fill: {+ overlap: '-mr-3',+ overflowChip:+ 'size-8 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',+ overflowChipText:+ 'text-xs font-semibold tabular-nums leading-none text-ink',+ inner:+ 'bg-panel size-8 rounded-full p-[2px] border-2 border-panel box-border',+ defaultEmptyIcon: 'w-4 h-4',+ },+};++/** Inner ring around `UserIcon` (no overlap margin — the row applies overlap on a wrapper). */+export function stackedAvatarInnerClass(size: StackedAvatarsSize = 'md') {+ return STACK_STYLE[size].inner;+}++/** Default +N chip shell (no text); pair with {@link stackedAvatarOverflowChipTextClass}. */+export function stackedAvatarOverflowChipClass(+ size: StackedAvatarsSize = 'md'+) {+ return STACK_STYLE[size].overflowChip;+}++export function stackedAvatarOverflowChipTextClass(+ size: StackedAvatarsSize = 'md'+) {+ return STACK_STYLE[size].overflowChipText;+}++/**+ * Muted user-in-ring placeholder: same outer ring as stacked faces+ * ({@link stackedAvatarInnerClass}); icon scales with `size`.+ */+export function StackedAvatarsDefaultEmptyPlaceholder(props: {+ size?: StackedAvatarsSize;+}) {+ const s = () => props.size ?? 'md';+ return (+ <div class={stackedAvatarInnerClass(s())}>+ <div class="flex size-full min-h-0 min-w-0 items-center justify-center overflow-hidden rounded-full bg-ink-extra-muted text-panel leading-none">+ <User+ class={cn(STACK_STYLE[s()].defaultEmptyIcon, 'block shrink-0')}+ aria-hidden+ />+ </div>+ </div>+ );+}++export type StackedAvatarInput = {+ userId: string;+ tooltip?: string;+ onPress?: () => void;+ ariaLabel?: string;+};++export type StackedAvatarsRowProps<T = unknown> = {+ each: Accessor<T[]>;+ max: number | Accessor<number>;+ size?: StackedAvatarsSize;+ /** Shown when `each()` is empty (e.g. connecting); if truthy, overrides `defaultEmptyUserPlaceholder`. */+ placeholder?: Accessor<JSX.Element | undefined | null | false>;+ /** When the list is empty and `placeholder` is unset or falsy, show the built-in muted user ring at `size`. */+ defaultEmptyUserPlaceholder?: boolean;+ /** Face slot; use `UserIcon` with `showTooltip={false}` if you add your own `Tooltip`. */+ children: (item: T, index: number) => JSX.Element;+ /** Plain tooltip on the +N chip when not using `overflowTooltipContent`. */+ overflowTooltip?:+ | string+ | ((ctx: StackedAvatarsOverflowContext<T>) => string | undefined);+ overflowTooltipContent?: (+ close: () => void,+ ctx: StackedAvatarsOverflowContext<T>+ ) => JSX.Element;+ overflowWrap?: (+ ctx: StackedAvatarsOverflowContext<T> & { chip: JSX.Element }+ ) => JSX.Element;+ renderOverflow?: (ctx: StackedAvatarsOverflowContext<T>) => JSX.Element;+ overflowChipClass?: string;+ overflowChipLabelClass?: string;+ class?: string;+ /**+ * `fill`: when `each().length >= max`, ResizeObserver + per-gap `margin-right` so the strip+ * spans the row (below that count, behaves like `pack`). `pack`: fixed overlap from `size`.+ */+ distribute?: 'pack' | 'fill';+};++function maxValue(max: number | Accessor<number>) {+ return typeof max === 'function' ? max() : max;+}++function defaultOverflowChip(+ size: StackedAvatarsSize,+ overflowCount: number,+ chipClass?: string,+ labelClass?: string+): JSX.Element {+ return (+ <div+ class={cn(stackedAvatarOverflowChipClass(size), chipClass)}+ data-ui="stacked-avatars-overflow-chip"+ >+ <span+ class={cn(stackedAvatarOverflowChipTextClass(size), labelClass)}+ >{`+${overflowCount}`}</span>+ </div>+ );+}++export function StackedAvatarsRow<T = unknown>(+ props: StackedAvatarsRowProps<T>+) {+ const size = () => props.size ?? 'md';++ const distributeFill = () => props.distribute === 'fill';++ const [rowEl, setRowEl] = createSignal<HTMLDivElement | null>(null);+ const [rowWidth, setRowWidth] = createSignal(0);++ const all = createMemo(() => props.each());++ const maxed = () => {+ const m = maxValue(props.max);+ if (!Number.isFinite(m) || m < 0) return 0;+ return m;+ };++ /** `distribute="fill"` only affects layout at or above the `max` slot cap. */+ const useFillWidthLayout = createMemo(+ () => distributeFill() && all().length >= maxed()+ );++ createEffect(() => {+ const el = rowEl();+ if (!useFillWidthLayout() || !el) return;+ const ro = new ResizeObserver(() => {+ setRowWidth(el.clientWidth);+ });+ ro.observe(el);+ setRowWidth(el.clientWidth);+ onCleanup(() => ro.disconnect());+ });++ const visible = createMemo(() => all().slice(0, maxed()));++ const overflow = createMemo(() => all().slice(maxed()));++ const overflowCount = createMemo(() => overflow().length);++ const overflowCtx = createMemo(+ (): StackedAvatarsOverflowContext<T> => ({+ overflowItems: overflow(),+ overflowCount: overflowCount(),+ })+ );++ const plainOverflowTooltip = createMemo(() => {+ const ctx = overflowCtx();+ const ot = props.overflowTooltip;+ if (typeof ot === 'string') return ot;+ if (typeof ot === 'function') return ot(ctx) ?? '';+ return `${ctx.overflowCount} more`;+ });++ const overlap = () => STACK_STYLE[size()].overlap;++ /**+ * Per-gap `margin-right` between consecutive stack slots so the row fills `rowWidth`+ * (negative = overlap, positive = gap).+ */+ const fillStepMarginPx = createMemo(() => {+ if (!useFillWidthLayout()) return null;++ const rowWidthPx = rowWidth();+ const visibleFaces = visible();+ const overflowFaceCount = overflowCount();+ const slotCount = visibleFaces.length + (overflowFaceCount > 0 ? 1 : 0);+ const faceDiameterPx = AVATAR_DIAMETER_PX[size()];++ if (slotCount < 2 || rowWidthPx < 1) return null;++ const gapCount = slotCount - 1;+ let marginRightPerGapPx =+ (rowWidthPx - slotCount * faceDiameterPx) / gapCount;+ const minMarginRightPx = -(faceDiameterPx - 6);+ const maxMarginRightPx = Math.max(24, Math.round(faceDiameterPx * 0.45));+ marginRightPerGapPx = Math.max(+ minMarginRightPx,+ Math.min(maxMarginRightPx, marginRightPerGapPx)+ );++ return marginRightPerGapPx;+ });++ const faceWrapperClass = (lastNoOverflowChip: boolean) =>+ cn(+ 'relative shrink-0',+ !(useFillWidthLayout() && fillStepMarginPx() !== null) && overlap(),+ !(useFillWidthLayout() && fillStepMarginPx() !== null) &&+ lastNoOverflowChip &&+ '!mr-0'+ );++ const faceWrapperStyle = (+ index: number,+ lastNoOverflowChip: boolean+ ): JSX.CSSProperties | undefined => {+ const stackingStyle: JSX.CSSProperties = {+ 'z-index': String(10 + index),+ };+ if (!useFillWidthLayout()) return stackingStyle;+ const marginRightPerGapPx = fillStepMarginPx();+ if (marginRightPerGapPx === null) return stackingStyle;+ const lastVisibleIndex = visible().length - 1;+ let slotMarginRightPx = marginRightPerGapPx;+ if (lastNoOverflowChip) slotMarginRightPx = 0;+ else if (index === lastVisibleIndex && overflowCount() === 0) {+ slotMarginRightPx = 0;+ }+ return { ...stackingStyle, 'margin-right': `${slotMarginRightPx}px` };+ };++ const placeholderEl = createMemo(() => {+ if (all().length > 0) return undefined;+ const custom = props.placeholder?.();+ if (custom) return custom;+ if (props.defaultEmptyUserPlaceholder) {+ return <StackedAvatarsDefaultEmptyPlaceholder size={size()} />;+ }+ return undefined;+ });++ const overflowSlot = () => {+ if (overflowCount() === 0) return null;++ const ctx = overflowCtx();+ const overflowSlotZIndex = String(10 + visible().length);+ const faceShell = (inner: JSX.Element) => (+ <div class="relative shrink-0" style={{ 'z-index': overflowSlotZIndex }}>+ {inner}+ </div>+ );++ if (props.renderOverflow) {+ return faceShell(props.renderOverflow(ctx));+ }++ const chip = defaultOverflowChip(+ size(),+ ctx.overflowCount,+ props.overflowChipClass,+ props.overflowChipLabelClass+ );++ if (props.overflowWrap) {+ return faceShell(props.overflowWrap({ ...ctx, chip }));+ }++ if (props.overflowTooltipContent) {+ return faceShell(+ <Tooltip+ unstyled+ tooltip={(close) => props.overflowTooltipContent!(close, ctx)}+ >+ {chip}+ </Tooltip>+ );+ }++ return faceShell(+ <Tooltip tooltip={plainOverflowTooltip()}>{chip}</Tooltip>+ );+ };++ return (+ <div+ ref={setRowEl}+ class={cn(STACKED_AVATARS_ROW_CLASS, props.class)}+ data-ui="stacked-avatars-row"+ >+ <Show when={all().length === 0}>+ <Show when={placeholderEl()}>+ <div class="relative mr-0 shrink-0">{placeholderEl()}</div>+ </Show>+ </Show>+ <Show when={all().length > 0}>+ <>+ <For each={visible()}>+ {(item, index) => {+ const lastNoOverflowChip =+ index() === visible().length - 1 && overflowCount() === 0;+ return (+ <div+ class={faceWrapperClass(lastNoOverflowChip)}+ style={faceWrapperStyle(index(), lastNoOverflowChip)}+ >+ {props.children(item, index())}+ </div>+ );+ }}+ </For>+ <Show when={overflowCount() > 0}>{overflowSlot()}</Show>+ </>+ </Show>+ </div>+ );+}diff --git a/js/app/packages/core/component/UserIcon.tsx b/js/app/packages/core/component/UserIcon.tsxindex 5503cf9ef6..0ad615d8e4 100644--- a/js/app/packages/core/component/UserIcon.tsx+++ b/js/app/packages/core/component/UserIcon.tsx@@ -103,32 +103,32 @@ export function UserIcon(props: UserIconProps) {<divonMouseDown={props.suppressClick ? undefined : getOrCreateDm}class={cn(- 'shrink-0 rounded-full bg-ink-extra-muted text-panel',+ 'relative inline-flex shrink-0 overflow-hidden rounded-full bg-ink-extra-muted text-panel leading-none',sizeClasses().container,props.class)}>- <Switch>- <Match when={props.isDeleted}>- <div- class={`${sizeClasses().container} shrink-0 rounded-full bg-ink-extra-muted/50 items-center`}- >- <Trash class={`${sizeClasses().icon} shrink-0`} />- </div>- </Match>- <Match when={props.id} keyed>- {(id) => <ProfilePicture id={id} sizeClass={sizeClasses()} />}- </Match>- <Match when={!props.id && props.email} keyed>- {(email) => (- <ProfilePicture- id={undefined}- email={email}- sizeClass={sizeClasses()}- />- )}- </Match>- </Switch>+ <div class="absolute inset-0 flex min-h-0 min-w-0 items-center justify-center">+ <Switch>+ <Match when={props.isDeleted}>+ <div class="flex size-full min-h-0 min-w-0 items-center justify-center rounded-full bg-ink-extra-muted/50">+ <Trash class={cn(sizeClasses().icon, 'block shrink-0')} />+ </div>+ </Match>+ <Match when={props.id} keyed>+ {(id) => <ProfilePicture id={id} sizeClass={sizeClasses()} />}+ </Match>+ <Match when={!props.id && props.email} keyed>+ {(email) => (+ <ProfilePicture+ id={undefined}+ email={email}+ sizeClass={sizeClasses()}+ />+ )}+ </Match>+ </Switch>+ </div></div>));diff --git a/js/app/packages/core/component/UserTooltip.tsx b/js/app/packages/core/component/UserTooltip.tsxindex f5746d0994..502d0a8b99 100644--- a/js/app/packages/core/component/UserTooltip.tsx+++ b/js/app/packages/core/component/UserTooltip.tsx@@ -83,7 +83,7 @@ export function UserTooltip(props: UserTooltipProps) {<Panel active><div class="bg-panel text-ink box-border border-accent overflow-hidden max-w-lg"><div class="flex items-center gap-2 p-2">- <div class="size-10 shrink-0 rounded-full bg-ink-extra-muted pointer-events-none">+ <div class="relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-ink-extra-muted pointer-events-none"><Switch><Match when={props.isDeleted}><div class="size-10 shrink-0 rounded-full bg-ink-extra-muted/50 flex items-center justify-center">diff --git a/js/app/packages/queries/channel/get-or-create-dm.ts b/js/app/packages/queries/channel/get-or-create-dm.tsnew file mode 100644index 0000000000..13dec3f2e0--- /dev/null+++ b/js/app/packages/queries/channel/get-or-create-dm.ts@@ -0,0 +1,47 @@+import { throwOnErr } from '@core/util/maybeResult';+import { type MutationCallbacks, withCallbacks } from '@queries/utils';+import { commsServiceClient } from '@service-comms/client';+import type { GetOrCreateDmResponse } from '@service-comms/generated/models';+import { useMutation } from '@tanstack/solid-query';+import { invalidateListChannels } from './channels';++export type GetOrCreateDirectMessageParams = {+ recipient_id: string;+};++/**+ * Create or resolve a 1:1 DM channel for a recipient. Invalidates the channel list on settle.+ */+export function useGetOrCreateDirectMessageMutation(+ callbacks?: MutationCallbacks<+ GetOrCreateDmResponse,+ Error,+ GetOrCreateDirectMessageParams,+ undefined+ >+) {+ return useMutation(() => ({+ gcTime: 0,+ mutationFn: async (vars: GetOrCreateDirectMessageParams) => {+ return await throwOnErr(async () =>+ commsServiceClient.getOrCreateDirectMessage({+ recipient_id: vars.recipient_id,+ })+ );+ },+ ...withCallbacks<+ GetOrCreateDmResponse,+ Error,+ GetOrCreateDirectMessageParams,+ undefined+ >(+ {+ onError(error) {+ console.error('failed to get or create direct message', error);+ },+ onSettled: () => void invalidateListChannels(),+ },+ callbacks+ ),+ }));+}