Skip to content

fix(viewer): skip deleted/deactivated asset immediately#2875

Merged
vpetersson merged 5 commits into
masterfrom
fix/skip-deleted-asset-immediately
May 12, 2026
Merged

fix(viewer): skip deleted/deactivated asset immediately#2875
vpetersson merged 5 commits into
masterfrom
fix/skip-deleted-asset-immediately

Conversation

@vpetersson
Copy link
Copy Markdown
Contributor

@vpetersson vpetersson commented May 12, 2026

Issues Fixed

Fixes #2430

Description

Previously, deleting or deactivating an asset while it was on screen had no effect until the originally-scheduled duration elapsed — a 1-hour image kept showing for the rest of the hour even after the operator removed it.

Viewer (src/anthias_viewer/__init__.py): the reload handler now also checks whether the currently-displayed asset is still in the active set. If not, it sets skip_event so asset_loop's wait() returns early and the loop rotates on the next tick. Playlist refresh itself still flows through the existing get_db_mtime short-circuit inside get_next_asset on the main thread; the subscriber thread only signals.

Server: API endpoints that mutate an asset's active state now publish reload alongside the Django page views that already did:

  • DeleteAssetViewMixin.delete (shared across all API versions)
  • AssetViewV1.put, AssetViewV1_1.put, AssetViewV1_2.update, AssetViewV2.update

The shared post-save bookkeeping for v1_2/v2 (active-asset repositioning + viewer publish) was extracted into api.helpers.finalize_asset_update to keep the view bodies short. Playlist reordering is not wired to publish reloadsave_active_assets_ordering only updates play_order, it can't deactivate an asset, so there's no scenario where the currently-displayed asset becomes inactive from a reorder alone.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

Previously a delete or deactivate on the currently-displayed asset
only took effect after its scheduled duration elapsed — a 1-hour
image kept showing for the rest of the hour. The viewer's reload
handler now also checks whether the displayed asset is still active
and wakes asset_loop's wait() so it rotates on the next tick. Server
API delete/update/reorder paths publish reload alongside the
existing Django page-view paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vpetersson vpetersson requested a review from a team as a code owner May 12, 2026 14:41
@vpetersson vpetersson self-assigned this May 12, 2026
@vpetersson vpetersson requested a review from Copilot May 12, 2026 14:41
Sonar flagged the v1_2.update and v2.update bodies as duplicated
once the issue #2430 viewer-publish was added on top of the
already-near-identical active-asset bookkeeping. Extract that
post-save block (refresh, reposition in the active list, save
ordering, publish reload) into ``api.helpers.finalize_asset_update``
so the API views shrink to a single call and Sonar's clone detector
no longer trips.

Also fixes the mypy attr-defined errors on the new test_viewer.py
tests by patching ``Asset.objects.filter`` via its string path
instead of ``viewer.Asset.objects`` (which isn't an explicit export).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

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 addresses issue #2430 by ensuring the viewer can immediately advance when the currently displayed asset is deleted or becomes inactive, instead of waiting for the originally configured duration to elapse.

Changes:

  • Viewer: extend the reload command handler to also signal a skip when the currently displayed asset is deleted/deactivated.
  • Server API: publish reload from asset-mutation endpoints (delete/update/reorder) so the viewer is notified promptly.
  • Tests: add viewer-side unit tests for the skip-on-reload behavior and server-side API tests asserting reload is published.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_viewer.py Adds unit tests covering reload handling + skip decision when current asset is deleted/deactivated.
src/anthias_viewer/__init__.py Implements _handle_reload() and _skip_if_current_asset_inactive() and wires reload command to new handler.
src/anthias_server/api/views/v2.py Publishes reload after asset update to wake viewer.
src/anthias_server/api/views/v1.py Publishes reload after asset update to wake viewer.
src/anthias_server/api/views/v1_2.py Publishes reload after asset update to wake viewer (adds import).
src/anthias_server/api/views/mixins.py Publishes reload on delete and playlist reorder.
src/anthias_server/api/tests/test_assets.py Adds API tests asserting reload is published on delete/update/reorder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/anthias_server/api/views/mixins.py Outdated
Comment thread src/anthias_server/api/tests/test_assets.py
Addresses Copilot review feedback on #2875:

- v1_1.AssetView.put now publishes reload too — issue #2430 affects
  v1_1 clients the same as v1/v1_2/v2 and there's no reason to leave
  it silent. Test extended to cover v1_1.

- PlaylistOrderViewMixin no longer publishes reload: the comment
  claimed reordering can drop an asset from the active set, but
  save_active_assets_ordering only updates play_order — it can't
  deactivate anything. Removing the inaccurate hook (and its test).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vpetersson vpetersson requested a review from Copilot May 12, 2026 14:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread src/anthias_server/api/views/mixins.py
Subsequent pushes on this PR didn't trigger the GitHub Actions
workflows (only Sonar + CodeQL ran). Forcing a fresh push to wake
up mypy / unit-tests / lint / openapi-schema workflows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

…set-immediately

# Conflicts:
#	src/anthias_server/api/tests/test_assets.py
@vpetersson vpetersson requested a review from Copilot May 12, 2026 15:04
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@vpetersson vpetersson merged commit 5c0b1a7 into master May 12, 2026
13 checks passed
vpetersson added a commit that referenced this pull request May 12, 2026
Pulls in viewer asset-deletion fix (#2875) and ansible boot.yml
refactor (#2810). No conflicts with the HDMI audio detection work.
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.

Deleted/Deactivated Images and Websites are not removed immediately

2 participants