Skip to content

armgit / macro

Public Imported from GitHub
0

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

fix(calls): stay in the channel after leaving its call (#9073)

Eric Hayes2cd21d017b6a
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index e9a169d992..0928c99822 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -371,9 +371,9 @@ resolved session ID; keep the existing `AgentSessionProvider` subscription to
notification source (`markRowNotificationsSeenOnOpen`) so read dots update
immediately and failed writes roll back; calendar grid selections also mark
the canonical event read, excluding team projections.
-- Route explicit call exits using the server's `callEnded` result: ended calls
- open their record; ongoing channel and scheduled calls return to the channel
- and Calendar. Preserve the session ID and send the server leave before media
+- Route explicit meeting-page exits using the server's `callEnded` result: ended
+ calls open their record; ongoing channel and scheduled calls return to the
+ channel and Calendar. Leaving from a channel's Call tab stays in the channel. Preserve the session ID and send the server leave before media
teardown; once the last participant drops, the server ends the call first.
- Diagnose browser call media with `call.media.*` spans and the `meeting.setup.id`
on `meeting.join`; keep provider messages, device labels/IDs, and call-link
diff --git a/apps/web/src/features/channel/Call/ChannelCallTab.tsx b/apps/web/src/features/channel/Call/ChannelCallTab.tsx
index 8923d6f0f6..5546d341eb 100644
--- a/apps/web/src/features/channel/Call/ChannelCallTab.tsx
+++ b/apps/web/src/features/channel/Call/ChannelCallTab.tsx
@@ -4,12 +4,10 @@ import { getDisplayName, tryMacroId } from '@core/user';
import PhoneIcon from '@icon/system/regular/phone-call.svg';
import { Telemetry } from '@macro-inc/observability';
import { useActiveCallQuery, useCallRecordQuery } from '@queries/call/call';
-import { useLocation, useNavigate } from '@solidjs/router';
import { Button } from '@ui';
import { type Accessor, createMemo, Match, Show, Switch } from 'solid-js';
import { ActiveCallLink } from './ActiveCallLink';
import { CallOverlay } from './CallOverlay';
-import { getCallExitPath } from './call-exit';
import { getCallJoinTab, getCallLeaveTab } from './call-tabs';
import { useCall } from './use-call';
@@ -103,8 +101,6 @@ export function ChannelCallTab(props: {
pendingJoin?: Accessor<boolean>;
}) {
const { setActiveTab } = useChannelTab();
- const navigate = useNavigate();
- const location = useLocation();
let leaving = false;
// Match ChannelCallButton / ChannelCallAutoJoin so leaving from the
@@ -123,35 +119,17 @@ export function ChannelCallTab(props: {
}
}
+ // Leaving keeps the user in this channel (onLeave switches to Messages),
+ // even when their hangup ends the call.
async function handleLeave() {
if (leaving) return;
leaving = true;
const callId = call.callCtx.activeCallId();
- const channelId = props.channelId;
- const from = location.key;
try {
await Telemetry.span('call.leave', async (span) => {
if (callId) span.setAttr('call.id', callId);
const result = await call.leaveCall();
span.setAttr('call.leave.ended', result?.callEnded ?? false);
- if (
- props.channelId !== channelId ||
- location.key !== from ||
- call.callCtx.isInCall() ||
- !result?.callEnded
- )
- return;
- // Leaving switches to Messages and unmounts this tab before cleanup
- // settles. The route key keeps that expected teardown distinct from
- // the user navigating elsewhere while the server responds.
- navigate(
- getCallExitPath({
- authenticated: true,
- callId,
- channelId,
- callEnded: true,
- })
- );
});
} finally {
leaving = false;
diff --git a/apps/web/src/features/channel/Call/tests/call-exit-navigation.test.tsx b/apps/web/src/features/channel/Call/tests/call-exit-navigation.test.tsx
index 48891420e3..f31545cc26 100644
--- a/apps/web/src/features/channel/Call/tests/call-exit-navigation.test.tsx
+++ b/apps/web/src/features/channel/Call/tests/call-exit-navigation.test.tsx
@@ -1,27 +1,16 @@
// @vitest-environment jsdom
-import {
- cleanup,
- fireEvent,
- render,
- screen,
- waitFor,
-} from '@solidjs/testing-library';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { createSignal, Show } from 'solid-js';
import { afterEach, expect, it, vi } from 'vitest';
import { ChannelCallTab } from '../ChannelCallTab';
const state = vi.hoisted(() => ({
navigate: vi.fn(),
- key: 'channel-route',
leave: async (): Promise<{ callEnded: boolean }> => ({ callEnded: false }),
}));
vi.mock('@solidjs/router', () => ({
useNavigate: () => state.navigate,
- useLocation: () => ({
- get key() {
- return state.key;
- },
- }),
+ useLocation: () => ({ key: 'channel-route' }),
}));
vi.mock('@channel/Channel/ChannelTabContext', () => ({
useChannelTab: () => ({ setActiveTab: () => {} }),
@@ -51,24 +40,15 @@ afterEach(() => {
vi.clearAllMocks();
});
-it.each([
- { callEnded: true, navigateAway: false, destination: '/calls/call/call-1' },
- { callEnded: false, navigateAway: false, destination: undefined },
- { callEnded: true, navigateAway: true, destination: undefined },
-])(
- 'handles hangup after the call tab unmounts: $callEnded, moved=$navigateAway',
+it.each([{ callEnded: true }, { callEnded: false }])(
+ 'stays in the channel after hangup (callEnded=$callEnded)',
async (test) => {
- state.key = 'channel-route';
const [inCallTab, setInCallTab] = createSignal(true);
- let finish!: (result: { callEnded: boolean }) => void;
- const response = new Promise<{ callEnded: boolean }>((resolve) => {
- finish = resolve;
- });
let leaving: Promise<{ callEnded: boolean }> | undefined;
state.leave = () => {
setInCallTab(false);
- leaving = response;
- return response;
+ leaving = Promise.resolve({ callEnded: test.callEnded });
+ return leaving;
};
render(() => (
<Show when={inCallTab()} fallback={<p>Channel messages</p>}>
@@ -76,14 +56,9 @@ it.each([
</Show>
));
fireEvent.click(screen.getByRole('button', { name: 'Leave call' }));
- expect(screen.getByText('Channel messages')).toBeTruthy();
- if (test.navigateAway) state.key = 'another-route';
- finish({ callEnded: test.callEnded });
await leaving;
- if (test.destination)
- await waitFor(() =>
- expect(state.navigate).toHaveBeenCalledExactlyOnceWith(test.destination)
- );
- else expect(state.navigate).not.toHaveBeenCalled();
+ await Promise.resolve();
+ expect(screen.getByText('Channel messages')).toBeTruthy();
+ expect(state.navigate).not.toHaveBeenCalled();
}
);
diff --git a/docs/agent-guide/calls.md b/docs/agent-guide/calls.md
index be36960562..ff1e85be6e 100644
--- a/docs/agent-guide/calls.md
+++ b/docs/agent-guide/calls.md
@@ -180,7 +180,7 @@ Check channel, scheduled, and instant calls with another participant remaining
and as the last participant, including at phone width. During a delayed leave,
the page shows `Leaving call…` without flashing setup; navigating elsewhere must
not be undone when cleanup finishes. Inline channel call controls return to
-Messages on leave and open the record when that hangup ends the call.
+Messages on leave and stay in the channel, even when that hangup ends the call.
`Copy Meeting Url` is available during the call.
Rejoining from a new page waits for the prior page's pending leave cleanup before
requesting another connection, so a slow leave cannot disconnect the replacement.