Skip to content

refactor(core): Phase 2 — introduce in-process EventBus for metric snapshots #1404

@shm11C3

Description

@shm11C3

Parent

Part of #1402. Depends on the new Phase 1 (workspace setup).

Goal

Add core::event_bus::EventBus (tokio::sync::broadcast<MetricsSnapshot>) inside the root-level core crate and route the existing real-time monitor event through it. Frontend behavior unchanged.

Workspace Context

After the new Phase 1, core/ is a separate crate at the repo root. Items under core::* in this issue refer to modules inside that crate (core/src/...). src-tauri/ continues to host the Tauri app and depends on the core crate via path.

Scope

  • Implement core::event_bus::EventBus and a MetricsSnapshot payload type in core/src/event_bus.rs (with MetricsSnapshot in core/src/models/).
  • Modify workers::system_monitor::SystemMonitorController (still under src-tauri/src/workers/) to publish to the EventBus via the core crate API instead of calling app.handle() directly for emit.
  • Add app::adapters::window::WindowAdapter under src-tauri/src/app/adapters/window.rs that subscribes to the EventBus and emits the existing HardwareMonitorUpdate Tauri event.
  • The HardwareMonitorUpdate wire format stays unchanged this phase.

Out of Scope

  • Moving the collector under core/ (Phase 3).
  • Replacing HardwareMonitorUpdate with a redesigned payload (deferred).

Definition of Done

  • Frontend dashboard updates in real time, indistinguishably from before.
  • Inside the collector loop, there is no direct call to tauri::Emitter::emit or AppHandle::emit.
  • A unit test under core/ exercises EventBus fan-out to multiple subscribers without a Tauri runtime — i.e. cargo test -p <core-crate> passes with no Tauri in the dependency graph.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions