Once the input sees a new peak voltage, the capacitor is charged up to that voltage. The capacitor attempts to discharge through the non-inverting pin on the OpAmp because the diode prevents the capacitor from discharging back through the output. This is what causes the output to stay at the peak value.
The circuit has an OpAmp buffer at the output to prevent the capacitor from discharging through a connected load.
The capacitor also has a button connected to it for manually discharging it.