Skip to content

fix(mcp): 预览翻过末页时给出下一节或历史版本终点 - #19

Closed
SXP-Simon wants to merge 1 commit into
mainfrom
fix/mcp-preview-page-recovery
Closed

SXP-Simon wants to merge 1 commit into
mainfrom
fix/mcp-preview-page-recovery

Conversation

@SXP-Simon

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

Copy link
Copy Markdown
Owner

翻过末页时告诉客户端该往哪里翻

多节稿的打印页码是连续的,预览的 page 则从每一节的 1 开始。旧版整页复盘和布局遇到越界只返回 invalid_page: Page not found。用实拍的巡测手记盲测时,Luna 试过第三页,随后还试了第零页。

现在,渲染发现确实越过末页时,错误会告诉客户端请求版本、节号和本节实际页数。如该版还有下一节,直接给出下一节的 section 和 page=1;如果已经是该版末节,则明确告知。查下一节只在缺页错误发生时执行。非法页号有独立提示,未改变合法预览的渲染流程。

验证

在「前两张看过了,接着翻」的独立交接题里,有提示的 Luna 把第一次整页复盘落在正确的下一张,省去一次已看页面的取图。在另一个留出题中,当前稿已有新节,但用户只想打印昨天的版本;两个会话都交对两页旧稿,有提示的一侧用 4 次业务调用,原版用 12 次。详细调用、混杂因素和 PDF 校验见验证评论。

新增真实 MCP stdio 回归覆盖默认图像、布局、整页复盘、历史版本末节与第零页。独立基于 3150e52,可与 #18 导出后定位缺页 分别评审。

Summary by Sourcery

Improve MCP preview pagination errors so clients can continue at the correct section or recognize the end of a revision.

New Features:

  • Provide actionable MCP preview errors when a requested page exceeds the section’s page count, including revision, section, page count, and the next section’s starting page when available.

Bug Fixes:

  • Distinguish invalid page numbers from pages beyond the end of a section across image, layout, review, and adjustment previews.

Enhancements:

  • Document per-section preview pagination and continuation behavior for current and historical revisions.

Documentation:

  • Document how preview page numbers reset per section and how end-of-section errors indicate continuation or the end of a revision.

Tests:

  • Expand real MCP stdio regression coverage for default, layout, review, historical-end, and zero-page preview requests.

Chores:

  • Record the new multi-section preview guidance in the changelog.

背景:跨节查看照片稿时,布局和整页复盘只提示找不到页,难以判断是到达末尾还是应该换节。

解决手段:复用已有渲染页数,越界时按请求版本查找后一节,提示节内页码与后续入口,区分末节和非法页号。

收益:接手者可以继续阅读剩余页面,并能识别历史版本的末尾。新增真实 stdio 回归覆盖两种情形。

Copy link
Copy Markdown
Owner Author

越界后能否靠工具自己接上

先有真实失败,再隔离错误回执。 #17 的试运行 有 4 次越界。本轮在原版上用另一份斜拍纸、一个无前文低能力会话复核三页稿;它一度把打印页码填进第一节,相继尝试不存在的页和第零页。复盘、布局都会返回没有节号的 Page not found。为单独评估出错以后怎么办,下面两题把同一次失败的原生工具请求与真实回执交给新接手的助手,用户不提供节号、参数或正确答案。基线与候选各用独立的 GPT-5.6 Luna / low 会话和同一份稿件数据库副本,使用真实 stdio,按需查看工具 schema 与返回的图片。

交接场景 原版 → 候选 核验结果
「前两张我看过了,刚才想翻后面那张总打不开」;4 张按 2+1+1 分节。交接调用为第 1 节第 3 页。 5 → 4 次业务调用;收到的整页复盘图片 9 → 6 张;响应 3,659,528 → 2,398,568 字节。 原版先重看第 1 节第 1 页。候选在列稿后直接看第 2 节第 1 页,再看第 3 节第 1 页。两边都交付同一个四页版面。
「我要打印昨天那本……看看最后写到哪一站,别把今天添的混进来。」交接请求固定在 v1,但库中最新已是 v3。 12 → 4 次业务调用;错误 3 → 0;响应 2,496,172 → 1,225,161 字节。 两边都答到第 9 站,PDF 均为 v1 两页,候选读出末站 21 cm。原版的 3 个错误都是猜了不存在的 read_section(view="exact"),单次对照不能把 8 次调用差额全部归因于页码提示。候选只复盘用户问的末页。

表中排除了已经发生的交接错误、握手、工具发现、宿主查看图片与用户对话;响应按完整 MCP result(含 Base64)紧凑 UTF-8 JSON 计。两份四页 PDF 逐字节相同,SHA-256 为 c05cda58ede6356620ec9ecd9933a4ebde750fef5ec67bc16129180dd6b175c4,用 MuPDF 在原照尺寸栅格化后,四页两两差异分别为 0、0、0、0 个像素。顶部 160 行原校名区也都与底纸相同。历史稿两份 PDF 的 SHA-256 均为 3bcce66828b8c06bdd2e3de888a059acfec1e18a2a3b1e6cb34563501d0e9b20。

实现与边界。 复用原来就会产生的渲染计数;发生真实缺页时才查同稿、所请求版本里的下一节。如果库里已有后来追加的节,查旧版仍会正确提示到达末节。报错不会翻页、写复盘记录或修改稿件。用户请求第零页或超出系统上限时先返回范围提示;这类输入没有测出本节实际页数。候选盲测后调整了错误措辞和零页提示;最终二进制重放这两条候选链,9 张返回图片与 2 份 PDF 均与候选逐字节相同,并重新验证了两项关键错误回执。

复现入口。 在仓库根目录运行 python3 scripts/build-text-worker.py、cargo build --locked --release -p panache-mcp、python3 crates/panache-mcp/tests/smoke.py target/release/panache-mcp。新断言在现有跨节样例上验证默认图像、布局、整页复盘,以及用旧版本查末节和第零页。Linux 上 Rust 1.94.1 的格式检查、工作区 Clippy、178 项工作区 Rust 测试及完整 SDK smoke 通过。与 #18 在同一 main 上独立验证,两个改动的 Git 树也可以自动合并。

方法参考 MCP 对模型可见工具错误的说明 和 Self-Harness 的轨迹回归方法。本轮覆盖两种已知出错后交接的情形,未测任意新任务的首轮成功率或 token 成本。

@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Propagate the rendered page count for out-of-range fine-edit requests, then use the request revision and section to add a next-section or last-section hint; reject page zero and other invalid page numbers separately.

  • crates/handwriting-core/src/fine_edit.rs L55, L76-81
  • crates/panache-mcp/src/drafts.rs L58-82
  • crates/panache-mcp/src/engine.rs L197-205, L269-273, L331-332
  • crates/panache-mcp/src/engine/adjustments.rs L26-27
  • crates/panache-mcp/src/preview.rs L90-94

Documentation

Document that preview page numbers restart at 1 per section and explain the next-section and historical-final-section guidance.

  • CHANGELOG.md L5-6
  • crates/panache-mcp/README.md L75-76

Tests

Extend the stdio smoke regression to check page-count and continuation hints across preview modes, historical revisions, and page zero.

  • crates/panache-mcp/tests/smoke.py L389-405

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

SXP-Simon added a commit that referenced this pull request Nov 24, 2026
## 整合范围

在当前 `main`(`f877788`)上整合本轮六个 MCP draft,保留已有接口和测试。这是统一的审阅与 CI 入口。原 PR
保留实验讨论和迭代记录。

| 原 PR | 纳入的行为 | 已核对的来源提交 |
| --- | --- | --- |
| #18 | 导出给出所查版本缺少整页复盘的节号与节内页码 | `f2bd1862b15b` |
| #19 | 翻过末页时按同一历史快照提示下一节或终点 | `b362df54e21f` |
| #20 | 按版本和页码只读找回原单,区分用户和模型反馈 | `4328a5ef9e85` |
| #21 | 查档轮次的客户端工具清单与转发示例 | `f8afa6e0e9f8` |
| #22 | 按补记前的版本和正文实际末页定位,重复引入时列出选项 | `08089ac7f08b` |
| #23 | 从作业/实验报告的日常说法找到笔迹扰动、偶发划改及同页验证 | `2fcdd17db13f` |

## 跨功能验证

合并相邻的检查单读取与导出覆盖查询,保留两套断言。客户端指南使用整合后提供的 `before_text` /
`page="last"`,从导出缺页回查时固定导出版本。缺单回执也说明现有档案对线下查看行为的证明边界。

新增 stdio
回归:当前版导出提示某页缺单,按导出版本查该页为空,按补记前的版本查同一节末页却有原单;再次导出的缺单清单应完全相同。本地及弱模型组合实验结果见本
PR 评论。

原有 #18–#23 在此 PR 合并前继续保持打开。

## Summary by Sourcery

整合 MCP 历史查单、缺页导出、多节导航、笔迹调节与复盘保护能力。

New Features:
- 扩展 MCP 历史复盘查询,可按稿件版本、节号和页码读取已有整页记录,并支持按新增原文定位补记前版本及指定节末页。
- 导出结果新增按打印顺序报告缺少整页复盘的节内页码,并完善跨节翻页提示。
- 新增笔迹松散度和偶发划改调节能力,并支持直接或按控件组提交调参。

Bug Fixes:
- 修正历史检查单无法区分受检版本与首次入档版本的问题,并为旧记录保留未知状态。
- 修正无效页码和多节稿件查询的错误提示,使其提供实际页数及后续节信息。

Enhancements:
- 支持在保留既有复盘记录的模式下改稿、查看成图和导出,同时阻止新增检查单与评语。
- 完善检查单查询、导出回查、客户端工具选择和 MCP 使用指引,并保持只读查询不产生新记录。

Documentation:
- 补充历史查单、缺页回查、保留复盘记录、笔迹调节及只读客户端调用的用户指南。

Tests:
- 增加历史版本末页定位、重复原文消歧、缺单导出一致性、页码提示、笔迹调节和保留复盘模式的 MCP 回归覆盖。

Chores:
- 为复盘记录增加首次入档版本的数据库字段及兼容旧数据的迁移处理。
@SXP-Simon SXP-Simon closed this Nov 24, 2026
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