fix token badge, hide pills on keyboard, reset tokens on nav
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.
This commit is contained in:
parent
e87220afb5
commit
f62cc4b7ac
1 changed files with 23 additions and 15 deletions
|
|
@ -13,7 +13,10 @@ import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
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.imePadding
|
||||||
|
import androidx.compose.foundation.layout.isImeVisible
|
||||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
|
@ -219,6 +222,7 @@ fun ChatScreen(
|
||||||
messages.clear()
|
messages.clear()
|
||||||
conversationId = null
|
conversationId = null
|
||||||
viewingLockedChat = false
|
viewingLockedChat = false
|
||||||
|
usedTokens = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openConversation(summary: ConversationSummary) {
|
fun openConversation(summary: ConversationSummary) {
|
||||||
|
|
@ -269,6 +273,7 @@ fun ChatScreen(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
viewingLockedChat = false
|
viewingLockedChat = false
|
||||||
|
usedTokens = 0
|
||||||
scope.launch {
|
scope.launch {
|
||||||
messages.clear()
|
messages.clear()
|
||||||
val cachedList = chat.messageRepo.getCached(summary.id)
|
val cachedList = chat.messageRepo.getCached(summary.id)
|
||||||
|
|
@ -655,11 +660,10 @@ fun ChatScreen(
|
||||||
ModelPill(
|
ModelPill(
|
||||||
label = modelDisplayName(session.config?.model ?: "", models),
|
label = modelDisplayName(session.config?.model ?: "", models),
|
||||||
onClick = { haptics.tick(); showModelSheet = true },
|
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
|
val ctxLen = models.find { it.id == session.config?.model }?.context_length ?: 1_000_000
|
||||||
Spacer(Modifier.width(8.dp))
|
|
||||||
TokenBadge(used = usedTokens, contextLength = ctxLen)
|
TokenBadge(used = usedTokens, contextLength = ctxLen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -704,6 +708,9 @@ fun ChatScreen(
|
||||||
.imePadding()
|
.imePadding()
|
||||||
.then(if (isTablet) Modifier.widthIn(max = 720.dp) else Modifier)
|
.then(if (isTablet) Modifier.widthIn(max = 720.dp) else Modifier)
|
||||||
) {
|
) {
|
||||||
|
@OptIn(ExperimentalLayoutApi::class)
|
||||||
|
val imeVisible = WindowInsets.isImeVisible
|
||||||
|
if (!imeVisible) {
|
||||||
Spacer(Modifier.height(24.dp))
|
Spacer(Modifier.height(24.dp))
|
||||||
ModePillsRow(
|
ModePillsRow(
|
||||||
activeMode = activeMode,
|
activeMode = activeMode,
|
||||||
|
|
@ -716,6 +723,7 @@ fun ChatScreen(
|
||||||
samplingPrefs = samplingPrefs,
|
samplingPrefs = samplingPrefs,
|
||||||
onSamplingChange = { samplingPrefs = it },
|
onSamplingChange = { samplingPrefs = it },
|
||||||
)
|
)
|
||||||
|
}
|
||||||
Spacer(Modifier.height(10.dp))
|
Spacer(Modifier.height(10.dp))
|
||||||
ChatInput(
|
ChatInput(
|
||||||
value = input,
|
value = input,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue