Skip to content

fix: show session aggregates when history is unavailable - #13

Merged
zhumengzhu merged 1 commit into
zhumengzhu:mainfrom
sebas77:fix/session-aggregate-visibility
Sep 4, 2026
Merged

fix: show session aggregates when history is unavailable#13
zhumengzhu merged 1 commit into
zhumengzhu:mainfrom
sebas77:fix/session-aggregate-visibility

Conversation

@sebas77

@sebas77 sebas77 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Problem

The sidebar shows Waiting for cache data when its per-message history list is empty, even if OpenCode session.get() already provides valid aggregate cache and token metrics.

This can occur when the initial history fetch is unavailable or resolves before the TUI message mirror is populated. The aggregate metrics remain valid, but the panel is hidden because hasData() only considers message-derived lineages and sub-agent data.

Fix

Treat a non-empty main-session aggregate as data for panel visibility.

Per-turn history remains responsible for trends and lineage details; if it is unavailable, the existing incomplete-history indicator remains applicable.

Validation

  • Reproduced with OpenCode 1.18.25 and OpenAI.
  • The affected session persisted 674,816 cache-read tokens in session.get().
  • Before this change, the plugin showed Waiting for cache data.
  • After this change, it displays the aggregate cache metrics.
  • Local Bun tests were not run because Bun is not installed; CI should run bun test.

Disclosure: This pull request, including the diagnosis and code change, was generated with AI assistance and reviewed through local runtime validation.

@zhumengzhu

Copy link
Copy Markdown
Owner

Thanks @sebas77 — reviewed carefully and verified the fix against the real data path:

  • session.get() aggregates are authoritative and were already the intended visibility source (sidebarShouldShow / the design doc say "main or subs have stats"), so this aligns the panel gate with that intent instead of inventing new behavior.
  • Reproduced the gate logic on the merge ref: hasData now renders the aggregate rows (Total hit / Detail / Model) when per-message history is empty, while a genuinely empty session still shows Waiting for cache data.
  • bun test on the merge ref: 453 pass / 0 fail (incl. module-load and eager-safe JSX guards).

One minor nit for future PRs: the new term re-invokes mainSessionHasStats(main()) one line below the identical mainHasStats memo — prefer reusing the memo (or the sidebarShouldShow helper) so the predicate keeps a single source of truth. Not blocking.

Merging now — this will ship in v0.7.4 tonight (2026-09-04). Thanks for the solid reproduction and disclosure.

@zhumengzhu
zhumengzhu merged commit 8abb27b into zhumengzhu:main Sep 4, 2026
1 check passed
zhumengzhu added a commit that referenced this pull request Sep 5, 2026
PR #13 (show session aggregates when history is unavailable) is the only
change since 0.7.3; release as a patch.
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.

2 participants