From f62cc4b7ac4bcf1000fc78241623c9e68cb4c972 Mon Sep 17 00:00:00 2001 From: Bruno Deanoz Date: Mon, 22 Jun 2026 01:01:53 +0200 Subject: [PATCH] fix token badge, hide pills on keyboard, reset tokens on nav MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three fixes: 1. Token badge only shown when usedTokens > 0 (not in old chats where we have no streaming data). Pushed to far right with Spacer weight. Reset to 0 on new chat and conversation switch. 2. Mode pills hidden when keyboard is open (WindowInsets.isImeVisible) — prevents the bottom dock from pushing too far up and overlapping chat content. Input field stays compact at the bottom. 3. ModelPill no longer constrained with weight(fill=false) which was causing layout issues. --- .../java/dev/kaizen/app/chat/ChatScreen.kt | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/dev/kaizen/app/chat/ChatScreen.kt b/app/src/main/java/dev/kaizen/app/chat/ChatScreen.kt index 7eca559..ad792f1 100644 --- a/app/src/main/java/dev/kaizen/app/chat/ChatScreen.kt +++ b/app/src/main/java/dev/kaizen/app/chat/ChatScreen.kt @@ -13,7 +13,10 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.imePadding +import androidx.compose.foundation.layout.isImeVisible import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -219,6 +222,7 @@ fun ChatScreen( messages.clear() conversationId = null viewingLockedChat = false + usedTokens = 0 } fun openConversation(summary: ConversationSummary) { @@ -269,6 +273,7 @@ fun ChatScreen( return } viewingLockedChat = false + usedTokens = 0 scope.launch { messages.clear() val cachedList = chat.messageRepo.getCached(summary.id) @@ -655,11 +660,10 @@ fun ChatScreen( ModelPill( label = modelDisplayName(session.config?.model ?: "", models), onClick = { haptics.tick(); showModelSheet = true }, - modifier = Modifier.weight(1f, fill = false), ) - if (usedTokens > 0 || messages.isNotEmpty()) { + Spacer(Modifier.weight(1f)) + if (usedTokens > 0) { val ctxLen = models.find { it.id == session.config?.model }?.context_length ?: 1_000_000 - Spacer(Modifier.width(8.dp)) TokenBadge(used = usedTokens, contextLength = ctxLen) } } @@ -704,18 +708,22 @@ fun ChatScreen( .imePadding() .then(if (isTablet) Modifier.widthIn(max = 720.dp) else Modifier) ) { - Spacer(Modifier.height(24.dp)) - ModePillsRow( - activeMode = activeMode, - onToggle = { mode -> - activeMode = if (activeMode == mode) null else mode - haptics.tick() - }, - reasoningPreset = reasoningPreset, - onReasoningChange = { reasoningPreset = it; haptics.tick() }, - samplingPrefs = samplingPrefs, - onSamplingChange = { samplingPrefs = it }, - ) + @OptIn(ExperimentalLayoutApi::class) + val imeVisible = WindowInsets.isImeVisible + if (!imeVisible) { + Spacer(Modifier.height(24.dp)) + ModePillsRow( + activeMode = activeMode, + onToggle = { mode -> + activeMode = if (activeMode == mode) null else mode + haptics.tick() + }, + reasoningPreset = reasoningPreset, + onReasoningChange = { reasoningPreset = it; haptics.tick() }, + samplingPrefs = samplingPrefs, + onSamplingChange = { samplingPrefs = it }, + ) + } Spacer(Modifier.height(10.dp)) ChatInput( value = input,