From 02772bc343cc206c149b69e84bb0da3497bda1d2 Mon Sep 17 00:00:00 2001 From: 134 Date: Mon, 29 Jun 2026 17:30:50 +0800 Subject: [PATCH] fix: preserve custom canvas skill tags on upgrade --- lib/canvas-skill-tags.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/canvas-skill-tags.ts b/lib/canvas-skill-tags.ts index 6a2a03810..367a4f1e9 100644 --- a/lib/canvas-skill-tags.ts +++ b/lib/canvas-skill-tags.ts @@ -224,18 +224,11 @@ export function normalizeCanvasSkillTags(value: unknown): CanvasSkillTag[] { function mergeCanvasSkillTagsWithDefaultUpdates(value: unknown): CanvasSkillTag[] { const currentTags = normalizeCanvasSkillTags(value); - const currentById = new Map(currentTags.map((tag) => [tag.id, tag])); - const defaultIds = new Set(DEFAULT_CANVAS_SKILL_TAGS.map((tag) => tag.id)); - const merged: CanvasSkillTag[] = DEFAULT_CANVAS_SKILL_TAGS.map((defaultTag) => { - const currentTag = currentById.get(defaultTag.id); - return currentTag?.iconUrl ? { ...defaultTag, iconUrl: currentTag.iconUrl } : defaultTag; - }); - - currentTags.forEach((tag) => { - if (!defaultIds.has(tag.id)) { - merged.push(tag); - } - }); + const currentIds = new Set(currentTags.map((tag) => tag.id)); + const missingDefaultTags = DEFAULT_CANVAS_SKILL_TAGS.filter( + (defaultTag) => !currentIds.has(defaultTag.id) + ); + const merged: CanvasSkillTag[] = [...currentTags, ...missingDefaultTags]; return normalizeCanvasSkillTags(merged); }