From 66c229131233c42aabe4a753716024b4286a2e7d Mon Sep 17 00:00:00 2001 From: AskaEth Date: Sun, 4 Oct 2026 22:07:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(chat):=20=E7=BC=96=E8=BE=91=E6=A1=86?= =?UTF-8?q?=E5=8F=AA=E6=98=BE=E7=A4=BA=E7=BA=AF=E6=96=87=E6=9C=AC=20?= =?UTF-8?q?=E2=80=94=E2=80=94=20=E7=9C=9F=E6=9C=89=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E6=97=B6=E6=89=8D=E5=89=A5=EF=BC=8C=E4=B8=94=E5=BC=B9=E5=B1=82?= =?UTF-8?q?=E6=98=8E=E8=AF=B4=E4=BC=9A=E6=9B=BF=E6=8D=A2=E6=8E=89=E4=BB=80?= =?UTF-8?q?=E4=B9=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主人拍板:编辑单条消息时输入框里只放纯文本,不再让用户对着
/ / ` / ` `(可带属性)/ ` ` 在这里也是普通文本。
+ */
+private val KNOWN_TAG_RE = Regex(
+ " ]*)?>| ` 这种 Web 形态的块间空行会与
+ * 分隔符叠加成四个换行,读起来就不是屏幕上那两段了。这里去掉的只可能是空白,
+ * 一个可见字符都不会掉。
+ *
+ * 一个气泡都解析不出时**原样返回 `content`**:那是「宁可不剥」的落点,不是错误。
+ */
+private fun visibleTextOf(content: String): String {
+ val bubbles = parse(content)
+ if (bubbles.isEmpty()) return content
+ return bubbles
+ .joinToString(BUBBLE_SEPARATOR) { bubble -> bubble.parts.joinToString("") { it.text }.trim() }
+ .trim()
+}
diff --git a/app/src/main/kotlin/top/yeij/cyrene/ui/chat/ChatViewModel.kt b/app/src/main/kotlin/top/yeij/cyrene/ui/chat/ChatViewModel.kt
index 6a6dd84..8cac68e 100644
--- a/app/src/main/kotlin/top/yeij/cyrene/ui/chat/ChatViewModel.kt
+++ b/app/src/main/kotlin/top/yeij/cyrene/ui/chat/ChatViewModel.kt
@@ -47,6 +47,7 @@ import top.yeij.cyrene.domain.chat.ImageDelivery
import top.yeij.cyrene.domain.chat.MessageFingerprint
import top.yeij.cyrene.domain.chat.RetryKeyMemory
import top.yeij.cyrene.domain.chat.SendChannel
+import top.yeij.cyrene.domain.chat.editableMessageOf
import top.yeij.cyrene.domain.chat.readBounded
import top.yeij.cyrene.domain.chat.toDocumentFailure
import top.yeij.cyrene.domain.parse.ParsedBubble
@@ -356,12 +357,18 @@ sealed interface MessageActionState {
val error: String?
/**
- * 编辑弹层。[draft] 初值是**服务端存的原始 `content`**(含 ` ` / ` ` / ` ` / ` ` / ` ` / ` ` / ` 大小写不认(解析器只认小写 p) 完整长度 624046 字符。 第一段 第二段 你好呀 第一行\n第二行 你好🎀再见 你好呀 第二段 hi *笑* 没闭合就结束")
+ }
+
+ @Test
+ fun `没闭合的 action 同样原样留着`() {
+ assertUntouched("