mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 12:19:06 +00:00
* feat: calendar integration
* feat: add ICS calendar API endpoints for room configuration and sync
* feat: add Celery background tasks for ICS sync
* feat: implement Phase 2 - Multiple active meetings per room with grace period
This commit adds support for multiple concurrent meetings per room, implementing
grace period logic and improved meeting lifecycle management for calendar integration.
## Database Changes
- Remove unique constraint preventing multiple active meetings per room
- Add last_participant_left_at field to track when meeting becomes empty
- Add grace_period_minutes field (default: 15) for configurable grace period
## Meeting Controller Enhancements
- Add get_all_active_for_room() to retrieve all active meetings for a room
- Add get_active_by_calendar_event() to find meetings by calendar event ID
- Maintain backward compatibility with existing get_active() method
## New API Endpoints
- GET /rooms/{room_name}/meetings/active - List all active meetings
- POST /rooms/{room_name}/meetings/{meeting_id}/join - Join specific meeting
## Meeting Lifecycle Improvements
- 15-minute grace period after last participant leaves
- Automatic reactivation when participant rejoins during grace period
- Force close calendar meetings 30 minutes after scheduled end time
- Update process_meetings task to handle multiple active meetings
## Whereby Integration
- Clear grace period when participants join via webhook events
- Track participant count for grace period management
## Testing
- Add comprehensive tests for multiple active meetings
- Test grace period behavior and participant rejoin scenarios
- Test calendar meeting force closure logic
- All 5 new tests passing
This enables proper calendar integration with overlapping meetings while
preventing accidental meeting closures through the grace period mechanism.
* feat: implement frontend for calendar integration (Phase 3 & 4)
- Created MeetingSelection component for choosing between multiple active meetings
- Shows both active meetings and upcoming calendar events (30 min ahead)
- Displays meeting metadata with privacy controls (owner-only details)
- Supports creation of unscheduled meetings alongside calendar meetings
- Added waiting page for users joining before scheduled start time
- Shows countdown timer until meeting begins
- Auto-transitions to meeting when calendar event becomes active
- Handles early joining with proper routing
- Created collapsible info panel showing meeting details
- Displays calendar metadata (title, description, attendees)
- Shows participant count and duration
- Privacy-aware: sensitive info only visible to room owners
- Integrated ICS settings into room configuration dialog
- Test connection functionality with immediate feedback
- Manual sync trigger with detailed results
- Shows last sync time and ETag for monitoring
- Configurable sync intervals (1 min to 1 hour)
- New /room/{roomName} route for meeting selection
- Waiting room at /room/{roomName}/wait?eventId={id}
- Classic room page at /{roomName} with meeting info
- Uses sessionStorage to pass selected meeting between pages
- Added new endpoints for active/upcoming meetings
- Regenerated TypeScript client with latest OpenAPI spec
- Proper error handling and loading states
- Auto-refresh every 30 seconds for live updates
- Color-coded badges for meeting status
- Attendee status indicators (accepted/declined/tentative)
- Responsive design with Chakra UI components
- Clear visual hierarchy between active and upcoming meetings
- Smart truncation for long attendee lists
This completes the frontend implementation for calendar integration,
enabling users to seamlessly join scheduled meetings from their
calendar applications.
* WIP: Migrate calendar integration frontend to React Query
- Migrate all calendar components from useApi to React Query hooks
- Fix Chakra UI v3 compatibility issues (Card, Progress, spacing props, leftIcon)
- Update backend Meeting model to include calendar fields
- Replace imperative API calls with declarative React Query patterns
- Remove old OpenAPI generated files that conflict with new structure
* fix: alembic migrations
* feat: add calendar migration
* feat: update ics, first version working
* feat: implement tabbed interface for room edit dialog
- Add General, Calendar, and Share tabs to organize room settings
- Move ICS settings to dedicated Calendar tab
- Move Zulip configuration to Share tab
- Keep basic room settings and webhooks in General tab
- Remove redundant migration file
- Fix Chakra UI v3 compatibility issues in calendar components
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: infinite loop
* feat: improve ICS calendar sync UX and fix room URL matching
- Replace "Test Connection" button with "Force Sync" button (Edit Room only)
- Show detailed sync results: total events downloaded vs room matches
- Remove emoticons and auto-hide timeout for cleaner UX
- Fix room URL matching to use UI_BASE_URL instead of BASE_URL
- Replace FaSync icon with LuRefreshCw for consistency
- Clear sync results when dialog closes or Force Sync pressed
- Update tests to reflect UI_BASE_URL change and exact URL matching
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: reorganize room edit dialog and fix Force Sync button
- Move WebHook configuration from General to dedicated WebHook tab
- Add WebHook tab after Share tab in room edit dialog
- Fix Force Sync button not appearing by adding missing isEditing prop
- Fix indentation issues in MeetingSelection component
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: complete calendar integration with UI improvements and code cleanup
Calendar Integration Tasks:
- Update upcoming meetings window from 30 to 120 minutes
- Include currently happening events in upcoming meetings API
- Create shared time utility functions (formatDateTime, formatCountdown, formatStartedAgo)
- Improve ongoing meetings UI logic with proper time detection
- Fix backend code organization and remove excessive documentation
UI/UX Improvements:
- Restructure room page layout using MinimalHeader pattern
- Remove borders from header and footer elements
- Change button text from "Leave Meeting" to "Leave Room"
- Remove "Back to Reflector" footer for cleaner design
- Extract WaitPageClient component for better separation
Backend Changes:
- calendar_events.py: Fix import organization and extend timing window
- rooms.py: Update API default from 30 to 120 minutes
- Enhanced test coverage for ongoing meeting scenarios
Frontend Changes:
- MinimalHeader: Add onLeave prop for custom navigation
- MeetingSelection: Complete layout restructure with shared utilities
- timeUtils: New shared utility file for consistent time formatting
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: remove wait page and simplify Join button with 5-minute disable logic
- Remove entire wait page directory and associated files
- Update handleJoinUpcoming to create unscheduled meeting directly
- Simplify Join button to single state:
- Always shows "Join" text
- Blue when meeting can be joined (ongoing or within 5 minutes)
- Gray/disabled when more than 5 minutes away
- Remove confusing "Join Now", "Join Early" text variations
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: improve calendar integration and meeting UI
- Refactor ICS sync tasks to use @asynctask decorator for cleaner async handling
- Extract meeting creation logic into reusable function
- Improve meeting selection UI with distinct current/upcoming sections
- Add early join functionality for upcoming meetings within 5-minute window
- Simplify non-ICS room workflow with direct Whereby embed
- Fix import paths and component organization
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: restore original recording consent functionality
- Remove custom ConsentDialogButton and WherebyEmbed components
- Merge RoomClient logic back into main room page
- Restore original consent UI: blue button with toast modal
- Maintain calendar integration features for ICS-enabled rooms
- Add consent-handler.md documentation of original functionality
- Preserve focus management and accessibility features
* fix: redirect Join Now button to local meeting page
- Change handleJoinDirect to use onMeetingSelect instead of opening external URL
- Join Now button now navigates to /{roomName}/{meetingId} instead of whereby.com
- Maintains proper routing within the application
* feat: remove restrictive message for non-owners in private rooms
- Remove confusing message about room owner permissions
- Cleaner UI for all users regardless of ownership status
- Users will only see available meetings and join options
* feat: improve meeting selection UI for better readability
- Limit page content to max 800px width for better 4K display readability
- Remove LIVE tag badge for cleaner interface
- Remove shadow from main live meeting box
- Remove blue border and hover effects for minimal design
- Change background to neutral gray for less visual noise
* feat: add room by name endpoint for non-authenticated access
- Add GET /rooms/name/{room_name} backend endpoint
- Endpoint supports non-authenticated access for public rooms
- Returns RoomDetails with webhook fields hidden for non-owners
- Update useRoomGetByName hook to use new direct endpoint
- Remove authentication requirement from frontend hook
- Regenerate API client types
Fixes: Non-authenticated users can now access room lobbies
* feat: add friendly message when no meetings are ongoing
- Show centered message with calendar icon when no meetings are active
- Message text: 'No meetings right now' with helpful description
- Contextual text for owners/shared rooms mentioning quick meeting option
- Consistent gray styling matching the rest of the interface
- Only displays when both currentMeetings and upcomingMeetings are empty
* style: center no meetings message and remove background
- Change from Box to Flex with flex=1 for vertical centering
- Remove gray background, border radius, and padding
- Message now appears cleanly centered in available space
- Maintains horizontal and vertical centering
* feat: move Create Meeting button to header
- Remove 'Start a Quick Meeting' box from main content area
- Add showCreateButton and onCreateMeeting props to MinimalHeader
- Create Meeting button now appears in header left of Leave Room
- Only shows for room owners or shared room users
- Update no meetings message to remove reference to quick meeting below
- Cleaner, more accessible UI with actions in the header
* style: change room title and no meetings text to pure black
- Update room title in MinimalHeader from gray.700 to black
- Update 'No meetings right now' text from gray.700 to black
- Improves visual hierarchy and readability
- Consistent with other pages' styling
* style: linting
* fix: remove plan files
* fix: alembic migration with named foreign keys
* feat: add SyncStatus enum and refactor ICS sync to use rooms controller
- Add SyncStatus enum to replace string literals in ICS sync status
- Replace direct SQL queries in worker with rooms_controller.get_ics_enabled()
- Improve type safety and maintainability of ICS sync code
- Enum values: SUCCESS, UNCHANGED, ERROR, SKIPPED maintain backward compatibility
* refactor: remove unnecessary docstring from get_ics_enabled method
The function name is self-explanatory
* fix: import top level
* feat: use Literal type for ICSStatus.status field
- Changed ICSStatus.status from str to Literal['enabled', 'disabled']
- Improves type safety and API documentation
* feat: update TypeScript definitions for ICSStatus Literal type
- OpenAPI generation now properly reflects Literal['enabled', 'disabled'] type
- Improves type safety for frontend consumers of the API
- Applied automatic formatting via pre-commit hooks
* refactor: replace loguru with structlog in ics_sync service
- Replace loguru import with structlog in services/ics_sync.py
- Update logging calls to use structlog's structured format with keyword args
- Maintains consistency with other services using structlog
- Changes: logger.info(f'...') -> logger.info('...', key=value) format
* chore: remove loguru dependency and improve type annotations
- Remove loguru from dependencies in pyproject.toml (replaced with structlog)
- Update meeting controller methods to properly return Optional types
- Update dependency lock file after loguru removal
* fix: resolve pyflakes warnings in ics_sync and meetings modules
Remove unused imports and variables to clean up code quality
* Remove grace period logic and improve meeting deactivation
- Removed grace_period_minutes and last_participant_left_at fields
- Simplified deactivation logic based on actual usage patterns:
* Active sessions: Keep meeting active regardless of scheduled time
* Calendar meetings: Wait until scheduled end if unused, deactivate immediately once used and empty
* On-the-fly meetings: Deactivate immediately when empty
- Created migration to drop unused database columns
- Updated tests to remove grace period test cases
* Update test to match new deactivation logic for calendar meetings
* fix: remove unwanted file
* fix: incompleted changes from EVENT_WINDOW*
* fix: update room ICS API tests to include required webhook fields and correct URL
- Add webhook_url and webhook_secret fields to room creation tests
- Fix room URL matching in ICS sync test to use UI_BASE_URL instead of BASE_URL
- Aligns test with actual API requirements and ICS sync service implementation
* fix: add Redis distributed locking to prevent race conditions in process_meetings
- Implement per-meeting locks using Redis to prevent concurrent processing
- Add lock extension after slow API calls (Whereby) to handle long-running operations
- Use redis-py's built-in lock.extend() with replace_ttl=True for simple TTL refresh
- Track and log skipped meetings when locked by other workers
- Document SSRF analysis showing it's low-risk due to async worker isolation
This prevents multiple workers from processing the same meeting simultaneously,
which could cause state corruption or duplicate deactivations.
* refactor: rename MinimalHeader to MeetingMinimalHeader for clarity
* fix: minor code quality improvements - add emoji constants, fix type safety, cleanup comments
* fix: database migration
* self-pr review
* self-pr review
* self-pr review treeshake
* fix: local fixes
* fix: creation of meeting
* fix: meeting selection create button
* compile fix
* fix: meeting selection responsive
* fix: rework process logic for meeting
* fix: meeting useEffect frontend-only dedupe (#647)
* meeting useEffect frontend-only dedupe
* format
* also get room by name backend fix
---------
Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
* invalidate meeting list on new meeting
* test fix
* room url copy button for ics
* calendar refresh quick action icon
* remove work.md
* meeting page frontend fixes
* hide number of meeting participants
* Revert "hide number of meeting participants"
This reverts commit 38906c5d1a.
* ui bits
* ui bits
* remove log
* room name typing stricten
* feat: protect atomic operation involving external service with redlock
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Igor Monadical <igor@monadical.com>
Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
895 lines
30 KiB
TypeScript
895 lines
30 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
Button,
|
|
Checkbox,
|
|
CloseButton,
|
|
Dialog,
|
|
Field,
|
|
Flex,
|
|
Heading,
|
|
Input,
|
|
Select,
|
|
Spinner,
|
|
IconButton,
|
|
createListCollection,
|
|
useDisclosure,
|
|
Tabs,
|
|
} from "@chakra-ui/react";
|
|
import { useEffect, useMemo, useState } from "react";
|
|
import { LuEye, LuEyeOff } from "react-icons/lu";
|
|
import useRoomList from "./useRoomList";
|
|
import type { components } from "../../reflector-api";
|
|
import {
|
|
useRoomCreate,
|
|
useRoomUpdate,
|
|
useRoomDelete,
|
|
useZulipStreams,
|
|
useZulipTopics,
|
|
useRoomGet,
|
|
useRoomTestWebhook,
|
|
} from "../../lib/apiHooks";
|
|
import { RoomList } from "./_components/RoomList";
|
|
import { PaginationPage } from "../browse/_components/Pagination";
|
|
import {
|
|
assertExists,
|
|
NonEmptyString,
|
|
parseNonEmptyString,
|
|
} from "../../lib/utils";
|
|
import ICSSettings from "./_components/ICSSettings";
|
|
import { roomAbsoluteUrl } from "../../lib/routesClient";
|
|
|
|
type Room = components["schemas"]["Room"];
|
|
|
|
interface SelectOption {
|
|
label: string;
|
|
value: string;
|
|
}
|
|
|
|
const RESERVED_PATHS = ["browse", "rooms", "transcripts"];
|
|
const SUCCESS_EMOJI = "✅";
|
|
const ERROR_EMOJI = "❌";
|
|
|
|
const roomModeOptions: SelectOption[] = [
|
|
{ label: "2-4 people", value: "normal" },
|
|
{ label: "2-200 people", value: "group" },
|
|
];
|
|
|
|
const recordingTriggerOptions: SelectOption[] = [
|
|
{ label: "None", value: "none" },
|
|
{ label: "Prompt", value: "prompt" },
|
|
{ label: "Automatic", value: "automatic-2nd-participant" },
|
|
];
|
|
|
|
const recordingTypeOptions: SelectOption[] = [
|
|
{ label: "None", value: "none" },
|
|
{ label: "Local", value: "local" },
|
|
{ label: "Cloud", value: "cloud" },
|
|
];
|
|
|
|
const roomInitialState = {
|
|
name: "",
|
|
zulipAutoPost: false,
|
|
zulipStream: "",
|
|
zulipTopic: "",
|
|
isLocked: false,
|
|
roomMode: "normal",
|
|
recordingType: "cloud",
|
|
recordingTrigger: "automatic-2nd-participant",
|
|
isShared: false,
|
|
webhookUrl: "",
|
|
webhookSecret: "",
|
|
icsUrl: "",
|
|
icsEnabled: false,
|
|
icsFetchInterval: 5,
|
|
};
|
|
|
|
export default function RoomsList() {
|
|
const { open, onOpen, onClose } = useDisclosure();
|
|
|
|
// Create collections for Select components
|
|
const roomModeCollection = createListCollection({
|
|
items: roomModeOptions,
|
|
});
|
|
|
|
const recordingTriggerCollection = createListCollection({
|
|
items: recordingTriggerOptions,
|
|
});
|
|
|
|
const recordingTypeCollection = createListCollection({
|
|
items: recordingTypeOptions,
|
|
});
|
|
const [roomInput, setRoomInput] = useState<null | typeof roomInitialState>(
|
|
null,
|
|
);
|
|
const [isEditing, setIsEditing] = useState(false);
|
|
const [editRoomId, setEditRoomId] = useState<string | null>(null);
|
|
const {
|
|
loading,
|
|
response,
|
|
refetch,
|
|
error: roomListError,
|
|
} = useRoomList(PaginationPage(1));
|
|
const [nameError, setNameError] = useState("");
|
|
const [linkCopied, setLinkCopied] = useState("");
|
|
const [selectedStreamId, setSelectedStreamId] = useState<number | null>(null);
|
|
const [testingWebhook, setTestingWebhook] = useState(false);
|
|
const [webhookTestResult, setWebhookTestResult] = useState<string | null>(
|
|
null,
|
|
);
|
|
const [showWebhookSecret, setShowWebhookSecret] = useState(false);
|
|
|
|
const createRoomMutation = useRoomCreate();
|
|
const updateRoomMutation = useRoomUpdate();
|
|
const deleteRoomMutation = useRoomDelete();
|
|
const { data: streams = [] } = useZulipStreams();
|
|
const { data: topics = [] } = useZulipTopics(selectedStreamId);
|
|
|
|
const {
|
|
data: detailedEditedRoom,
|
|
isLoading: isDetailedEditedRoomLoading,
|
|
error: detailedEditedRoomError,
|
|
} = useRoomGet(editRoomId);
|
|
|
|
const error = roomListError || detailedEditedRoomError;
|
|
|
|
// room being edited, as fetched from the server
|
|
const editedRoom: typeof roomInitialState | null = useMemo(
|
|
() =>
|
|
detailedEditedRoom
|
|
? {
|
|
name: detailedEditedRoom.name,
|
|
zulipAutoPost: detailedEditedRoom.zulip_auto_post,
|
|
zulipStream: detailedEditedRoom.zulip_stream,
|
|
zulipTopic: detailedEditedRoom.zulip_topic,
|
|
isLocked: detailedEditedRoom.is_locked,
|
|
roomMode: detailedEditedRoom.room_mode,
|
|
recordingType: detailedEditedRoom.recording_type,
|
|
recordingTrigger: detailedEditedRoom.recording_trigger,
|
|
isShared: detailedEditedRoom.is_shared,
|
|
webhookUrl: detailedEditedRoom.webhook_url || "",
|
|
webhookSecret: detailedEditedRoom.webhook_secret || "",
|
|
icsUrl: detailedEditedRoom.ics_url || "",
|
|
icsEnabled: detailedEditedRoom.ics_enabled || false,
|
|
icsFetchInterval: detailedEditedRoom.ics_fetch_interval || 5,
|
|
}
|
|
: null,
|
|
[detailedEditedRoom],
|
|
);
|
|
|
|
// a room input value or a last api room state
|
|
const room = roomInput || editedRoom || roomInitialState;
|
|
|
|
const roomTestWebhookMutation = useRoomTestWebhook();
|
|
|
|
// Update selected stream ID when zulip stream changes
|
|
useEffect(() => {
|
|
if (room.zulipStream && streams.length > 0) {
|
|
const selectedStream = streams.find((s) => s.name === room.zulipStream);
|
|
if (selectedStream !== undefined) {
|
|
setSelectedStreamId(selectedStream.stream_id);
|
|
}
|
|
} else {
|
|
setSelectedStreamId(null);
|
|
}
|
|
}, [room.zulipStream, streams]);
|
|
|
|
const streamOptions: SelectOption[] = streams.map((stream) => {
|
|
return { label: stream.name, value: stream.name };
|
|
});
|
|
|
|
const topicOptions: SelectOption[] = topics.map((topic) => ({
|
|
label: topic.name,
|
|
value: topic.name,
|
|
}));
|
|
|
|
const streamCollection = createListCollection({
|
|
items: streamOptions,
|
|
});
|
|
|
|
const topicCollection = createListCollection({
|
|
items: topicOptions,
|
|
});
|
|
|
|
const handleCopyUrl = (roomName: NonEmptyString) => {
|
|
navigator.clipboard.writeText(roomAbsoluteUrl(roomName)).then(() => {
|
|
setLinkCopied(roomName);
|
|
setTimeout(() => {
|
|
setLinkCopied("");
|
|
}, 2000);
|
|
});
|
|
};
|
|
|
|
const handleCloseDialog = () => {
|
|
setShowWebhookSecret(false);
|
|
setWebhookTestResult(null);
|
|
setEditRoomId(null);
|
|
onClose();
|
|
};
|
|
|
|
const handleTestWebhook = async () => {
|
|
if (!room.webhookUrl) {
|
|
setWebhookTestResult("Please enter a webhook URL first");
|
|
return;
|
|
}
|
|
if (!editRoomId) {
|
|
console.error("No room ID to test webhook");
|
|
return;
|
|
}
|
|
|
|
setTestingWebhook(true);
|
|
setWebhookTestResult(null);
|
|
|
|
try {
|
|
const response = await roomTestWebhookMutation.mutateAsync({
|
|
params: {
|
|
path: {
|
|
room_id: editRoomId,
|
|
},
|
|
},
|
|
});
|
|
|
|
if (response.success) {
|
|
setWebhookTestResult(
|
|
`${SUCCESS_EMOJI} Webhook test successful! Status: ${response.status_code}`,
|
|
);
|
|
} else {
|
|
let errorMsg = `${ERROR_EMOJI} Webhook test failed`;
|
|
errorMsg += ` (Status: ${response.status_code})`;
|
|
if (response.error) {
|
|
errorMsg += `: ${response.error}`;
|
|
} else if (response.response_preview) {
|
|
// Try to parse and extract meaningful error from response
|
|
// Specific to N8N at the moment, as there is no specification for that
|
|
// We could just display as is, but decided here to dig a little bit more.
|
|
try {
|
|
const preview = JSON.parse(response.response_preview);
|
|
if (preview.message) {
|
|
errorMsg += `: ${preview.message}`;
|
|
}
|
|
} catch {
|
|
// If not JSON, just show the preview text (truncated)
|
|
const previewText = response.response_preview.substring(0, 150);
|
|
errorMsg += `: ${previewText}`;
|
|
}
|
|
} else if (response?.message) {
|
|
errorMsg += `: ${response.message}`;
|
|
}
|
|
setWebhookTestResult(errorMsg);
|
|
}
|
|
} catch (error) {
|
|
console.error("Error testing webhook:", error);
|
|
setWebhookTestResult("❌ Failed to test webhook. Please check your URL.");
|
|
} finally {
|
|
setTestingWebhook(false);
|
|
}
|
|
|
|
// Clear result after 5 seconds
|
|
setTimeout(() => {
|
|
setWebhookTestResult(null);
|
|
}, 5000);
|
|
};
|
|
|
|
const handleSaveRoom = async () => {
|
|
try {
|
|
if (RESERVED_PATHS.includes(room.name)) {
|
|
setNameError("This room name is reserved. Please choose another name.");
|
|
return;
|
|
}
|
|
|
|
const roomData = {
|
|
name: room.name,
|
|
zulip_auto_post: room.zulipAutoPost,
|
|
zulip_stream: room.zulipStream,
|
|
zulip_topic: room.zulipTopic,
|
|
is_locked: room.isLocked,
|
|
room_mode: room.roomMode,
|
|
recording_type: room.recordingType,
|
|
recording_trigger: room.recordingTrigger,
|
|
is_shared: room.isShared,
|
|
webhook_url: room.webhookUrl,
|
|
webhook_secret: room.webhookSecret,
|
|
ics_url: room.icsUrl,
|
|
ics_enabled: room.icsEnabled,
|
|
ics_fetch_interval: room.icsFetchInterval,
|
|
};
|
|
|
|
if (isEditing) {
|
|
await updateRoomMutation.mutateAsync({
|
|
params: {
|
|
path: { room_id: assertExists(editRoomId) },
|
|
},
|
|
body: roomData,
|
|
});
|
|
} else {
|
|
await createRoomMutation.mutateAsync({
|
|
body: roomData,
|
|
});
|
|
}
|
|
|
|
setRoomInput(null);
|
|
setIsEditing(false);
|
|
setEditRoomId("");
|
|
setNameError("");
|
|
refetch();
|
|
onClose();
|
|
handleCloseDialog();
|
|
} catch (err: any) {
|
|
if (
|
|
err?.status === 400 &&
|
|
err?.body?.detail == "Room name is not unique"
|
|
) {
|
|
setNameError(
|
|
"This room name is already taken. Please choose a different name.",
|
|
);
|
|
} else {
|
|
setNameError("An error occurred. Please try again.");
|
|
}
|
|
}
|
|
};
|
|
|
|
const handleEditRoom = async (roomId: string, roomData) => {
|
|
// Reset states
|
|
setShowWebhookSecret(false);
|
|
setWebhookTestResult(null);
|
|
|
|
setRoomInput({
|
|
name: roomData.name,
|
|
zulipAutoPost: roomData.zulip_auto_post,
|
|
zulipStream: roomData.zulip_stream,
|
|
zulipTopic: roomData.zulip_topic,
|
|
isLocked: roomData.is_locked,
|
|
roomMode: roomData.room_mode,
|
|
recordingType: roomData.recording_type,
|
|
recordingTrigger: roomData.recording_trigger,
|
|
isShared: roomData.is_shared,
|
|
webhookUrl: roomData.webhook_url || "",
|
|
webhookSecret: roomData.webhook_secret || "",
|
|
icsUrl: roomData.ics_url || "",
|
|
icsEnabled: roomData.ics_enabled || false,
|
|
icsFetchInterval: roomData.ics_fetch_interval || 5,
|
|
});
|
|
setEditRoomId(roomId);
|
|
setIsEditing(true);
|
|
setNameError("");
|
|
onOpen();
|
|
};
|
|
|
|
const handleDeleteRoom = async (roomId: string) => {
|
|
try {
|
|
await deleteRoomMutation.mutateAsync({
|
|
params: {
|
|
path: { room_id: roomId },
|
|
},
|
|
});
|
|
refetch();
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
};
|
|
|
|
const handleRoomChange = (e) => {
|
|
let { name, value, type, checked } = e.target;
|
|
if (name === "name") {
|
|
value = value
|
|
.replace(/[^a-zA-Z0-9\s-]/g, "")
|
|
.replace(/\s+/g, "-")
|
|
.toLowerCase();
|
|
setNameError("");
|
|
}
|
|
setRoomInput({
|
|
...room,
|
|
[name]: type === "checkbox" ? checked : value,
|
|
});
|
|
};
|
|
|
|
const myRooms: Room[] =
|
|
response?.items.filter((roomData) => !roomData.is_shared) || [];
|
|
const sharedRooms: Room[] =
|
|
response?.items.filter((roomData) => roomData.is_shared) || [];
|
|
|
|
if (loading && !response)
|
|
return (
|
|
<Flex
|
|
flexDir="column"
|
|
alignItems="center"
|
|
justifyContent="center"
|
|
h="100%"
|
|
>
|
|
<Spinner size="xl" />
|
|
</Flex>
|
|
);
|
|
|
|
if (roomListError)
|
|
return <div>{`${roomListError.name}: ${roomListError.message}`}</div>;
|
|
|
|
return (
|
|
<Flex
|
|
flexDir="column"
|
|
w={{ base: "full", md: "container.xl" }}
|
|
mx="auto"
|
|
pt={2}
|
|
>
|
|
<Flex
|
|
flexDir="row"
|
|
justifyContent="space-between"
|
|
alignItems="center"
|
|
mb={4}
|
|
>
|
|
<Heading size="lg">Rooms {loading && <Spinner size="sm" />}</Heading>
|
|
<Button
|
|
colorPalette="primary"
|
|
onClick={() => {
|
|
setIsEditing(false);
|
|
setRoomInput(null);
|
|
setNameError("");
|
|
setShowWebhookSecret(false);
|
|
setWebhookTestResult(null);
|
|
onOpen();
|
|
}}
|
|
>
|
|
Add Room
|
|
</Button>
|
|
</Flex>
|
|
|
|
<Dialog.Root
|
|
open={open}
|
|
onOpenChange={(e) => (e.open ? onOpen() : handleCloseDialog())}
|
|
size="lg"
|
|
>
|
|
<Dialog.Backdrop />
|
|
<Dialog.Positioner>
|
|
<Dialog.Content>
|
|
<Dialog.Header>
|
|
<Dialog.Title>
|
|
{isEditing ? "Edit Room" : "Add Room"}
|
|
</Dialog.Title>
|
|
<Dialog.CloseTrigger asChild>
|
|
<CloseButton />
|
|
</Dialog.CloseTrigger>
|
|
</Dialog.Header>
|
|
<Dialog.Body>
|
|
<Tabs.Root defaultValue="general">
|
|
<Tabs.List>
|
|
<Tabs.Trigger value="general">General</Tabs.Trigger>
|
|
<Tabs.Trigger value="calendar">Calendar</Tabs.Trigger>
|
|
<Tabs.Trigger value="share">Share</Tabs.Trigger>
|
|
<Tabs.Trigger value="webhook">WebHook</Tabs.Trigger>
|
|
</Tabs.List>
|
|
|
|
<Tabs.Content value="general" pt={6}>
|
|
<Field.Root>
|
|
<Field.Label>Room name</Field.Label>
|
|
<Input
|
|
name="name"
|
|
placeholder="room-name"
|
|
value={room.name}
|
|
onChange={handleRoomChange}
|
|
/>
|
|
<Field.HelperText>
|
|
No spaces or special characters allowed
|
|
</Field.HelperText>
|
|
{nameError && (
|
|
<Field.ErrorText>{nameError}</Field.ErrorText>
|
|
)}
|
|
</Field.Root>
|
|
|
|
<Field.Root mt={4}>
|
|
<Checkbox.Root
|
|
name="isLocked"
|
|
checked={room.isLocked}
|
|
onCheckedChange={(e) => {
|
|
const syntheticEvent = {
|
|
target: {
|
|
name: "isLocked",
|
|
type: "checkbox",
|
|
checked: e.checked,
|
|
},
|
|
};
|
|
handleRoomChange(syntheticEvent);
|
|
}}
|
|
>
|
|
<Checkbox.HiddenInput />
|
|
<Checkbox.Control>
|
|
<Checkbox.Indicator />
|
|
</Checkbox.Control>
|
|
<Checkbox.Label>Locked room</Checkbox.Label>
|
|
</Checkbox.Root>
|
|
</Field.Root>
|
|
|
|
<Field.Root mt={4}>
|
|
<Field.Label>Room size</Field.Label>
|
|
<Select.Root
|
|
value={[room.roomMode]}
|
|
onValueChange={(e) =>
|
|
setRoomInput({ ...room, roomMode: e.value[0] })
|
|
}
|
|
collection={roomModeCollection}
|
|
>
|
|
<Select.HiddenSelect />
|
|
<Select.Control>
|
|
<Select.Trigger>
|
|
<Select.ValueText placeholder="Select room size" />
|
|
</Select.Trigger>
|
|
<Select.IndicatorGroup>
|
|
<Select.Indicator />
|
|
</Select.IndicatorGroup>
|
|
</Select.Control>
|
|
<Select.Positioner>
|
|
<Select.Content>
|
|
{roomModeOptions.map((option) => (
|
|
<Select.Item key={option.value} item={option}>
|
|
{option.label}
|
|
<Select.ItemIndicator />
|
|
</Select.Item>
|
|
))}
|
|
</Select.Content>
|
|
</Select.Positioner>
|
|
</Select.Root>
|
|
</Field.Root>
|
|
|
|
<Field.Root mt={4}>
|
|
<Field.Label>Recording type</Field.Label>
|
|
<Select.Root
|
|
value={[room.recordingType]}
|
|
onValueChange={(e) =>
|
|
setRoomInput({
|
|
...room,
|
|
recordingType: e.value[0],
|
|
recordingTrigger:
|
|
e.value[0] !== "cloud"
|
|
? "none"
|
|
: room.recordingTrigger,
|
|
})
|
|
}
|
|
collection={recordingTypeCollection}
|
|
>
|
|
<Select.HiddenSelect />
|
|
<Select.Control>
|
|
<Select.Trigger>
|
|
<Select.ValueText placeholder="Select recording type" />
|
|
</Select.Trigger>
|
|
<Select.IndicatorGroup>
|
|
<Select.Indicator />
|
|
</Select.IndicatorGroup>
|
|
</Select.Control>
|
|
<Select.Positioner>
|
|
<Select.Content>
|
|
{recordingTypeOptions.map((option) => (
|
|
<Select.Item key={option.value} item={option}>
|
|
{option.label}
|
|
<Select.ItemIndicator />
|
|
</Select.Item>
|
|
))}
|
|
</Select.Content>
|
|
</Select.Positioner>
|
|
</Select.Root>
|
|
</Field.Root>
|
|
|
|
<Field.Root mt={4}>
|
|
<Field.Label>Cloud recording start trigger</Field.Label>
|
|
<Select.Root
|
|
value={[room.recordingTrigger]}
|
|
onValueChange={(e) =>
|
|
setRoomInput({ ...room, recordingTrigger: e.value[0] })
|
|
}
|
|
collection={recordingTriggerCollection}
|
|
disabled={room.recordingType !== "cloud"}
|
|
>
|
|
<Select.HiddenSelect />
|
|
<Select.Control>
|
|
<Select.Trigger>
|
|
<Select.ValueText placeholder="Select trigger" />
|
|
</Select.Trigger>
|
|
<Select.IndicatorGroup>
|
|
<Select.Indicator />
|
|
</Select.IndicatorGroup>
|
|
</Select.Control>
|
|
<Select.Positioner>
|
|
<Select.Content>
|
|
{recordingTriggerOptions.map((option) => (
|
|
<Select.Item key={option.value} item={option}>
|
|
{option.label}
|
|
<Select.ItemIndicator />
|
|
</Select.Item>
|
|
))}
|
|
</Select.Content>
|
|
</Select.Positioner>
|
|
</Select.Root>
|
|
</Field.Root>
|
|
|
|
<Field.Root mt={4}>
|
|
<Checkbox.Root
|
|
name="isShared"
|
|
checked={room.isShared}
|
|
onCheckedChange={(e) => {
|
|
const syntheticEvent = {
|
|
target: {
|
|
name: "isShared",
|
|
type: "checkbox",
|
|
checked: e.checked,
|
|
},
|
|
};
|
|
handleRoomChange(syntheticEvent);
|
|
}}
|
|
>
|
|
<Checkbox.HiddenInput />
|
|
<Checkbox.Control>
|
|
<Checkbox.Indicator />
|
|
</Checkbox.Control>
|
|
<Checkbox.Label>Shared room</Checkbox.Label>
|
|
</Checkbox.Root>
|
|
</Field.Root>
|
|
</Tabs.Content>
|
|
|
|
<Tabs.Content value="calendar" pt={6}>
|
|
<ICSSettings
|
|
roomName={parseNonEmptyString(room.name)}
|
|
icsUrl={room.icsUrl}
|
|
icsEnabled={room.icsEnabled}
|
|
icsFetchInterval={room.icsFetchInterval}
|
|
onChange={(settings) => {
|
|
setRoomInput({
|
|
...room,
|
|
icsUrl:
|
|
settings.ics_url !== undefined
|
|
? settings.ics_url
|
|
: room.icsUrl,
|
|
icsEnabled:
|
|
settings.ics_enabled !== undefined
|
|
? settings.ics_enabled
|
|
: room.icsEnabled,
|
|
icsFetchInterval:
|
|
settings.ics_fetch_interval !== undefined
|
|
? settings.ics_fetch_interval
|
|
: room.icsFetchInterval,
|
|
});
|
|
}}
|
|
isOwner={true}
|
|
isEditing={isEditing}
|
|
/>
|
|
</Tabs.Content>
|
|
|
|
<Tabs.Content value="share" pt={6}>
|
|
<Field.Root>
|
|
<Checkbox.Root
|
|
name="zulipAutoPost"
|
|
checked={room.zulipAutoPost}
|
|
onCheckedChange={(e) => {
|
|
const syntheticEvent = {
|
|
target: {
|
|
name: "zulipAutoPost",
|
|
type: "checkbox",
|
|
checked: e.checked,
|
|
},
|
|
};
|
|
handleRoomChange(syntheticEvent);
|
|
}}
|
|
>
|
|
<Checkbox.HiddenInput />
|
|
<Checkbox.Control>
|
|
<Checkbox.Indicator />
|
|
</Checkbox.Control>
|
|
<Checkbox.Label>
|
|
Automatically post transcription to Zulip
|
|
</Checkbox.Label>
|
|
</Checkbox.Root>
|
|
</Field.Root>
|
|
|
|
<Field.Root mt={4}>
|
|
<Field.Label>Zulip stream</Field.Label>
|
|
<Select.Root
|
|
value={room.zulipStream ? [room.zulipStream] : []}
|
|
onValueChange={(e) =>
|
|
setRoomInput({
|
|
...room,
|
|
zulipStream: e.value[0],
|
|
zulipTopic: "",
|
|
})
|
|
}
|
|
collection={streamCollection}
|
|
disabled={!room.zulipAutoPost}
|
|
>
|
|
<Select.HiddenSelect />
|
|
<Select.Control>
|
|
<Select.Trigger>
|
|
<Select.ValueText placeholder="Select stream" />
|
|
</Select.Trigger>
|
|
<Select.IndicatorGroup>
|
|
<Select.Indicator />
|
|
</Select.IndicatorGroup>
|
|
</Select.Control>
|
|
<Select.Positioner>
|
|
<Select.Content>
|
|
{streamOptions.map((option) => (
|
|
<Select.Item key={option.value} item={option}>
|
|
{option.label}
|
|
<Select.ItemIndicator />
|
|
</Select.Item>
|
|
))}
|
|
</Select.Content>
|
|
</Select.Positioner>
|
|
</Select.Root>
|
|
</Field.Root>
|
|
|
|
<Field.Root mt={4}>
|
|
<Field.Label>Zulip topic</Field.Label>
|
|
<Select.Root
|
|
value={room.zulipTopic ? [room.zulipTopic] : []}
|
|
onValueChange={(e) =>
|
|
setRoomInput({ ...room, zulipTopic: e.value[0] })
|
|
}
|
|
collection={topicCollection}
|
|
disabled={!room.zulipAutoPost}
|
|
>
|
|
<Select.HiddenSelect />
|
|
<Select.Control>
|
|
<Select.Trigger>
|
|
<Select.ValueText placeholder="Select topic" />
|
|
</Select.Trigger>
|
|
<Select.IndicatorGroup>
|
|
<Select.Indicator />
|
|
</Select.IndicatorGroup>
|
|
</Select.Control>
|
|
<Select.Positioner>
|
|
<Select.Content>
|
|
{topicOptions.map((option) => (
|
|
<Select.Item key={option.value} item={option}>
|
|
{option.label}
|
|
<Select.ItemIndicator />
|
|
</Select.Item>
|
|
))}
|
|
</Select.Content>
|
|
</Select.Positioner>
|
|
</Select.Root>
|
|
</Field.Root>
|
|
</Tabs.Content>
|
|
|
|
<Tabs.Content value="webhook" pt={6}>
|
|
<Field.Root>
|
|
<Field.Label>Webhook URL</Field.Label>
|
|
<Input
|
|
name="webhookUrl"
|
|
type="url"
|
|
placeholder="https://example.com/webhook"
|
|
value={room.webhookUrl}
|
|
onChange={handleRoomChange}
|
|
/>
|
|
<Field.HelperText>
|
|
Optional: URL to receive notifications when transcripts
|
|
are ready
|
|
</Field.HelperText>
|
|
</Field.Root>
|
|
|
|
{room.webhookUrl && (
|
|
<>
|
|
<Field.Root mt={4}>
|
|
<Field.Label>Webhook Secret</Field.Label>
|
|
<Flex gap={2}>
|
|
<Input
|
|
name="webhookSecret"
|
|
type={showWebhookSecret ? "text" : "password"}
|
|
value={room.webhookSecret}
|
|
onChange={handleRoomChange}
|
|
placeholder={
|
|
isEditing && room.webhookSecret
|
|
? "••••••••"
|
|
: "Leave empty to auto-generate"
|
|
}
|
|
flex="1"
|
|
/>
|
|
{isEditing && room.webhookSecret && (
|
|
<IconButton
|
|
size="sm"
|
|
variant="ghost"
|
|
aria-label={
|
|
showWebhookSecret
|
|
? "Hide secret"
|
|
: "Show secret"
|
|
}
|
|
onClick={() =>
|
|
setShowWebhookSecret(!showWebhookSecret)
|
|
}
|
|
>
|
|
{showWebhookSecret ? <LuEyeOff /> : <LuEye />}
|
|
</IconButton>
|
|
)}
|
|
</Flex>
|
|
<Field.HelperText>
|
|
Used for HMAC signature verification (auto-generated
|
|
if left empty)
|
|
</Field.HelperText>
|
|
</Field.Root>
|
|
|
|
{isEditing && (
|
|
<>
|
|
<Flex
|
|
mt={2}
|
|
gap={2}
|
|
alignItems="flex-start"
|
|
direction="column"
|
|
>
|
|
<Button
|
|
size="sm"
|
|
variant="outline"
|
|
onClick={handleTestWebhook}
|
|
disabled={testingWebhook || !room.webhookUrl}
|
|
>
|
|
{testingWebhook ? (
|
|
<>
|
|
<Spinner size="xs" mr={2} />
|
|
Testing...
|
|
</>
|
|
) : (
|
|
"Test Webhook"
|
|
)}
|
|
</Button>
|
|
{webhookTestResult && (
|
|
<div
|
|
style={{
|
|
fontSize: "14px",
|
|
wordBreak: "break-word",
|
|
maxWidth: "100%",
|
|
padding: "8px",
|
|
borderRadius: "4px",
|
|
backgroundColor: webhookTestResult.startsWith(
|
|
SUCCESS_EMOJI,
|
|
)
|
|
? "#f0fdf4"
|
|
: "#fef2f2",
|
|
border: `1px solid ${webhookTestResult.startsWith(SUCCESS_EMOJI) ? "#86efac" : "#fca5a5"}`,
|
|
}}
|
|
>
|
|
{webhookTestResult}
|
|
</div>
|
|
)}
|
|
</Flex>
|
|
</>
|
|
)}
|
|
</>
|
|
)}
|
|
</Tabs.Content>
|
|
</Tabs.Root>
|
|
</Dialog.Body>
|
|
<Dialog.Footer>
|
|
<Button variant="ghost" onClick={handleCloseDialog}>
|
|
Cancel
|
|
</Button>
|
|
<Button
|
|
colorPalette="primary"
|
|
onClick={handleSaveRoom}
|
|
disabled={
|
|
!room.name || (room.zulipAutoPost && !room.zulipTopic)
|
|
}
|
|
>
|
|
{isEditing ? "Save" : "Add"}
|
|
</Button>
|
|
</Dialog.Footer>
|
|
</Dialog.Content>
|
|
</Dialog.Positioner>
|
|
</Dialog.Root>
|
|
|
|
<RoomList
|
|
title="My Rooms"
|
|
rooms={myRooms}
|
|
linkCopied={linkCopied}
|
|
onCopyUrl={handleCopyUrl}
|
|
onEdit={handleEditRoom}
|
|
onDelete={handleDeleteRoom}
|
|
emptyMessage="No rooms found"
|
|
/>
|
|
|
|
<RoomList
|
|
title="Shared Rooms"
|
|
rooms={sharedRooms}
|
|
linkCopied={linkCopied}
|
|
onCopyUrl={handleCopyUrl}
|
|
onEdit={handleEditRoom}
|
|
onDelete={handleDeleteRoom}
|
|
emptyMessage="No shared rooms found"
|
|
pt={4}
|
|
/>
|
|
</Flex>
|
|
);
|
|
}
|