Show the offline screen when the network link is gone; plain panel
CI / test-bookworm (push) Failing after 2s
CI / test-latest (push) Successful in 36s

With no address on any interface (cable out, no wifi) the kiosk now
switches to the offline screen right away and returns when the network
and server are back. An unreachable server with the network up still
leaves the page running for InfoFlow's offline cache. The panel on the
local pages loses its blue top edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rothmanandClaude Opus 5.5 committed 2026-11-04 23:22:19 +01:00
1 parent 4d061f5211
commit be80288a6e
3 files changed
+51 -8

No files matched your search

+24 -5
View File
@@ -40,6 +40,7 @@ PROBE_MAX_AGE_LOADING = 10
PROBE_MAX_AGE_ONLINE = 60
HUNG_RELOAD_AFTER = 3
HUNG_RESTART_AFTER = 6
NO_NETWORK = "Geen netwerkverbinding (netwerkkabel los?)"
BLANK_URLS = {"", "about:blank", "chrome://newtab/", "chrome://new-tab-page/"}
@@ -124,6 +125,17 @@ class Agent:
log.warning(message)
self.state["last_error"] = {"at": int(self.wall()), "message": message}
def has_network(self) -> bool:
"""False when no interface has an address, e.g. the cable is out and there is no wifi."""
return bool(self.addresses())
def show_offline(self, config: dict[str, Any], reason: str) -> None:
if self.offline_since is None:
self.offline_since = self.wall()
self.state["offline_since"] = int(self.offline_since)
self.error(f"Kiosk-URL niet bereikbaar ({reason}); offlinepagina getoond")
self.navigate(self.offline_url(config, reason))
def setup_required(self) -> bool:
return self.paths.setup_code_file.exists() and not self.paths.admin_file.exists()
@@ -187,6 +199,8 @@ class Agent:
if kind != "remote" or url_changed:
ok, reason = self.reachable(target, 0 if url_changed else PROBE_MAX_AGE_LOADING)
if not ok and not self.has_network():
reason = NO_NETWORK
if ok:
if self.offline_since is not None:
log.info("Kiosk-URL weer bereikbaar na %.0f s", self.wall() - self.offline_since)
@@ -195,14 +209,19 @@ class Agent:
self.offline_since = None
self.state["offline_since"] = None
elif kind != "offline" or url_changed:
if self.offline_since is None:
self.offline_since = self.wall()
self.state["offline_since"] = int(self.offline_since)
self.error(f"Kiosk-URL niet bereikbaar ({reason}); offlinepagina getoond")
self.navigate(self.offline_url(config, reason))
self.show_offline(config, reason)
self.hung = 0
return
# Without any network the page cannot recover by itself: say so on screen. When only
# the server is unreachable the page stays, so InfoFlow can show its offline cache.
if not self.has_network():
self.state.update(target_reachable=False, reason=NO_NETWORK, checked_at=int(self.wall()))
self._probe = None
self.hung = 0
self.show_offline(config, NO_NETWORK)
return
if self.last_load is None:
self.last_load = self.clock()