fix error banner sticky, token badge always visible

- loadError auto-clears after 4s for unlock failures
- loadError reset on every conversation switch (was sticky)
- Token badge always shown (was hidden when usedTokens == 0,
  making it invisible for all loaded chats)

Note: locked chat "Authentifizierungsfehler" happens because
POST /api/v1/auth/unlock is not deployed yet on the server.
After git pull + docker build on prod, biometric unlock works.
This commit is contained in:
Bruno Deanoz 2026-06-22 01:14:55 +02:00
parent 77976ea974
commit e697dd7e76

View file

@ -228,9 +228,11 @@ fun ChatScreen(
fun unlockAndOpen(summary: ConversationSummary) { fun unlockAndOpen(summary: ConversationSummary) {
val cfg = session.config ?: return val cfg = session.config ?: return
scope.launch { scope.launch {
loadError = null
val unlockToken = KaizenApi.requestUnlock(cfg.baseUrl, cfg.token) val unlockToken = KaizenApi.requestUnlock(cfg.baseUrl, cfg.token)
if (unlockToken == null) { if (unlockToken == null) {
loadError = context.getString(R.string.biometric_failed) loadError = context.getString(R.string.biometric_failed)
scope.launch { kotlinx.coroutines.delay(4000); if (loadError == context.getString(R.string.biometric_failed)) loadError = null }
return@launch return@launch
} }
val stored = KaizenApi.fetchLockedMessages(cfg.baseUrl, cfg.token, summary.id, unlockToken) val stored = KaizenApi.fetchLockedMessages(cfg.baseUrl, cfg.token, summary.id, unlockToken)
@ -288,6 +290,7 @@ fun ChatScreen(
} }
viewingLockedChat = false viewingLockedChat = false
usedTokens = 0 usedTokens = 0
loadError = null
scope.launch { scope.launch {
messages.clear() messages.clear()
val cachedList = chat.messageRepo.getCached(summary.id) val cachedList = chat.messageRepo.getCached(summary.id)
@ -673,12 +676,10 @@ fun ChatScreen(
onClick = { haptics.tick(); showModelSheet = true }, onClick = { haptics.tick(); showModelSheet = true },
) )
Spacer(Modifier.weight(1f)) 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
TokenBadge(used = usedTokens, contextLength = ctxLen) TokenBadge(used = usedTokens, contextLength = ctxLen)
} }
} }
}
// Error banner when initial data load fails // Error banner when initial data load fails
if (loadError != null) { if (loadError != null) {