From 3c711cbe04d8299c97bf25ceba656f7fa2b8dfdf Mon Sep 17 00:00:00 2001 From: lucaronin Date: Sun, 8 Mar 2026 16:33:59 +0100 Subject: [PATCH] fix: parse lowercase 'archived' frontmatter field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The frontend writes 'archived: true' (lowercase) via handleUpdateFrontmatter, but the Rust parser only recognized 'Archived' (titlecase). This caused all notes archived from within Laputa to be read back as not archived — they continued appearing in the sidebar and note list after restart. Fix: add alias = "archived" to the serde attribute, matching the pattern already used for 'trashed'/'Trashed'. Regression tests added for both lowercase and titlecase variants. --- src-tauri/src/vault/mod.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/vault/mod.rs b/src-tauri/src/vault/mod.rs index b998bae7..74ed8858 100644 --- a/src-tauri/src/vault/mod.rs +++ b/src-tauri/src/vault/mod.rs @@ -108,7 +108,7 @@ struct Frontmatter { owner: Option, #[serde(rename = "Cadence")] cadence: Option, - #[serde(rename = "Archived")] + #[serde(rename = "Archived", alias = "archived")] archived: Option, #[serde(rename = "Trashed", alias = "trashed")] trashed: Option, @@ -1374,6 +1374,28 @@ Company: Acme Corp ); } + #[test] + fn test_parse_archived_lowercase_alias() { + let dir = TempDir::new().unwrap(); + let content = "---\narchived: true\n---\n# Old Quarter\n"; + let entry = parse_test_entry(&dir, "old-quarter.md", content); + assert!( + entry.archived, + "lowercase 'archived' must be parsed via alias (frontend writes lowercase)" + ); + } + + #[test] + fn test_parse_archived_titlecase() { + let dir = TempDir::new().unwrap(); + let content = "---\nArchived: true\n---\n# Old Quarter\n"; + let entry = parse_test_entry(&dir, "old-quarter-2.md", content); + assert!( + entry.archived, + "titlecase 'Archived' must also be parsed" + ); + } + #[test] fn test_trashed_false_when_absent() { let dir = TempDir::new().unwrap();