Skip to content

feat(core): track setup status of components on start/reload#1312

Merged
roflcoopter merged 1 commit intodevfrom
feature/setup_status_tracking
Apr 9, 2026
Merged

feat(core): track setup status of components on start/reload#1312
roflcoopter merged 1 commit intodevfrom
feature/setup_status_tracking

Conversation

@roflcoopter
Copy link
Copy Markdown
Owner

Store and track setup status of components/domains to later be consumed by the frontend

Copilot AI review requested due to automatic review settings April 8, 2026 05:46
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 8, 2026

Deploy Preview for viseron canceled.

Name Link
🔨 Latest commit b147429
🔍 Latest deploy log https://app.netlify.com/projects/viseron/deploys/69d5f029047d7b0008c6e4ba

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds structured tracking of component lifecycle/setup status (including errors) and exposes that status for frontend consumption, while enhancing reload-time validation to return structured errors.

Changes:

  • Introduces ComponentState, ComponentError*, and component setup-status events/error accumulation in viseron.components.
  • Updates config reload validation to return ComponentError objects and clear/propagate validation errors onto existing components.
  • Adds a core API (Viseron.get_setup_status) to expose component (and attached domain) setup status; updates tests accordingly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
viseron/components/__init__.py Adds component state machine, structured errors, status event dispatching, and new validation result type.
viseron/reload.py Switches reload validation to structured errors and clears stale validation errors on reload start.
viseron/domains/__init__.py Propagates domain setup failures into the owning component’s error list.
viseron/const.py Adds a new event topic for component setup status changes.
viseron/__init__.py Exposes get_setup_status() for frontend consumption of setup status.
tests/test_reload.py Updates reload validation/reload-config tests for structured errors and new return types.
tests/components/test__init__.py Adds/updates tests for component state transitions and error tracking.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +154 to +158
EventComponentSetupStatusData(
component=self._name,
state=self._state.value,
error=self._errors[-1].message if self._errors else None,
validation_error=self._validation_error,
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_dispatch_status_event() reads self._errors without holding _errors_lock (self._errors[-1]). Since errors can be appended from other threads (eg, domain setup threads), this can race and produce inconsistent/incorrect event payloads. Consider taking a locked snapshot (or using the errors property) before building the event data.

Copilot uses AI. Check for mistakes.
@roflcoopter roflcoopter force-pushed the feature/setup_status_tracking branch from 2f5bff7 to b147429 Compare April 8, 2026 06:05
@roflcoopter roflcoopter merged commit b1058bc into dev Apr 9, 2026
17 checks passed
@roflcoopter roflcoopter deleted the feature/setup_status_tracking branch April 9, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants