Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

feat: integrate compose-richtext to enable markdown rendering in message bubbles

Rishabh Bajpaiaf96777a6c2a
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 561912e..17b3e13 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -89,6 +89,10 @@ dependencies {
// HTML parsing for webfetch tool
implementation("org.jsoup:jsoup:1.17.2")
+ // Markdown rendering
+ implementation("com.halilibo.compose-richtext:richtext-ui-material3:0.17.0")
+ implementation("com.halilibo.compose-richtext:richtext-commonmark:0.17.0")
+
// Debug
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
diff --git a/app/src/main/java/com/gotcha/ui/MessageBubble.kt b/app/src/main/java/com/gotcha/ui/MessageBubble.kt
index 1329492..2d28404 100644
--- a/app/src/main/java/com/gotcha/ui/MessageBubble.kt
+++ b/app/src/main/java/com/gotcha/ui/MessageBubble.kt
@@ -14,6 +14,8 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
+import com.halilibo.richtext.markdown.Markdown
+import com.halilibo.richtext.ui.material3.Material3RichText
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.VolumeUp
import androidx.compose.material3.Icon
@@ -113,13 +115,16 @@ fun MessageBubble(
)
}
} else {
- Text(
- text = displayText,
- style = when (message.kind) {
- MessageKind.TOOL -> MaterialTheme.typography.bodySmall
- else -> MaterialTheme.typography.bodyMedium
+ if (message.kind == MessageKind.TOOL) {
+ Text(
+ text = displayText,
+ style = MaterialTheme.typography.bodySmall
+ )
+ } else {
+ Material3RichText {
+ Markdown(displayText)
}
- )
+ }
}
}
if (isAssistant && message.text.isNotEmpty()) {
diff --git a/app/test_dep.gradle b/app/test_dep.gradle
new file mode 100644
index 0000000..38db41e
--- /dev/null
+++ b/app/test_dep.gradle
@@ -0,0 +1,3 @@
+apply plugin: 'com.android.application'
+repositories { mavenCentral(); google() }
+dependencies { implementation "com.halilibo.compose-richtext:richtext-commonmark:0.17.0" }