PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
fix(comments): a status whose comment can't be found is listed nowhere
alehel931b9a599a71
diff --git a/ROADMAP.md b/ROADMAP.mdindex 47f3351b0..65e509f11 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -199,7 +199,7 @@ Ranked; detail and the full milestone table in [docs/roadmap.md](docs/roadmap.md- **2026-10-20 (M3, #3535):** Escape with a menu open closes the menu and keeps the text selection; the next Escape clears it, as before. One keypress used to do both. A synthetic UI regression checks it. Estimates unchanged.- **2026-10-16 (M3, close prompt keyboard):** The "Save changes?" prompt opens with Save chosen (Enter saves, as before) and the arrow keys and Tab / Shift+Tab move the choice to Cancel or Don't save, shown with a focus ring; Enter or Space press the chosen button and Escape still cancels. Before, Enter always saved whatever was Tab-focused. Estimates unchanged.- **2026-10-21 (M3, #3808):** Page thumbnails in the Inspector can be resized independently from the document and Organize, with a slider, buttons and `thumbnail-zoom` control option. Selection, page following and reload are covered by regressions. Estimates unchanged.-- **2026-10-22 (M5, comment threads):** Replies join the comment their `/IRT` references, not every comment sharing its `/NM`; PyMuPDF names each page's first comment `fitz-A0`, so all replies used to land under page 1. The Comments header counts comments without their replies (28, as Acrobat says, for a file it used to call 44) with the replies in small text under it ("16 replies", in every catalogue), and a reply's thread line runs from the avatar above it to its own. A reply to a reply shows in its thread in the panel too (it was listed nowhere), an `/IRT` that leads to no comment (itself, a loop, a pop-up, an unlisted object) leaves its annotation a comment of its own instead of hiding it, and a Replace Text caret isn't counted as a reply. The comment tools refuse an `id` several comments share instead of acting on the first (page 1's), and take `page` + `index` for those; `comment_list` reads a status or checkmark from the annotation it was set on, as the panel does, and reports a reply's own on the reply. UI, engine and automation regressions cover it. Estimates unchanged.+- **2026-10-22 (M5, comment threads):** Replies join the comment their `/IRT` references, not every comment sharing its `/NM`; PyMuPDF names each page's first comment `fitz-A0`, so all replies used to land under page 1. The Comments header counts comments without their replies (28, as Acrobat says, for a file it used to call 44) with the replies in small text under it ("16 replies", in every catalogue), and a reply's thread line runs from the avatar above it to its own. A reply to a reply shows in its thread in the panel too (it was listed nowhere), an `/IRT` that leads to no comment (itself, a loop, a pop-up, an unlisted object) leaves its annotation a comment of its own instead of hiding it (a status or checkmark that leads nowhere is listed nowhere), and a Replace Text caret isn't counted as a reply. The comment tools refuse an `id` several comments share instead of acting on the first (page 1's), and take `page` + `index` for those; `comment_list` reads a status or checkmark from the annotation it was set on, as the panel does, and reports a reply's own on the reply. UI, engine and automation regressions cover it. Estimates unchanged.- **2026-10-22 (M2, #3107 / PR #3438):** Inline-image parsing falls back to the existing EI heuristic when missing declared samples, headers or terminators exceed the content-window budget, instead of waiting for an impossible allocation. Exact-length parsing for available samples and ordinary large streamed images is retained. Estimates unchanged.- **2026-10-21 (M14, Brazilian Portuguese):** Completed the `pt-br` catalog against the current 2,674-key union, including signature validation and accessibility messages; no build or compilation run. Localization remains partial because help and unpredictable engine/OS error details are not translated.- **2026-10-21 (M14, #3557):** Preferences: the OK button stays below the scrolling settings instead of being the last thing in them, so it is in reach in a short window.diff --git a/crates/automation/src/comments.rs b/crates/automation/src/comments.rsindex 0ebf622e9..876c0ca2f 100644--- a/crates/automation/src/comments.rs+++ b/crates/automation/src/comments.rs@@ -228,7 +228,7 @@ impl Automation {};let roots: Vec<Value> = all.iter()- .filter(|c| !c.is_reply() && only.is_none_or(|p| c.page == p))+ .filter(|c| c.is_comment() && only.is_none_or(|p| c.page == p)).map(|c| {let mut v = view(c);states(c, &mut v);diff --git a/crates/automation/tests/it/automation.rs b/crates/automation/tests/it/automation.rsindex d5a06d350..cffcab4d3 100644--- a/crates/automation/tests/it/automation.rs+++ b/crates/automation/tests/it/automation.rs@@ -2122,21 +2122,24 @@ trailer << /Root 1 0 R >>}/// A status or checkmark belongs to the annotation its `/IRT` names: one set on a reply is not-/// its comment's, as the Comments panel shows it, and is reported on the reply.+/// its comment's, as the Comments panel shows it, and is reported on the reply. One whose+/// annotation can't be found is not a comment of its own.#[test]fn a_checkmark_on_a_reply_is_not_its_comments() {let dir = workdir("reply-checkmark");- // Contributor-original PDF: a comment, a reply, and a checkmark and a status on the reply.+ // Contributor-original PDF: a comment, a reply, a checkmark and a status on the reply, and a+ // status whose annotation (object 9) doesn't exist.std::fs::write(dir.join("checked.pdf"),b"%PDF-1.71 0 obj << /Type /Catalog /Pages 2 0 R >> endobj2 0 obj << /Type /Pages /Kids [3 0 R] /Count 1 >> endobj-3 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 300 200] /Annots [4 0 R 5 0 R 6 0 R 7 0 R] >> endobj+3 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 300 200] /Annots [4 0 R 5 0 R 6 0 R 7 0 R 8 0 R] >> endobj4 0 obj << /Type /Annot /Subtype /Text /Rect [100 100 120 120] /T (Alpha) /Contents (COMMENT) >> endobj5 0 obj << /Type /Annot /Subtype /Text /Rect [100 60 120 80] /IRT 4 0 R /T (Beta) /Contents (REPLY) >> endobj6 0 obj << /Type /Annot /Subtype /Text /Rect [100 60 120 80] /IRT 5 0 R /T (Beta) /StateModel /Marked /State /Marked >> endobj7 0 obj << /Type /Annot /Subtype /Text /Rect [100 60 120 80] /IRT 5 0 R /T (Beta) /StateModel /Review /State /Accepted >> endobj+8 0 obj << /Type /Annot /Subtype /Text /Rect [200 20 220 40] /F 30 /IRT 9 0 R /T (Gamma) /StateModel /Review /State /Rejected >> endobjtrailer << /Root 1 0 R >>%%EOF",)diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rsindex e64bbcb61..42238e775 100644--- a/crates/engine/src/lib.rs+++ b/crates/engine/src/lib.rs@@ -5331,7 +5331,7 @@ pub fn comment_kind(a: &pdfcraft_render::Annotation) -> &str {/// pop-ups; the number is the comment's position on its page.pub fn comment_summary(name: &str, all: &[pdfcraft_render::Annotation], sort: SummarySort) -> String {use std::fmt::Write;- let top: Vec<&pdfcraft_render::Annotation> = all.iter().filter(|a| !a.is_reply() && a.state.is_none()).collect();+ let top: Vec<&pdfcraft_render::Annotation> = all.iter().filter(|a| a.is_comment()).collect();// Each reply under the annotation its `/IRT` points at, in document order, gathered once.type Children<'a> = std::collections::HashMap<(usize, usize), Vec<&'a pdfcraft_render::Annotation>>;let mut children = Children::new();diff --git a/crates/render/src/inspect.rs b/crates/render/src/inspect.rsindex f65a9b697..15e10898c 100644--- a/crates/render/src/inspect.rs+++ b/crates/render/src/inspect.rs@@ -461,6 +461,13 @@ impl Annotation {self.parent.is_some()}+ /// A comment of its own: not a reply, and not a status or checkmark. One whose comment can't+ /// be found (deleted from another page, or never listed) has nothing to show, so it is listed+ /// nowhere: not as a card, on the page or in a count.+ pub fn is_comment(&self) -> bool {+ !self.is_reply() && self.state.is_none()+ }+/// Whether this annotation's `/IRT` points at `other`.pub fn replies_to(&self, other: &Annotation) -> bool {self.parent == Some((other.page, other.index))diff --git a/crates/ui-egui/src/comments.rs b/crates/ui-egui/src/comments.rsindex 0ff321978..86ef9efbf 100644--- a/crates/ui-egui/src/comments.rs+++ b/crates/ui-egui/src/comments.rs@@ -624,7 +624,7 @@ impl PageCx<'_> {/// Top-level comments on this page, in paint order.fn comments(&self) -> impl Iterator<Item = &Annotation> {- self.info.annotations.iter().filter(move |a| !self.hidden && a.page == self.page && !a.is_reply() && a.subtype != "Popup")+ self.info.annotations.iter().filter(move |a| !self.hidden && a.page == self.page && a.is_comment() && a.subtype != "Popup")}/// Where a comment is on screen: one rectangle, or one per marked line for text markup.diff --git a/crates/ui-egui/src/comments_panel.rs b/crates/ui-egui/src/comments_panel.rsindex 260fab6e5..2fe11e98f 100644--- a/crates/ui-egui/src/comments_panel.rs+++ b/crates/ui-egui/src/comments_panel.rs@@ -91,7 +91,7 @@ pub fn is_marked(thread: &[&Annotation]) -> bool {/// The number shown in the header: comments, not their replies or status changes (as Acrobat/// counts them).pub fn count(info: &DocInfo) -> usize {- info.annotations.iter().filter(|a| !a.is_reply() && a.state.is_none()).count()+ info.annotations.iter().filter(|a| a.is_comment()).count()}/// The replies under the header's count, at any depth: not status changes, checkmarks or a@@ -178,7 +178,7 @@ pub(crate) fn show(if let Some(parent) = a.parent {let key = if a.state.is_none() { tops.get(&(a.page, a.index)).copied().unwrap_or(parent) } else { parent };replies.entry(key).or_default().push(a);- } else {+ } else if a.is_comment() {let count = page_counts.entry(a.page).or_default();*count = count.saturating_add(1);}@@ -190,7 +190,7 @@ pub(crate) fn show(let mut roots: Vec<&Annotation> = info.annotations.iter()- .filter(|a| !a.is_reply())+ .filter(|a| a.is_comment()).filter(|a| query.as_deref().is_none_or(|q| matches(a, q) || replies_of(a).iter().any(|r| matches(r, q)))).filter(|a| !cv.hidden_types.iter().any(|t| t == kind_label(a))).filter(|a| !cv.hidden_authors.contains(&a.author.clone().unwrap_or_default()))@@ -550,13 +550,13 @@ fn legible(c: Color32, t: &Tokens) -> Color32 {pub(crate) fn header_controls(ui: &mut egui::Ui, info: &DocInfo, view: &mut DocView, hidden: bool) -> Option<&'static str> {let mut command = None;let cv = &mut view.comments;- let mut types: Vec<String> = info.annotations.iter().filter(|a| !a.is_reply()).map(|a| kind_label(a).to_string()).collect();+ let mut types: Vec<String> = info.annotations.iter().filter(|a| a.is_comment()).map(|a| kind_label(a).to_string()).collect();types.sort();types.dedup();- let mut authors: Vec<String> = info.annotations.iter().filter(|a| !a.is_reply()).map(|a| a.author.clone().unwrap_or_default()).collect();+ let mut authors: Vec<String> = info.annotations.iter().filter(|a| a.is_comment()).map(|a| a.author.clone().unwrap_or_default()).collect();authors.sort();authors.dedup();- let mut colors: Vec<(String, Option<[f32; 3]>)> = info.annotations.iter().filter(|a| !a.is_reply()).map(|a| (color_key(a), a.color)).collect();+ let mut colors: Vec<(String, Option<[f32; 3]>)> = info.annotations.iter().filter(|a| a.is_comment()).map(|a| (color_key(a), a.color)).collect();colors.sort_by(|a, b| a.0.cmp(&b.0));colors.dedup_by(|a, b| a.0 == b.0);let active = !(cv.hidden_types.is_empty()diff --git a/crates/ui-egui/tests/it/comments.rs b/crates/ui-egui/tests/it/comments.rsindex 1b8f289c1..29dcd0ce7 100644--- a/crates/ui-egui/tests/it/comments.rs+++ b/crates/ui-egui/tests/it/comments.rs@@ -1206,12 +1206,13 @@ trailer << /Root 1 0 R >>%%EOF";// Contributor-original PDF. Page 1: an unnamed comment with a reply and a reply to that reply,-// and a Replace Text strikeout with its grouped caret. Page 2: an `/IRT` to the annotation-// itself, to an annotation no page lists (object 11), to a pop-up, to a link and to a form field.+// a Replace Text strikeout with its grouped caret, and a hidden status whose comment no page+// lists. Page 2: an `/IRT` to the annotation itself, to an annotation no page lists (object 11),+// to a pop-up, to a link and to a form field.const THREAD_EDGES: &[u8] = b"%PDF-1.71 0 obj << /Type /Catalog /Pages 2 0 R >> endobj2 0 obj << /Type /Pages /Kids [3 0 R 4 0 R] /Count 2 >> endobj-3 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 300 200] /Annots [5 0 R 6 0 R 7 0 R 8 0 R 9 0 R] >> endobj+3 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 300 200] /Annots [5 0 R 6 0 R 7 0 R 8 0 R 9 0 R 19 0 R] >> endobj4 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 300 200] /Annots [10 0 R 12 0 R 13 0 R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R] >> endobj5 0 obj << /Type /Annot /Subtype /Text /Rect [20 160 40 180] /T (Alpha) /Contents (Unnamed parent) >> endobj6 0 obj << /Type /Annot /Subtype /Text /Rect [20 160 40 180] /IRT 5 0 R /T (Beta) /Contents (Direct reply) >> endobj@@ -1227,12 +1228,16 @@ const THREAD_EDGES: &[u8] = b"%PDF-1.716 0 obj << /Type /Annot /Subtype /Widget /FT /Tx /T (field) /Rect [200 60 260 80] >> endobj17 0 obj << /Type /Annot /Subtype /Text /Rect [20 50 40 70] /IRT 15 0 R /T (Delta) /Contents (Points at a link) >> endobj18 0 obj << /Type /Annot /Subtype /Text /Rect [20 20 40 40] /IRT 16 0 R /T (Delta) /Contents (Points at a form field) >> endobj+19 0 obj << /Type /Annot /Subtype /Text /Rect [240 20 260 40] /F 30 /IRT 11 0 R /T (Delta) /StateModel /Review /State /Accepted /Contents (Stray status) >> endobjtrailer << /Root 1 0 R >>%%EOF";#[test]fn replies_that_lead_nowhere_stay_comments_and_deeper_replies_join_their_thread() {- let h = harness_with_bytes(THREAD_EDGES.to_vec(), |app| app.set_option("panel", "comments").unwrap());+ let mut h = harness_with_bytes(THREAD_EDGES.to_vec(), |app| {+ app.set_option("panel", "comments").unwrap();+ app.set_option("quick", "select").unwrap();+ });// An `/IRT` that reaches no listed comment leaves its annotation a comment of its own,// rather than a reply shown nowhere.// Links, form widgets and pop-ups are never parents: neither reader lists them as comments.@@ -1248,6 +1253,11 @@ fn replies_that_lead_nowhere_stay_comments_and_deeper_replies_join_their_thread(// replies, not the Replace Text caret grouped with its strikeout.h.get_by_label("7");h.get_by_label("2 replies");+ // A status whose comment no page lists is not a comment: no card, and nothing to pick on the+ // page where it sits.+ assert_eq!(h.query_all_by_label("Stray status").count(), 0);+ click_pt(&mut h, (250.0, 30.0));+ assert_eq!(h.state().views[0].comments.selected, None);}// Contributor-original PDF: a comment, a reply, and a checkmark and a status set on the reply.