mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-11-07 09:47:23 +00:00
The plugin page rendered nothing until the operator clicked refresh, and even the click handler was never wired — while every unit test was green and the API returned correct numbers. Four separate mistakes stacked here: 1. The script waited on DOMContentLoaded, an event that had already been dispatched by the time the kernel injects a plugin mount. Replaced with pluginAPI.onTabShown (the kernel's own mechanism, fires with the DOM in place) PLUS an immediate call, because onTabShown alone leaves the page blank when the tab is already open at boot. The billing page does both; I had reduced it to one and broke first paint. 2. The re-entry guard flag lived in a closure variable. The tab's DOM is rebuilt on re-entry, so the handler was wired against a node that no longer existed. The flag now lives on the NODE (__ccqWired), which is what makes re-wiring correct. 3. refresh() swallowed its fetch failure and rendered "no sources", so a broken page and an empty account list looked identical. Failures now surface in the header line, including when pluginAPI.call is missing (an old kernel). 4. THE ACTUAL REASON the page stayed blank: there were TWO ccquota plugins. The embed (go:embed plugins/*.lua) version and the on-disk one both loaded, and the UI injected the EMBED copy — 5182 characters, predating every fix — while every edit I made and every hot reload went to the disk copy. The running binary was serving stale plugin code no amount of reloading could fix. Only a rebuild surfaced it, and only measuring the served <script> length (7053 vs 5182) showed which copy the browser had. Lesson worth keeping: "the file on disk is what runs" is false for anything under go:embed. Compare what the SERVER sends before editing the same file twice and concluding the edit did nothing. Verified in the browser: 2 account cards, 4 window bars, real balances, no overflow, no console errors, refresh button 48x29 and functional. Co-Authored-By: ModelRouter <noreply@modelrouter.dev>