Tone down system notices in chat timeline
This commit is contained in:
1 parent
ae0bf93ed1
commit
e5e13a38f1
1 file changed
+20
-9
@@ -242,6 +242,7 @@ private fun MessageBubble(
|
|||||||
val isThinking = message.status == "thinking" || message.kind == MessageKind.Thinking
|
val isThinking = message.status == "thinking" || message.kind == MessageKind.Thinking
|
||||||
val isTool = message.kind == MessageKind.Tool
|
val isTool = message.kind == MessageKind.Tool
|
||||||
val isToolResult = message.kind == MessageKind.ToolResult
|
val isToolResult = message.kind == MessageKind.ToolResult
|
||||||
|
val isSystemNotice = message.role == MessageRole.System && !isToolResult && !isTool
|
||||||
val bubbleColor = when {
|
val bubbleColor = when {
|
||||||
isToolResult && message.status == "tool-error" -> MaterialTheme.colorScheme.errorContainer
|
isToolResult && message.status == "tool-error" -> MaterialTheme.colorScheme.errorContainer
|
||||||
isToolResult -> MaterialTheme.colorScheme.tertiaryContainer
|
isToolResult -> MaterialTheme.colorScheme.tertiaryContainer
|
||||||
@@ -280,30 +281,36 @@ private fun MessageBubble(
|
|||||||
|
|
||||||
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = alignment) {
|
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = alignment) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxWidth(0.88f),
|
modifier = if (isSystemNotice) Modifier.fillMaxWidth() else Modifier.fillMaxWidth(0.88f),
|
||||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||||
horizontalAlignment = if (message.role == MessageRole.User) Alignment.End else Alignment.Start,
|
horizontalAlignment = if (isSystemNotice) Alignment.CenterHorizontally else if (message.role == MessageRole.User) Alignment.End else Alignment.Start,
|
||||||
) {
|
) {
|
||||||
|
if (!isSystemNotice) {
|
||||||
Text(
|
Text(
|
||||||
text = label,
|
text = label,
|
||||||
style = MaterialTheme.typography.labelMedium,
|
style = MaterialTheme.typography.labelMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clip(androidx.compose.foundation.shape.RoundedCornerShape(20.dp))
|
.clip(androidx.compose.foundation.shape.RoundedCornerShape(if (isSystemNotice) 14.dp else 20.dp))
|
||||||
.border(
|
.border(
|
||||||
width = if (isTool || isToolResult) 1.dp else 0.dp,
|
width = when {
|
||||||
|
isSystemNotice -> 0.dp
|
||||||
|
isTool || isToolResult -> 1.dp
|
||||||
|
else -> 0.dp
|
||||||
|
},
|
||||||
color = when {
|
color = when {
|
||||||
isToolResult && message.status == "tool-error" -> MaterialTheme.colorScheme.error
|
isToolResult && message.status == "tool-error" -> MaterialTheme.colorScheme.error
|
||||||
isToolResult -> MaterialTheme.colorScheme.tertiary
|
isToolResult -> MaterialTheme.colorScheme.tertiary
|
||||||
isTool -> MaterialTheme.colorScheme.secondary
|
isTool -> MaterialTheme.colorScheme.secondary
|
||||||
else -> MaterialTheme.colorScheme.surfaceVariant
|
else -> MaterialTheme.colorScheme.surfaceVariant
|
||||||
},
|
},
|
||||||
shape = androidx.compose.foundation.shape.RoundedCornerShape(20.dp),
|
shape = androidx.compose.foundation.shape.RoundedCornerShape(if (isSystemNotice) 14.dp else 20.dp),
|
||||||
)
|
)
|
||||||
.background(bubbleColor)
|
.background(if (isSystemNotice) MaterialTheme.colorScheme.surfaceContainerHigh else bubbleColor)
|
||||||
.padding(14.dp),
|
.padding(if (isSystemNotice) 10.dp else 14.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
) {
|
) {
|
||||||
when {
|
when {
|
||||||
@@ -382,7 +389,11 @@ private fun MessageBubble(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
Text(text = displayText, style = MaterialTheme.typography.bodyLarge)
|
Text(
|
||||||
|
text = displayText,
|
||||||
|
style = if (isSystemNotice) MaterialTheme.typography.bodyMedium else MaterialTheme.typography.bodyLarge,
|
||||||
|
color = if (isSystemNotice) MaterialTheme.colorScheme.onSurfaceVariant else MaterialTheme.colorScheme.onSurface,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row(
|
Row(
|
||||||
@@ -396,7 +407,7 @@ private fun MessageBubble(
|
|||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
)
|
)
|
||||||
if (displayStatus != null) {
|
if (displayStatus != null && !isSystemNotice) {
|
||||||
StatusPill(text = displayStatus)
|
StatusPill(text = displayStatus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user