/** Auto-closes selectedCamera when the selected live session disappears from liveSessions. */ export function useAutoCloseLiveSession(selectedCamera, liveSessions) { watch( [() => selectedCamera.value, () => liveSessions.value], ([sel, sessions]) => { if (!sel || typeof sel.hasStream === 'undefined') return const stillActive = (sessions ?? []).some(s => s.id === sel.id) if (!stillActive) selectedCamera.value = null }, { deep: true }, ) }