Fix TUI panel persistent "Waiting for cache data..." message despite valid cache data#14
Merged
Merged
Conversation
…tivity - Add build.tui.mjs to compile src/index.tsx → dist/tui.js using @opentui/solid universal renderer - Point ./tui export to dist/tui.js so OpenCode loads precompiled JSX with proper Solid reactivity - Guard Array.isArray on props.api.state.provider iteration - Listen to session.updated event to recompute on aggregate data
v0.5.0 nests babel-preset-solid options under options.solid, not at the root level. Without the wrapper, the esbuild plugin uses default solid-js/web DOM runtime instead of @opentui/solid universal renderer, breaking TUI rendering.
Owner
|
Thank you for the fix! Because your PR modifies the build process, I needed to verify the release workflow. I’ve gone ahead and released your PR as a beta version. Once we confirm it’s working properly, I’ll merge it and ship it in the main release. Could you please test the beta version? Remove the old cache by running |
Open
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where the TokenCachePanel in the TUI side panel would indefinitely show "Waiting for cache data..." even when session token data (cache reads/writes/costs) is present and confirmed via opencode export and debug toasts.
Root Cause:
OpenCode loads TUI plugins by importing the module's ./tui export at runtime. When that export points to src/index.tsx (raw TSX), OpenCode applies a non-Solid JSX transform. This means JSX expressions like , {data().hitRate}, {t().title}, and Solid reactive bindings (createMemo/createSignal) are never compiled into Solid's reactive DOM primitives. The component renders once with the initial hasData: false state and never updates when dataSignal is set inside createEffect. In contrast, the server-side plugin (dist/index.js) works fine because it is compiled by tsc with standard TypeScript JSX handling.
Fix:
Precompile the TUI entry – Added build.tui.mjs that uses esbuild-plugin-solid with { moduleName: '@opentui/solid', generate: 'universal' } to produce dist/tui.js. The ./tui export now points to this compiled file.
Added Array.isArray guard on api.state.provider – Prevents a TypeError during early render when api.state.provider hasn't been initialised as an array yet (src/index.tsx:469).
Added session.updated event listener – Forces a recomputation when the session aggregate data loads asynchronously (src/index.tsx:667). This is a safety net; the precompilation fix alone was sufficient in testing, but this provides robustness.
Testing:
Installed the plugin via marketplace and npm in a project using the TUI side panel.
Ran an OpenCode session generating token cache activity.
Verified that the panel now shows real-time hit rate, read/write counts, model, cost, etc., instead of the waiting message.