Skip to content

Commit 7a52a15

Browse files
0xadam-brownOpenCode
andcommitted
fix(android): Refine Buddy live feed layout
Limit the Buddy sheet height, refresh relative timestamps outside recording state, and simplify live feed rows with compact category pills. Use LocalWindowInfo for the sheet height calculation to satisfy Compose lint. Co-Authored-By: OpenCode <noreply@opencode.ai>
1 parent 32e2021 commit 7a52a15

1 file changed

Lines changed: 41 additions & 40 deletions

File tree

‎sentry-android-buddy/src/main/java/io/sentry/android/buddy/SentryBuddyUi.kt‎

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.Row
2525
import androidx.compose.foundation.layout.fillMaxSize
2626
import androidx.compose.foundation.layout.fillMaxWidth
2727
import androidx.compose.foundation.layout.height
28+
import androidx.compose.foundation.layout.heightIn
2829
import androidx.compose.foundation.layout.offset
2930
import androidx.compose.foundation.layout.padding
3031
import androidx.compose.foundation.layout.size
@@ -68,6 +69,7 @@ import androidx.compose.ui.layout.positionInRoot
6869
import androidx.compose.ui.platform.LocalClipboardManager
6970
import androidx.compose.ui.platform.LocalContext
7071
import androidx.compose.ui.platform.LocalDensity
72+
import androidx.compose.ui.platform.LocalWindowInfo
7173
import androidx.compose.ui.res.painterResource
7274
import androidx.compose.ui.text.AnnotatedString
7375
import androidx.compose.ui.text.font.FontFamily
@@ -148,18 +150,20 @@ private fun SentryBuddyOverlayContent(
148150
controller.action()
149151
state = controller.state
150152
liveFeed = controller.liveFeed
153+
nowMs = System.currentTimeMillis()
151154
}
152155

153156
fun dispatchAnalysis(action: SentryBuddySessionController.() -> Unit) {
154157
analysisScope.launch {
155158
withContext(Dispatchers.IO) { controller.action() }
156159
state = controller.state
157160
liveFeed = controller.liveFeed
161+
nowMs = System.currentTimeMillis()
158162
}
159163
}
160164

161165
LaunchedEffect(state) {
162-
if (state is SentryBuddySessionState.Recording) {
166+
if (state !is SentryBuddySessionState.Closed) {
163167
while (true) {
164168
nowMs = System.currentTimeMillis()
165169
delay(1000)
@@ -487,6 +491,8 @@ private fun BuddySheet(
487491
if (state is SentryBuddySessionState.Closed || state is SentryBuddySessionState.Recording) {
488492
return
489493
}
494+
val maxSheetHeight =
495+
with(LocalDensity.current) { LocalWindowInfo.current.containerSize.height.toDp() } * 0.75f
490496

491497
ModalBottomSheet(
492498
onDismissRequest = { onDispatch { close() } },
@@ -495,7 +501,11 @@ private fun BuddySheet(
495501
shape = RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp),
496502
) {
497503
Column(
498-
modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()).padding(24.dp),
504+
modifier =
505+
Modifier.fillMaxWidth()
506+
.heightIn(max = maxSheetHeight)
507+
.verticalScroll(rememberScrollState())
508+
.padding(24.dp),
499509
verticalArrangement = Arrangement.spacedBy(16.dp),
500510
) {
501511
when (state) {
@@ -698,49 +708,40 @@ private fun LiveFeedRows(
698708
) {
699709
Row(
700710
modifier = Modifier.fillMaxWidth().padding(14.dp),
701-
horizontalArrangement = Arrangement.spacedBy(12.dp),
702-
verticalAlignment = Alignment.Top,
711+
horizontalArrangement = Arrangement.spacedBy(10.dp),
712+
verticalAlignment = Alignment.CenterVertically,
703713
) {
704-
Box(modifier = Modifier.size(10.dp).background(color, CircleShape).offset(y = 5.dp))
705-
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) {
706-
Row(
707-
modifier = Modifier.fillMaxWidth(),
708-
horizontalArrangement = Arrangement.SpaceBetween,
709-
verticalAlignment = Alignment.CenterVertically,
710-
) {
711-
Text(item.title(), color = BuddyInk, fontWeight = FontWeight.Bold)
712-
Text(
713-
relativeTime(item.timestamp.time, nowMs),
714-
color = BuddyMuted,
715-
style = MaterialTheme.typography.labelMedium,
716-
)
717-
}
718-
item.subtitle()?.let {
719-
Text(it, color = BuddyMuted, style = MaterialTheme.typography.bodySmall)
720-
}
721-
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
722-
Text(
723-
item.category.label,
724-
color = color,
725-
style = MaterialTheme.typography.labelMedium,
726-
fontWeight = FontWeight.Bold,
727-
)
728-
if (link != null) {
729-
Text(
730-
"Open in Sentry",
731-
color = BuddyPurple,
732-
style = MaterialTheme.typography.labelMedium,
733-
fontWeight = FontWeight.Bold,
734-
)
735-
}
736-
}
737-
}
714+
LiveFeedCategoryPill(item.category.label, color)
715+
Text(
716+
item.title(),
717+
modifier = Modifier.weight(1f),
718+
color = BuddyInk,
719+
fontWeight = FontWeight.Bold,
720+
)
721+
Text(
722+
relativeTime(item.timestamp.time, nowMs),
723+
color = BuddyMuted,
724+
style = MaterialTheme.typography.labelMedium,
725+
)
738726
}
739727
}
740728
}
741729
}
742730
}
743731

732+
@Composable
733+
private fun LiveFeedCategoryPill(label: String, color: Color) {
734+
Surface(color = color.copy(alpha = 0.12f), shape = RoundedCornerShape(18.dp)) {
735+
Text(
736+
label,
737+
modifier = Modifier.padding(horizontal = 9.dp, vertical = 5.dp),
738+
color = color,
739+
style = MaterialTheme.typography.labelSmall,
740+
fontWeight = FontWeight.Bold,
741+
)
742+
}
743+
}
744+
744745
@Composable
745746
private fun SentryBuddyGlyph(tint: Color, modifier: Modifier = Modifier) {
746747
Icon(
@@ -1000,8 +1001,8 @@ private fun Int.positiveChip(label: String): String? = if (this > 0) "$this $lab
10001001

10011002
private fun BuddyLiveFeedItem.title(): String =
10021003
when (category) {
1003-
BuddyLiveFeedItem.Category.SCREEN -> "Screen: ${timelineItem.name.orEmpty()}"
1004-
BuddyLiveFeedItem.Category.STEP -> "Step: ${timelineItem.name.orEmpty()}"
1004+
BuddyLiveFeedItem.Category.SCREEN -> timelineItem.name ?: "Unknown screen"
1005+
BuddyLiveFeedItem.Category.STEP -> timelineItem.name ?: "Unnamed step"
10051006
BuddyLiveFeedItem.Category.ERROR -> timelineItem.name ?: "Error captured"
10061007
BuddyLiveFeedItem.Category.FAILED_HTTP -> httpTitle()
10071008
BuddyLiveFeedItem.Category.SLOW_SPAN -> timelineItem.name ?: "Slow span"

0 commit comments

Comments
 (0)