From ec6e0da8224a54dd7273adc2a797f149fd9795c8 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Wed, 20 May 2026 12:51:53 +0800
Subject: [PATCH] chore: mark stable baseline as 7.6.0

---
 Apptag/SmartCategorization/SmartStartService.swift |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/Apptag/SmartCategorization/SmartStartService.swift b/Apptag/SmartCategorization/SmartStartService.swift
index 97016f4..52dae14 100644
--- a/Apptag/SmartCategorization/SmartStartService.swift
+++ b/Apptag/SmartCategorization/SmartStartService.swift
@@ -261,7 +261,8 @@
                 source: .localCatalog,
                 reason: "Matched Smart Start catalog entry: \(matched.name)",
                 provenance: matched.sourceEvidence,
-                defaultNote: matched.localizedNote
+                defaultNote: matched.localizedNote,
+                defaultNoteCandidates: matched.notes?.values.map { $0 } ?? []
             ))
         }
 
@@ -314,6 +315,10 @@
                 continue
             }
             if let result = TagDatabase.ensureSystemTag(for: categoryID, in: &store) {
+                if var tagDef = store.tags[result.name] {
+                    tagDef.color = categoryID.defaultColorIndex
+                    store.tags[result.name] = tagDef
+                }
                 if result.created {
                     createdTagCount += 1
                 }
@@ -348,12 +353,21 @@
             }
 
             if let defaultNote = assignment.defaultNote?.trimmingCharacters(in: .whitespacesAndNewlines),
-               !defaultNote.isEmpty,
-               store.appNotes[path]?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty != false {
-                store.appNotes[path] = String(defaultNote.prefix(TagDatabase.maxAppNoteLength))
-                uncommonPaths.insert(path)
-                if store.uncommonSources[path] == nil {
-                    store.uncommonSources[path] = .auto
+               !defaultNote.isEmpty {
+                let currentNote = store.appNotes[path]?.trimmingCharacters(in: .whitespacesAndNewlines)
+                let knownDefaultNotes = Set(assignment.defaultNoteCandidates.compactMap(normalizedNote))
+                let normalizedCurrentNote = normalizedNote(currentNote)
+                let shouldSeedNote = currentNote?.isEmpty != false
+                    || normalizedCurrentNote.map { knownDefaultNotes.contains($0) } == true
+
+                if shouldSeedNote {
+                    store.appNotes[path] = String(defaultNote.prefix(TagDatabase.maxAppNoteLength))
+                    if currentNote?.isEmpty != false {
+                        uncommonPaths.insert(path)
+                        if store.uncommonSources[path] == nil {
+                            store.uncommonSources[path] = .auto
+                        }
+                    }
                 }
             }
         }

--
Gitblit v1.9.3