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
join_call param in channel (#2593)
Will Hutchinsondfed6b304daa
diff --git a/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx b/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsxindex f965b0611f..9785cc35e1 100644--- a/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx+++ b/js/app/packages/block-channel/component/NewChannelBlockAdapter.tsx@@ -8,9 +8,14 @@ import {ChannelTabProvider,useChannelTab,} from '@channel/Channel/ChannelTabContext';+import {+ isJoinCallRequested,+ URL_PARAMS as CHANNEL_URL_PARAMS,+} from '@channel/Channel/link';import { useBlockId } from '@core/block';import { EntityPermissionsGate } from '@core/component/EntityPermissionsGate';-import { createSignal, Match, Show, Suspense, Switch } from 'solid-js';+import { createSignal, Match, onMount, Show, Suspense, Switch } from 'solid-js';+import { useSearchParams } from '@solidjs/router';import { blockHandleSignal } from '@core/signal/load';import { createMethodRegistration } from '@core/orchestrator';import { URL_PARAMS } from '@block-channel/constants';@@ -29,6 +34,7 @@ import { ChannelParticipantsTab } from '@channel/Participants/ChannelParticipantimport {CallAudioSink,CallProvider,+ ChannelCallAutoJoin,ChannelCallButton,ChannelCallTab,useCall,@@ -40,6 +46,7 @@ import { useMaybePreviewPanel } from '@app/component/PreviewPanel';type ChannelTargetMessageParams = {[URL_PARAMS.message]?: string;[URL_PARAMS.thread]?: string;+ [CHANNEL_URL_PARAMS.joinCall]?: string;};export type BlockChannelProps = ChannelTargetMessageParams;@@ -66,11 +73,17 @@ function NewTop(props: { channelId: string }) {const call = useCall(() => props.channelId);const participants = () =>participantsQuery.isLoading ? [] : participantsQuery.data;+ // Show the Call tab whenever we're actually in the call, mid-join, or+ // the tab is being displayed (e.g. via the auto-join flow that flips+ // `activeTab` to `call` before the join request resolves).+ const showCallTab = () =>+ ENABLE_CALLS() &&+ (call.isInThisChannel() || call.isJoining() || activeTab() === 'call');const tabs = () => {let filtered = [...CHANNEL_TABS];if (channelType() === ChannelTypeEnum.DirectMessage)filtered = filtered.filter((tab) => tab.value !== 'participants');- if (!ENABLE_CALLS() || !call.isInThisChannel())+ if (!showCallTab())filtered = filtered.filter((tab) => tab.value !== 'call');return filtered.map((tab) =>tab.value === 'call' ? { ...tab, label: <CallTabLabel /> } : tab@@ -104,8 +117,35 @@ export function NewChannelBlockAdapter(props: BlockChannelProps) {const isPreview = !!useMaybePreviewPanel();const channelId = useBlockId();const blockHandle = blockHandleSignal.get;- const [activeTab, setActiveTab] =- createSignal<ChannelTabId>(DEFAULT_CHANNEL_TAB);+ const [searchParams, setSearchParams] = useSearchParams();++ // Decide whether the user asked to auto-join the call (via ?join_call=true+ // deep link or programmatic open props) before creating signals so we+ // can land directly on the Call tab without flashing Messages first.+ // Skipped inside a preview panel so hover-previews don't auto-join.+ const wantsJoinCall =+ !isPreview &&+ (isJoinCallRequested(props[CHANNEL_URL_PARAMS.joinCall]) ||+ isJoinCallRequested(searchParams[CHANNEL_URL_PARAMS.joinCall]));++ const [activeTab, setActiveTab] = createSignal<ChannelTabId>(+ wantsJoinCall ? 'call' : DEFAULT_CHANNEL_TAB+ );+ const [pendingJoinCall, setPendingJoinCall] = createSignal(wantsJoinCall);++ // 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(() => {+ if (+ wantsJoinCall &&+ searchParams[CHANNEL_URL_PARAMS.joinCall] !== undefined+ ) {+ setSearchParams(+ { [CHANNEL_URL_PARAMS.joinCall]: undefined },+ { replace: true }+ );+ }+ });const convertTargetMessage = (params: ChannelTargetMessageParams@@ -135,6 +175,13 @@ export function NewChannelBlockAdapter(props: BlockChannelProps) {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);+ }},});};@@ -143,6 +190,11 @@ export function NewChannelBlockAdapter(props: BlockChannelProps) {<EntityPermissionsGate entityType="channel" entityId={channelId}><CallProvider><ChannelTabProvider activeTab={activeTab} setActiveTab={setActiveTab}>+ <ChannelCallAutoJoin+ channelId={channelId}+ pendingJoinCall={pendingJoinCall}+ onHandled={() => setPendingJoinCall(false)}+ /><div class="h-full flex flex-col">{/*Mounted above <Switch> so remote call audio keeps playing when@@ -166,7 +218,10 @@ export function NewChannelBlockAdapter(props: BlockChannelProps) {<ChannelParticipantsTab channelId={channelId} /></Match><Match when={activeTab() === 'call'}>- <ChannelCallTab channelId={channelId} />+ <ChannelCallTab+ channelId={channelId}+ pendingJoin={pendingJoinCall}+ /></Match></Switch><NewTop channelId={channelId} />diff --git a/js/app/packages/channel/Call/ChannelCallAutoJoin.tsx b/js/app/packages/channel/Call/ChannelCallAutoJoin.tsxnew file mode 100644index 0000000000..3893878329--- /dev/null+++ b/js/app/packages/channel/Call/ChannelCallAutoJoin.tsx@@ -0,0 +1,59 @@+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';++/**+ * Auto-joins the call for this channel whenever `pendingJoinCall` flips to+ * true. Used to support deep-links like+ * `/app/channel/{channel_id}?join_call=true` that drop the user straight+ * into the call.+ *+ * Must be rendered inside `<CallProvider>` and `<ChannelTabProvider>`.+ */+export function ChannelCallAutoJoin(props: {+ channelId: string;+ pendingJoinCall: Accessor<boolean>;+ onHandled: () => void;+}) {+ const { setActiveTab } = useChannelTab();+ // Mirror ChannelCallButton's tab-sync behavior so leaving via the+ // CallOverlay (or a disconnect) returns the user to the default tab+ // even when the join was triggered here instead of via the button.+ const call = useCall(() => props.channelId, {+ onJoin: () => setActiveTab('call'),+ onLeave: () => setActiveTab(DEFAULT_CHANNEL_TAB),+ });++ createEffect(() => {+ if (!props.pendingJoinCall()) return;++ untrack(() => {+ if (!ENABLE_CALLS()) {+ props.onHandled();+ return;+ }++ // If the user is mid-transition on this channel's call (e.g. they+ // clicked the call button at the same moment), let that flow win.+ if (call.isJoining() || call.isLeaving()) {+ props.onHandled();+ return;+ }++ if (call.isInThisChannel()) {+ setActiveTab('call');+ props.onHandled();+ return;+ }++ call+ .joinCall()+ .catch((e) => console.error('Auto-join call failed', e))+ .finally(() => props.onHandled());+ });+ });++ return null;+}diff --git a/js/app/packages/channel/Call/ChannelCallTab.tsx b/js/app/packages/channel/Call/ChannelCallTab.tsxindex b621eb16fa..d54bae3a56 100644--- a/js/app/packages/channel/Call/ChannelCallTab.tsx+++ b/js/app/packages/channel/Call/ChannelCallTab.tsx@@ -1,12 +1,32 @@-import { Show } from 'solid-js';+import { type Accessor, Show } from 'solid-js';import { useCall } from './useCall';import { CallOverlay } from './CallOverlay';-export function ChannelCallTab(props: { channelId: string }) {+export function ChannelCallTab(props: {+ channelId: string;+ /**+ * When true, show a "Joining call…" placeholder if we aren't yet+ * connected to this channel's call. Used for auto-join flows (e.g.+ * `?join_call=true` deep links) so the tab can render meaningful+ * content before the join request lands.+ */+ pendingJoin?: Accessor<boolean>;+}) {const call = useCall(() => props.channelId);+ const showJoining = () =>+ call.isJoining() || (props.pendingJoin?.() ?? false);return (- <Show when={call.isInThisChannel()}>+ <Show+ when={call.isInThisChannel()}+ fallback={+ <Show when={showJoining()}>+ <div class="flex size-full items-center justify-center text-ink-muted">+ Joining call…+ </div>+ </Show>+ }+ ><CallOverlay onLeave={call.leaveCall} /></Show>);diff --git a/js/app/packages/channel/Call/index.ts b/js/app/packages/channel/Call/index.tsindex f6d7f43cbe..92b65b2ab8 100644--- a/js/app/packages/channel/Call/index.ts+++ b/js/app/packages/channel/Call/index.ts@@ -9,3 +9,4 @@ export { CallOverlay } from './CallOverlay';export { CallAudioSink } from './CallAudioSink';export { ChannelCallButton } from './ChannelCallButton';export { ChannelCallTab } from './ChannelCallTab';+export { ChannelCallAutoJoin } from './ChannelCallAutoJoin';diff --git a/js/app/packages/channel/Channel/link.ts b/js/app/packages/channel/Channel/link.tsindex 9407920ce5..e05346864d 100644--- a/js/app/packages/channel/Channel/link.ts+++ b/js/app/packages/channel/Channel/link.ts@@ -6,6 +6,7 @@export const URL_PARAMS = {thread: 'channel_thread_id',message: 'channel_message_id',+ joinCall: 'join_call',};export function getChannelParams(@@ -21,3 +22,8 @@ export function getChannelParams(return params;}++/** True when a `join_call` param value means "please join the call". */+export function isJoinCallRequested(value: unknown): boolean {+ return value === 'true' || value === true;+}