mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 10:47:41 +00:00
fix: /status shows incorrect context percentage — totalTokens clamped to contextTokens (#15114) (#15133)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: a489669fc7
Co-authored-by: echoVic <16428813+echoVic@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -22,8 +22,11 @@ export const shortenText = (value: string, maxLen: number) => {
|
||||
export const formatTokensCompact = (
|
||||
sess: Pick<SessionStatus, "totalTokens" | "contextTokens" | "percentUsed">,
|
||||
) => {
|
||||
const used = sess.totalTokens ?? 0;
|
||||
const used = sess.totalTokens;
|
||||
const ctx = sess.contextTokens;
|
||||
if (used == null) {
|
||||
return ctx ? `unknown/${formatKTokens(ctx)} (?%)` : "unknown used";
|
||||
}
|
||||
if (!ctx) {
|
||||
return `${formatKTokens(used)} used`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user