Skip to content

fix(gui): fix pages argument for precise kernel and remove dead babeldoc code - #1181

Open
raappo wants to merge 2 commits into
PDFMathTranslate:mainfrom
raappo:main
Open

raappo wants to merge 2 commits into
PDFMathTranslate:mainfrom
raappo:main

Conversation

@raappo

@raappo raappo commented Sep 1, 2026 •

Copy link
Copy Markdown

Fixes #713

Changes

  • Fix Page Indexing: The GUI collects 0-based page integers internally, but the pdf2zh_next CLI strictly expects 1-based page arguments. Updated v2_bridge.py to correctly shift the indices by +1 when passing the arguments to the precise kernel.
  • Dead Code Removal: Cleaned up the unused babeldoc_translate_file function in gui.py. This logic was deprecated during the migration to the KernelRegistry mechanism in commit 84efe44, and its presence was misleading as translations are now solely executed via kernel.translate().

Copilot AI lite review requested due to automatic review settings September 1, 2026 08:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The updated pages conversion changes existing v2-bridge behavior without corresponding test updates, and the BabelDOC GUI cleanup appears incomplete (unused model-loader code remains).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR addresses the GUI “pages” selection bug for the precise (v2) kernel by correcting page index conversion when bridging v1-style requests to v2 CLI args, and removes a large block of unused BabelDOC GUI translation code.

Changes:

  • Adjust v2_bridge to convert 0-based page index lists into 1-based v2 --pages CLI strings.
  • Remove the unused babeldoc_translate_file implementation from the GUI codepath.
File summaries
File Description
pdf2zh/kernel/v2_bridge.py Fixes v1→v2 pages conversion so precise kernel receives correct --pages values.
pdf2zh/gui.py Deletes dead BabelDOC translation function code from the GUI module.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pdf2zh/kernel/v2_bridge.py
Comment thread pdf2zh/gui.py
Comment on lines 399 to 401
# Global setup
custom_blue = gr.themes.Color(
c50="#E8F3FF",
Comment thread pdf2zh/kernel/v2_bridge.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The page-index fix is consistent with existing CLI parsing (0-based internal) and is covered by an updated unit test, and the removed GUI code has no remaining references in the repo.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

This branch has not been deployed

No deployments
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.

bug(babeldoc gui): pages not work

2 participants