Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions app/src/components/meetings/UpcomingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,20 @@ export function UpcomingTable({
const handleJoin = async (meeting: UpcomingMeeting) => {
if (!meeting.meet_url) return;
const platform = meeting.platform ?? inferPlatformFromUrl(meeting.meet_url) ?? undefined;
log('[upcoming] joining %s platform=%s', meeting.calendar_event_id, platform);
// Mint a fresh correlation id per join. It becomes the call record's
// `request_id` (recent-calls list key + per-call detail filename), so it
// MUST be unique per join — reusing the deterministic `calendar_event_id`
// collapsed re-joins of the same event onto one request_id, overwriting the
// earlier call's transcript and double-highlighting the history row (#4338).
// `calendar_event_id` stays the dedup/policy key only (handleJoinPolicyChange,
// setJoiningId), mirroring the background auto-join in calendar.rs.
const correlationId = crypto.randomUUID();
log(
'[upcoming] joining %s platform=%s correlationId=%s',
meeting.calendar_event_id,
platform,
correlationId
);
setJoiningId(meeting.calendar_event_id);
try {
await joinMeetViaBackendBot({
Expand All @@ -356,7 +369,7 @@ export function UpcomingTable({
systemPrompt: personaDescription || undefined,
mascotId: mascotId || undefined,
listenOnly: true,
correlationId: meeting.calendar_event_id,
correlationId,
riveColors,
});
} catch (err) {
Expand Down
39 changes: 34 additions & 5 deletions app/src/components/meetings/__tests__/UpcomingTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,41 @@ describe('UpcomingTable', () => {

await waitFor(() => expect(joinMock).toHaveBeenCalledOnce());
expect(joinMock).toHaveBeenCalledWith(
expect.objectContaining({
meetUrl: 'https://meet.google.com/abc-def-ghi',
listenOnly: true,
correlationId: 'evt-1',
})
expect.objectContaining({ meetUrl: 'https://meet.google.com/abc-def-ghi', listenOnly: true })
);
// The correlation id MUST be a freshly-minted unique id, NOT the
// deterministic calendar_event_id — reusing the event id collapsed
// re-joins onto one request_id (#4338).
const { correlationId } = joinMock.mock.calls[0][0] as { correlationId: string };
expect(correlationId).toBeTruthy();
expect(correlationId).not.toBe('evt-1');
});

it('mints a unique correlationId per join so re-joining the same event does not collide (#4338)', async () => {
joinMock.mockResolvedValue({
meetUrl: 'https://meet.google.com/abc-def-ghi',
platform: 'gmeet',
});
// Same meeting (same calendar_event_id) returned across reloads.
listMock.mockResolvedValue([makeMeeting()]);
renderWithProviders(<UpcomingTable />);

const joinBtn = await screen.findByRole('button', { name: /^join$/i });
fireEvent.click(joinBtn);
await waitFor(() => expect(joinMock).toHaveBeenCalledOnce());
// handleJoin disables the row via `joiningId` until its `finally` runs;
// wait for the button to re-enable before the second click so it isn't
// swallowed by the disabled state (timing-dependent otherwise).
await waitFor(() => expect((joinBtn as HTMLButtonElement).disabled).toBe(false));
fireEvent.click(joinBtn);
await waitFor(() => expect(joinMock).toHaveBeenCalledTimes(2));
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const first = (joinMock.mock.calls[0][0] as { correlationId: string }).correlationId;
const second = (joinMock.mock.calls[1][0] as { correlationId: string }).correlationId;
expect(first).not.toBe('evt-1');
expect(second).not.toBe('evt-1');
// Two joins of the same calendar event must yield distinct correlation ids.
expect(first).not.toBe(second);
});

it('does not show a join button for meetings without a conferencing URL', async () => {
Expand Down
Loading