Repository navigation
feat(minimax-pet): 0.7.0 回复按 Markdown 渲染 - #127
Merged
Merged
Conversation
MyPrototypeWhat
changed the base branch from
feat/minimax-pet-host-navigation
to
main
November 12, 2026 08:47
- 新增 markdown.mjs:把任务最近回复的 mdast 转成 DOM 节点,覆盖标题、强调、 行内代码、围栏代码块、列表与任务清单、表格、引用、分隔线、链接; 通知卡片与提醒预览使用压平后的纯文本。 - 原始 HTML 只作为文本显示,链接只显示可读地址、不打开,图片不发起请求。 渲染全程使用 createElement/createTextNode,不拼 HTML 字符串。 - vendor/markdown.mjs 由 tools/build-markdown.mjs 打包 unified 11.0.5 + remark-parse 11.0.0 + remark-gfm 4.0.1(esbuild 0.25.12),并生成 markdown.LICENSE.txt(59 个 MIT 包);npm run build:markdown 可逐字节重建。 - 面板详情、桌面卡片详情按同一套 --mcode-* 变量排版,窄卡片降一档字号。 - 新增 dev/markdown.test.mjs,补充桌面卡片与面板接线测试,更新 README(中英)、 DEVELOPMENT、PROVENANCE 与根 README 表格。
MyPrototypeWhat
force-pushed
the
feat/minimax-pet-markdown
branch
from
November 12, 2026 08:49
6df2365 to
bc02b14
Compare
MyPrototypeWhat
marked this pull request as ready for review
November 12, 2026 09:30
- renderMarkdown 替换节点时保留 scrollTop:流式回复每轮都会变,之前会把阅读位置拉回顶部。 - dataset.mdSource 改存短键(长度 + FNV-1a),不再把整段回复复制进属性。 - 表格对齐读 remark-gfm 记在 table 节点上的列对齐,之前读的是 cell.align,永远取不到。 - 补测试:列对齐、滚动位置、短键;DEVELOPMENT 与注释同步说明。
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.
MiniMax Pet 0.7.0:任务最近回复按 Markdown 渲染,标题、列表、代码块、表格、引用、链接都不再露出原始语法。原始 HTML 只作为文本显示,图片不发起网络请求,页面不会把模型输出拼成 HTML。通知卡片和提醒预览仍是纯文本。
解析用 vendor 进来的 unified + remark-parse + remark-gfm(MIT),由
npm run build:markdown打包成单文件并生成许可证清单。这一版叠在 #124(0.6.0 打开对话与主题跟随)之上,review 顺序是 #124 → 本 PR。Written by Claude Opus 5.5
改了什么
miniapp/client/markdown.mjsrenderMarkdown(target, text):把 mdast 转成 DOM,createElement/createTextNode全程不拼字符串;文本未变时跳过重绘(dataset.mdSource),后台刷新不会打断阅读位置。role="heading"+aria-level,不产生 h1/h2 抢占页面层级)、段落、粗体/斜体/删除线、行内代码、围栏代码块(带语言标签)、有序/无序/嵌套列表、任务清单(data-checked,不生成表单控件)、表格(横向滚动容器,tabindex="0"可键盘滚动)、引用、分隔线、链接。md-raw文本,行内标签丢弃;[x](javascript:…)、data:这类地址不挂到title上;图片只显示「[图片:alt]」,不做请求。markdownToPlainText(text):给 5 行预览用的压平输出,列表带•/序号并按层级缩进,表格用制表符。sources/.../tools/build-markdown.mjs用 esbuild(platform: neutral,Node 测试也能 import)打包 unified 11.0.5 + remark-parse 11.0.0 + remark-gfm 4.0.1,产物miniapp/client/vendor/markdown.mjs(153 KiB)。markdown.LICENSE.txt,每个包的许可原文都在里面。npm run build:markdown连跑两次产物 md5 一致,check:package逐字节比对。#detail-reply改为<div role="region" tabindex="0">渲染;桌面卡片详情同一套渲染,280px 窗口里降一档字号(12px/17px);通知栈和最近提醒预览走压平文本。.md规则全部使用页面已有的--mcode-*变量,明暗都覆盖;表格、代码块在容器内滚动,不撑破布局。测试
sources/minimax-ai/minimax-pet:npm test250 通过(新增dev/markdown.test.mjs12 个用例,桌面卡片与面板接线各补 1 个),npm run test:smoke70/70(含/assets/markdown.mjs、/assets/vendor/markdown.mjs)。<script>、<img onerror>、javascript:、data:链接、未闭合语法、控制字符、超长输入都不产生元素或协议处理。npm run check:plugins/minimax-ai/minimax-pet: OK。评审
独立代码评审已跑完,两个问题在本分支修掉(第二个 commit):
renderMarkdown替换节点时会把阅读位置拉回顶部;现在替换前后保留scrollTop,注释与 DEVELOPMENT 也改成如实描述。cell.align,但 remark-gfm 把对齐记在 table 节点上,所以data-align从未写入、两条 CSS 规则是死代码;改为按列读取。dataset.mdSource从整段回复改成「长度 + FNV-1a」短键,避免 200k 字符的回复在属性里再存一份。未验证
许可
vendored 解析器及依赖共 59 个 MIT 包,版权声明集中在
miniapp/client/vendor/markdown.LICENSE.txt;本包自身仍是 MIT。