Skip to content

feat: add background monitoring mode with system tray support #1275

@shm11C3

Description

@shm11C3

Summary

Add a background monitoring mode that keeps HardwareVisualizer running in the system tray and continues collecting metrics even after the main window is closed.

This allows users to keep historical data collection running without leaving the main window open all the time.

Motivation

Currently, monitoring is effectively tied to the main window being open.
For a hardware monitoring app, this makes it harder to:

  • keep collecting long-running history in normal daily use
  • inspect what happened after a temporary spike or abnormal event
  • use the app as a lightweight always-on monitor

Keeping the app alive in the background would improve the usefulness of historical insights while reducing UI friction.

Goals

  • Keep metric collection running after the main window is closed
  • Provide a system tray entry point to reopen the app
  • Allow users to explicitly pause or quit background monitoring
  • Make the close behavior understandable and controllable

Non-Goals

  • Full service/daemon separation
  • Full auto-start support in the initial implementation
  • Alerting/notifications in the initial implementation
  • Perfect parity across all platforms in the first release

Proposed UX

Initial behavior

  • When the user closes the main window, the app remains running in the background
  • A system tray icon remains visible while the app is active
  • Monitoring continues in the background

Tray menu

  • Open HardwareVisualizer
  • Pause monitoring / Resume monitoring
  • Quit

Close behavior

Because users may expect the close button to fully exit the app, the behavior should be explicit.

Possible approach:

  • On first close, show a dialog such as:
    • "Close window and keep monitoring in background?"
    • options:
      • Continue in background
      • Quit app
      • Remember my choice

Scope

v1

  • Add system tray icon
  • Keep app alive after window close
  • Continue monitoring in background
  • Add tray menu with:
    • Open
    • Pause/Resume monitoring
    • Quit

Future follow-ups

  • Setting: "Close to tray instead of quitting"
  • Setting: "Launch on login"
  • Reduce polling/storage frequency while backgrounded
  • Threshold-based notifications
  • Background-only startup mode

Technical Notes

This should be designed as a background monitoring mode, not just a tray UI feature.

Recommended separation:

  • Collector: sensor polling and aggregation
  • Persistence: history storage
  • MonitoringState: running / paused / stopped
  • WindowState: visible / hidden
  • TrayController: open / pause / quit actions

Important points:

  • Monitoring should not depend on the window being visible
  • UI rendering work should stop when the window is hidden
  • "Quit" must fully stop background collection and exit the process
  • "Pause monitoring" should stop collection without requiring process exit

Platform Notes

To keep scope reasonable, this can be implemented with Windows-first support.

Reason:

  • The value is highest there
  • Background behavior and user expectation around tray apps are clearer
  • Linux support may require extra consideration depending on sensor access and environment differences

Acceptance Criteria

  • Closing the main window does not stop monitoring
  • The app remains accessible from the system tray
  • The tray menu can reopen the main window
  • The tray menu can pause and resume monitoring
  • The tray menu can fully quit the app
  • Historical data continues to be recorded while the window is closed
  • Hidden/background mode does not keep unnecessary UI update work running
  • The close behavior is explained to users clearly at least once

Open Questions

  • Should background mode be enabled by default, or opt-in via settings?
  • Should first implementation target Windows only?
  • Should hidden/background mode use the same polling interval as foreground mode?
  • Should "Pause monitoring" also pause history persistence, or only sensor collection?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Proposal

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions