From 72323953878440770c21b4e2cb0365d6f605931b Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Mon, 17 Aug 2026 23:49:42 +0300 Subject: [PATCH] fix(#928): use active usedTokens in ContextDetailSheet progress bar (#929) Co-authored-by: M57 --- .../main/java/com/m57/hermescontrol/ui/chat/ChatScreen.kt | 1 + .../ui/chat/components/ContextDetailSheet.kt | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatScreen.kt b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatScreen.kt index ea441bf8..7e27072a 100644 --- a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatScreen.kt +++ b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatScreen.kt @@ -801,6 +801,7 @@ fun ChatScreen( if (showContextSheet && state.contextBreakdown != null) { ContextDetailSheet( breakdown = state.contextBreakdown!!, + usedTokens = state.usedContextTokens, fullTokens = state.fullContextTokens, onDismiss = { showContextSheet = false }, ) diff --git a/app/src/main/java/com/m57/hermescontrol/ui/chat/components/ContextDetailSheet.kt b/app/src/main/java/com/m57/hermescontrol/ui/chat/components/ContextDetailSheet.kt index ee12405f..50403b63 100644 --- a/app/src/main/java/com/m57/hermescontrol/ui/chat/components/ContextDetailSheet.kt +++ b/app/src/main/java/com/m57/hermescontrol/ui/chat/components/ContextDetailSheet.kt @@ -33,13 +33,15 @@ import kotlin.math.min * token breakdown (input / output / cache read / cache write / reasoning) and * the message count, plus a prominent used / full bar. * - * `fullTokens` is the model context window (denominator); `breakdown` carries - * the per-category counts from `GET /api/sessions/{id}`. + * @param breakdown Sourced per-category token counts from `GET /api/sessions/{id}`. + * @param usedTokens Tokens currently in the active session prompt window (matches ContextUsageChip), or null. + * @param fullTokens The active model's full context window (denominator). */ @OptIn(ExperimentalMaterial3Api::class) @Composable fun ContextDetailSheet( breakdown: ContextBreakdown, + usedTokens: Long?, fullTokens: Long?, onDismiss: () -> Unit, sheetState: SheetState = rememberModalBottomSheetState(), @@ -49,7 +51,7 @@ fun ContextDetailSheet( sheetState = sheetState, ) { val full = fullTokens ?: 0L - val used = breakdown.inputTokens + val used = usedTokens ?: breakdown.inputTokens val fraction = if (full > 0L) min(1f, used.toFloat() / full.toFloat()) else 0f val pct = (fraction * 100).toInt() val statusColors = LocalHermesStatusColors.current