← Back to Pull requests

M12: head Advanced Search results with the page label (#7870) #7871

Open
unknown opened this pull request with 460 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 19, 2026 17:55 UTC
Author

What this changes

The Advanced Search panel (⇧⌘F) now heads each page's results with the page's label, not its physical number. In a book whose front matter is numbered i, ii, iii and the body 1, 2, 3, a hit on the fourth page was headed Page 4; it is now Page 1, the name the page box, the Pages panel, the Comments panel and the Fields panel already use for that page.

The heading already used the Page {label} string; search_ui::panel filled it with p + 1. The panel now gets the document's pages (&info.pages instead of info.pages.len()) and shows PageInfo::label, which the inspector always fills (the physical number for unlabelled pages, so documents without /PageLabels look the same). A page index past the list falls back to the number, as before.

Fixes #7870

How you verified it

  • cargo fmt --check -p pdfcraft-ui-egui

  • cargo clippy -p pdfcraft-ui-egui --all-targets --no-deps -- -D warnings: clean. Without --no-deps, clippy 1.99.1 stops on clippy::collapsible_match in crates/xfdf/src/xfdf.rs:326, a file this PR does not touch.

  • cargo test -p pdfcraft-ui-egui: lib 1052 passed; it 1934 passed, 10 failed, 4 ignored. The 10 are eight ocr:: tests, comments::the_selection_bar_stays_inside_the_pages_area and editing::a_custom_property_whose_name_the_tools_refuse_is_listed_and_left_alone, the same set #7542 reports failing locally on main; none touch the Search panel.

  • New test viewer::advanced_search_heads_results_with_page_labels: labels a two-page document i, ii, searches, and expects the headings Page i and Page ii and no Page 1/Page 2. With the two src files reverted it fails at get_by_label("Page i"); restored, it passes, together with advanced_search_lists_results_with_context.

  • cargo xtask parity, cargo xtask layers: OK. cargo check -p pdfcraft-ui-egui --target wasm32-unknown-unknown: OK.
  • Never-crash

  • No new unwrap/expect/panic!/unreachable!/todo! outside tests

  • No indexing with input-derived positions (page_info.get(p))

  • No unsafe

  • N/A: no crash fixed
  • Provenance

  • No assets, fonts or copied code. Acrobat shows logical page numbers in its page displays when its "Use logical page numbers" preference is on; I have not compared its search results list specifically.
  • Security

  • N/A: no paths, tools, channels or network access touched
  • Parity and reach

  • view.advanced-search notes and evidence updated; status stays partial (other documents, folders and indexes are still missing).

  • Headless: text_find keeps reporting physical page numbers and doc_info lists each page's label, so an agent can map one to the other; the notes say so. I did not add a label to text_find's output.

  • No docs describe this heading.
  • Anything a reviewer should look at first

    Not changed: two other places put a physical number into the Page {label} string, dialogs/pageboxes.rs:213 (Set Page Boxes) and workflows/combine_grid/card.rs:49 (Combine cards, which show files that are not open, so there is no DocInfo to read). No screenshot: the only visible change is the heading text, which the test asserts.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Advanced Search results now display each page’s label when available, including labels such as Roman numerals, instead of always showing the physical page number.
    * Pages without a label continue to display their one-based page number.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 460 lines (+345 / -115) across 5 files Reviewer: mansur-akhmadi Review duration: 16811m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.46) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 460 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.367
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #7871"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.6% (MEDIUM) · Higher = larger blast radius
    45.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.3% · Safe to merge
    24.3%