Skip to content

fix(ui_bundler): revalidate asset-bundle cache signature so patched webui assets invalidate without restart - #1853

Open
wgnrai wants to merge 1 commit into
agent0ai:mainfrom
wgnrai:fix/ui-bundler-cache-invalidation
Open

wgnrai wants to merge 1 commit into
agent0ai:mainfrom
wgnrai:fix/ui-bundler-cache-invalidation

Conversation

@wgnrai

@wgnrai wgnrai commented Aug 25, 2026

Copy link
Copy Markdown

Problem

get_ui_asset_bundle() cached the UI asset bundle in an in-memory cache keyed by entry-URL hash only, and returned the cached bundle WITHOUT recomputing _bundle_signature() (which already covers plugin webui file mtimes). Any change to core or plugin webui assets after process start (e.g. a plugin patching _model_config/webui/model-config-store.js) left the server serving a stale bundle version via /ui/asset-bundle until restart. The stale version kept splash.html's service-worker registration unchanged, so browsers kept executing pre-patch JS — in our case a preset-save loop that silently dropped a model slot on every save. We hit this on a live deployment with a plugin-patched preset UI.

Root cause

The cache hit path never revalidated against the signature. The signature function already existed and already covered all asset roots; the bug was purely that it was not checked on cache hits.

Fix

Recompute the signature on every call (stat-pass over bundle roots, ~300 files, once per page load — negligible); reuse the cached bundle only on signature match; rebuild + re-cache on mismatch. Clients self-heal automatically: new bundle version → splash registers the service worker under the new URL → activate handler purges old caches.

Verification

  • Regression test test_bundle_cache_invalidates_when_plugin_asset_changes (touch plugin asset → next get_ui_asset_bundle returns new version + new content)
  • 4/4 ui_bundler tests + 18/18 related webui asset suites pass
  • End-to-end confirmed on a live deployment (patched preset-save UI now persists after the fix; it failed 5× before)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…cache on asset patches

get_ui_asset_bundle cached by entry-URL hash only and returned the cached
bundle without recomputing _bundle_signature, so patched plugin/core webui
assets (e.g. _model_config/webui/*) never invalidated the in-memory bundle
until run_ui restart. /ui/asset-bundle served a stale version, splash.html
kept the old SW registration, and stale model-config-store.js dropped the
vision slot on preset save.

Now the signature is computed on every call and the cached bundle is used
only when cached['signature'] matches; on mismatch the bundle is rebuilt
and re-cached. Server-side fix self-heals clients (new version -> splash
re-registers SW -> cleanupCaches purges old caches).

Refs: dev-ticket-2026-08-24-webui-preset-save-sw-bug.md
@wgnrai

wgnrai commented Sep 23, 2026

Copy link
Copy Markdown
Author

Refreshed this against latest main. The bundle cache still serves stale patched assets after a webui change without the signature revalidation, so the fix still applies.

@wgnrai
wgnrai force-pushed the fix/ui-bundler-cache-invalidation branch from 2e7deb3 to 5ba6b5d Compare September 23, 2026 04:40
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.

1 participant