impl InputAggregator {
    #[cfg(coverage)]
    pub async fn run(&mut self) -> Result<()> {
        loop {
            self.process_keyboard_updates();
            let quick_toggle_now = self.quick_toggle_active();
            self.observe_quick_toggle(quick_toggle_now);

            if self.remote_failsafe_expired() {
                self.begin_local_release();
            }

            if self.pending_release || self.pending_kill {
                let chord_released = if self.pending_keys.is_empty() {
                    !self
                        .keyboards
                        .iter()
                        .any(|k| k.magic_grab() || k.magic_kill())
                } else {
                    self.pending_keys
                        .iter()
                        .all(|key| !self.keyboards.iter().any(|k| k.has_key(*key)))
                };

                if chord_released {
                    let pending_kill = self.pending_kill;
                    self.finish_local_release(!pending_kill);
                    if pending_kill {
                        return Ok(());
                    }
                }
            }

            for mouse in &mut self.mice {
                mouse.process_events();
            }

            tokio::task::yield_now().await;
        }
    }

    #[cfg(not(coverage))]
    pub async fn run(&mut self) -> Result<()> {
        // Example approach: poll each aggregator in a simple loop
        let mut tick = interval(Duration::from_millis(10));
        let mut current = Layout::SideBySide;
        let input_rescan_interval = input_rescan_interval_from_env();
        let mut last_input_rescan_at = Instant::now();
        self.publish_routing_state_if_changed();
        loop {
            let mut want_kill = false;
            self.process_keyboard_updates();
            if !input_rescan_interval.is_zero()
                && last_input_rescan_at.elapsed() >= input_rescan_interval
            {
                last_input_rescan_at = Instant::now();
                let remote_active = self.remote_capture_active();
                if let Err(err) = self.scan_input_devices(remote_active, false) {
                    warn!("⚠️ input device rescan failed: {err:#}");
                }
            }
            for kbd in &self.keyboards {
                want_kill |= kbd.magic_kill();
            }
            self.poll_launcher_routing_request();
            self.poll_launcher_quick_toggle_request();
            self.poll_launcher_clipboard_request();
            self.poll_launcher_wake_request();
            let quick_toggle_now = self.quick_toggle_active();
            self.observe_quick_toggle(quick_toggle_now);
            let magic_now = self.keyboards.iter().any(|k| k.magic_grab());
            let magic_left = self.keyboards.iter().any(|k| k.magic_left());
            let magic_right = self.keyboards.iter().any(|k| k.magic_right());

            if magic_now && !self.magic_active {
                self.toggle_grab();
            }
            if (magic_left || magic_right) && self.magic_active {
                current = match current {
                    Layout::SideBySide => Layout::FullLeft,
                    Layout::FullLeft => Layout::FullRight,
                    Layout::FullRight => Layout::SideBySide,
                };
                apply_layout(current);
            }
            if want_kill && !self.pending_kill {
                warn!("🧙  magic chord - killing 🪄 AVADA KEDAVRA!!! 💥💀⚰️");
                self.remote_capture_enabled.store(false, Ordering::Relaxed);
                for k in &mut self.keyboards {
                    k.send_empty_report();
                    k.set_send(false);
                }
                for m in &mut self.mice {
                    m.reset_state();
                    m.set_send(false);
                }
                self.pending_kill = true;
                self.capture_pending_keys();
                self.pending_release_started_at = Some(Instant::now());
            }

            if self.remote_failsafe_expired() {
                warn!(
                    "🛟 remote input failsafe expired after {} ms; returning control to this machine",
                    self.remote_failsafe_timeout.as_millis()
                );
                self.begin_local_release();
            }

            if self.pending_release || self.pending_kill {
                let chord_released = if self.pending_keys.is_empty() {
                    !self
                        .keyboards
                        .iter()
                        .any(|k| k.magic_grab() || k.magic_kill())
                } else {
                    self.pending_keys
                        .iter()
                        .all(|key| !self.keyboards.iter().any(|k| k.has_key(*key)))
                };
                let timed_out = self.pending_release_timed_out();
                if chord_released || timed_out {
                    if timed_out {
                        warn!(
                            "⌛ local release timed out waiting for key-up events; forcing the handoff"
                        );
                    }
                    self.finish_local_release(!self.pending_kill);
                    if self.pending_kill {
                        return Ok(());
                    }
                }
            }

            let mut mouse_relayed = false;
            for mouse in &mut self.mice {
                mouse_relayed |= mouse.process_events();
            }
            if mouse_relayed {
                self.record_hid_relayed();
            }
            self.maybe_send_wake_nudge();

            self.magic_active = magic_now;
            tick.tick().await;
        }
    }

}
