feat(livekit): close the room when a pod is deleted

DELETE /api/pods/:id now also calls closeRoom (RoomServiceClient.deleteRoom)
to end the live LiveKit room and disconnect anyone connected. PodView listens
for RoomEvent.Disconnected and returns the user to the pod list, so a deleted
pod cleanly kicks everyone out instead of stranding them in a dead room.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kartikeya
2026-06-27 17:22:07 -07:00
parent e29fabc3f1
commit 891d4b12bd
3 changed files with 23 additions and 3 deletions
+8 -2
View File
@@ -50,6 +50,8 @@ export function PodView({
const audioRef = useRef<HTMLDivElement>(null);
const beatRef = useRef<BeatHandle | null>(null);
const screenTrackRef = useRef<MediaStreamTrack | null>(null);
const onLeaveRef = useRef(onLeave);
onLeaveRef.current = onLeave;
// Subscribe to live room state: participants, active speakers, remote audio.
useEffect(() => {
@@ -63,13 +65,16 @@ export function PodView({
}
};
const onAudioGone = (track: RemoteTrack) => track.detach().forEach((el) => el.remove());
// Room closed out from under us (e.g. the pod was deleted) → back to the list.
const onDisconnected = () => onLeaveRef.current();
room
.on(RoomEvent.ParticipantConnected, refresh)
.on(RoomEvent.ParticipantDisconnected, refresh)
.on(RoomEvent.ActiveSpeakersChanged, refresh)
.on(RoomEvent.TrackSubscribed, onAudio)
.on(RoomEvent.TrackUnsubscribed, onAudioGone);
.on(RoomEvent.TrackUnsubscribed, onAudioGone)
.on(RoomEvent.Disconnected, onDisconnected);
return () => {
room
@@ -77,7 +82,8 @@ export function PodView({
.off(RoomEvent.ParticipantDisconnected, refresh)
.off(RoomEvent.ActiveSpeakersChanged, refresh)
.off(RoomEvent.TrackSubscribed, onAudio)
.off(RoomEvent.TrackUnsubscribed, onAudioGone);
.off(RoomEvent.TrackUnsubscribed, onAudioGone)
.off(RoomEvent.Disconnected, onDisconnected);
};
}, [room, me]);