fix(usage): keep cache-write data and correct hit-rate gaps - #2548
Merged
Conversation
The trend chart's cache hit-rate polyline dropped null buckets and joined the remaining points into one polyline, so an idle stretch (all token counters at zero, no cache telemetry) was visually bridged by a high dashed line connecting the buckets on either side - the chart implied a ~97% hit rate over hours where the tooltip correctly showed no data. - split the hit-rate series into contiguous segments that stop at buckets without telemetry; an isolated point renders as a dot - add hover marker dots for every series so small values stay visible on a zero-baseline token axis (e.g. 276K next to a 20M peak reads as flat zero without an anchor) - format the tooltip hit rate with formatHitRate (two-decimal truncate) instead of Math.round for consistency with the summary cards
Splitting the hit-rate series at buckets without telemetry left isolated dots and blank stretches, which read as a broken chart. Idle buckets already draw every token series at zero, so plot the hit rate at 0% there too and keep one continuous dashed line; the tooltip mirrors the line with 0.00% instead of an en dash.
Keep provider-reported cache-write tokens in the backend records, aggregates, persisted statistics, and API response while removing the noisy series from the current chart UI. Render synthesized idle buckets at 0% for continuity, but keep active buckets without cache telemetry as gaps and show an unavailable tooltip value instead of claiming a measured 0% hit rate. Add focused coverage for the hidden series, segmented trend, and tooltip semantics.
1688mengdie
pushed a commit
to BitFun-SIG/taiji-plugin-library
that referenced
this pull request
Aug 27, 2026
usage hit-rate semantics Adopted-from: GCWing#2534 (fix/usage-stat-chart-hit-rate, head 89c939f) Scope: drop cache_write metric from statistics pipeline + chart, keep hit-rate trend line continuous (gaps plot at 0%). Conflict resolution per commander directive: - cache_write display/aggregation tug-of-war with GCWing#2548 resolved in favor of GCWing#2534 in CHART PIPELINE (series dropped) while backend telemetry fields retained per GCWing#2548 data-retention (api types + test fixtures keep cacheWriteTokens). - Rate rendering merged: rateFor(number|null) + unconditional hover dot + tooltip value hoveredHitRate ?? 0 to mirror rendered line. Verification: cargo check -p bitfun-services-core --jobs 4 0e0w + pnpm type-check (recorded in sync-record-2534-adopt-20260827.md)
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.
Summary
Integrates #2534 with two follow-up corrections:
–in the tooltip instead of claiming a measured 0% hit rate.The final product diff against
mainis frontend-only; the Rust token-usage backend is unchanged.Verification
cargo test -p bitfun-services-core --no-default-features --features token-usage-statistics --lib token_usage::— 16 passedcargo test -p bitfun-services-core --no-default-features --features local-storage --test storage_owner_contracts token_usage_service_persists_records_and_filters_subagents_by_default— 1 passedcargo test -p bitfun-core --no-default-features --features agent-runtime --lib service::token_usage— 10 passedpnpm --dir src/web-ui run test:run src/infrastructure/config/components/UsageStatisticsConfig.test.tsx src/infrastructure/api/tokenUsageStatisticsApi.test.ts --pool=threads --maxWorkers=1— 11 passedpnpm run i18n:audit— passedpnpm run appearance:contract-audit— passedgit diff --check— passedpnpm run type-check:webremains blocked by the pre-existing generated API errorwebsocket-adapter.ts(21,3): Module "@/generated/api" has no exported member 'GitTrustReport'.Validation scope
AI-assisted change with focused automated verification. No development server, interactive UI validation, or runtime remote-scenario validation was performed. The backend response shape remains unchanged, so this change does not add a new mixed-version protocol requirement.