mirror of
https://github.com/cassandra/home-information.git
synced 2026-04-20 06:29:50 -04:00
* Implement Phase 1 & 3 of auto-view switching feature - Add TransientViewSuggestion dataclass to console transient_models - Create TransientViewManager singleton for managing view suggestions - Add auto-view console settings (enabled, idle timeout, duration) - Add console helper methods for auto-view settings - Modify API status endpoint to include transient view suggestions - Create auto-view JavaScript module with user interaction tracking - Integrate auto-view with status polling system - Add CSS styling for auto-view indicator - Use antinode.js pattern for asynchronous content loading * Implement Phase 2: AlertManager integration with auto-view switching - Integrate AlertManager with TransientViewManager for EVENT alarms - Add auto-view suggestion logic for motion/movement detection alarms - Implement camera URL resolution using sensor_id from alarm source details - Create extensible structure for future WEATHER/CONSOLE alarm support - Replace TODO comment with actual implementation using recent alarms - Use alarm priority and type for suggestion priority and trigger reason * Fix flake8 linting issues - Fix console settings parameter ordering to include value_range_str - Fix transient_view_manager.py indentation and line continuation issues - Add newline at end of file * Add high-value unit tests and fix missing configurations - Create focused unit tests for TransientViewManager singleton behavior - Test priority-based suggestion replacement business logic - Add integration tests for AlertManager with TransientViewManager - Test motion detection alarms trigger auto-view suggestions - Test alarm priority propagation to suggestion priority - Add auto-view.js to Django pipeline configuration in js_hi_grid_content - Fix SecurityLevel enum values (OFF instead of DISARMED) - Ensure proper test isolation for singleton pattern tests * Fix test isolation issues in integration tests - Reset singleton instances properly between test iterations - Ensure clean state for each alarm priority test * Simplify integration tests and fix timezone issues - Use timezone-aware datetimes for Django compatibility - Simplify complex integration tests to focus on actual business logic - Test priority handling and suggestion replacement directly - Remove overly complex mocking that didn't add value - All tests now pass reliably * Refactor antinode.js to add public loadAsyncContent API for programmatic content loading - Add AN.loadAsyncContent() method for JavaScript-initiated DOM replacement - Update auto-view.js to use the new public API instead of internal functions - Remove unnecessary fallback logic and references to internal handleNewContentAdded - Rewrite antinode.js documentation to be comprehensive and well-structured - Document all features including the new programmatic API - Preserve detailed version support explanation in dedicated section * Updated copyright dates. * Refactor auto-view switching with improved encapsulation Move responsibility boundaries to better encapsulate auto-view logic: **Alert Model:** - Add get_view_url() method to encapsulate view URL generation - Move URL extraction logic from AlertManager to Alert model - Add comprehensive documentation about HiGridView constraint - Handle EVENT alarm source with sensor_id mapping to camera URLs **TransientViewManager:** - Add consider_alert_for_auto_view() method with all business logic - Move auto-view decision making from AlertManager - Centralize settings access and alert type filtering - Handle motion detection filtering and URL validation **AlertManager:** - Simplify to coordinator role, just delegates to TransientViewManager - Remove auto-view decision logic and URL generation methods - Clean delegation: if new_alert exists, consider it for auto-view **Test Coverage:** - Add high-value business logic tests for Alert.get_view_url() - Add TransientViewManager decision logic tests with realistic scenarios - Add AlertManager delegation tests (some test isolation issues remain) - Remove obsolete integration tests for old implementation **Technical Improvements:** - Better separation of concerns with each class owning its domain logic - Clear constraint documentation where URLs are generated - Extensible design for future alarm source types (WEATHER, etc.) - Mock only at system boundaries following testing best practices Note: Some unit tests need refinement for test isolation - will be addressed separately. * Fix auto-view switching unit tests and improve test reliability - Replace excessive mocking with real behavior testing in AlertManager delegation tests - Fix state pollution between tests by adding proper cleanup in setUp/tearDown methods - Clear singleton state for both AlertManager and TransientViewManager between tests - Add proper settings mocking for tests running in full suite context - Fix test data to ensure separate alerts are created for proper testing - Remove unused imports and variables to pass flake8 quality checks - Improve test isolation following testing best practices from docs/dev/Testing.md All auto-view related tests now pass consistently both in isolation and when run together. * Refine auto-view switching implementation and fix test issues - Fix singleton test isolation issues in alert and notification manager tests - Remove unused AUTO_VIEW_IDLE_TIMEOUT backend setting (frontend handles idle detection) - Add event throttling and passive listeners to auto-view.js for better performance - Clean up test setup code and improve reliability - All 1521 tests now pass, flake8 clean This refinement improves performance and removes unnecessary backend configuration while maintaining full functionality of the auto-view switching feature. * Update CLAUDE.md to use Makefile targets for tests and linting Replace direct Django/flake8 commands with make test and make lint to eliminate directory path issues and improve reliability * Fix new alert detection by tracking queue insertion time The alert system was missing new alerts due to timing differences between when events occur and when they get added to the alert queue. The client's "since" timestamp was newer than the event's original timestamp, causing alerts to be filtered out even though they were newly added to the queue. Changes: - Add queue_insertion_datetime field to Alert class - Set queue_insertion_datetime when alerts are added to AlertQueue - Update get_most_important_unacknowledged_alert to use queue_insertion_datetime instead of start_datetime for "new alert" detection - Preserve existing behavior for get_most_recent_alarm (uses alarm timestamps) This ensures new alerts are properly detected regardless of processing delays between event occurrence and queue insertion. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Simplify auto-view alert filtering logic Remove brittle string-based filtering in TransientViewManager. The event subsystem already filters alerts based on user-defined rules, so any alert that reaches the TransientViewManager should be considered a valid candidate for auto-view switching. Changes: - Remove alarm type and source filtering from _should_alert_trigger_auto_view - Trust the event subsystem's upstream filtering based on user preferences - Only verify that alerts have valid data (first_alarm exists) - Let configuration settings and view URL availability be the only filters This respects separation of concerns and removes unnecessary duplication of filtering logic between the event and view management subsystems. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Update test description to reflect actual behavior The test was checking that non-motion alerts don't trigger auto-view, but after simplifying the filtering logic, the test still passes because these alerts don't have valid camera view URLs. Updated the test description to accurately reflect what's being tested - alerts without view URLs are handled correctly. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Refactor view URL generation to fix ZoneMinder auto-view issues - Move view URL logic from Alert to Alarm class for better encapsulation - Remove AlarmSource.EVENT restriction allowing all alarm types to have view URLs - Add sensor_id field to AlarmSourceDetails for clean data propagation - Create ViewUrlUtils utility class with proper entity/sensor relationship traversal - Update Event.to_alarm to propagate sensor_id from SensorResponse - Add comprehensive tests for ViewUrlUtils with proper database setup Fixes issue where ZoneMinder motion detection events returned None for get_view_url due to alarm source filtering and missing sensor_id propagation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix ViewUrlUtils bugs and remove obsolete tests - Fixed entity relationship name from entity_states to states - Fixed filtering to use entity_state_type_str field instead of property - Simplified tests to use actual URL generation instead of excessive mocking - Removed obsolete alert view URL tests that used fake sensor IDs - All 7 comprehensive ViewUrlUtils tests now pass The ViewUrlUtils now correctly detects video stream capabilities and generates proper URLs for ZoneMinder motion detection events. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * A few debug logging improvements while debugging. * Add development data injection system for frontend testing Creates a safe, external mechanism to inject test data into API responses for frontend testing without modifying backend state or triggering Django auto-reload. Uses dual safety checks (DEBUG + DEBUG_FORCE flags) to prevent production use. Components: - DevInjectionManager utility class for cache/file-based data injection - DEBUG_FORCE_TRANSIENT_VIEW_OVERRIDE setting with base/development config - Single-line integration in StatusView for transient view overrides - Management command for external data injection and control Usage: python manage.py dev_inject transient_view '{"url":"/test"}' Options: --persistent, --cache, --list, --clear * Phase 1: Create hi.testing Django app and migrate dev injection system - Create proper hi.testing Django app structure with apps.py - Copy all files from hi/tests to hi/testing (parallel structure) - Add hi.testing to INSTALLED_APPS in development.py (alongside hi.tests) - Move dev_inject management command from config to testing app - Update dev injection imports in api/views.py to use hi.testing - Verify system works: command available, imports successful Both hi.tests and hi.testing coexist safely during transition. Dev injection system now in semantically correct location. * Complete migration from hi.tests to hi.testing Django app Phase 2 & 3: Mass import migration and cleanup - Update 105+ files to import from hi.testing instead of hi.tests - Remove hi.tests from INSTALLED_APPS in development.py - Delete old hi/tests directory and all contents - Fix internal imports within hi.testing module - Clean up migration artifacts Results: - All imports now use proper hi.testing Django app - Dev injection system fully functional in new location - Clean codebase with proper semantic organization - Development-only safety pattern maintained * Document development data injection system in Testing.md Add high-level overview of the dev injection system as a general-purpose runtime behavior modification tool. Uses status response injection as concrete example while positioning it as extensible mechanism for any injection point. References detailed docs in DevInjectionManager. * Fix flake8 linting violations in testing module * Fix sensor ID type consistency and video stream URL logic - Change AlarmSourceDetails.sensor_id from str to int for type consistency - Fix ViewUrlUtils to use video stream sensor ID instead of source sensor ID - Update tests to use proper sensor ID types and expected video stream URLs - Fix unit test data setup with proper entity/sensor relationships * Fix URL bar not reverting when auto-view switches back to original view - Track original URL when entering transient view - Use history.back() to properly pop transient URL from browser history stack - Add fallback using replaceState() if history navigation fails - Ensure URL bar matches displayed content after auto-view revert * Fix URL management for multiple consecutive transient views - Track all transient URLs in array as they are pushed by antinode.js - Pop all tracked URLs with comprehensive sanity checking when reverting - Handle race conditions by validating current URL matches expected before each pop - Enforce invariant that original URL is restored using replaceState fallback - Prevent history corruption when antinode.js fails or timing issues occur * Refactor auto-view.js for better maintainability - Add resetTransientState() helper to consolidate state cleanup - Extract popTransientUrlIfMatches() to reduce code duplication - Simplify revertToOriginalView() and makeTransientViewPermanent() - Add section organization comments for better readability - Reduce complexity in restoreOriginalUrl() method * Improve auto-view transient indicator to be layout-friendly Replace top banner with constrained visual indicator: - Border effect around main content area during transient views - Corner badge with reason and pulse animation - Indicator constrained to main panel, no content occlusion - Responsive design for mobile devices * Fix corner badge visibility and use warning colors - Use portal approach: append badge to body with calculated positioning - Safer implementation that doesn't modify main content area styling - Change colors from primary to warning for alert-like appearance - Add dynamic repositioning on window resize - Preserve SVG layout responsiveness * Improve auto-view indicator design per feedback - Remove pulse animation for cleaner, less distracting indicator - Change from rounded to rectangular badge design - Move badge to bottom-right corner, flush to main content boundary - Dynamic width sizing: auto-width up to max-width of main content - Short text = minimal occlusion, long text = bottom banner equivalent * Refatored recently added new "testing" module. * Updated testing doc for new testing URL location. --------- Co-authored-by: Tony Cassandra <github@cassandra.org> Co-authored-by: Claude <noreply@anthropic.com>
Developer Documentation
See the markdown files in this directory for various developer-related documentation.
The code is the best documentation for lower-level details, but there are some higher-level concepts that are useful to help orient developers. This is the place for that high-level, developer-specific documentation.