feat(chat): render images + attachments in assistant bubbles (#720)
Assistant messages could not display inline images or attachments on the mobile client. The markdown renderer had no image block, and AssistantBubble only rendered MarkdownText + timestamp, ignoring message.attachments (only UserBubble did). - Add MdBlock.Image + standalone  parsing in MarkdownText. Accepts http(s) gateway URLs and data:image/...;base64 inline media. - Render message.attachments inside AssistantBubble (mirrors UserBubble) via InlineAttachment / AsyncImage. - Add parser unit tests for image blocks (url, data: URL, inline-in-paragraph). Local verification: ./gradlew ktlintCheck compileDebugKotlin assembleDebug all green; app-debug.apk produced. Fixes feature gap where agent-delivered media (e.g. MEDIA:/ images sent to chat) was invisible in the Android app. Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
0180fb12c2
commit
50fdc12992
3 files changed
+92
No files matched your search
@@ -194,4 +194,32 @@ class MarkdownTextFeatureTest {
|
||||
assertEquals("use val x = 1 here", an.toString())
|
||||
assertTrue(an.spanStyles.any { it.item.fontFamily != null })
|
||||
}
|
||||
|
||||
// 12. STANDALONE MARKDOWN IMAGE -> MdBlock.Image (agent-media rendering)
|
||||
@Test
|
||||
fun testStandaloneImage_parsesToImageBlock() {
|
||||
val md = ""
|
||||
val block = parseBlocks(md).singleOrNull() as? MdBlock.Image
|
||||
assertTrue("expected a single Image block", block != null)
|
||||
assertEquals("https://example.com/cat.jpg", block!!.uri)
|
||||
assertEquals("cute cat", block.alt)
|
||||
}
|
||||
|
||||
// 12b. data: URL (base64 inline media) also accepted as an image uri
|
||||
@Test
|
||||
fun testImage_dataUrl_accepted() {
|
||||
val uri = "data:image/jpeg;base64,/9j/abc"
|
||||
val md = ""
|
||||
val block = parseBlocks(md).singleOrNull() as? MdBlock.Image
|
||||
assertTrue("data: URL should parse to Image block", block != null)
|
||||
assertEquals(uri, block!!.uri)
|
||||
}
|
||||
|
||||
// 12c. inline image inside a paragraph is left as text (scope guard)
|
||||
@Test
|
||||
fun testInlineImage_inParagraph_staysText() {
|
||||
val md = "see this  for reference"
|
||||
val blocks = parseBlocks(md)
|
||||
assertTrue("should remain a paragraph", blocks.single() is MdBlock.Paragraph)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user