Skip to content

feat: interactive (touch) web assets with idle reset - #3533

Open
vpetersson-bot wants to merge 9 commits into
masterfrom
feat/interactive-touch-assets
Open

vpetersson-bot wants to merge 9 commits into
masterfrom
feat/interactive-touch-assets

Conversation

@vpetersson-bot

@vpetersson-bot vpetersson-bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Issues Fixed

Adds touchscreen support for kiosk-style web pages (internal tracker SIRI-2498).

Description

A web page asset can now be marked interactive. On a screen with a touchscreen, people can use the page; everything else in the playlist ignores input.

  • Per asset: interactive and idle_timeout_s (5-3600, default 60), stored in metadata. Exposed as v2 API fields, a switch in the edit modal, and in the controller mirror. All additive.
  • Webview (C++):
    • An application-wide input gate drops every touch, click and key press unless the current asset is interactive. Closed by default.
    • New D-Bus slots: setInteractive, msSinceInput and resetSession. resetSession clears cookies, the HTTP cache and Web Storage, then reloads the asset's URL.
    • Interactive pages can only navigate within their own origin.
    • No context menu, file picker or pinch-zoom.
    • Auto-refresh is held while someone is using the page.
  • Viewer:
    • Untouched, an interactive page plays like any other page.
    • Once touched, rotation holds until nobody has touched it for idle_timeout_s. Then the page's session is reset and rotation resumes.
    • Skips still work.
    • All new slots are version-skew tolerant: an older webview latches them off.
  • Container plumbing: libinput ignores devices udev hasn't tagged, and the viewer has no udevd.
    • The host's udev db is mounted at /run/udev-host:ro, and only the input (c13:*) entries are copied into the container's /run/udev. Mounting it wholesale would change how cage and GStreamer pick DRM/V4L2 devices.
    • On eglfs boards, viewer joins the host's input GID, using the same pattern as host-render.
    • Rotation: neither cage nor Qt eglfs rotates touch with the display; both only scale it. The start script writes a libinput calibration matrix for screen_rotation into the touchscreen's copied udev entry, and keeps any matrix the host already set. libinput reads it only when the device is added, so changing the rotation with a touchscreen attached restarts the viewer.
  • Mirror: the drift check now skips fields a screen doesn't report. Without that, every sync would re-PATCH screens on older releases forever.
  • Docs: website/content/docs/touchscreens.md, plus hardware notes in the anthias-hardware skill.

Known limits (documented):

  • A touchscreen plugged in after the viewer starts isn't seen until the viewer restarts.
  • Balena isn't supported yet (no host bind mount).
  • 32-bit Qt5 boards: the gate compiles in and closes input, but touch isn't plumbed.

Reviewer guide: the core logic is InputGate and View::resetSession in view.cpp, _wait_interactive and _maybe_reapply_rotation in src/anthias_viewer/__init__.py, and viewer_setup_touch_input in bin/lib/viewer/common.sh.

Allowed sites (per asset)

metadata.allowed_sites holds extra sites an interactive page may open beyond its own. Each entry is a host, a *.host (the host and its subdomains) or a full scheme://host[:port], up to 50 per asset.

  • Edit dialog: an "Allowed sites" textarea under the touch switch. It drops lines it can't read.
  • v2 API: allowed_sites, strict (a 400 for invalid entries).
  • Mirror: copied to managed screens like the other settings.
  • Webview: new setAllowedSites slot, sent before the gate opens and queued during a reset.
  • Verified on the x86 with the real panel: with the off-site origin listed, a same-site link that 302s there was followed; after removing it, the same tap was blocked. A QtWebEngine test covers this too (7/7 passing).

Review follow-ups

A second-opinion review raised four issues. All four are fixed:

  • Redirects: a visitor's same-site link that redirects off-site is blocked. The asset's own redirects (http to https, a sign-in hop) are still followed, and the site they land on counts as the asset's. Without that, a redirecting asset URL never loaded once the gate opened.
  • Reset ordering: the reset waits for clearHttpCacheCompleted (Qt 6.7+) before any navigation, and asset commands that arrive meanwhile are queued and replayed in order. Older Qt turns off HTTP caching on interactive pages instead. If Qt never reports completion, the reset finishes after 5 s rather than queueing commands forever.
  • Auto-refresh: the refresh interval survives the reset reload.
  • Failed resets: the viewer checks that a reset succeeded and retries at the poll cadence through the interruptible wait.
  • Tests: offscreen QtWebEngine regression tests are in bin/test_webview_interactive.sh. All 6 pass on Qt 6.8.2 (x86 viewer image). The redirecting-asset test fails on the version without the fix.

Testing

  • pytest -m "not integration": 3404 passed. That includes tests/test_interactive_assets.py and new v2 API tests. ruff check, ruff format --check and mypy are clean apart from two missing optional build-tool stubs.
  • The webview compiles against Qt 6 (built on a Pi 5 from the latest-pi5 image). The Qt 5 build was not compiled. The APIs used exist in Qt 5.15.
  • End to end on a Pi 5, with a uinput virtual touchscreen and a headless cage output, using the new binary plus the Python and shell overlays:
    • Taps on a non-interactive page: dropped.
    • Taps on the interactive page: delivered, with correct coordinates.
    • Same-origin link: navigated. Off-origin link: blocked.
    • Rotation held 37 s past the asset's duration while in use.
    • Reset exactly 15 s after the last touch: page back to its URL with localStorage and cookies cleared.
    • Single-asset playlist: reset reloads the page.
    • Auto-refresh (5 s) didn't fire during 20 s of use.
  • Pi 4 (eglfs, 1 GB) with the real panel, full feature on the branch head, events injected through the panel's evdev node:
    • Taps on the non-interactive page: dropped.
    • Corner taps landed exactly on the circle centres: (75,74), (1845,74), (75,1005), (1845,1005) on 1920×1080.
    • Off-site link blocked; same-site link followed.
    • The page held 79 s on a 30 s slot while in use, then reset 21 s after the last tap (20 s setting).
    • At 90°, the viewer restarted itself, the matrix was written, and taps aimed at the portrait circles' physical positions landed at (74,75), (1005,75), (74,1845) and (1005,1845).
  • Rotation, with a virtual touchscreen tapping the panel's top-left, top-right and bottom-left corners:
    • Pi 4 eglfs: 90°, 180° and 270° all land exactly where the matrix predicts. At 90° on a 1080×1920 page the taps land at (100,1819), (100,119) and (1000,1819).
    • Pi 5 cage on a real 1366×768 HDMI display: 0° and 90° are both correct.
    • Changing 0°→90° through the API restarted the viewer, rewrote the matrix and recalibrated touch.
  • Real touch panel (ILITEK USB HID on a 1366×768 HDMI display, Pi 5, cage), with events injected through the panel's own evdev node and the viewer coming up from a cold boot:
    • The panel was detected and its udev entry copied; the viewer user got the input group.
    • Plain page: tap dropped. Interactive page: taps land exactly (0.75, 0.5 of the panel → 1024, 384).
    • Same-origin link followed; off-origin link blocked.
    • Reset 15 s after the last touch, with storage and cookies cleared.
    • At 90°, the viewer restarted and recalibrated; the corner taps landed at (38,1298), (38,68) and (730,1298), as expected.
  • x86 (cage, Intel Whiskey Lake) with the real panel, branch head, fingers on the panel plus injected taps for rotation:
    • Upgrade path: upgrade_containers.sh from this branch rendered the compose file with the /run/udev-host mount.
    • Panel detected; the viewer got the host input group.
    • Corner taps landed inside the targets; same-site link followed; off-site link blocked.
    • The page held while in use and reset exactly 20 s after the last tap, twice.
    • At 90° the viewer restarted, the matrix was written, and injected taps landed on the portrait target centres. Finger taps in portrait matched as well.
  • Hands-on test with fingers on the panel (Pi 5, current branch head): passed.
    • All 4 corner targets were hit, with every tap inside the 90 px circles.
    • Same-site link followed; off-site link blocked.
    • The page held 45 s on a 30 s slot while in use, then reset 21 s after the last tap (20 s idle setting).
    • Taps on the non-interactive page were ignored.

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).

🤖 Generated with Claude Code

- Per-asset `interactive` + `idle_timeout_s` (5-3600, default 60) in
  metadata; v2 API fields, edit-modal switch, controller mirror
- Webview: application-wide input gate, closed unless the current asset
  is interactive; setInteractive / msSinceInput / resetSession D-Bus
  slots; navigation pinned to the asset's origin; no context menu,
  file picker or pinch-zoom; auto-refresh held while in use
- Viewer: holds rotation while the page is in use, resets the session
  (cookies, cache, Web Storage, back to the asset URL) after idle
- Container: copy the host udev db's input entries into the viewer and
  give the viewer user the host input group so libinput sees touch
- Mirror drift check ignores fields an older screen doesn't report
- Docs page and hardware notes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
@vpetersson-bot
vpetersson-bot requested a review from a team as a code owner November 29, 2026 07:20
Copilot AI lite review requested due to automatic review settings November 29, 2026 07:20
@vpetersson-bot vpetersson-bot self-assigned this Nov 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

- Write a libinput calibration matrix for the rotation into the copied
  touchscreen udev entries; a host-set matrix is kept
- Restart the viewer when the rotation changes with a touchscreen
  attached, since libinput reads the matrix only at device add
- Split the interactive wait's per-poll decision out of the loop and
  share the D-Bus missing-method check (SonarCloud)
- Docs and hardware notes: rotation is supported

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Copilot AI lite review requested due to automatic review settings November 30, 2026 09:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

…loop

Addresses SonarCloud on this PR: the idle-reset signal was a 0.0
sentinel compared with ==, and _wait_interactive was over the
cognitive-complexity limit. The idle check now happens in the loop
directly, with the reset and in-use logging pulled into helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Copilot AI lite review requested due to automatic review settings November 30, 2026 10:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Copilot AI lite review requested due to automatic review settings November 30, 2026 11:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Copilot AI lite review requested due to automatic review settings November 30, 2026 11:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

Co-authored-by: multica-agent <github@multica.ai>
Copilot AI lite review requested due to automatic review settings November 30, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

- The viewer opens the input gate right after loadPage, so the asset's
  own redirect (http -> https, a sign-in hop) was judged against the
  pre-redirect origin and blocked: the page never loaded. Follow the
  redirects that directly follow our load and treat the origins that
  chain lands on as the asset's site; a visitor's link that redirects
  off-site is still blocked.
- Finish a session reset after 5 s if QWebEngineProfile never reports
  clearHttpCacheCompleted, instead of queueing every asset command
  forever.
- Regression test for a redirecting asset; docs updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Copilot AI lite review requested due to automatic review settings November 30, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

…tings

- Touch chip next to interactive web assets in the schedule table
- Advanced section opens by default for interactive assets, so the touch
  settings aren't hidden

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Copilot AI lite review requested due to automatic review settings November 30, 2026 19:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

- metadata.allowed_sites: hosts, *.host (host and subdomains) or full
  origins; normalised on read, strict 400 in the v2 API, lenient in the
  edit form (one per line)
- Edit dialog: Allowed sites textarea under the touch switch
- Webview: setAllowedSites D-Bus slot (queued during a reset); the
  navigation guard also accepts listed sites
- Viewer sends the list before opening the input gate; mirrored to
  managed screens
- Tests (Python + QtWebEngine) and docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Copilot AI lite review requested due to automatic review settings November 30, 2026 20:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

2 participants