fix(vegas): keep plugin data and visuals fresh during Vegas scroll mode#291
fix(vegas): keep plugin data and visuals fresh during Vegas scroll mode#291ChuckBuilds merged 2 commits intomainfrom
Conversation
Plugins using ESPN APIs and other data sources were not updating during Vegas mode because the render loop blocked for 60-600s per iteration, starving the scheduled update tick. This adds a non-blocking background thread that runs plugin updates every ~1s during Vegas mode, bridges update notifications to the stream manager, and clears stale scroll caches so all three content paths (native, scroll_helper, fallback) reflect fresh data. - Add background update tick thread in Vegas coordinator (non-blocking) - Add _tick_plugin_updates_for_vegas() bridge in display controller - Fix fallback capture to call update() instead of only update_data() - Clear scroll_helper.cached_image on update for scroll-based plugins - Drain background thread on Vegas stop/exit to prevent races Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe changes introduce a periodic plugin update mechanism in Vegas mode that detects plugin state changes, invalidates scroll caches, and refreshes content. This involves wiring callback support into the coordinator loop, adding background thread execution with interval throttling, and updating the plugin adapter and stream manager to handle cache invalidation. Changes
Sequence DiagramsequenceDiagram
participant VegasLoop as Vegas Render Loop
participant Coordinator as VegasModeCoordinator
participant DisplayCtrl as DisplayController
participant PluginMgr as PluginManager
participant StreamMgr as StreamManager
participant PluginAdapter as PluginAdapter
loop Each Render Iteration (Vegas Mode)
VegasLoop->>Coordinator: run_iteration()
Coordinator->>Coordinator: _drain_update_thread()
activate Coordinator
Note over Coordinator: Drain accumulated<br/>update results
deactivate Coordinator
alt Update thread interval elapsed
Coordinator->>DisplayCtrl: _tick_plugin_updates_for_vegas() [background]
activate DisplayCtrl
DisplayCtrl->>PluginMgr: Snapshot plugin_last_update
DisplayCtrl->>PluginMgr: Invoke _tick_plugin_updates()
DisplayCtrl->>DisplayCtrl: Detect changed plugin IDs
DisplayCtrl-->>Coordinator: Return changed plugin IDs
deactivate DisplayCtrl
end
Coordinator->>StreamMgr: process_updates(plugin_ids)
activate StreamMgr
loop For each updated plugin
StreamMgr->>PluginAdapter: invalidate_cache(plugin_id)
StreamMgr->>PluginAdapter: invalidate_plugin_scroll_cache(plugin, plugin_id)
activate PluginAdapter
PluginAdapter->>PluginAdapter: Clear scroll_helper.cached_image
deactivate PluginAdapter
StreamMgr->>StreamMgr: _fetch_plugin_content(plugin_id)
end
deactivate StreamMgr
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/vegas_mode/coordinator.py`:
- Around line 343-351: STATIC pauses currently skip the update-tick block
because the early continue after handling a static pause prevents
run_scheduled_updates from being called; update the logic in coordinator.py
around _check_static_plugin_trigger / _handle_static_pause so that after a
static pause is handled you still drive the background updater: remove the
unconditional continue or refactor the static-pause branch to repeatedly call
run_scheduled_updates (and any timing/tick advancement) while waiting for the
static pause to finish, then consume the segment via
stream_manager.get_next_segment() and proceed normally; ensure the same change
is applied to the analogous block covering lines 381-405.
- Around line 543-555: _drain_update_thread currently only logs on timeout but
doesn't signal the caller; change its contract to return a boolean (or otherwise
set a clear flag) so callers can detect a still-running background updater.
Specifically, update the method _drain_update_thread(self, timeout: float = 2.0)
to return True if the thread is still alive after join(timeout) and False if it
finished (and clear/self._update_thread = None when finished); then update
DisplayController.run() (and any caller that expects to resume
_tick_plugin_updates or call run_scheduled_updates) to check the return value
and suppress scheduling/ticks while True is returned (or while the flag
indicates the worker is alive). Ensure references to _update_thread.is_alive()
and _tick_plugin_updates / run_scheduled_updates behavior are updated
accordingly.
In `@src/vegas_mode/plugin_adapter.py`:
- Around line 411-426: The Vegas fetch path must not call plugin.update()
because process_updates() already triggers background refreshes; remove the
synchronous plugin.update() invocation in the fallback branch (the block that
checks has_update) and instead only attempt the non-blocking fallback pattern by
checking and calling plugin.update_data() when present; update the logging
around plugin_id to reflect that update() is intentionally skipped and that only
update_data() will be used as the fallback so we don't perform a second
synchronous refresh on the render/prefetch thread.
- Around line 613-616: The code only clears scroll_helper.cached_image, leaving
cached_array and total_scroll_width stale; replace resetting cached_image with a
call to scroll_helper.clear_cache() so the full ScrollHelper state
(cached_image, cached_array, total_scroll_width, etc.) is reset, and update the
debug log to reflect that the full cache was cleared (use plugin_id in the log
as before).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 19d7d602-c1fa-49fc-a52b-5f37728fd5df
📒 Files selected for processing (4)
src/display_controller.pysrc/vegas_mode/coordinator.pysrc/vegas_mode/plugin_adapter.pysrc/vegas_mode/stream_manager.py
- Extract _drive_background_updates() helper and call it from both the render loop and the static-pause wait loop so plugin data stays fresh during static pauses (was skipped by the early `continue`) - Remove synchronous plugin.update() from the fallback capture path; the background update tick already handles API refreshes so the content-fetch thread should only call lightweight update_data() - Use scroll_helper.clear_cache() instead of just clearing cached_image so cached_array, total_scroll_width and scroll_position are also reset Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reconcile squash-merged PRs (ChuckBuilds#277, ChuckBuilds#290, ChuckBuilds#291) from upstream. Resolve conflict in vegas_mode/coordinator.py: keep both the interrupt check callback (upstream) and inline cycle restart (Dev). Co-Authored-By: 5ymb01 <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reconcile squash-merged PRs (ChuckBuilds#277, ChuckBuilds#290, ChuckBuilds#291) from upstream. Resolve conflict in vegas_mode/coordinator.py: keep both the interrupt check callback (upstream) and inline cycle restart (wip). Co-Authored-By: 5ymb01 <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
run_scheduled_updates()every ~1s, so ESPN/API plugins refresh data without stalling the 125 FPS scroll_tick_plugin_updates_for_vegas()in display controller detects which plugins actually updated and notifies Vegas viamark_plugin_updated()scroll_helper.cached_imageon updated plugins so scroll-based plugins (stocks, news, odds-ticker, leaderboard, text-display) rebuild visuals from fresh data_capture_display_content()now callsplugin.update()first (ESPN pattern), falling back toupdate_data()for legacy plugins_drain_update_thread()to prevent races with the main loop's own update tickTest plan
pytest tests/)"Vegas update tick: N plugin(s) updated")🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes