Fix scheduled refresh not updating correctly and broken default image on first load#629
Open
saulob wants to merge 18 commits intofatihak:mainfrom
Open
Fix scheduled refresh not updating correctly and broken default image on first load#629saulob wants to merge 18 commits intofatihak:mainfrom
saulob wants to merge 18 commits intofatihak:mainfrom
Conversation
- Remove duplicate scheduled refresh check in PluginInstance.should_refresh() that incorrectly triggered refresh before the scheduled time by comparing latest_refresh hour string against scheduled time string - Change PlaylistRefresh.execute() to return None instead of loading a stale cached image when plugin does not need refresh, preventing the display from reverting to outdated clock images - Handle None return from execute() in RefreshTask._run() to skip plugins that are not due for refresh
… UTC Align default timezone with refresh_task which already defaults to UTC. Previously, if timezone was not configured, the clock would display US/Eastern time instead of the expected system/configured timezone. fix: scheduled plugin should not refresh before scheduled time on first run When a scheduled plugin is created with no previous refresh history, it now waits until the scheduled time instead of refreshing immediately.
…xists Display a 'No image displayed yet' message on the dashboard when the system starts fresh and no plugin has generated an image yet.
…ex on skip - Revert DEFAULT_TIMEZONE back to US/Eastern since UTC is not available in the settings UI timezone list - When a plugin instance is skipped (not time to refresh), revert the playlist index so the same plugin is retried on the next cycle instead of advancing to the next one and causing a 1-minute delay
- Stop reverting playlist index when a plugin is skipped, preventing the playlist from being stuck on the same plugin indefinitely - Add null check after generate_image() to gracefully skip plugins that fail to produce an image instead of crashing
- Loop through all plugins in the playlist to find one that needs refreshing, instead of only checking one plugin per cycle - Prevents delayed refresh when playlist has many plugins (e.g. 10 plugins with 1-min cycle no longer takes 10 min to reach a plugin)
- ManualRefresh raises RuntimeError with descriptive message - update_now returns error response when image is null in dev mode
- Detect bfcache restore via pageshow event and force reload - Ensures last refresh time and image are up to date after update
There was a problem hiding this comment.
Pull request overview
This PR targets InkyPi’s refresh/playlist behavior and UI resilience, aiming to improve scheduled/interval refresh correctness, avoid crashes when plugins fail to generate images, and improve browser UX when navigating back.
Changes:
- Updates playlist selection/refresh logic in
RefreshTask, including skipping/force refresh behavior and additional error handling for missing images. - Refines
PluginInstance.should_refresh()scheduled-refresh behavior for first-run and subsequent runs. - Improves the main UI page with a first-load placeholder and forces reload on back navigation; adds API error handling when a plugin returns no image.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
src/templates/inky.html |
Adds back-navigation reload behavior and an image placeholder on load/error. |
src/refresh_task.py |
Changes playlist iteration and refresh execution behavior; adds handling for None images and more logging. |
src/model.py |
Adjusts scheduled refresh logic in PluginInstance.should_refresh(). |
src/blueprints/plugin.py |
Returns a clearer API error when generate_image() returns None. |
Comments suppressed due to low confidence (1)
src/model.py:325
- The scheduled-refresh check further down also compares
scheduled_time(tz-naive) withlatest_refresh_dt.time()/current_time.time()(tz-aware). Even after the initial-refresh case is fixed, this block will still raise the sameTypeErrorfor scheduled plugins. Consider convertinglatest_refresh_dtinto the same timezone ascurrent_time, then compare full datetimes (date + scheduled wall time) instead oftimeobjects.
if "scheduled" in self.refresh:
scheduled_time_str = self.refresh.get("scheduled")
scheduled_time = datetime.strptime(scheduled_time_str, "%H:%M").time()
latest_refresh_date = latest_refresh_dt.date()
current_date = current_time.date()
# Determine if a refresh is needed based on scheduled time and last refresh
if (latest_refresh_date < current_date and current_time.time() >= scheduled_time) or \
(latest_refresh_date == current_date and latest_refresh_dt.time() < scheduled_time <= current_time.time()):
return True
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
added 6 commits
March 25, 2026 22:47
Author
|
All Copilot review comments addressed. Fixed timezone handling, separated rotation from refresh logic, ensured cached images are used when not due, reduced log noise, and added pytest coverage. All tests passing, ready for review |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
This PR improves the refresh logic and fixes stability issues in InkyPi. Fixes #380
Changes
Impact