Skip to content

Feature/add UI - #3

Open
LiteObject wants to merge 28 commits into
masterfrom
feature/add-ui
Open

LiteObject wants to merge 28 commits into
masterfrom
feature/add-ui

Conversation

@LiteObject

Copy link
Copy Markdown
Owner

No description provided.

LiteObject added 12 commits July 5, 2025 22:40
- Introduced a Streamlit-based UI dashboard for monitoring RTSP processing.
- Implemented an event broadcasting system for real-time updates.
- Updated main application to support launching with a UI option.
- Enhanced README and requirements to include Streamlit and related instructions.
- Added tests for UI imports to ensure functionality without Streamlit installed.
…e; improve event broadcasting with deque for memory efficiency; add context manager for notification dispatcher cleanup.
…s; update device discovery and message sending methods for improved performance and reliability.
…ing and saving of events to a JSON file for improved data retention and recovery.
…nhance logging and background service status checks.
…c context; implement thread handling to avoid event loop errors.
…shboard features, troubleshooting, and updated dependencies
@LiteObject
LiteObject requested a review from Copilot July 7, 2025 03:31

This comment was marked as outdated.

…g and error handling. Update YOLOv8 model initialization for singleton pattern and improve UI dashboard metrics display.
@LiteObject
LiteObject requested a review from Copilot July 11, 2025 03:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a comprehensive Streamlit UI dashboard for real-time monitoring of the RTSP processing system. The changes include creating a web-based interface with live event streaming, metrics tracking, and enhanced async support for Google Hub broadcasts, along with a sophisticated event broadcasting system for cross-process communication.

  • Implements a real-time web dashboard with live metrics, image gallery, and event streaming
  • Adds cross-process event broadcasting system using persistent JSON storage for UI updates
  • Enhances async support in Google Hub communication with better error handling and timeout management

Reviewed Changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/ui_dashboard.py New Streamlit dashboard with real-time monitoring features and event display
src/event_broadcaster.py New event broadcasting system for cross-process communication and persistence
src/services.py Enhanced with event emission and cleanup methods for broadcaster integration
src/google_broadcast.py Refactored to support async operations with proper zeroconf handling
src/app.py Extended with UI launcher options and graceful shutdown handling
src/notification_dispatcher.py Added context manager support and improved cleanup
run_ui.py New standalone entry point for UI dashboard
README.md Updated documentation with new UI features and troubleshooting

Comment thread src/ui_dashboard.py Outdated

# Auto-refresh
if st.session_state.auto_refresh:
time.sleep(2)

Copilot AI Jul 11, 2025

Copy link

Choose a reason for hiding this comment

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

Using time.sleep() in a Streamlit app can block the UI thread. Consider using st.empty() with a placeholder and manual refresh triggers instead of blocking sleep.

Suggested change
time.sleep(2)
placeholder = st.empty()
for _ in range(20): # Adjust the range for a 2-second delay (20 iterations of 0.1s)
time.sleep(0.1)
placeholder.text("Refreshing...")

Copilot uses AI. Check for mistakes.
Comment thread src/google_broadcast.py Outdated
try:
# Create CastInfo for the known device
services = {HostServiceInfo(device_ip, port)}
services: Set[Union[HostServiceInfo, 'MDNSServiceInfo']] = {

Copilot AI Jul 11, 2025

Copy link

Choose a reason for hiding this comment

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

Using forward reference string 'MDNSServiceInfo' suggests this type may not be properly imported. Consider importing the actual type or removing it from the type hint if not needed.

Suggested change
services: Set[Union[HostServiceInfo, 'MDNSServiceInfo']] = {
services: Set[Union[HostServiceInfo, MDNSServiceInfo]] = {

Copilot uses AI. Check for mistakes.
Comment thread src/computer_vision.py
@@ -32,7 +36,6 @@ def __new__(cls, model_path='yolov8n.pt'):
with cls._lock:
if model_path not in cls._instances:
instance = super().__new__(cls)

Copilot AI Jul 11, 2025

Copy link

Choose a reason for hiding this comment

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

The model initialization has been moved to init but the singleton pattern still creates the instance in new. This creates a race condition where _model might not be initialized when the instance is returned.

Suggested change
instance = super().__new__(cls)
instance = super().__new__(cls)
instance._model = YOLO(model_path) # Initialize the model here

Copilot uses AI. Check for mistakes.
Comment thread src/services.py Outdated
return False
finally:
# Explicit frame cleanup to free memory
del frame

Copilot AI Jul 11, 2025

Copy link

Choose a reason for hiding this comment

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

Explicit del frame in finally block may cause issues if frame was not successfully created due to exceptions in earlier code. Consider checking if frame exists before deletion.

Suggested change
del frame
if 'frame' in locals() and frame is not None:
del frame

Copilot uses AI. Check for mistakes.
Comment thread src/app.py Resolved
Comment thread README.md Outdated
Comment on lines 46 to 48
- `streamlit` - Real-time web dashboard with live event updates
- `streamlit` - Real-time web dashboard (optional UI)

Copilot AI Jul 11, 2025

Copy link

Choose a reason for hiding this comment

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

Duplicate streamlit entry in the dependencies list. One line says 'with live event updates' and the next says '(optional UI)'.

Suggested change
- `streamlit` - Real-time web dashboard with live event updates
- `streamlit` - Real-time web dashboard (optional UI)
- `streamlit` - Real-time web dashboard with live event updates (optional UI)

Copilot uses AI. Check for mistakes.
…nhance logging and background service status checks.
…nhance logging and background service status checks.
…event-driven UI updates and performance optimizations.
…meter; update related function signatures and logging for improved message broadcasting.
…arious services

- Implement tests for configuration validation in `test_config.py`, covering required fields and error reporting.
- Create tests for event persistence in `test_event_persistence.py`, ensuring correct document writing and handling of concurrent reads.
- Add tests for event schema functionality in `test_event_schema.py`, verifying event type stability and image path retrieval.
- Introduce tests for Google Cast broadcast helpers in `test_google_broadcast.py`, validating message sending and playback handling.
- Develop health check tests in `test_health_checks.py`, ensuring probes run off the event loop and handle exceptions correctly.
- Implement image analysis tests in `test_image_analysis.py`, covering various response scenarios and provider failures.
- Extend image capture tests in `test_image_capture.py` to include cleanup functionality for old images.
- Add LLM factory tests in `test_llm_factory.py`, ensuring correct model defaults and parameter forwarding.
- Create notification dispatcher tests in `test_notification_dispatcher.py`, validating async behavior and deduplication.
- Implement service tests in `test_services.py` for frame processing, ensuring correct event emission and notification handling.
- Add stream reader tests in `test_stream_reader.py`, verifying frame publishing and reconnection logic.
- Extend TTS service tests in `test_tts.py` to cover engine selection and thread safety.
- Implement UI formatting tests in `test_ui_formatting.py`, ensuring proper HTML escaping and event rendering.
- Remove unused YOLOv8 model file `yolov8n.pt`.
- Introduced unit tests for the SQLite event store, covering event appending, querying, and retention policies.
- Added tests for Google broadcast functionality, including local audio server and connection handling.
- Implemented tests for image analysis, ensuring proper handling of unsupported providers and fallback mechanisms.
- Enhanced image capture tests to validate frame saving and thumbnail generation.
- Created an end-to-end integration test for the processing pipeline, simulating a fake camera and notification system.
- Developed tests for LLM factory to ensure proper configuration and error handling.
- Added tests for process image functions, ensuring correct base64 conversion and prompt generation.
- Implemented service tests to validate analysis throttling and token budget management.
- Introduced throttle tests to verify cooldown and hourly cap functionality.
- Enhanced UI formatting tests to ensure proper event rendering and data masking.
…ns and styling improvements

fix: implement secret redaction in error messages to prevent sensitive data exposure

docs: update CHANGELOG for UI enhancements and security improvements; add new test cases for secret redaction
…with Material icons and CSV download functionality
- Introduced runtime settings to enable/disable notifications and adjust Chromecast volume dynamically.
- Updated dashboard to reflect changes in notification settings and volume.
- Implemented new functions in `runtime_settings.py` for loading and saving settings.
- Enhanced event store to retrieve events based on frame and image.
- Modified notification dispatcher to utilize runtime volume settings.
- Updated tests to cover new functionality and ensure proper behavior of runtime settings.
- Enhanced EventBroadcaster to emit events with an optional camera name.
- Updated EventStore schema to include a camera column and added migration logic for legacy databases.
- Implemented camera filtering in event retrieval methods and added methods for camera-specific statistics.
- Modified health checks to support multiple RTSP streams based on configured cameras.
- Introduced TokenBudget class to manage daily token limits shared across cameras.
- Updated AsyncRTSPProcessingService to handle camera-specific processing and notifications.
- Enhanced tests to cover new camera functionalities, including configuration validation and event emission.
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