From 084d3d9c71d3427bc6a27db5915f775caa6efdc4 Mon Sep 17 00:00:00 2001 From: lucaronin Date: Tue, 14 Apr 2026 17:32:47 +0200 Subject: [PATCH] fix: preserve exact linked note titles --- src/components/NoteItem.test.tsx | 38 +++++++++++++++++++++- src/components/inspector/shared.test.ts | 25 ++++++++++++++ src/components/inspector/shared.ts | 2 +- src/components/note-item/PropertyChips.tsx | 5 ++- 4 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 src/components/inspector/shared.test.ts diff --git a/src/components/NoteItem.test.tsx b/src/components/NoteItem.test.tsx index fd3d19d8..af196441 100644 --- a/src/components/NoteItem.test.tsx +++ b/src/components/NoteItem.test.tsx @@ -240,11 +240,47 @@ describe('NoteItem', () => { ) const chip = screen.getByTestId('property-chip-topics-0') - expect(chip).toHaveTextContent('Ai') + expect(chip).toHaveTextContent('AI') expect(chip).toHaveStyle({ color: 'var(--accent-green)', backgroundColor: 'var(--accent-green-light)' }) expect(chip.querySelector('svg')).not.toBeNull() }) + it('preserves exact linked note title formatting in relationship chips', () => { + const linkedTopic = makeEntry({ + path: '/vault/topic/ai-ml.md', + filename: 'ai-ml.md', + title: 'AI / ML', + isA: 'Topic', + }) + const topicType = makeEntry({ + path: '/vault/type/topic.md', + filename: 'topic.md', + title: 'Topic', + isA: 'Type', + color: 'green', + }) + const sourceEntry = makeEntry({ + path: '/vault/note/source.md', + filename: 'source.md', + title: 'Source', + isA: 'Note', + relationships: { Topics: ['[[topic/ai-ml]]'] }, + }) + + render( + , + ) + + expect(screen.getByTestId('property-chip-topics-0')).toHaveTextContent('AI / ML') + }) + it('opens URL chips on Cmd+click only and keeps regular clicks inert', () => { const entry = makeEntry({ path: '/vault/note/source.md', diff --git a/src/components/inspector/shared.test.ts b/src/components/inspector/shared.test.ts new file mode 100644 index 00000000..e35bc11e --- /dev/null +++ b/src/components/inspector/shared.test.ts @@ -0,0 +1,25 @@ +import { describe, expect, it } from 'vitest' +import { makeEntry } from '../../test-utils/noteListTestUtils' +import { resolveRefProps } from './shared' + +describe('resolveRefProps', () => { + it('uses the resolved entry title for relationship labels', () => { + const linkedTopic = makeEntry({ + path: '/vault/topic/ai-ml.md', + filename: 'ai-ml.md', + title: 'AI / ML', + isA: 'Topic', + }) + const topicType = makeEntry({ + path: '/vault/type/topic.md', + filename: 'topic.md', + title: 'Topic', + isA: 'Type', + color: 'green', + }) + + const props = resolveRefProps('[[topic/ai-ml]]', [linkedTopic, topicType], { Topic: topicType }) + + expect(props.label).toBe('AI / ML') + }) +}) diff --git a/src/components/inspector/shared.ts b/src/components/inspector/shared.ts index 5b24e8e7..7d0b5bfb 100644 --- a/src/components/inspector/shared.ts +++ b/src/components/inspector/shared.ts @@ -31,7 +31,7 @@ export function resolveRefProps(ref: string, entries: VaultEntry[], typeEntryMap const te = typeEntryMap[refType ?? ''] const icon = resolved?.icon return { - label: wikilinkDisplay(ref), + label: resolved?.title ?? wikilinkDisplay(ref), noteIcon: icon ?? null, typeColor: getTypeColor(refType, te?.color), bgColor: getTypeLightColor(refType, te?.color), diff --git a/src/components/note-item/PropertyChips.tsx b/src/components/note-item/PropertyChips.tsx index c0a2536b..ccf668e1 100644 --- a/src/components/note-item/PropertyChips.tsx +++ b/src/components/note-item/PropertyChips.tsx @@ -71,10 +71,9 @@ function resolveRelationshipChip( allEntries: VaultEntry[], typeEntryMap: Record, ): PropertyChipValue | null { - const label = wikilinkDisplay(ref) - if (!label) return null - const targetEntry = resolveEntry(allEntries, wikilinkTarget(ref)) + const label = targetEntry?.title ?? wikilinkDisplay(ref) + if (!label) return null if (!targetEntry) { return { label,