fix(#928): use active usedTokens in ContextDetailSheet progress bar (#929)

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-08-17 23:49:42 +03:00
1 parent acd82c0085
commit 7232395387
2 files changed
+6 -3

No files matched your search

@@ -801,6 +801,7 @@ fun ChatScreen(
if (showContextSheet && state.contextBreakdown != null) {
ContextDetailSheet(
breakdown = state.contextBreakdown!!,
usedTokens = state.usedContextTokens,
fullTokens = state.fullContextTokens,
onDismiss = { showContextSheet = false },
)
@@ -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