{
    if now >= next_diagnostics_sample.get() {
        let network = diagnostics_network.borrow_mut().snapshot();
        let uplink = crate::uplink_telemetry::load_uplink_telemetry(&uplink_telemetry_path);
        let client_process_cpu_pct = diagnostics_process
            .borrow_mut()
            .sample_percent()
            .unwrap_or(0.0);
        record_diagnostics_sample(
            &widgets,
            &state.borrow(),
            preview.as_ref().map(|preview| preview.as_ref()),
            uplink.as_ref(),
            network,
            client_process_cpu_pct,
        );
        next_diagnostics_sample.set(now + Duration::from_secs(1));
    }

    let (camera_probe_active, camera_label, mic_probe_active) = {
        let state = state.borrow();
        (
            state.channels.camera && state.devices.camera.is_some(),
            state.devices.camera.clone(),
            state.channels.microphone && state.devices.microphone.is_some(),
        )
    };
    if let Err(err) = tests.borrow_mut().sync_relay_uplink_probe(
        child_running,
        camera_probe_active,
        camera_label.as_deref(),
        &camera_preview_path,
        mic_probe_active,
        &mic_level_path,
    ) {
        widgets
            .status_label
            .set_text(&format!("Local uplink monitor could not start: {err}"));
    }
}
