package com.example.aiapp import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.material3.Card import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp /** * A message another agent sent this session, closed until somebody asks. * * Closed by default, like a tool call and for the same reason: these are long, there can be several * in a row, and what a reader scanning the transcript needs from one is that it happened and who * sent it. The first line comes with the heading because a name alone does not say which message * this was. * * Drawn as its own kind rather than as the reader's own bubble. They did not say this, and a * transcript that puts it in their voice is making a claim about who asked for the work that * follows -- which is exactly the question a peer message is usually the answer to. */ @Composable fun PeerMessageRow( item: TranscriptItem.PeerNote, expanded: Boolean, onToggle: (Float) -> Unit, replies: ParsedReplies, modifier: Modifier = Modifier, ) { Card(modifier.fillMaxWidth().clickableAt(onToggle)) { Column(Modifier.padding(12.dp)) { Row(verticalAlignment = Alignment.CenterVertically) { Text("Message from ${item.from}", style = MaterialTheme.typography.titleSmall) if (!expanded) { Spacer(Modifier.width(8.dp)) Text( item.text.lineSequence().firstOrNull { it.isNotBlank() }.orEmpty(), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, // The head, not the tail: a message is identified by how it opens. overflow = TextOverflow.Ellipsis, ) } } if (expanded) MarkdownText(item.text, replies, Modifier.padding(top = 6.dp)) } } }