git.iko.soy/parseable-android
on master help sign in
Fix crash when opening stream with empty dataset (#9)

When logs were empty but isLoading was true, the LogViewerScreen fell through to the LazyColumn branch instead of showing a loading state. This caused an IndexOutOfBoundsException during Compose recomposition when logKeys[index] was accessed on an empty list. Two fixes: - Add explicit loading state branch (CircularProgressIndicator) when logs are empty and isLoading is true, preventing the empty LazyColumn from being rendered during the loading-to-empty-state transition - Guard logKeys[index] with getOrElse to prevent any out-of-bounds access from Compose snapshot timing edge cases https://claude.ai/code/session_01T4TzcfT9saHNUuKQn74RLh Co-authored-by: Claude <noreply@anthropic.com>

commit42ca6b19b02c1f60cb5712319ec04eb4e777a70a authoriko <mail@iko.soy> dateSun 15 Feb 2026, 18:00 (8 months ago) parent5efe23f
1 file changed+9−2
app/src/main/java/com/parseable/android/ui/screens/logviewer/LogViewerScreen.kt+9−2
app/src/main/java/com/parseable/android/ui/screens/logviewer/LogViewerScreen.kt+9−2
@@ -301,6 +301,13 @@ fun LogViewerScreen(
301301 }
302302 }
303303 }
304+ } else if (state.logs.isEmpty() && state.isLoading) {
305+ Box(
306+ modifier = Modifier.fillMaxSize(),
307+ contentAlignment = Alignment.Center,
308+ ) {
309+ CircularProgressIndicator()
310+ }
304311 } else if (state.logs.isEmpty() && !state.isLoading) {
305312 val emptyMessage = when {
306313 state.isStreaming ->
@@ -365,9 +372,9 @@ fun LogViewerScreen(
365372 ) {
366373 itemsIndexed(
367374 state.logs,
368− key = { index, _ -> logKeys[index] },
375+ key = { index, _ -> logKeys.getOrElse(index) { "log_$index" } },
369376 ) { index, logEntry ->
370− val key = logKeys[index]
377+ val key = logKeys.getOrElse(index) { "log_$index" }
371378 LogEntryCard(
372379 logEntry = logEntry,
373380 isExpanded = expandedLogKey == key,