From 3e6f72f5f4f906a208cb2387224d25b89d5f1ea1 Mon Sep 17 00:00:00 2001 From: Muse Sweep Date: Sat, 24 Oct 2026 15:37:52 -0500 Subject: [PATCH 1/2] fix(id/web): classify_tag only treats auto-{ISO_DATE} names as auto-backups Any filename starting with 'auto-' was classified FileKind::Auto even when the remainder was not a date, so ordinary files like auto-notes.txt sorted out of the primary list and rendered with an 'auto: ?' badge. Gate the Auto classification on parse_iso_timestamp succeeding, and add regression tests for non-date auto- names. Fixes #809 --- pkgs/id/src/web/routes.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pkgs/id/src/web/routes.rs b/pkgs/id/src/web/routes.rs index 141998d9c..e46383ed9 100644 --- a/pkgs/id/src/web/routes.rs +++ b/pkgs/id/src/web/routes.rs @@ -150,10 +150,12 @@ pub struct FileInfo { fn classify_tag(name: &str) -> (FileKind, Option) { // Check for auto-backup: "auto-{ISO_DATE}" if let Some(iso_str) = name.strip_prefix("auto-") { - // Try to parse the ISO date to extract a unix timestamp - // Format: 2026-03-12T06:42:30.015Z - let ts = parse_iso_timestamp(iso_str); - return (FileKind::Auto, ts); + // Only an auto-backup when the remainder actually parses as an + // ISO date (format: 2026-03-12T06:42:30.015Z). An ordinary file + // that merely starts with "auto-" (auto-notes.txt) is Primary. + if let Some(ts) = parse_iso_timestamp(iso_str) { + return (FileKind::Auto, Some(ts)); + } } // Check for archive: "{name}.archive.{unix_timestamp}" @@ -2427,6 +2429,17 @@ mod tests { assert!(ts.is_some()); } + #[test] + fn test_classify_tag_auto_prefix_non_date_is_primary() { + // Regression (#809): an ordinary file that merely starts with + // "auto-" is not an auto-backup — only "auto-{ISO_DATE}" is. + for name in ["auto-notes.txt", "auto-2026-report.md", "auto-", "auto-draft"] { + let (kind, ts) = classify_tag(name); + assert_eq!(kind, FileKind::Primary, "{name}"); + assert!(ts.is_none(), "{name}"); + } + } + #[test] fn test_classify_tag_archive() { let (kind, ts) = classify_tag("notes.md.archive.1711000000"); From 8fc8c38a6ca032266a9d00b61ae3bff0dbd51e75 Mon Sep 17 00:00:00 2001 From: Muse Sweep Date: Sat, 24 Oct 2026 19:10:04 -0500 Subject: [PATCH 2/2] style(id-web): rustfmt the #809 classify_tag regression test The for-loop array in test_classify_tag_auto_prefix_non_date_is_primary exceeded the line width; cargo-fmt-check / rustfmt-check / treefmt-check failed on PR #810 for this file only. Applies rustfmt's own layout. --- pkgs/id/src/web/routes.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/id/src/web/routes.rs b/pkgs/id/src/web/routes.rs index e46383ed9..4ea8f5b43 100644 --- a/pkgs/id/src/web/routes.rs +++ b/pkgs/id/src/web/routes.rs @@ -2433,7 +2433,12 @@ mod tests { fn test_classify_tag_auto_prefix_non_date_is_primary() { // Regression (#809): an ordinary file that merely starts with // "auto-" is not an auto-backup — only "auto-{ISO_DATE}" is. - for name in ["auto-notes.txt", "auto-2026-report.md", "auto-", "auto-draft"] { + for name in [ + "auto-notes.txt", + "auto-2026-report.md", + "auto-", + "auto-draft", + ] { let (kind, ts) = classify_tag(name); assert_eq!(kind, FileKind::Primary, "{name}"); assert!(ts.is_none(), "{name}");