Skip to content

Fix TUI panel persistent "Waiting for cache data..." message despite valid cache data#14

Merged
Hotakus merged 2 commits into
Hotakus:masterfrom
logic3body:master
Jun 27, 2026
Merged

Fix TUI panel persistent "Waiting for cache data..." message despite valid cache data#14
Hotakus merged 2 commits into
Hotakus:masterfrom
logic3body:master

Conversation

@logic3body

Copy link
Copy Markdown
Contributor

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.

…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.
@Hotakus

Hotakus commented Jun 25, 2026

Copy link
Copy Markdown
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 rm -rf ~/.cache/opencode/packages/opencode-visual-cache@latest, then install and test the beta using the package name opencode-visual-cache@beta.

@Hotakus Hotakus mentioned this pull request Jun 25, 2026
@Hotakus Hotakus self-assigned this Jun 27, 2026
@Hotakus Hotakus added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Jun 27, 2026
@Hotakus Hotakus merged commit be14f26 into Hotakus:master Jun 27, 2026
2 checks passed
@Hotakus Hotakus linked an issue Jun 27, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot work

2 participants