Repository navigation
fix(chat): 裸 minis:// URL 渲染为可点击链接(粗体包裸链接不渲染的根因) - #394
Merged
Merged
Conversation
…rkdown
Field evidence (screenshot 368.jpg, session 1bd04f03 "油猴脚本更新添加
网站支持", model glm-5.3): the assistant emitted the file link as
**minis://attachments/uploads/susu.wiki_______-3.4.txt**
— a bare URL wrapped in bold markers, NOT the [label](url) form. The DB
parts_json is unambiguous. parseInline has branches for code, bold,
[link](url), italic — but NO autolink branch: the bold branch consumed the
run, painted bold dark text with no "url" annotation, and the tap died
before ChatLinkResolver ever ran. Nothing was blue because nothing was a
link; that is also why older chats looked fine — those models emitted
proper markdown links, and the previous PR (#393) fixed resolution for
links that DO render, which this one never reached.
- parseInline gains a bare-URL autolink branch (GFM-style): schemes
minis://, https://, http://. Matched after code/bold so those keep their
own semantics; bold recursion re-enters the parser, so **<url>** now
renders a bold link — the exact field case.
- bareUrlEnd(): whitespace ends the run; ')' ends it only when parens are
balanced (Wikipedia-style /Go_(programming_language) survives); CJK
full-width punctuation terminates, while CJK ideographs continue inside
the URL (relay filenames are commonly Chinese); ASCII sentence
punctuation is trimmed off the tail.
- Annotated spans use the same "url" tag the markdown-link branch writes,
so the tap handler, ChatLinkResolver.resolve, and PR #393's
cross-project sweep all fire unchanged.
Tests: BareUrlAutolinkTest (12 cases) pins the field case, CJK-period and
ASCII-period trimming, paren balance, md-link and inline-code immutability,
CJK filenames, multi-URL lines, non-URL schemes staying plain. The full
matrix was replayed in Python against the parser mirror first (11/11 OK).
…as its own branch list **minis://…** is the field case: the bold branch routes its body through appendRecursive, which never re-entered parseInline's new autolink branch. Mirror the same scheme/bareUrlEnd handling here so the bold-wrapped URL renders as a bold link with the same url annotation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
真根因(DB 取证,非推断)
用户澄清:链接根本不是蓝色可点击状态——即渲染层从未把它当链接。上一 PR(#393)修的是"已渲染链接解析不到文件",而这次是压根没渲染成链接,两者是不同层的问题。
从 minis.db 的
parts_json取到原始消息(session1bd04f03,模型 glm-5.3):模型把裸 URL 用 粗体 包裹发出,不是
[label](url)形态。StreamingMarkdownParseInline.parseInline的分支顺序:行内代码 → 粗体 →[link](url)→ 斜体 → …… 没有 autolink 分支。裸 URL 被粗体分支吞掉:SpanStyle(fontWeight=Bold)加深色文本,不写 "url" annotation → 点击处理器根本收不到 URL → ChatLinkResolver 没机会运行 → 点了没反应。之前版本没这问题,因为旧会话的模型恰好都发的是标准
[文本](minis://…)链接;GLM-5.3 改发粗体裸 URL,渲染层就跟不上了。修复([T-chatlink-bare-url-autolink])
parseInline增加 GFM 风格 裸 URL autolink 分支:minis://、https://、http://三种 scheme(排在 code/bold 之后,不影响原有语义);bareUrlEnd扫描边界:空白结束;)仅在括号配平时结束(Wikipedia 式/Go_(programming_language)完整保留);CJK 全角标点终止(。然后…不会被吞进 URL),CJK 汉字继续(中转站文件名常为中文);ASCII 句尾标点修剪;**<url>**现在渲染为粗体链接——正是现场案例;[link](url)完全相同的"url"annotation tag,点击处理、ChatLinkResolver.resolve、fix(chat): minis:// 链接跨项目解析失败——回退扫描项目树 #393 的跨项目扫描全部原样生效。测试
BareUrlAutolinkTest12 用例:现场粗体案例、CJK 句号与 ASCII 句号修剪、括号配平、md 链接与行内代码不受影响、中文文件名、一行双链接、非 URL scheme 保持纯文本。整个判定矩阵先用 Python 对解析镜像回放 11/11 通过,再落 Kotlin 测试。