From 4bb491f9a355cd0fd0d21f7c6c1f861d547a7f10 Mon Sep 17 00:00:00 2001 From: Vinay Mehta <14790730+vimeh@users.noreply.github.com> Date: Mon, 16 Feb 2026 01:39:32 -0800 Subject: [PATCH] fix(thread): filter synthetic root node and fix off-by-one in message thread The thread graph includes a synthetic root node with id "0" which caused a panic when parsing IDs and an index-out-of-bounds when displaying message headers. Filter out the root before fetching and use the correct index for display. Refs: #630 --- src/email/message/command/thread.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/email/message/command/thread.rs b/src/email/message/command/thread.rs index aa16db21..05d6d9b4 100644 --- a/src/email/message/command/thread.rs +++ b/src/email/message/command/thread.rs @@ -93,7 +93,10 @@ impl MessageThreadCommand { let ids: Vec<_> = envelopes .graph() .nodes() - .map(|e| e.id.parse::().unwrap()) + .filter_map(|e| { + let id = e.id.parse::().unwrap_or(0); + if id > 0 { Some(id) } else { None } + }) .collect(); let emails = if self.preview { @@ -107,7 +110,7 @@ impl MessageThreadCommand { for (i, email) in emails.to_vec().iter().enumerate() { bodies.push_str(glue); - bodies.push_str(&format!("-------- Message {} --------\n\n", ids[i + 1])); + bodies.push_str(&format!("-------- Message {} --------\n\n", ids[i])); let tpl = email .to_read_tpl(&account_config, |mut tpl| {