An electrosurgical system includes an electrosurgical device adapted to direct energy to tissue and a fluid path leading to the electrosurgical device. The system also includes an optical sensor unit operably associated with the fluid path. The optical sensor unit includes a light-emitting element to generate light output and a light-receiving element to collect light outputted from the light-emitting element. The light-emitting element and the light-receiving element are disposed such that light output from the light-emitting element passes through the fluid path to the light-receiving element. The optical sensor unit is capable of detecting an air bubble in the fluid path passing through the optical sensor unit using a sensed characteristic of light collected at the light-receiving element.