diff --git a/CHANGELOG.md b/CHANGELOG.md index e627cee..7021437 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to the OpenClaw Home Assistant Integration will be documented in this file. +## [0.1.20] - 2026-02-20 + +### Changed +- Added versioned card resource URL (`/openclaw/openclaw-chat-card.js?v=...`) to reduce stale frontend caching issues. +- Added runtime source diagnostics (`import.meta.url`) in card console output to verify which script file is actually loaded. +- Updated root loader shim to import versioned card bundle URL. + ## [0.1.19] - 2026-02-20 ### Changed diff --git a/custom_components/openclaw/__init__.py b/custom_components/openclaw/__init__.py index 66ce295..460abb8 100644 --- a/custom_components/openclaw/__init__.py +++ b/custom_components/openclaw/__init__.py @@ -70,8 +70,10 @@ _MAX_CHAT_HISTORY = 200 # Path to the chat card JS inside the integration package (custom_components/openclaw/www/) _CARD_FILENAME = "openclaw-chat-card.js" _CARD_PATH = Path(__file__).parent / "www" / _CARD_FILENAME -# URL at which the card JS will be served (registered via register_static_path) -_CARD_URL = f"/openclaw/{_CARD_FILENAME}" +# URL at which the card JS is served (registered via register_static_path) +_CARD_STATIC_URL = f"/openclaw/{_CARD_FILENAME}" +# Versioned URL used for Lovelace resource registration to avoid stale browser cache +_CARD_URL = f"{_CARD_STATIC_URL}?v=0.1.20" type OpenClawConfigEntry = ConfigEntry @@ -259,13 +261,13 @@ async def _async_register_static_path(hass: HomeAssistant) -> str | None: from homeassistant.components.http import StaticPathConfig # noqa: PLC0415 await hass.http.async_register_static_paths( - [StaticPathConfig(_CARD_URL, str(_CARD_PATH), cache_headers=True)] + [StaticPathConfig(_CARD_STATIC_URL, str(_CARD_PATH), cache_headers=True)] ) except (ImportError, AttributeError): - hass.http.register_static_path(_CARD_URL, str(_CARD_PATH), True) + hass.http.register_static_path(_CARD_STATIC_URL, str(_CARD_PATH), True) hass.data[static_key] = True - _LOGGER.debug("Registered static path: %s", _CARD_URL) + _LOGGER.debug("Registered static path: %s", _CARD_STATIC_URL) return _CARD_URL diff --git a/custom_components/openclaw/manifest.json b/custom_components/openclaw/manifest.json index 6543396..421e936 100644 --- a/custom_components/openclaw/manifest.json +++ b/custom_components/openclaw/manifest.json @@ -8,7 +8,7 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/techartdev/OpenClawHomeAssistant/issues", "requirements": [], - "version": "0.1.19", + "version": "0.1.20", "dependencies": ["conversation"], "after_dependencies": ["hassio", "lovelace"] } diff --git a/custom_components/openclaw/www/openclaw-chat-card.js b/custom_components/openclaw/www/openclaw-chat-card.js index f00fa06..193965e 100644 --- a/custom_components/openclaw/www/openclaw-chat-card.js +++ b/custom_components/openclaw/www/openclaw-chat-card.js @@ -13,7 +13,7 @@ * + subscribes to openclaw_message_received events. */ -const CARD_VERSION = "0.2.0"; +const CARD_VERSION = "0.2.1"; // Max time (ms) to show the thinking indicator before falling back to an error const THINKING_TIMEOUT_MS = 120_000; @@ -1055,3 +1055,5 @@ console.info( "color: white; background: #2563eb; font-weight: bold; padding: 2px 6px; border-radius: 4px 0 0 4px;", "color: #2563eb; background: #e5e7eb; font-weight: bold; padding: 2px 6px; border-radius: 0 4px 4px 0;" ); + +console.info("OPENCLAW-CHAT-CARD source", import.meta.url); diff --git a/www/openclaw-chat-card.js b/www/openclaw-chat-card.js index b6f3e50..ec37ca5 100644 --- a/www/openclaw-chat-card.js +++ b/www/openclaw-chat-card.js @@ -1,7 +1,9 @@ (async () => { try { if (!customElements.get("openclaw-chat-card")) { - await import("/openclaw/openclaw-chat-card.js"); + const src = "/openclaw/openclaw-chat-card.js?v=0.1.20"; + console.info("OpenClaw loader importing", src); + await import(src); } } catch (err) { console.error("OpenClaw: failed to load chat card bundle from /openclaw/openclaw-chat-card.js", err);