Skip to content

feat: markdown math, mermaid and long images, domain lookup, local AI writing assistant - #430

Merged
qianmoQ merged 15 commits into
devlive-community:devfrom
qianmoQ:dev
Dec 3, 2026
Merged

qianmoQ merged 15 commits into
devlive-community:devfrom
qianmoQ:dev

Conversation

@qianmoQ

@qianmoQ qianmoQ commented Dec 3, 2026

Copy link
Copy Markdown
Member

改动说明 / Summary

一批独立提交:Markdown 编辑器(公式、Mermaid、长图)、新的在线插件「域名信息查询」、内置插件「AI 写作助手」,以及侧栏、工具市场、插件图标和若干修复。每个提交只做一件事,可以逐个审阅。

A batch of independent commits: the Markdown editor gains math, Mermaid and long-image export; a new online Domain Lookup plugin; a new built-in AI Writing Assistant; plus sidebar, market, icon and fix work. One change per commit, so they can be reviewed one by one.

应用 / App

  • a5ff41b 侧栏可以隐藏与展开(标题栏按钮,⌘/Ctrl+\)/ the sidebar can be hidden and shown again
  • e443892 工具市场「全部工具」可多选卸载,确认后依次卸载 / select several tools in All tools and uninstall them at once
  • a2b3a8b 63b482e 18 种 accent 都有自己的图标底色;74 个插件图标重绘为 24×24 线性图标,check rules 新增 plugin-accent 与 plugin-icon / every accent gets a tile color; 74 plugin icons redrawn as line icons, with new rules to keep them that way

Markdown 编辑器 / Markdown editor (0.2.5)

  • 8cd4e29 LaTeX 公式渲染为 MathML(行内与块级),输出经白名单过滤 / LaTeX math as MathML, with the output whitelisted
  • 22a550d mermaid 代码块渲染为图表(纯 Rust,嵌入为 SVG 图片),出错时显示原文 / mermaid blocks become diagrams rendered in Rust; errors show the source
  • be2e176 导出长图:宽度、边距、倍率与主题可调,保存 PNG 或复制图片 / export the document as a long PNG, saved or copied
  • 6b92ab9 7e340be SDK 新增 host.clipboard.writeImage(png)(应用 0.2.6 起,插件先判断是否存在),并登记为仅宿主侧改动 / new SDK method for copying PNG images, feature-detected by plugins, listed as host-only

域名信息查询 / Domain Lookup (new online plugin) — 8b8b75d

  • 经 RDAP 查询注册商、关键日期、EPP 状态、DNS 与 DNSSEC;按 RFC 9537 与占位文本标注隐去的隐私信息,并区分注册局与注册商 / registrar, dates, statuses, name servers and DNSSEC over RDAP, with redacted data attributed to the registry or registrar
  • 没有 RDAP 的顶级域(.de、.cn)显示 IANA 顶级域信息;批量查询按服务器排队,遵守 Retry-After,可导出 CSV;lookup 开放给命令行与 Agent / TLDs without RDAP show the IANA record; batches queue per server, honor Retry-After and export CSV; lookup is exposed to the CLI and agents
  • 39b729a 宿主网络修复:Verisign 对不存在域名的 404 不带长度、关闭 TLS 时不发 close_notify,之前被当作网络错误;按 curl 与浏览器的做法视为正常结束。插件因此需要 0.2.6 / host fix: close-delimited bodies ending without TLS close_notify are no longer network errors, so the plugin needs app 0.2.6

AI 写作助手 / AI Writing Assistant (new built-in plugin) — bb3c402

  • candle 在 CPU 上本地运行 Qwen2.5 Instruct(0.5B 491 MB / 1.5B 1.1 GB,Q4_K_M,Apache-2.0):润色、纠错、改写、精简、扩写、摘要、翻译、自定义指令;文本不离开本机 / local Qwen2.5 Instruct via candle for eight writing actions; text never leaves the computer
  • 模型作为插件资源下载(续传、SHA-256 校验、镜像),模型卡片即模型管理器;分词器直接用 GGUF 里的词表,不需要额外文件和 C 依赖 / models are plugin resources, so their cards are the model manager; the tokenizer is built from the GGUF vocabulary with no extra file or C dependency
  • 以可取消任务运行,结果流式显示,闲置 5 分钟释放内存;其他工具可直接调用 generate,为 Markdown 编辑器接入做准备 / runs as a cancellable streaming task, unloads after 5 idle minutes, and other tools can start generate

其他修复 / Other fixes

  • 5b46fd7 83ebaa3 设备样机、节日头像、证件照等插件补上文件访问权限(截图读取失败),并新增规则要求在线插件声明用到的宿主能力 / declare file access for plugins that read user files (the device mockup failed to read screenshots), and a rule that requires the permission
  • 6df7f42 发布脚本复用 CI 结果,不再检查在线插件 / release script reuses CI results and leaves online plugins out

关联 Issue / Related issues

Closes #132
Closes #158
Closes #102
Closes #183
Refs #205 — 本 PR 提供本地模型与写作助手;Markdown 编辑器的选区 AI 动作(diff 确认、未下载模型时引导)在后续 PR 中完成 / this PR adds the local models and writing assistant; selection actions in the Markdown editor follow in a later PR

改动类型 / Type of change

  • 新工具 / New tool
  • 新功能或改进 / Feature or improvement
  • 问题修复 / Bug fix
  • 重构或性能 / Refactor or performance
  • 文档、翻译或构建 / Docs, translations or build

已测试的平台 / Tested on

  • macOS(Apple Silicon)

  • macOS(Intel)

  • Windows(x64)

  • Linux(x64)

  • 长图导出在 WKWebView 中验证了深浅主题;公式与 Mermaid 在 WASM 沙箱中验证 / long image verified in WKWebView with both themes; math and Mermaid verified in the WASM sandbox

  • 域名查询在 WASM 沙箱中对线上服务器验证:github.com(含注册商隐去声明)、未注册的 .com(404)、denic.de(IANA 信息)、例子.中国 / domain lookup verified against live RDAP servers

  • AI 写作助手用真实的 0.5B 模型跑通翻译与纠错(TF_AI_MODEL=… cargo test -p tfp-ai-writer -- --ignored);测试机负载很高,速度数据不具参考性 / AI assistant verified with the real 0.5B model; the test machine was heavily loaded, so timings are not representative

  • 新增的 AI 写作助手与域名查询页面尚未在完整应用中手动点测 / the two new pages have not been clicked through in the full app yet

自查清单 / Checklist

  • cargo xtask check 全部通过 / passes — ran rustfmt, clippy (stable and 1.99) and tests for the changed crates, check rules, plugin versions, web typecheck and eslint; the full cargo xtask check was not run
  • 提交信息为英文 Conventional Commits,一个提交只做一件事 / Commits are English Conventional Commits, one change per commit
  • 数据处理都在 Rust 中完成,前端只负责展示 / All data processing happens in Rust; the UI only displays results
  • Rust 测试写在单独的 *_test.rs 文件中 / Rust tests live in separate *_test.rs files
  • 界面文字都通过 i18n,zh-CN 与 en-US 的键一致;Rust 只返回错误码 / UI text goes through i18n with matching keys; Rust returns error codes only
  • 样式只使用语义化 token 与 @toolforge/ui 组件 / Styles use semantic tokens and @toolforge/ui components only
  • 耗时操作以任务运行 / Long-running work runs as tasks

截图 / Screenshots

N/A

scripts/release.sh ran the full cargo xtask check before tagging. Most of
that time went to the online plugins in market/, which the app neither
depends on nor bundles: they are built and published by plugins.yml and
checked by PR CI. The commit being released has usually passed CI on every
platform already when it was merged.

- skip local checks when ci.yml passed on HEAD in the remote's repository
  (shown in the plan, so a dry run tells which path will be taken)
- otherwise run the new cargo xtask check app: rules, rustfmt, clippy and
  tests for every crate outside market/, and the frontend checks without
  the online plugin UIs
- keep the old behaviour behind --full-checks
device-mockup, festival-avatar, id-photo-maker, avro-inspector and
native-deps-inspector read the picked file through the host but did not
declare fs:user-selected, so the host refused every read and the tools
only ever reported that the file could not be read.

Saving was broken as well: the mockup, avatar and ID photo tools used an
<a download> link, which the desktop WebView ignores. They now ask for a
path with the save dialog; the ID photo PNG is written by a new UI-only
save function because the host only writes text from the UI.
The host grants file and network access only from the manifest, so a
backend that reads files or sends requests without declaring
fs:user-selected or network fails on every call. Five plugins shipped
that way unnoticed.

cargo xtask check rules now scans each online plugin's backend sources
(tests excluded) for the guest file and network APIs and reports the
missing permission against its manifest.
A button next to the logo in the title bar, or Cmd/Ctrl+\, collapses the
left sidebar to give tools the full window width and brings it back. The
choice is saved with the other preferences. Cmd/Ctrl+B is left alone
because editor plugins use it for bold.

The sidebar narrows with a width transition while its content keeps a
fixed width, so nothing reflows during the animation, and the hidden
sidebar is inert so it cannot take keyboard focus.
Removing many online plugins meant opening each card's menu one by one.
Tools installed from the online market now have a checkbox on the all
tools tab; a sticky bar shows the selection, can select every removable
tool in the current filter, and uninstalls the selection after a
confirmation listing them.

Built-in tools cannot be uninstalled and get no checkbox. Tools are
removed one after another, a failure does not stop the rest, and a
summary toast reports how many were removed. The interaction and wording
match the bulk actions on the online tab.
Plugins use 18 accent values, but only six had a tile color, so 47 tools
such as amber, red or teal ones all fell back to the same green tile.

Add tile colors for every accent, and deepen orange, cyan and the new
yellow so a white glyph keeps at least 3:1 contrast at the gradient
midpoint. cargo xtask check rules now rejects an accent without a tile
color, a test keeps the xtask list, accentTiles and tokens.css in step,
and the plugin guide lists the allowed values.
74 plugin icons were 64x64 drawings with their own colored square, most
of them the same placeholder circle. In the app they sat as a second
tile inside the accent tile, and on the website, which uses icons as a
mask, they rendered as a solid block.

Redraw each one as a 24x24 currentColor line icon that depicts its tool,
matching the rest of the catalog, and bump the published plugins whose
icon changed. cargo xtask check rules now rejects icons that are not
24x24, do not stroke with currentColor or hard-code colors, and the
plugin guide states the requirement.
$...$ and $$...$$ formulas showed up as plain text. The backend now
enables math parsing and converts each formula to MathML with
pulldown-latex, so the preview and exported HTML typeset it natively
without scripts, fonts or a network connection. Invalid LaTeX is marked
in red inside the formula instead of failing the render, and the status
bar counts formulas.

pulldown-latex writes formula text, error context and the source
annotation unescaped, so <, > and " are swapped for private-use
placeholders before conversion and written back as entities afterwards;
output with any element outside the MathML set falls back to escaped
code. Tests cover the injection cases found while probing the library.

Refs devlive-community#132
Mermaid blocks were shown as code. The backend now renders them to SVG
with mermaid-rs-renderer in Rust, so flowcharts, sequence, class, state,
ER, pie and Gantt diagrams appear in the preview and in exported HTML
without mermaid.js or a network connection. A diagram that fails to
parse shows the error above its source instead of breaking the page.

The SVG is embedded as a data URI image: an SVG image cannot run
scripts or load external resources, so labels and style directives stay
inert whether or not the renderer escapes them. Text is measured with
character widths because the sandbox has no system fonts, diagrams over
64 KB are refused, and diagrams sit on a white card in dark mode.

Refs devlive-community#158
Plugins could only put text on the clipboard. host.clipboard.writeImage
takes PNG bytes and sends them to a new clipboard_write_png command as
the raw request body, since a multi-megabyte image passed as a JSON
number array spends seconds in serialization. The host decodes the PNG
and writes it with the clipboard plugin; broken data reports a
translatable error.

The SDK is shared by the host at runtime, so on older apps the method is
undefined and plugins check for it before offering image copy.
Sharing notes in chat apps meant stitching screenshots. Export long image
in the More menu turns the document into one PNG whose height follows
the content, with adjustable width, margin, 1x to 3x resolution and a
light, dark or app-matching theme. It can be saved, or copied to the
clipboard on apps that provide image copy.

The standalone export is laid out off screen at the chosen width; once
images and fonts are ready its height is measured and the same DOM is
drawn through an SVG foreignObject. The SVG is loaded from a data URL
because WebKit taints the canvas for foreignObject images from blob
URLs, which was confirmed in WKWebView. The scale drops automatically
when the canvas would exceed browser limits, and a document too tall
even at 1x gets a clear message. The backend checks the PNG signature
before writing the file.

Refs devlive-community#102
An HTTP/1 response with neither Content-Length nor Transfer-Encoding ends when the server
closes the connection. Some servers, such as Verisign's RDAP service for its 404 answers,
close TLS without sending close_notify, so rustls reported UnexpectedEof and plugins saw a
network error instead of the status. curl and browsers treat this as the end of the body;
responses with a length or chunked encoding still fail when cut short.
Find the registry from the IANA bootstrap file, cached by ETag, and follow the registrar's
RDAP link for contacts. Show the registrar, key dates, EPP statuses, name servers and DNSSEC,
and mark redacted data from RFC 9537 declarations and placeholder text, saying whether the
registry or the registrar redacted it.

- a 404 means the registry has no such domain; expiry shows unknown or expired, never a
  negative countdown
- TLDs without RDAP, such as .de and .cn, show the IANA record instead, since plugins
  cannot use WHOIS on port 43
- batches queue per RDAP host with one request in flight, wait for Retry-After or back off
  with jitter, stop on 403, cache results for six hours and export CSV
- lookup is open to the CLI and agents; needs app 0.2.6 for Verisign's not-found answers

Refs devlive-community#183
Run Qwen2.5 Instruct (0.5B or 1.5B, Q4_K_M GGUF) with candle on the CPU to polish, proofread,
rewrite, shorten, expand, summarize, translate or follow a custom instruction. The models are
plugin resources, so their cards are the model manager: download with resume and SHA-256
checks from Hugging Face or its mirrors, switch, and delete.

- a byte-level BPE tokenizer built from the GGUF vocabulary and merges, so no tokenizer file
  or C regex library is needed; markers typed by users stay plain text
- generate runs as a cancellable task: chunked prefill, low-temperature sampling, streamed
  partial text through throttled logs; the model unloads after five idle minutes
- other tools can start the generate task; it picks the best downloaded model and answers
  ai.no_model when there is none

Refs devlive-community#205
@qianmoQ
qianmoQ merged commit b8c3159 into devlive-community:dev Dec 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant