1package soy.iko.opencode.ui.chat
3import soy.iko.opencode.data.model.AssistantMessage
4import soy.iko.opencode.data.model.MessageWithParts
5import soy.iko.opencode.data.model.ReasoningPart
6import soy.iko.opencode.data.model.TextPart
7import soy.iko.opencode.data.model.UserMessage
10 * Render a conversation as Markdown for sharing/exporting. Each message becomes a
11 * role-prefixed section containing its text parts; reasoning and tool parts are
12 * omitted to keep the exported transcript readable. Pure (no Android deps) so it can
13 * be unit-tested directly.
15fun buildConversationMarkdown(messages: List<MessageWithParts>, title: String?): String {
16 val sb = StringBuilder()
17 if (!title.isNullOrBlank()) {
18 sb.append("# ").append(title.trim()).append("\n\n")
20 for (message in messages) {
21 val heading = when (message.info) {
22 is UserMessage -> "## You"
23 is AssistantMessage -> "## opencode"
26 val body = message.parts
29 is TextPart -> part.text.takeIf { it.isNotBlank() }
30 is ReasoningPart -> part.text.takeIf { it.isNotBlank() }?.let { "_${it}_" }
36 if (body.isEmpty()) continue
37 sb.append(heading).append("\n\n").append(body).append("\n\n")
39 return sb.toString().trimEnd()
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list