Devices and systems with methods for detecting a sealing condition between a patient interface and a patient, and adjusting the patient interface to maintain the patient interface in sealing contact with the patient. The patient interface may include a sealing structure to form a seal on the patient, and a positioning structure to secure the sealing structure to the patient. The patient interface may include a sensor coupled to the sealing structure. A processor determines the sealing condition between the sealing structure and the patient based on a signal from the sensor, and adjusts at least one of the sealing structure and the positioning structure to maintain the sealing structure in sealing contact with the patient. A prediction system predicts a leak between the sealing structure and the patient based on the sensor signal. A learning system learns how to fit the sealing structure to the patient to form a seal.