Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
@@ -801,6 +801,7 @@ fun ChatScreen(
|
|||||||
if (showContextSheet && state.contextBreakdown != null) {
|
if (showContextSheet && state.contextBreakdown != null) {
|
||||||
ContextDetailSheet(
|
ContextDetailSheet(
|
||||||
breakdown = state.contextBreakdown!!,
|
breakdown = state.contextBreakdown!!,
|
||||||
|
usedTokens = state.usedContextTokens,
|
||||||
fullTokens = state.fullContextTokens,
|
fullTokens = state.fullContextTokens,
|
||||||
onDismiss = { showContextSheet = false },
|
onDismiss = { showContextSheet = false },
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -33,13 +33,15 @@ import kotlin.math.min
|
|||||||
* token breakdown (input / output / cache read / cache write / reasoning) and
|
* token breakdown (input / output / cache read / cache write / reasoning) and
|
||||||
* the message count, plus a prominent used / full bar.
|
* the message count, plus a prominent used / full bar.
|
||||||
*
|
*
|
||||||
* `fullTokens` is the model context window (denominator); `breakdown` carries
|
* @param breakdown Sourced per-category token counts from `GET /api/sessions/{id}`.
|
||||||
* the per-category 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)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun ContextDetailSheet(
|
fun ContextDetailSheet(
|
||||||
breakdown: ContextBreakdown,
|
breakdown: ContextBreakdown,
|
||||||
|
usedTokens: Long?,
|
||||||
fullTokens: Long?,
|
fullTokens: Long?,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
sheetState: SheetState = rememberModalBottomSheetState(),
|
sheetState: SheetState = rememberModalBottomSheetState(),
|
||||||
@@ -49,7 +51,7 @@ fun ContextDetailSheet(
|
|||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
) {
|
) {
|
||||||
val full = fullTokens ?: 0L
|
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 fraction = if (full > 0L) min(1f, used.toFloat() / full.toFloat()) else 0f
|
||||||
val pct = (fraction * 100).toInt()
|
val pct = (fraction * 100).toInt()
|
||||||
val statusColors = LocalHermesStatusColors.current
|
val statusColors = LocalHermesStatusColors.current
|
||||||
|
|||||||
Reference in New Issue
Block a user