Skip to content

fix(crates/handwriting-core): 让带中点条件标签的流程图正常出图 - #63

Merged
SXP-Simon merged 1 commit into
mainfrom
fix/worksheet-diagram
Nov 27, 2026
Merged

SXP-Simon merged 1 commit into
mainfrom
fix/worksheet-diagram

Conversation

@SXP-Simon

@SXP-Simon SXP-Simon commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

为什么改

在循环分析作业里,模型用工具推荐的原生绘图语法画流程图,在两条分支箭头旁写上条件。解析器遇到 node[midway,right] 和 \le 时,按现有保底行为把整段源代码当作正文。模型随后改用外部 PNG,图和正文的笔迹很难一致。

这个草稿做什么

识别连线上的 midway 标签,以及标签里的 ≤ 和 ≥ 命令。直线的标签放在中间,直角路径的标签放在转角,继续画线仍然从原来的端点出发。仅扩展已有绘图子集,其余未知样式继续保留原文。

一个可单独重现的片段:

\begin{circuitikz}
\draw[->] (0,0) -- (4,0) node[midway,above] {$i\le10$};
\end{circuitikz}

本机证据

  • 用 Windows 真实 MCP 和文本预处理器,分别保存同一段六节点、含循环回边的流程图。基线第一页布局返回 410 个字形,开头是反斜杠、b、e、g。此分支返回 1 个图形,打开 PNG 能看到六个节点、条件和箭头。
  • 10 项语法回归和 1 项实际电路导出测试通过,核心 crate 的 Clippy 通过。测试覆盖路径端点、折线、无前置路径的中点标签和未知选项。
  • 可以独立合入。docs(crates/panache-mcp): 在建稿时说明正文插图的线稿效果 #58 讨论导入位图后的线稿效果,本草稿修复在使用位图之前就发生的原生绘图失败。

Summary by Sourcery

Enable native rendering of circuit flowchart conditions placed along connection paths.

New Features:

  • Support midway labels on straight and right-angle circuit paths, including condition text using ≤ and ≥ symbols.

Bug Fixes:

  • Prevent supported flowchart condition labels from causing the circuit parser to fall back to rendering the entire source as text while preserving path endpoints and rejecting unsupported options.

Tests:

  • Add regression coverage for midpoint and corner labels, Unicode inequality conversion, endpoint preservation, and unsupported midpoint options.

背景:循环流程图的中点标签和不等式命令曾导致整个绘图环境逐字输出。

解决手段:解析受限的线段中点标签和不等式命令,验证标签位置与箭头端点。

收益:这类作业的流程图能随正文一起绘制。
@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

解析连线上的受限 midway 标签并将其放到路径中点,同时保留线段端点;支持标签中的 ≤ 和 ≥ 命令。

  • crates/handwriting-core/src/text/circuit.rs L168-181, L270-275 (+5 small edits)
  • crates/handwriting-core/src/text/circuit/labels.rs L83-84

Tests

验证直线与折线路径的中点标签位置、端点和箭头行为,以及无前置路径或未知选项时的拒绝行为。

  • crates/handwriting-core/tests/circuitikz.rs L72-102

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai

sourcery-ai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Sorry @SXP-Simon, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 22 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@SXP-Simon
SXP-Simon merged commit 8028123 into main Nov 27, 2026
1 check passed
SXP-Simon added a commit that referenced this pull request Nov 27, 2026
## 为什么改

一份手写作业里,模型改用 PNG
画方框和箭头。缩小看整页时,模型把成品交了出来,使用者后来指出图线比文字粗很多。原有照片外观提示主要看文字和底纸,推荐区域可能没有框到图。

## 这个草稿做什么

- 看普通成图时,若本节含内嵌位图的标记,返回一句针对图文混排页的提醒:选一段图线和附近字,在同一倍率下看粗细和墨色。普通成图仍可直接看。
-
整页检查利用已有的本页布局与调整后的坐标,找第一张位图和附近的非位图笔迹。二者能一起放进原尺寸裁图时,直接返回可复制的局部预览参数。区域过大或超出纸面时,改为提醒选小区域。比较同页图和字只需当前版本。
- 局部检查沿用已有只读预览。是否偏粗由看到的图像决定。若图确实太重,可以改插图源并复看,正文的墨色不需要跟着改。#58
讲的是导入时位图如何变成线稿,此处处理的是成图后怎样验收。

## Windows 实际验证

- 合成纸上放入手写字和一张含方框、横线的 PNG。工具给出的 **179 × 178
像素**区域同时包含插图和正文字形,局部调用返回底纸与成图两张裁图,保持原倍率。纯文字页和纯图片页均不产生整页图文对照建议。局部取图没有新增整页检查记录。
-
用同一页有意画粗的方框图、同一随机种子和同一句「像同一支笔写的,能交吗」做独立会话对照。转发器省略启动说明,保留真实工具及图像,核对工具调用与回答。

| 版本 | Luna | Terra |
| --- | --- | --- |
| 当前 main | 从整页指出图粗,未取局部裁图 | 从整页指出图粗,未取局部裁图 |
| 最终草稿 | 从整页指出图粗,未取局部裁图 | 按参数取回 **291 × 212** 裁图,再指出框和连线比字粗黑 |

中间版本还暴露了两个问题:只有整页检查带提示时,Luna
有一次只看普通成图,判断「可以交」。加入普通预览提示后,它又曾把同页对照误填为比较两个相同版本。因此最终两个入口都说明了同页如何检查。两模型每个版本各一次,最终对这张明显粗线图的识别均为
**2/2**。有证据的收益是 Terra 主动取到同倍率裁图,尚不能据此判断模型识别率提高。

MCP 的 16 项单元测试和 Clippy 通过。新增的真实 stdio 回归可用 `python
crates/panache-mcp/tests/illustration_ink_check.py <panache-mcp>`
复跑。该自动建议聚焦每页第一张位图,原生流程图的生成问题由 #63 独立处理。

## Summary by Sourcery

Enable MCP reviews to identify and compare embedded illustration lines
with nearby handwriting without changing the surrounding text ink.

New Features:
- Add image-preview guidance for comparing embedded diagram strokes with
nearby handwriting at the same zoom.
- Generate page-level review regions and native-scale preview parameters
covering the first embedded image and adjacent text when available.

Enhancements:
- Track text versus illustration glyphs through rendering and fine-edit
geometry to support mixed-content inspection.

Documentation:
- Document the recommended review workflow for comparing hand-drawn
diagrams with nearby writing.

Tests:
- Add an end-to-end MCP regression covering mixed diagram and text
previews, crop contents, and review-record behavior.
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