mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-04 14:25:08 +00:00
* fix(display): tear down Vegas mode on controller cleanup DisplayController.cleanup() never called VegasModeCoordinator.cleanup(), so the Vegas teardown (stop, pipeline/stream reset, adapter cache drop) was unreachable. Call it before the display manager is cleaned up, and skip it when Vegas was never created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(vegas): default max_cycle_duration to the documented 240s The template, the web UI help, CONFIG_REFERENCE and the controller all say 240, but the code defaulted to 600 in two places, so a config without the key ran Vegas iterations 2.5x longer than documented. from_config now falls back to the dataclass field defaults instead of repeating each one, so the two copies can no longer drift, and the controller's follower scroll-speed default reads VegasModeConfig's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(display): let run.py -d show display_manager's DEBUG output display_manager pinned its logger to INFO at import, overriding the root level, so debug mode never showed its DEBUG lines. Use get_logger() from src.logging_config like the rest of the core and leave the level to the logging setup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(display): run each startup validation check once StartupValidator.validate_all() ran twice at boot, before and after the plugin manager was created, so every config, cache, display and systemd-unit warning was logged twice. The second pass now runs only the plugin checks. Drop the commented-out raise_on_errors line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(vegas): one INFO line per plugin-list refresh StreamManager logged "=" * 60 banners and a line per plugin (INCLUDED, SKIPPED, FETCHING CONTENT, SEGMENT CREATED) at INFO on every refresh and fetch, i.e. at each cycle start and every 30s. Log one INFO summary of the rotation per refresh and move the per-plugin detail, the weighting breakdown and "no content this cycle" to DEBUG (the adapter still warns when every content path fails). Also drop the check/cross marks from the controller's log messages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(vegas): drop the per-iteration static-mode plugin scan run_iteration() rebuilt _static_mode_plugins on every iteration, asking every plugin for its display mode and logging the set at INFO, but nothing ever read it: static pauses are triggered by _check_static_plugin_trigger() from the next segment. Delete it, the coordinator's get_ordered_plugins() that only it used, and the write-only _static_pause_plugin / _static_pause_start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(vegas): remove the staging buffer that was never filled StreamManager and RenderPipeline carried a double-buffer design that nothing used: _staging_buffer was only ever cleared or swapped, so swap_buffers() never did anything and should_recompose()'s staging_count > 0 branch was dead, and _active_scroll_image, _staging_scroll_image, _is_rendering, _last_frame_time and _frame_interval were written but never read. Delete the machinery and rewrite the docstrings around what actually carries updates: _pending_updates, consumed by process_updates() in swap mode and invalidate_pending_updates() in continuous mode. should_recompose() no longer builds a buffer-status dict every frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(display): tidy the display controller without changing behaviour - Import VegasModeCoordinator locally instead of through module globals (there is no circular import to avoid). - Drop hasattr() checks on attributes PluginManager.__init__ always sets (plugin_executor, plugin_last_update, get_plugin_lock, run_scheduled_updates*, stop_update_worker) and the dead "older manager" fallbacks; keep the health_tracker None checks, now via _health_tracker(). - Extract _display_once() for the per-frame display call both render loops copied, _advance_on_demand() for the two on-demand rotations, _reset_on_demand_fields() for the error and clear paths, and _timezone() / _in_window() for the two schedule checks. - Remove always-true conditions and the unreachable non-plugin else branch in run(), and read _was_display_active / _last_published_mode / vegas_coordinator directly now that __init__ declares them. - Declare the follower render state in __init__, name its tuning constants, add _follower_sign(), and share the 90/s sync send interval with the render pipeline (SYNC_SEND_INTERVAL). - Delete history narration and the "Opt #N" labels, fix the comment that called _scroll_speed constant (hot reload updates it), and drop a startup timing log that measured nothing. - render_pipeline / plugin_adapter: read display_manager.width/height as the properties they are, drop an empty TYPE_CHECKING block, an aliased threading import and a duplicated `if result and self.sync_manager:`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(display): trim dead code from display_manager - Add _new_canvas() for the image/draw/fontmode="1" setup that was copied six times. - Call resolve_double_sided() and compose_pixel_mapper_config() directly instead of through a module alias and a passthrough method, and replace the comment that said the passthrough read class attributes. - Delete the unused _initialized flag and _ORIENTATION_ROTATE_DEGREES alias (no core or monorepo reader; tests stop resetting the flag), the test pattern's unreachable no-matrix branch (it only runs once the matrix exists), `del old_image # help GC` (a no-op on a local), a duplicated early return in process_deferred_updates, and stale comments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(vegas): remove unread fields and test-only helpers, fix docstrings - ContentSegment: drop total_width, fetched_at, is_stale, image_count and is_static, none of which is read. - StreamManager: drop _current_index (never advanced) and the test-only get_all_content_for_composition() and has_pending_updates(); VegasModeConfig: drop the test-only is_plugin_included(). - geometry.find_blank_cut() has had no production caller since the crop moved to item boundaries; delete it and its tests. - PluginAdapter: the _finalize docstring described separator_width between every image, and _crop_to_budget's said cuts snap to the nearest blank column; both now describe what the code does. - Coordinator: the static-pause interrupt log no longer blames follower mode for every interrupt, and set_update_callback names the callback the controller actually wires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(scroll): correct ScrollHelper comments and drop dead branches - Four comments said the strip always starts with display_width of blank; it does only when lead_gap is None (Vegas passes its own). - Delete the "Width calculation mismatch" warning: the image is created at the calculated width, so the two can never differ. - Remove the two scroll_delay <= 0 fallbacks (which disagreed with each other): set_scroll_delay clamps it to at least 0.001 and nothing in core or the plugin monorepo assigns it directly. - Trim the scipy history from the blend docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(run): drop a redundant comment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(display): log set_scrolling_state only when it changes Vegas and scrolling plugins set the scrolling state every frame, so once display_manager's DEBUG output became visible in debug mode it printed "Scrolling state set to: True" about 120 times a second. Log only when the value differs from the previous one; the state, activity timestamp and frame hold still update on every call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(changelog): display-vegas Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
92 lines
3.7 KiB
Python
92 lines
3.7 KiB
Python
"""
|
|
Regression tests for DisplayController._tick_plugin_updates_for_vegas().
|
|
|
|
PR #299 added logic to detect which plugins actually got fresh data on a
|
|
scheduled-update tick and notify Vegas mode via
|
|
vegas_coordinator.mark_plugin_updated(), so a live score change reaches the
|
|
scroll within seconds instead of waiting for a full cycle. PR #330's
|
|
multi-display sync refactor deleted this method (folding the callback back
|
|
to the plain _tick_plugin_updates(), which reports nothing), silently
|
|
orphaning VegasModeCoordinator.mark_plugin_updated() -- it has had zero
|
|
callers since.
|
|
"""
|
|
|
|
import os
|
|
from typing import Dict, List, Optional
|
|
from unittest.mock import MagicMock
|
|
|
|
# display_controller imports display_manager, which imports the hardware
|
|
# rgbmatrix module unless EMULATOR=true was set before import. Use the
|
|
# emulator (same convention as test_display_dirty_tracking.py and
|
|
# test/plugins/conftest.py) so this file collects on machines without the
|
|
# hardware library — and so display_manager gets the emulator binding no
|
|
# matter which test module imports it first.
|
|
os.environ.setdefault("EMULATOR", "true")
|
|
|
|
from src.display_controller import DisplayController
|
|
|
|
|
|
def _make_controller(updated: Optional[List[str]] = None, vegas_coordinator: Optional[MagicMock] = None) -> DisplayController:
|
|
dc = object.__new__(DisplayController)
|
|
dc.plugin_manager = MagicMock()
|
|
dc.plugin_manager.run_scheduled_updates_with_changes.return_value = list(updated or [])
|
|
dc.vegas_coordinator = vegas_coordinator
|
|
return dc
|
|
|
|
|
|
class TestTickPluginUpdatesForVegas:
|
|
def test_marks_only_plugins_whose_timestamp_advanced(self):
|
|
vc = MagicMock()
|
|
dc = _make_controller(updated=["stock-news"], vegas_coordinator=vc)
|
|
|
|
dc._tick_plugin_updates_for_vegas()
|
|
|
|
vc.mark_plugin_updated.assert_called_once_with("stock-news")
|
|
|
|
def test_no_advance_marks_nothing(self):
|
|
vc = MagicMock()
|
|
dc = _make_controller(updated=[], vegas_coordinator=vc)
|
|
|
|
dc._tick_plugin_updates_for_vegas()
|
|
|
|
vc.mark_plugin_updated.assert_not_called()
|
|
|
|
def test_no_vegas_coordinator_does_not_raise(self):
|
|
dc = _make_controller(updated=["stock-news"], vegas_coordinator=None)
|
|
|
|
dc._tick_plugin_updates_for_vegas() # must not raise
|
|
|
|
def test_mark_plugin_updated_exception_does_not_propagate(self):
|
|
"""One plugin's mark_plugin_updated failing must not stop the tick
|
|
or crash the update loop it runs in."""
|
|
vc = MagicMock()
|
|
vc.mark_plugin_updated.side_effect = [RuntimeError("boom"), None]
|
|
dc = _make_controller(updated=["a", "b"], vegas_coordinator=vc)
|
|
|
|
dc._tick_plugin_updates_for_vegas() # must not raise
|
|
|
|
assert vc.mark_plugin_updated.call_count == 2
|
|
|
|
|
|
class TestVegasCoordinatorCallbackWiring:
|
|
def test_initialize_wires_vegas_aware_tick_as_update_callback(self):
|
|
"""The Vegas coordinator must be given the Vegas-aware
|
|
_tick_plugin_updates_for_vegas as its update callback, not the plain
|
|
_tick_plugin_updates() -- that's the exact wiring PR #330 dropped."""
|
|
dc = object.__new__(DisplayController)
|
|
dc.config = {"display": {"vegas_scroll": {"enabled": True}}, "sync": {}}
|
|
dc.display_manager = MagicMock()
|
|
dc.plugin_manager = MagicMock()
|
|
dc.sync_manager = MagicMock()
|
|
dc._check_live_priority = MagicMock()
|
|
dc._check_vegas_interrupt = MagicMock(return_value=False)
|
|
|
|
fake_coordinator = MagicMock()
|
|
|
|
from unittest.mock import patch
|
|
with patch('src.vegas_mode.VegasModeCoordinator',
|
|
MagicMock(return_value=fake_coordinator)):
|
|
dc._initialize_vegas_mode()
|
|
|
|
fake_coordinator.set_update_callback.assert_called_once_with(dc._tick_plugin_updates_for_vegas)
|