fix(ai): sidebar-nav-v1 also canonicalises wrong-glyph icons via label

Why: f1923ff1 added coerceNavTabIcon to bottom-nav-v1 and noted that
sidebar-nav-v1 should adopt the same helper. Without it, a sidebar
nav with \`{ label: 'Profile', icon: 'profile' }\` would still render
a placeholder circle (resolver doesn't know "profile" is a known
wrong-glyph alias for "user") instead of the lucide:user glyph.

What: import coerceNavTabIcon and apply it in buildItemV1 before
stamping iconFontName onto the Icon child node. Same convention
single-sourced. Existing 1435 tests still pass — no test relied on
the prior pass-through behavior for known wrong-glyph names.
This commit is contained in:
Fini 2026-05-09 20:59:48 +08:00
parent ac8dfcee1b
commit 9fd6abb8ea

View file

@ -1,3 +1,4 @@
import { coerceNavTabIcon } from './coerce-params.js';
import type { ElementTree } from './helpers.js';
import { resolveTheme, type V1Theme } from './resolve-theme.js';
@ -99,6 +100,10 @@ function buildItemV1(
inactiveLabelColor: string,
): ElementTree {
const active = item.active === true;
// Same wrong-glyph swap pattern as bottom-nav-v1 (Cart→shopping-cart,
// Profile→user, etc). Reuses the shared helper so the convention is
// single-sourced.
const icon = coerceNavTabIcon(item.label, item.icon, 'buildSidebarNavV1');
const node: ElementTree = {
type: 'frame',
name: `Item (${item.label})`,
@ -115,7 +120,7 @@ function buildItemV1(
type: 'icon_font',
name: 'Icon',
role: 'sidebar-nav-icon',
iconFontName: item.icon,
iconFontName: icon,
iconFontFamily: 'lucide',
width: 18,
height: 18,