Two things, both about the transcript telling the truth about itself. Markdown is rendered rather than shown as its source. The parsing is mikepenz/multiplatform-markdown-renderer, not something written here: markdown is somebody else's specification, and a hand-written subset of one disagrees with it at the edges, which is where the bug reports come from. `Markdown.kt` is only the mapping onto this app's palette, so code, links and rules take the Catppuccin values the rest of the app uses rather than the renderer's defaults. The queued-message list was cleared wholesale whenever a turn ended. But the backend holds a queue of its own and takes one message per turn, so a turn ending is precisely the moment the *rest* are still waiting -- the bubbles vanished while the messages were on their way, which reads as everything after the first having been dropped. Now a held message leaves the list exactly two ways: the session reads it, which arrives as a UserMessage, or its send failed and there is nothing to wait for. Measured first, because the report was that the backend dropped them: three messages sent behind one long turn were all delivered in order (ONE, TWO, THREE) against current main, so the loss was in the display. Verified on the emulator: headings, emphasis, inline code, nested lists, a quote bar, a fenced block, a rule and a link all render, and the three queued messages sit through their turn. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
45 lines
1.9 KiB
Kotlin
45 lines
1.9 KiB
Kotlin
package com.example.aiapp
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.text.font.FontFamily
|
|
import com.mikepenz.markdown.m3.Markdown
|
|
import com.mikepenz.markdown.m3.markdownColor
|
|
import com.mikepenz.markdown.m3.markdownTypography
|
|
|
|
/**
|
|
* An assistant's reply, rendered as the markdown it is written in.
|
|
*
|
|
* The parsing is the library's. Markdown is somebody else's specification, and a hand-written
|
|
* subset of one disagrees with it at the edges -- which is where the bug reports come from, one
|
|
* case at a time. This file's whole job is the mapping onto the app's palette.
|
|
*
|
|
* Colours come from the theme rather than from the renderer's defaults, so code, links and rules
|
|
* are the same Catppuccin values the rest of the app uses. Nothing here picks a colour of its own.
|
|
*/
|
|
@Composable
|
|
fun MarkdownText(text: String, modifier: Modifier = Modifier) {
|
|
Markdown(
|
|
content = text,
|
|
colors =
|
|
markdownColor(
|
|
text = MaterialTheme.colorScheme.onSurface,
|
|
codeText = codeColor,
|
|
inlineCodeText = codeColor,
|
|
linkText = linkColor,
|
|
dividerColor = MaterialTheme.colorScheme.outlineVariant,
|
|
codeBackground = MaterialTheme.colorScheme.surfaceVariant,
|
|
inlineCodeBackground = MaterialTheme.colorScheme.surfaceVariant,
|
|
),
|
|
// Body text at the size everything else in the transcript uses, and code in a monospace
|
|
// face: a code block set in the body font stops looking like code at all.
|
|
typography =
|
|
markdownTypography(
|
|
text = MaterialTheme.typography.bodyLarge,
|
|
code = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace),
|
|
),
|
|
modifier = modifier,
|
|
)
|
|
}
|