Skip to content

fix(chat): 裸 minis:// URL 渲染为可点击链接(粗体包裸链接不渲染的根因) - #394

Merged
tall-1997 merged 4 commits into
mainfrom
fix/markdown-bare-url-autolink
Nov 18, 2026
Merged

tall-1997 merged 4 commits into
mainfrom
fix/markdown-bare-url-autolink

Conversation

@tall-1997

Copy link
Copy Markdown
Owner

真根因(DB 取证,非推断)

用户澄清:链接根本不是蓝色可点击状态——即渲染层从未把它当链接。上一 PR(#393)修的是"已渲染链接解析不到文件",而这次是压根没渲染成链接,两者是不同层的问题。

从 minis.db 的 parts_json 取到原始消息(session 1bd04f03,模型 glm-5.3):

**minis://attachments/uploads/susu.wiki_______-3.4.txt**(已更新为 v3.5+隐蔽化版)

模型把裸 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 的跨项目扫描全部原样生效。

测试

BareUrlAutolinkTest 12 用例:现场粗体案例、CJK 句号与 ASCII 句号修剪、括号配平、md 链接与行内代码不受影响、中文文件名、一行双链接、非 URL scheme 保持纯文本。整个判定矩阵先用 Python 对解析镜像回放 11/11 通过,再落 Kotlin 测试。

…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.
@tall-1997
tall-1997 merged commit 7d191a6 into main Nov 18, 2026
1 check passed
@tall-1997
tall-1997 deleted the fix/markdown-bare-url-autolink branch November 18, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant