Skip to content

armgit / macro

Public Imported from GitHub
0

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

feat(channels): list live calls at the top of the Chat sidebar (#9038)

Eric Hayesd0393aebeb33
diff --git a/apps/web/src/features/channels-view/live-calls-sidebar.tsx b/apps/web/src/features/channels-view/live-calls-sidebar.tsx
index cc2dead11f..f0e70ff0d0 100644
--- a/apps/web/src/features/channels-view/live-calls-sidebar.tsx
+++ b/apps/web/src/features/channels-view/live-calls-sidebar.tsx
@@ -1,44 +1,111 @@
+import { useCallContextOptional } from '@channel/Call/CallContext';
import { getMeetingPath, getMeetingShareToken } from '@channel/Call/call-link';
+import { joinChannelCall } from '@channel/Call/join-channel-call';
+import { openChannelCallTab } from '@channel/Call/open-channel-call-tab';
import { DebugSuspense } from '@channel/DebugSuspense';
+import { toast } from '@core/component/Toast/Toast';
+import { ENABLE_CALLS } from '@core/constant/featureFlags';
+import { useChannelsContext } from '@core/context/channels';
import { useUserId } from '@core/context/user';
import { idToDisplayName } from '@core/user/util';
+import { fireAndForget } from '@core/util/fireAndForget';
+import { useActiveCallsQuery } from '@queries/call/call';
import { useNavigate } from '@solidjs/router';
import { Show } from 'solid-js';
-import { LiveCallsSidebar } from '../meetings/components/live-calls-sidebar';
+import { match } from 'ts-pattern';
+import {
+ type LiveCallRow,
+ LiveCallsSidebar,
+} from '../meetings/components/live-calls-sidebar';
import { useActiveQuickCallsSource } from '../meetings/queries/active-quick-calls';
import { useQuickCallsFlag } from '../meetings/use-quick-calls-flag';
-function ChannelsLiveCalls() {
+type ChatLiveCall = LiveCallRow &
+ ({ kind: 'channel'; channelId: string } | { kind: 'quick'; url: string });
+
+async function selectChannelCall(call: { channelId: string; joined: boolean }) {
+ if (call.joined) return openChannelCallTab(call.channelId);
+ try {
+ await joinChannelCall(call.channelId);
+ } catch (error) {
+ console.error('Failed to join call', error);
+ toast.failure('Failed to join call');
+ }
+}
+
+function ChatLiveCalls() {
const userId = useUserId();
- const source = useActiveQuickCallsSource(userId);
const navigate = useNavigate();
- const calls = () =>
- source.calls().map((call) => ({
- id: call.id,
- url: call.url,
- label: `Call with ${
- (call.createdBy && idToDisplayName(call.createdBy)) || 'someone'
- }`,
- }));
+ const callCtx = useCallContextOptional();
+ const channelsCtx = useChannelsContext();
+ const channelCalls = useActiveCallsQuery();
+ const flag = useQuickCallsFlag();
+ const quickCalls = useActiveQuickCallsSource(() =>
+ !flag().loading && flag().enabled ? userId() : undefined
+ );
+
+ const joinedCallId = () =>
+ callCtx?.isInCall() ? callCtx.activeCallId() : null;
+
+ const calls = (): ChatLiveCall[] => {
+ const quick = quickCalls.calls();
+ const quickCallIds = new Set(quick.map((call) => call.callId));
+ const channelsById = channelsCtx.channelsById();
+
+ // A quick call is backed by a channel call; list it once, as the meeting.
+ const channelRows = (channelCalls.data ?? []).flatMap(
+ (call): ChatLiveCall[] => {
+ const channel = channelsById[call.channelId];
+ if (!channel || quickCallIds.has(call.callId)) return [];
+ return [
+ {
+ kind: 'channel',
+ id: call.callId,
+ channelId: call.channelId,
+ label: channel.name ?? 'Channel call',
+ joined: joinedCallId() === call.callId,
+ },
+ ];
+ }
+ );
+ const quickRows = quick.map(
+ (call): ChatLiveCall => ({
+ kind: 'quick',
+ id: call.id,
+ url: call.url,
+ label: `Call with ${
+ (call.createdBy && idToDisplayName(call.createdBy)) || 'someone'
+ }`,
+ joined: !!call.callId && joinedCallId() === call.callId,
+ })
+ );
+ return [...channelRows, ...quickRows];
+ };
return (
<LiveCallsSidebar
calls={calls()}
- onJoin={(call) => {
- const token = getMeetingShareToken(call.url);
- if (token) navigate(getMeetingPath(token));
- }}
+ onSelect={(call) =>
+ match(call)
+ .with({ kind: 'channel' }, (channelCall) =>
+ fireAndForget(selectChannelCall(channelCall), 'channel-call')
+ )
+ .with({ kind: 'quick' }, (quickCall) => {
+ const token = getMeetingShareToken(quickCall.url);
+ if (token) navigate(getMeetingPath(token));
+ })
+ .exhaustive()
+ }
/>
);
}
-/** Active quick calls belong to the Chat workspace, outside its conversation tree. */
+/** Live calls belong to the Chat workspace, outside its conversation tree. */
export function ChannelsLiveCallsSidebar() {
- const flag = useQuickCallsFlag();
return (
- <Show when={!flag().loading && flag().enabled}>
+ <Show when={ENABLE_CALLS}>
<DebugSuspense name="ChannelsView.live-calls">
- <ChannelsLiveCalls />
+ <ChatLiveCalls />
</DebugSuspense>
</Show>
);
diff --git a/apps/web/src/features/meetings/components/live-calls-sidebar.test.tsx b/apps/web/src/features/meetings/components/live-calls-sidebar.test.tsx
new file mode 100644
index 0000000000..0f3149229b
--- /dev/null
+++ b/apps/web/src/features/meetings/components/live-calls-sidebar.test.tsx
@@ -0,0 +1,34 @@
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import userEvent from '@testing-library/user-event';
+import { afterEach, expect, it, vi } from 'vitest';
+import { LiveCallsSidebar } from './live-calls-sidebar';
+
+afterEach(cleanup);
+
+it('offers Open for a call the user is in and Join for the rest', async () => {
+ const onSelect = vi.fn();
+ render(() => (
+ <LiveCallsSidebar
+ calls={[
+ { id: 'in', label: 'design', joined: true },
+ { id: 'out', label: 'standup', joined: false },
+ ]}
+ onSelect={onSelect}
+ />
+ ));
+
+ await userEvent.click(screen.getByRole('button', { name: 'Open design' }));
+ expect(onSelect).toHaveBeenLastCalledWith(
+ expect.objectContaining({ id: 'in' })
+ );
+
+ await userEvent.click(screen.getByRole('button', { name: 'Join standup' }));
+ expect(onSelect).toHaveBeenLastCalledWith(
+ expect.objectContaining({ id: 'out' })
+ );
+});
+
+it('renders nothing without live calls', () => {
+ render(() => <LiveCallsSidebar calls={[]} onSelect={vi.fn()} />);
+ expect(screen.queryByText('Live')).toBeNull();
+});
diff --git a/apps/web/src/features/meetings/components/live-calls-sidebar.tsx b/apps/web/src/features/meetings/components/live-calls-sidebar.tsx
index ab158d5376..25aabf35fa 100644
--- a/apps/web/src/features/meetings/components/live-calls-sidebar.tsx
+++ b/apps/web/src/features/meetings/components/live-calls-sidebar.tsx
@@ -1,19 +1,22 @@
import { ViewSidebar } from '@app/components/view-shell/ViewSidebar';
-import PhoneIncomingIcon from '@icon/system/fill/phone-incoming-fill.svg';
+import PhoneCallIcon from '@icon/system/fill/phone-call-fill.svg';
import { Key } from '@solid-primitives/keyed';
import { Tooltip } from '@ui';
import { createUniqueId, Show } from 'solid-js';
-import type { ActiveQuickCall } from '../context/call-sidebar';
-type LiveCallDisplay = Pick<ActiveQuickCall, 'id' | 'url'> & {
+export type LiveCallRow = {
+ id: string;
label: string;
+ /** The user is already in this call, so the row opens it instead. */
+ joined: boolean;
};
-export function LiveCallsSidebar(props: {
- calls: readonly LiveCallDisplay[];
- onJoin: (call: LiveCallDisplay) => void;
+export function LiveCallsSidebar<T extends LiveCallRow>(props: {
+ calls: readonly T[];
+ onSelect: (call: T) => void;
}) {
const titleId = createUniqueId();
+ const action = (call: LiveCallRow) => (call.joined ? 'Open' : 'Join');
return (
<Show when={props.calls.length > 0}>
@@ -24,8 +27,9 @@ export function LiveCallsSidebar(props: {
>
<h2
id={titleId}
- class="flex h-(--sidebar-row-height) shrink-0 items-center px-(--sidebar-item-inset) text-xs font-medium text-ink-muted"
+ class="flex h-(--sidebar-row-height) shrink-0 items-center gap-2 px-(--sidebar-item-inset) text-xs font-medium text-ink-muted"
>
+ <span class="size-1.5 rounded-full bg-accent motion-safe:animate-pulse" />
Live
</h2>
<div class="flex min-h-0 flex-col gap-(--sidebar-row-gap) overflow-y-auto overscroll-contain">
@@ -37,13 +41,20 @@ export function LiveCallsSidebar(props: {
class="min-w-0 shrink-0"
>
<ViewSidebar.Item
- aria-label={`Join ${call().label}`}
- onClick={() => props.onJoin(call())}
+ aria-label={`${action(call())} ${call().label}`}
+ class="bg-accent-bg text-ink not-disabled:hover:bg-accent-bg not-disabled:hover:overlay-hover"
+ onClick={() => props.onSelect(call())}
>
<ViewSidebar.Icon class="text-accent">
- <PhoneIncomingIcon class="incoming-call-shake" />
+ <PhoneCallIcon />
</ViewSidebar.Icon>
<span class="min-w-0 flex-1 truncate">{call().label}</span>
+ <span
+ aria-hidden="true"
+ class="ml-auto shrink-0 text-xs font-medium text-accent"
+ >
+ {action(call())}
+ </span>
</ViewSidebar.Item>
</Tooltip>
)}
diff --git a/apps/web/src/features/meetings/context/call-sidebar.ts b/apps/web/src/features/meetings/context/call-sidebar.ts
index a047a30372..4cd5846c7a 100644
--- a/apps/web/src/features/meetings/context/call-sidebar.ts
+++ b/apps/web/src/features/meetings/context/call-sidebar.ts
@@ -3,6 +3,8 @@ import type { UpcomingCalendarEvent } from '../core/upcoming-calendar-events';
export type ActiveQuickCall = {
id: string;
+ /** The live call behind the meeting, once someone has joined. */
+ callId?: string;
createdBy: string;
title: string;
url: string;
diff --git a/apps/web/src/features/meetings/queries/active-quick-calls.test.ts b/apps/web/src/features/meetings/queries/active-quick-calls.test.ts
index fc310d8790..35290b6e5f 100644
--- a/apps/web/src/features/meetings/queries/active-quick-calls.test.ts
+++ b/apps/web/src/features/meetings/queries/active-quick-calls.test.ts
@@ -72,6 +72,7 @@ it('retains live calls on a failed background refresh and clears its error after
await vi.waitFor(() => expect(source.calls()).toHaveLength(1));
expect(source.calls()[0]).toEqual({
id: meeting.id,
+ callId: meeting.callId,
createdBy: meeting.createdBy,
title: meeting.title,
url: `${window.location.origin}/app/meet/join/${meeting.shareToken}`,
diff --git a/apps/web/src/features/meetings/queries/active-quick-calls.ts b/apps/web/src/features/meetings/queries/active-quick-calls.ts
index af5c0fe048..8c4e25ba48 100644
--- a/apps/web/src/features/meetings/queries/active-quick-calls.ts
+++ b/apps/web/src/features/meetings/queries/active-quick-calls.ts
@@ -17,6 +17,7 @@ export function useActiveQuickCallsSource(
userId() && !query.isPending && !accessDenied()
? (query.data ?? []).map((meeting) => ({
id: meeting.id,
+ callId: meeting.callId ?? undefined,
createdBy: meeting.createdBy,
title: meeting.title,
url: getMeetingUrl(meeting.shareToken),
diff --git a/docs/agent-guide/calls.md b/docs/agent-guide/calls.md
index dc92c3e514..fddf40899f 100644
--- a/docs/agent-guide/calls.md
+++ b/docs/agent-guide/calls.md
@@ -62,6 +62,12 @@ A channel's `Calls` tab lists that channel's recordings with the same rows, filt
by the channel id. Its search field matches call names and transcripts in that
channel.
+The desktop Chat sidebar lists every live channel call and quick call in a `Live`
+section above the conversations. Each row reads `Join`, or `Open` when you are
+already in that call, which returns to the channel's Call tab. To see the section
+without starting a real call, answer `/call/active` and `/call/<channelId>/active`
+with a fake call through CDP `Fetch` interception.
+
In the native iOS call drawer, the horizontal participant row excludes the person
shown in the large video. While holding or scrolling the row (including momentum),
the displayed primary and row membership stay fixed; speaking indicators still