mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-10-22 01:53:33 +00:00
🩹 fix: surface projections as estimates, not authoritative snapshots
A first-cut projection carries the SDK's windowing but omits instruction/tool overhead, so rendering it as `isEstimate: false` showed a confident under-count for snapshot-less branches. Mark projection-sourced views `isEstimate: true` + `snapshotActive: false` (and drop the snapshot field) so they present as a better estimate than sumBranch — improved used/window number, estimate framing, no misleading granular breakdown with ~0 tools. Real snapshots stay authoritative. (Codex round 3, projection.ts:139.)
This commit is contained in:
parent
536d2ca46f
commit
0e521390af
1 changed files with 9 additions and 3 deletions
|
|
@ -249,12 +249,18 @@ export default function useTokenUsage({
|
|||
* slots in ahead of the estimate when no snapshot exists. Snapshot and
|
||||
* projection share the render-relevant fields, so they render uniformly. */
|
||||
let effective: ContextSnapshot | TContextUsageEvent | null = null;
|
||||
/** A server projection is the SDK's windowing but, in this first cut, omits
|
||||
* instruction/tool overhead — so it's surfaced as an ESTIMATE (a better one
|
||||
* than sumBranch), never a false-authoritative number. Real snapshots stay
|
||||
* authoritative. */
|
||||
let projected = false;
|
||||
if (currentActive) {
|
||||
effective = snapshot;
|
||||
} else if (branchSnapshot != null) {
|
||||
effective = branchSnapshot;
|
||||
} else if (projection != null) {
|
||||
effective = projection;
|
||||
projected = true;
|
||||
}
|
||||
|
||||
if (effective != null) {
|
||||
|
|
@ -274,9 +280,9 @@ export default function useTokenUsage({
|
|||
usedTokens,
|
||||
maxTokens,
|
||||
percent: maxTokens > 0 ? Math.min((usedTokens / maxTokens) * 100, 100) : 0,
|
||||
isEstimate: false,
|
||||
snapshot: effective as ContextSnapshot,
|
||||
snapshotActive: true,
|
||||
isEstimate: projected,
|
||||
snapshot: projected ? null : (effective as ContextSnapshot),
|
||||
snapshotActive: !projected,
|
||||
branchTotals,
|
||||
branchUsage,
|
||||
totalUsage,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue