From 8bd83908912f5698c011cfda9c1d9b505c428de7 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 22:34:34 +0200 Subject: [PATCH 01/14] feat(search): add TagService.findByNameContaining for NL tag resolution Co-Authored-By: Claude Sonnet 4.6 --- .../org/raddatz/familienarchiv/tag/TagService.java | 4 ++++ .../raddatz/familienarchiv/tag/TagServiceTest.java | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/tag/TagService.java b/backend/src/main/java/org/raddatz/familienarchiv/tag/TagService.java index 0a077a2d..361d7d22 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/tag/TagService.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/tag/TagService.java @@ -46,6 +46,10 @@ public class TagService { return enrichWithRelatives(matched); } + public List findByNameContaining(String fragment) { + return tagRepository.findByNameContainingIgnoreCase(fragment); + } + public Tag getById(UUID id) { return tagRepository.findById(id) .orElseThrow(() -> DomainException.notFound(ErrorCode.TAG_NOT_FOUND, "Tag not found: " + id)); diff --git a/backend/src/test/java/org/raddatz/familienarchiv/tag/TagServiceTest.java b/backend/src/test/java/org/raddatz/familienarchiv/tag/TagServiceTest.java index d0373f7b..3c097073 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/tag/TagServiceTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/tag/TagServiceTest.java @@ -666,4 +666,17 @@ class TagServiceTest { // verify findAllById was called at least twice: once for extras, once inside resolveEffectiveColors verify(tagRepository, atLeastOnce()).findAllById(any()); } + + // ─── findByNameContaining ───────────────────────────────────────────────── + + @Test + void findByNameContaining_delegatesToRepository() { + Tag krieg = Tag.builder().id(UUID.randomUUID()).name("Krieg").build(); + when(tagRepository.findByNameContainingIgnoreCase("krieg")).thenReturn(List.of(krieg)); + + List result = tagService.findByNameContaining("krieg"); + + assertThat(result).containsExactly(krieg); + verify(tagRepository).findByNameContainingIgnoreCase("krieg"); + } } -- 2.49.1 From 8905135006f728b223515c8cafe2ea29d0a2b060 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 22:35:24 +0200 Subject: [PATCH 02/14] feat(search): add TagHint record for NL tag resolution API surface Co-Authored-By: Claude Sonnet 4.6 --- .../org/raddatz/familienarchiv/search/TagHint.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 backend/src/main/java/org/raddatz/familienarchiv/search/TagHint.java diff --git a/backend/src/main/java/org/raddatz/familienarchiv/search/TagHint.java b/backend/src/main/java/org/raddatz/familienarchiv/search/TagHint.java new file mode 100644 index 00000000..c488796f --- /dev/null +++ b/backend/src/main/java/org/raddatz/familienarchiv/search/TagHint.java @@ -0,0 +1,14 @@ +package org.raddatz.familienarchiv.search; + +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.UUID; + +public record TagHint( + @Schema(requiredMode = Schema.RequiredMode.REQUIRED) + UUID id, + @Schema(requiredMode = Schema.RequiredMode.REQUIRED) + String name, + String color +) { +} -- 2.49.1 From 7eee688ce9f7844a31035f057c4e8ba2b04d5eb6 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 22:37:45 +0200 Subject: [PATCH 03/14] feat(search): extend NlQueryInterpretation with resolvedTags + tagsApplied Positional record fields added; all 3 construction sites updated with neutral defaults; NlQueryParserService wired for TagService (4th constructor arg); NlQueryParserServiceTest and NlSearchControllerTest synced. Co-Authored-By: Claude Sonnet 4.6 --- .../familienarchiv/search/NlQueryInterpretation.java | 6 +++++- .../familienarchiv/search/NlQueryParserService.java | 12 +++++++++--- .../search/NlQueryParserServiceTest.java | 6 +++++- .../search/NlSearchControllerTest.java | 4 ++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryInterpretation.java b/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryInterpretation.java index 5313f093..37611488 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryInterpretation.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryInterpretation.java @@ -15,8 +15,12 @@ public record NlQueryInterpretation( @Schema(requiredMode = Schema.RequiredMode.REQUIRED) List keywords, @Schema(requiredMode = Schema.RequiredMode.REQUIRED) + List resolvedTags, + @Schema(requiredMode = Schema.RequiredMode.REQUIRED) String rawQuery, @Schema(requiredMode = Schema.RequiredMode.REQUIRED) - boolean keywordsApplied + boolean keywordsApplied, + @Schema(requiredMode = Schema.RequiredMode.REQUIRED) + boolean tagsApplied ) { } diff --git a/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java b/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java index 5938fb5e..4bf043e8 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java @@ -10,12 +10,15 @@ import org.raddatz.familienarchiv.exception.DomainException; import org.raddatz.familienarchiv.exception.ErrorCode; import org.raddatz.familienarchiv.person.Person; import org.raddatz.familienarchiv.person.PersonService; +import org.raddatz.familienarchiv.tag.Tag; import org.raddatz.familienarchiv.tag.TagOperator; +import org.raddatz.familienarchiv.tag.TagService; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.time.LocalDate; import java.util.ArrayList; +import java.util.LinkedHashSet; import java.util.List; import java.util.UUID; @@ -28,10 +31,13 @@ public class NlQueryParserService { private static final int MAX_QUERY = 500; private static final int MAX_NAME_LENGTH = 200; private static final int MAX_CANDIDATES = 10; + private static final int MIN_TAG_TERM = 3; + private static final int MAX_RESOLVED_TAGS = 10; private final OllamaClient ollamaClient; private final PersonService personService; private final DocumentService documentService; + private final TagService tagService; public NlSearchResponse search(String query, Pageable pageable) { if (query == null || query.length() < MIN_QUERY || query.length() > MAX_QUERY) { @@ -50,7 +56,7 @@ public class NlQueryParserService { NlQueryInterpretation interpretation = new NlQueryInterpretation( List.of(), resolution.ambiguous(), ext.dateFrom(), ext.dateTo(), - keywords, ext.rawQuery(), false); + keywords, List.of(), ext.rawQuery(), false, false); return new NlSearchResponse(DocumentSearchResult.of(List.of()), interpretation); } @@ -65,7 +71,7 @@ public class NlQueryParserService { DocumentSearchResult docs = documentService.searchDocumentsByPersonId( personId, ext.dateFrom(), ext.dateTo(), pageable); NlQueryInterpretation interpretation = new NlQueryInterpretation( - resolved, List.of(), ext.dateFrom(), ext.dateTo(), keywords, ext.rawQuery(), false); + resolved, List.of(), ext.dateFrom(), ext.dateTo(), keywords, List.of(), ext.rawQuery(), false, false); return new NlSearchResponse(docs, interpretation); } @@ -82,7 +88,7 @@ public class NlQueryParserService { DocumentSearchResult docs = documentService.searchDocuments(filters, DocumentSort.DATE, "desc", pageable); boolean keywordsApplied = !text.isBlank(); NlQueryInterpretation interpretation = new NlQueryInterpretation( - resolved, List.of(), ext.dateFrom(), ext.dateTo(), keywords, ext.rawQuery(), keywordsApplied); + resolved, List.of(), ext.dateFrom(), ext.dateTo(), keywords, List.of(), ext.rawQuery(), keywordsApplied, false); return new NlSearchResponse(docs, interpretation); } diff --git a/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java b/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java index 65d73685..aa79b94a 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java @@ -13,7 +13,9 @@ import org.raddatz.familienarchiv.exception.DomainException; import org.raddatz.familienarchiv.exception.ErrorCode; import org.raddatz.familienarchiv.person.Person; import org.raddatz.familienarchiv.person.PersonService; +import org.raddatz.familienarchiv.tag.Tag; import org.raddatz.familienarchiv.tag.TagOperator; +import org.raddatz.familienarchiv.tag.TagService; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -32,6 +34,7 @@ class NlQueryParserServiceTest { @Mock OllamaClient ollamaClient; @Mock PersonService personService; @Mock DocumentService documentService; + @Mock TagService tagService; NlQueryParserService service; @@ -40,11 +43,12 @@ class NlQueryParserServiceTest { @BeforeEach void setUp() { MockitoAnnotations.openMocks(this); - service = new NlQueryParserService(ollamaClient, personService, documentService); + service = new NlQueryParserService(ollamaClient, personService, documentService, tagService); when(documentService.searchDocuments(any(), any(), any(), any())) .thenReturn(DocumentSearchResult.of(List.of())); when(documentService.searchDocumentsByPersonId(any(), any(), any(), any())) .thenReturn(DocumentSearchResult.of(List.of())); + when(tagService.findByNameContaining(anyString())).thenReturn(List.of()); } // --- Factory helpers --- diff --git a/backend/src/test/java/org/raddatz/familienarchiv/search/NlSearchControllerTest.java b/backend/src/test/java/org/raddatz/familienarchiv/search/NlSearchControllerTest.java index b35b1c52..c0d30f40 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/search/NlSearchControllerTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/search/NlSearchControllerTest.java @@ -48,7 +48,7 @@ class NlSearchControllerTest { PersonHint hint = new PersonHint(UUID.randomUUID(), "Walter Raddatz"); NlQueryInterpretation interp = new NlQueryInterpretation( List.of(hint), List.of(), null, null, - List.of("Krieg"), "Briefe von Walter im Krieg", true); + List.of("Krieg"), List.of(), "Briefe von Walter im Krieg", true, false); return new NlSearchResponse(DocumentSearchResult.of(List.of()), interp); } @@ -77,7 +77,7 @@ class NlSearchControllerTest { PersonHint b = new PersonHint(UUID.randomUUID(), "Walter Schmidt"); NlQueryInterpretation interp = new NlQueryInterpretation( List.of(), List.of(a, b), null, null, - List.of(), "Briefe von Walter", false); + List.of(), List.of(), "Briefe von Walter", false, false); NlSearchResponse resp = new NlSearchResponse(DocumentSearchResult.of(List.of()), interp); when(nlQueryParserService.search(anyString(), any())).thenReturn(resp); -- 2.49.1 From e94414b81a1ecf9687f061e879baf49018087a03 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 22:49:54 +0200 Subject: [PATCH 04/14] refactor(search): extract ChipType to chip-types.ts; audit NL fixtures Pre-implementation step for #743: ChipType union extracted from InterpretationChipRow and +page.svelte into shared chip-types.ts; resolvedTags/tagsApplied neutral defaults added to test fixtures. Co-Authored-By: Claude Sonnet 4.6 --- frontend/e2e/nl-search.spec.ts | 4 +++- frontend/src/routes/documents/+page.svelte | 3 +-- frontend/src/routes/search/InterpretationChipRow.svelte | 3 ++- .../src/routes/search/InterpretationChipRow.svelte.spec.ts | 2 ++ frontend/src/routes/search/chip-types.ts | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 frontend/src/routes/search/chip-types.ts diff --git a/frontend/e2e/nl-search.spec.ts b/frontend/e2e/nl-search.spec.ts index bd869582..65ede99f 100644 --- a/frontend/e2e/nl-search.spec.ts +++ b/frontend/e2e/nl-search.spec.ts @@ -13,8 +13,10 @@ const interpretation = { dateFrom: '1914-01-01', dateTo: '1918-12-31', keywords: ['krieg'], + resolvedTags: [{ id: '33333333-3333-3333-3333-333333333333', name: 'Weltkrieg', color: 'sage' }], rawQuery: 'Was hat Walter an Emma im Krieg geschrieben?', - keywordsApplied: true + keywordsApplied: true, + tagsApplied: true }; const nlResponse = { diff --git a/frontend/src/routes/documents/+page.svelte b/frontend/src/routes/documents/+page.svelte index b9a2ece5..5481e729 100644 --- a/frontend/src/routes/documents/+page.svelte +++ b/frontend/src/routes/documents/+page.svelte @@ -10,6 +10,7 @@ import BulkSelectionBar from '$lib/document/BulkSelectionBar.svelte'; import TimelineDensityFilter from '$lib/document/TimelineDensityFilter.svelte'; import SmartSearchStatus from '../search/SmartSearchStatus.svelte'; import InterpretationChipRow from '../search/InterpretationChipRow.svelte'; +import type { ChipType } from '../search/chip-types.js'; import DisambiguationPicker from '../search/DisambiguationPicker.svelte'; import { bulkSelectionStore } from '$lib/document/bulkSelection.svelte'; import { getErrorMessage, parseBackendError } from '$lib/shared/errors'; @@ -269,8 +270,6 @@ function paramsFromInterpretation(interp: NlQueryInterpretation) { }; } -type ChipType = 'sender' | 'directional' | 'date' | 'keyword'; - function removeChip(type: ChipType, value?: string) { if (!nlInterpretation) return; const p = paramsFromInterpretation(nlInterpretation); diff --git a/frontend/src/routes/search/InterpretationChipRow.svelte b/frontend/src/routes/search/InterpretationChipRow.svelte index 8e9cdbc0..62a26c81 100644 --- a/frontend/src/routes/search/InterpretationChipRow.svelte +++ b/frontend/src/routes/search/InterpretationChipRow.svelte @@ -3,8 +3,9 @@ import { SvelteSet } from 'svelte/reactivity'; import { m } from '$lib/paraglide/messages.js'; import type { components } from '$lib/generated/api'; +import type { ChipType } from './chip-types.js'; + type NlQueryInterpretation = components['schemas']['NlQueryInterpretation']; -type ChipType = 'sender' | 'directional' | 'date' | 'keyword'; let { interpretation, diff --git a/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts b/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts index f3164389..59b82e0b 100644 --- a/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts +++ b/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts @@ -17,8 +17,10 @@ const makeInterpretation = ( resolvedPersons: [], ambiguousPersons: [], keywords: [], + resolvedTags: [], rawQuery: 'test', keywordsApplied: true, + tagsApplied: false, ...overrides }); diff --git a/frontend/src/routes/search/chip-types.ts b/frontend/src/routes/search/chip-types.ts new file mode 100644 index 00000000..d78c58b8 --- /dev/null +++ b/frontend/src/routes/search/chip-types.ts @@ -0,0 +1 @@ +export type ChipType = 'sender' | 'directional' | 'date' | 'keyword' | 'theme'; -- 2.49.1 From fc557bd9ae33ed0312dd5f7c5694655caff19179 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 22:54:33 +0200 Subject: [PATCH 05/14] =?UTF-8?q?feat(search):=20implement=20keyword?= =?UTF-8?q?=E2=86=92tag=20resolution=20in=20NlQueryParserService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keywords that substring-match the tag taxonomy become OR-union tag filters; non-matching keywords stay as FTS text. Resolved tags surface in the NlQueryInterpretation as TagHint objects with effective colours. The rawQuery fallback is now guarded by hadStructuredMatch to prevent double-apply when all keywords resolve. Co-Authored-By: Claude Sonnet 4.6 --- .../search/NlQueryParserService.java | 63 ++++++++++++++++--- .../search/NlQueryParserServiceTest.java | 37 +++++++++++ 2 files changed, 93 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java b/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java index 4bf043e8..41d3dbd2 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java @@ -50,6 +50,11 @@ public class NlQueryParserService { List personNames = ext.personNames() != null ? ext.personNames() : List.of(); List keywords = ext.keywords() != null ? ext.keywords() : List.of(); + TagResolution tagResolution = resolveTags(keywords); + List resolvedTagHints = tagResolution.hints(); + List resolvedTagNames = tagResolution.tagNames(); + List remainingKeywords = tagResolution.remaining(); + NameResolution resolution = resolveNames(personNames); if (!resolution.ambiguous().isEmpty()) { @@ -64,31 +69,35 @@ public class NlQueryParserService { List noMatchFragments = resolution.noMatchFragments(); List extraFragments = resolution.extraFragments(); - String text = buildText(keywords, noMatchFragments, extraFragments, ext.rawQuery()); + boolean hadStructuredMatch = !resolvedTagHints.isEmpty() || !resolved.isEmpty(); + String text = buildText(remainingKeywords, noMatchFragments, extraFragments, ext.rawQuery(), hadStructuredMatch); if (resolved.size() == 1 && isAnyRole(ext.personRole())) { UUID personId = resolved.get(0).id(); DocumentSearchResult docs = documentService.searchDocumentsByPersonId( personId, ext.dateFrom(), ext.dateTo(), pageable); NlQueryInterpretation interpretation = new NlQueryInterpretation( - resolved, List.of(), ext.dateFrom(), ext.dateTo(), keywords, List.of(), ext.rawQuery(), false, false); + resolved, List.of(), ext.dateFrom(), ext.dateTo(), keywords, resolvedTagHints, ext.rawQuery(), false, false); return new NlSearchResponse(docs, interpretation); } UUID sender = buildSender(resolved, ext.personRole()); UUID receiver = buildReceiver(resolved, ext.personRole()); + boolean tagsApplied = !resolvedTagHints.isEmpty(); + TagOperator tagOperator = tagsApplied ? TagOperator.OR : TagOperator.AND; + SearchFilters filters = new SearchFilters( text.isBlank() ? null : text, ext.dateFrom(), ext.dateTo(), sender, receiver, - List.of(), null, - null, TagOperator.AND, false); + resolvedTagNames, null, + null, tagOperator, false); DocumentSearchResult docs = documentService.searchDocuments(filters, DocumentSort.DATE, "desc", pageable); boolean keywordsApplied = !text.isBlank(); NlQueryInterpretation interpretation = new NlQueryInterpretation( - resolved, List.of(), ext.dateFrom(), ext.dateTo(), keywords, List.of(), ext.rawQuery(), keywordsApplied, false); + resolved, List.of(), ext.dateFrom(), ext.dateTo(), keywords, resolvedTagHints, ext.rawQuery(), keywordsApplied, tagsApplied); return new NlSearchResponse(docs, interpretation); } @@ -128,14 +137,48 @@ public class NlQueryParserService { return new NameResolution(resolved, ambiguous, noMatchFragments, extraFragments); } + private TagResolution resolveTags(List keywords) { + LinkedHashSet seen = new LinkedHashSet<>(); + List remaining = new ArrayList<>(); + + for (String kw : keywords) { + if (kw == null || kw.length() < MIN_TAG_TERM) { + remaining.add(kw); + continue; + } + List matches = tagService.findByNameContaining(kw); + if (matches.isEmpty()) { + remaining.add(kw); + } else { + seen.addAll(matches); + } + } + + if (seen.size() > MAX_RESOLVED_TAGS) { + log.debug("Keyword matched {} tags; capping at {}", seen.size(), MAX_RESOLVED_TAGS); + } + List capped = seen.size() > MAX_RESOLVED_TAGS + ? new ArrayList<>(seen).subList(0, MAX_RESOLVED_TAGS) + : new ArrayList<>(seen); + + tagService.resolveEffectiveColors(capped); + + List hints = capped.stream() + .map(t -> new TagHint(t.getId(), t.getName(), t.getColor())) + .toList(); + List tagNames = capped.stream().map(Tag::getName).toList(); + + return new TagResolution(hints, tagNames, remaining); + } + private String buildText(List keywords, List noMatchFragments, - List extraFragments, String rawQuery) { + List extraFragments, String rawQuery, boolean hadStructuredMatch) { List parts = new ArrayList<>(); parts.addAll(keywords); parts.addAll(noMatchFragments); parts.addAll(extraFragments); String text = String.join(" ", parts).strip(); - if (text.isBlank() && rawQuery != null && !rawQuery.isBlank()) { + if (text.isBlank() && !hadStructuredMatch && rawQuery != null && !rawQuery.isBlank()) { return rawQuery; } return text; @@ -163,4 +206,10 @@ public class NlQueryParserService { List noMatchFragments, List extraFragments ) {} + + private record TagResolution( + List hints, + List tagNames, + List remaining + ) {} } diff --git a/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java b/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java index aa79b94a..29eaf0f9 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java @@ -441,4 +441,41 @@ class NlQueryParserServiceTest { assertThat(resp.interpretation().keywordsApplied()).isTrue(); } + + // --- Tag resolution helpers --- + + private Tag tag(UUID id, String name) { + return Tag.builder().id(id).name(name).build(); + } + + private Tag tag(UUID id, String name, String color) { + return Tag.builder().id(id).name(name).color(color).build(); + } + + private TagHint tagHint(UUID id, String name, String color) { + return new TagHint(id, name, color); + } + + private static final UUID T1 = UUID.fromString("00000000-0000-0000-0001-000000000001"); + + // --- 24. Single keyword resolves to one tag → tag filter applied --- + + @Test + void search_singleKeywordResolvesToTag_appliesTagFilter() { + Tag hochzeit = tag(T1, "Hochzeit"); + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("Hochzeit"))); + when(tagService.findByNameContaining("Hochzeit")).thenReturn(List.of(hochzeit)); + + NlSearchResponse resp = service.search("Briefe über Hochzeit", PAGE); + + ArgumentCaptor cap = ArgumentCaptor.forClass(SearchFilters.class); + verify(documentService).searchDocuments(cap.capture(), any(), any(), any()); + assertThat(cap.getValue().tags()).containsExactly("Hochzeit"); + assertThat(cap.getValue().tagOperator()).isEqualTo(TagOperator.OR); + assertThat(resp.interpretation().resolvedTags()).hasSize(1); + assertThat(resp.interpretation().resolvedTags().get(0).name()).isEqualTo("Hochzeit"); + assertThat(resp.interpretation().tagsApplied()).isTrue(); + assertThat(cap.getValue().text()).isNull(); + } } -- 2.49.1 From 6cb1025881a84414ac53b03fc7ebadec27097479 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 22:57:17 +0200 Subject: [PATCH 06/14] test(search): add 11 tag-resolution test cases to NlQueryParserServiceTest Covers multi-tag match, no-match FTS fallback, mixed resolution, personRole bypass, cap at 10, short-keyword skip, dedup, rawQuery suppression when all keywords resolve, flag independence, colour propagation via resolveEffectiveColors, and colour=null when depth constraint prevents resolution. Co-Authored-By: Claude Sonnet 4.6 --- .../search/NlQueryParserServiceTest.java | 198 ++++++++++++++++++ 1 file changed, 198 insertions(+) diff --git a/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java b/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java index 29eaf0f9..d1e9c970 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/search/NlQueryParserServiceTest.java @@ -21,6 +21,7 @@ import org.springframework.data.domain.Pageable; import java.time.LocalDate; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -478,4 +479,201 @@ class NlQueryParserServiceTest { assertThat(resp.interpretation().tagsApplied()).isTrue(); assertThat(cap.getValue().text()).isNull(); } + + private static final UUID T2 = UUID.fromString("00000000-0000-0000-0001-000000000002"); + + // --- 25. Keyword matches multiple tags → all in resolvedTags, OR-union --- + + @Test + void search_keywordMatchesMultipleTags_allIncluded() { + Tag hochzeit1 = tag(T1, "Hochzeit Raddatz"); + Tag hochzeit2 = tag(T2, "Hochzeit Braun"); + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("Hochzeit"))); + when(tagService.findByNameContaining("Hochzeit")).thenReturn(List.of(hochzeit1, hochzeit2)); + + NlSearchResponse resp = service.search("Briefe über Hochzeit", PAGE); + + ArgumentCaptor cap = ArgumentCaptor.forClass(SearchFilters.class); + verify(documentService).searchDocuments(cap.capture(), any(), any(), any()); + assertThat(cap.getValue().tags()).containsExactlyInAnyOrder("Hochzeit Raddatz", "Hochzeit Braun"); + assertThat(cap.getValue().tagOperator()).isEqualTo(TagOperator.OR); + assertThat(resp.interpretation().resolvedTags()).hasSize(2); + } + + // --- 26. Keyword no tag match → stays as FTS text, resolvedTags empty --- + + @Test + void search_keywordNoTagMatch_staysAsFtsText() { + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("Feldpost"))); + + NlSearchResponse resp = service.search("Feldpost Briefe", PAGE); + + ArgumentCaptor cap = ArgumentCaptor.forClass(SearchFilters.class); + verify(documentService).searchDocuments(cap.capture(), any(), any(), any()); + assertThat(cap.getValue().text()).contains("Feldpost"); + assertThat(cap.getValue().tags()).isEmpty(); + assertThat(resp.interpretation().resolvedTags()).isEmpty(); + assertThat(resp.interpretation().tagsApplied()).isFalse(); + } + + // --- 27. Mixed: one keyword resolves, one doesn't → tag filter + FTS text --- + + @Test + void search_mixedKeywords_oneResolves_oneStaysAsText() { + Tag hochzeit = tag(T1, "Hochzeit"); + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("Hochzeit", "Feldpost"))); + when(tagService.findByNameContaining("Hochzeit")).thenReturn(List.of(hochzeit)); + + NlSearchResponse resp = service.search("Hochzeit und Feldpost", PAGE); + + ArgumentCaptor cap = ArgumentCaptor.forClass(SearchFilters.class); + verify(documentService).searchDocuments(cap.capture(), any(), any(), any()); + assertThat(cap.getValue().tags()).containsExactly("Hochzeit"); + assertThat(cap.getValue().tagOperator()).isEqualTo(TagOperator.OR); + assertThat(cap.getValue().text()).contains("Feldpost"); + assertThat(resp.interpretation().resolvedTags()).hasSize(1); + assertThat(resp.interpretation().tagsApplied()).isTrue(); + } + + // --- 28. personRole=any + 1 person + resolvable keyword → personId search, tagsApplied=false --- + + @Test + void search_personRoleAny_singlePerson_resolvableKeyword_tagsAppliedFalse() { + Person walter = person(P1, "Walter", "Raddatz"); + Tag hochzeit = tag(T1, "Hochzeit"); + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of("Walter"), "any", null, null, List.of("Hochzeit"))); + when(personService.findByDisplayNameContaining("Walter")).thenReturn(List.of(walter)); + when(tagService.findByNameContaining("Hochzeit")).thenReturn(List.of(hochzeit)); + + NlSearchResponse resp = service.search("Briefe von Walter über Hochzeit", PAGE); + + verify(documentService).searchDocumentsByPersonId(eq(P1), isNull(), isNull(), eq(PAGE)); + verify(documentService, never()).searchDocuments(any(), any(), any(), any()); + assertThat(resp.interpretation().tagsApplied()).isFalse(); + assertThat(resp.interpretation().resolvedTags()).hasSize(1); + assertThat(resp.interpretation().resolvedTags().get(0).name()).isEqualTo("Hochzeit"); + } + + // --- 29. Cap: keyword matches > 10 tags → capped at 10 --- + + @Test + void search_keywordMatchesMoreThanMaxTags_cappedAtTen() { + List eleven = new ArrayList<>(); + for (int i = 0; i < 11; i++) { + eleven.add(tag(UUID.randomUUID(), "Thema " + i)); + } + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("Thema"))); + when(tagService.findByNameContaining("Thema")).thenReturn(eleven); + + NlSearchResponse resp = service.search("Dokumente zum Thema", PAGE); + + assertThat(resp.interpretation().resolvedTags()).hasSize(10); + ArgumentCaptor cap = ArgumentCaptor.forClass(SearchFilters.class); + verify(documentService).searchDocuments(cap.capture(), any(), any(), any()); + assertThat(cap.getValue().tags()).hasSize(10); + } + + // --- 30. Short keyword (< 3 chars) → skipped, not passed to TagService --- + + @Test + void search_shortKeyword_skippedByTagResolution() { + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("ab", "Krieg"))); + + service.search("ab Krieg", PAGE); + + verify(tagService, never()).findByNameContaining("ab"); + verify(tagService).findByNameContaining("Krieg"); + ArgumentCaptor cap = ArgumentCaptor.forClass(SearchFilters.class); + verify(documentService).searchDocuments(cap.capture(), any(), any(), any()); + assertThat(cap.getValue().text()).contains("ab"); + } + + // --- 31. Dedup: same tag matched by two keywords → appears once --- + + @Test + void search_sameTagMatchedByTwoKeywords_deduplicatedToOne() { + Tag hochzeit = tag(T1, "Hochzeit"); + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("Hochzeit", "hoch"))); + when(tagService.findByNameContaining("Hochzeit")).thenReturn(List.of(hochzeit)); + when(tagService.findByNameContaining("hoch")).thenReturn(List.of(hochzeit)); + + NlSearchResponse resp = service.search("Hochzeit hoch", PAGE); + + assertThat(resp.interpretation().resolvedTags()).hasSize(1); + ArgumentCaptor cap = ArgumentCaptor.forClass(SearchFilters.class); + verify(documentService).searchDocuments(cap.capture(), any(), any(), any()); + assertThat(cap.getValue().tags()).hasSize(1); + } + + // --- 32. All keywords resolve → rawQuery fallback suppressed, text=null --- + + @Test + void search_allKeywordsResolveToTags_rawQueryFallbackSuppressed() { + Tag hochzeit = tag(T1, "Hochzeit"); + when(ollamaClient.parse(anyString())) + .thenReturn(new OllamaExtraction(List.of(), "any", null, null, List.of("Hochzeit"), "raw query text")); + when(tagService.findByNameContaining("Hochzeit")).thenReturn(List.of(hochzeit)); + + NlSearchResponse resp = service.search("Hochzeit", PAGE); + + ArgumentCaptor cap = ArgumentCaptor.forClass(SearchFilters.class); + verify(documentService).searchDocuments(cap.capture(), any(), any(), any()); + assertThat(cap.getValue().text()).isNull(); + assertThat(cap.getValue().tags()).containsExactly("Hochzeit"); + } + + // --- 33. Flag independence: keywordsApplied=false AND tagsApplied=true --- + + @Test + void search_allKeywordsResolveToTags_keywordsAppliedFalse_tagsAppliedTrue() { + Tag hochzeit = tag(T1, "Hochzeit"); + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("Hochzeit"))); + when(tagService.findByNameContaining("Hochzeit")).thenReturn(List.of(hochzeit)); + + NlSearchResponse resp = service.search("Hochzeit Briefe", PAGE); + + assertThat(resp.interpretation().keywordsApplied()).isFalse(); + assertThat(resp.interpretation().tagsApplied()).isTrue(); + } + + // --- 34. Color carried through from resolveEffectiveColors --- + + @Test + void search_tagHint_carriesColorSetByResolveEffectiveColors() { + Tag hochzeit = tag(T1, "Hochzeit"); + doAnswer(invocation -> { + Collection tags = invocation.getArgument(0); + tags.forEach(t -> t.setColor("sage")); + return null; + }).when(tagService).resolveEffectiveColors(any()); + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("Hochzeit"))); + when(tagService.findByNameContaining("Hochzeit")).thenReturn(List.of(hochzeit)); + + NlSearchResponse resp = service.search("Hochzeit", PAGE); + + assertThat(resp.interpretation().resolvedTags().get(0).color()).isEqualTo("sage"); + } + + // --- 35. Color stays null when resolveEffectiveColors leaves it unset --- + + @Test + void search_tagHint_colorIsNull_whenNoColorResolved() { + Tag hochzeit = tag(T1, "Hochzeit"); + when(ollamaClient.parse(anyString())) + .thenReturn(extraction(List.of(), "any", null, null, List.of("Hochzeit"))); + when(tagService.findByNameContaining("Hochzeit")).thenReturn(List.of(hochzeit)); + + NlSearchResponse resp = service.search("Hochzeit", PAGE); + + assertThat(resp.interpretation().resolvedTags().get(0).color()).isNull(); + } } -- 2.49.1 From 86690fdbb6e71732fae101ed6e9a72d414075981 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 22:59:07 +0200 Subject: [PATCH 07/14] test(search): DataJpaTest for descendant-expansion via TagRepository Verifies the recursive CTE in findDescendantIdsByName expands a parent tag to include all child IDs, and that findByNameContainingIgnoreCase matches both parent and child names when the fragment appears in both. Co-Authored-By: Claude Sonnet 4.6 --- .../NlSearchTagResolutionIntegrationTest.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 backend/src/test/java/org/raddatz/familienarchiv/search/NlSearchTagResolutionIntegrationTest.java diff --git a/backend/src/test/java/org/raddatz/familienarchiv/search/NlSearchTagResolutionIntegrationTest.java b/backend/src/test/java/org/raddatz/familienarchiv/search/NlSearchTagResolutionIntegrationTest.java new file mode 100644 index 00000000..bbe0a88b --- /dev/null +++ b/backend/src/test/java/org/raddatz/familienarchiv/search/NlSearchTagResolutionIntegrationTest.java @@ -0,0 +1,56 @@ +package org.raddatz.familienarchiv.search; + +import org.junit.jupiter.api.Test; +import org.raddatz.familienarchiv.PostgresContainerConfig; +import org.raddatz.familienarchiv.config.FlywayConfig; +import org.raddatz.familienarchiv.tag.Tag; +import org.raddatz.familienarchiv.tag.TagRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest; +import org.springframework.context.annotation.Import; + +import java.util.List; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataJpaTest +@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) +@Import({PostgresContainerConfig.class, FlywayConfig.class}) +class NlSearchTagResolutionIntegrationTest { + + @Autowired + private TagRepository tagRepository; + + @Test + void findDescendantIdsByName_parentName_includesChildId() { + Tag parent = tagRepository.save(Tag.builder().name("Krieg").build()); + Tag child = tagRepository.save(Tag.builder().name("Weltkrieg").parentId(parent.getId()).build()); + + List ids = tagRepository.findDescendantIdsByName("Krieg"); + + assertThat(ids).containsExactlyInAnyOrder(parent.getId(), child.getId()); + } + + @Test + void findDescendantIdsByName_childName_returnsOnlyChild() { + Tag parent = tagRepository.save(Tag.builder().name("Krieg").build()); + Tag child = tagRepository.save(Tag.builder().name("Weltkrieg").parentId(parent.getId()).build()); + + List ids = tagRepository.findDescendantIdsByName("Weltkrieg"); + + assertThat(ids).containsExactly(child.getId()); + assertThat(ids).doesNotContain(parent.getId()); + } + + @Test + void findByNameContainingIgnoreCase_parentSubstring_matchesParentOnly() { + Tag parent = tagRepository.save(Tag.builder().name("Krieg").build()); + tagRepository.save(Tag.builder().name("Weltkrieg").parentId(parent.getId()).build()); + + List found = tagRepository.findByNameContainingIgnoreCase("Krieg"); + + assertThat(found).extracting(Tag::getName).containsExactlyInAnyOrder("Krieg", "Weltkrieg"); + } +} -- 2.49.1 From 573bca49861ce5a3ec1d1812721aadc17b5bfb7e Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 22:59:58 +0200 Subject: [PATCH 08/14] feat(i18n): add search_chip_theme_prefix to de/en/es message bundles Co-Authored-By: Claude Sonnet 4.6 --- frontend/messages/de.json | 1 + frontend/messages/en.json | 1 + frontend/messages/es.json | 1 + 3 files changed, 3 insertions(+) diff --git a/frontend/messages/de.json b/frontend/messages/de.json index 1315a8c7..5ea1b00a 100644 --- a/frontend/messages/de.json +++ b/frontend/messages/de.json @@ -42,6 +42,7 @@ "search_chip_sender": "Absender", "search_chip_date": "Zeitraum", "search_chip_keyword": "Stichwort", + "search_chip_theme_prefix": "Thema", "search_chip_directional_label": "Von {from} zu {to}, Filter entfernen", "search_disambiguation_trigger_label": "Mehrere Personen gefunden — zum Auswählen klicken", "search_disambiguation_cue": "(auswählen…)", diff --git a/frontend/messages/en.json b/frontend/messages/en.json index a1315bdc..be3af0ce 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -42,6 +42,7 @@ "search_chip_sender": "Sender", "search_chip_date": "Period", "search_chip_keyword": "Keyword", + "search_chip_theme_prefix": "Topic", "search_chip_directional_label": "From {from} to {to}, remove filter", "search_disambiguation_trigger_label": "Several people found — click to choose", "search_disambiguation_cue": "(choose…)", diff --git a/frontend/messages/es.json b/frontend/messages/es.json index 86f2c52e..c5fb2fc8 100644 --- a/frontend/messages/es.json +++ b/frontend/messages/es.json @@ -42,6 +42,7 @@ "search_chip_sender": "Remitente", "search_chip_date": "Período", "search_chip_keyword": "Palabra clave", + "search_chip_theme_prefix": "Tema", "search_chip_directional_label": "De {from} a {to}, eliminar filtro", "search_disambiguation_trigger_label": "Se encontraron varias personas — haga clic para elegir", "search_disambiguation_cue": "(elegir…)", -- 2.49.1 From 847874abb385240a92ba854983381bd8e6f3a44d Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 23:01:11 +0200 Subject: [PATCH 09/14] feat(api): add TagHint schema and extend NlQueryInterpretation with resolvedTags/tagsApplied Manual update since Docker compose backend runs old build; regenerate with npm run generate:api once new backend is deployed. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/lib/generated/api.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/lib/generated/api.ts b/frontend/src/lib/generated/api.ts index 33d0904c..20653696 100644 --- a/frontend/src/lib/generated/api.ts +++ b/frontend/src/lib/generated/api.ts @@ -1905,8 +1905,10 @@ export interface components { /** Format: date */ dateTo?: string; keywords: string[]; + resolvedTags: components["schemas"]["TagHint"][]; rawQuery: string; keywordsApplied: boolean; + tagsApplied: boolean; }; NlSearchResponse: { result: components["schemas"]["DocumentSearchResult"]; @@ -1917,6 +1919,12 @@ export interface components { id: string; displayName: string; }; + TagHint: { + /** Format: uuid */ + id: string; + name: string; + color?: string; + }; SearchMatchData: { transcriptionSnippet?: string; titleOffsets: components["schemas"]["MatchOffset"][]; -- 2.49.1 From 5387bc92470fa0737ef05566af2338043607aaad Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 23:33:53 +0200 Subject: [PATCH 10/14] feat(search): render removable theme chips in InterpretationChipRow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When tagsApplied is true, each resolvedTag renders as a 'Thema: Name' chip with optional inline color style from the tag's resolved color. Clicking × calls onRemoveChip('theme', tag.name). Co-Authored-By: Claude Sonnet 4.6 --- .../search/InterpretationChipRow.svelte | 53 ++++++++++++- .../InterpretationChipRow.svelte.spec.ts | 76 +++++++++++++++++++ 2 files changed, 126 insertions(+), 3 deletions(-) diff --git a/frontend/src/routes/search/InterpretationChipRow.svelte b/frontend/src/routes/search/InterpretationChipRow.svelte index 62a26c81..2356a774 100644 --- a/frontend/src/routes/search/InterpretationChipRow.svelte +++ b/frontend/src/routes/search/InterpretationChipRow.svelte @@ -6,6 +6,7 @@ import type { components } from '$lib/generated/api'; import type { ChipType } from './chip-types.js'; type NlQueryInterpretation = components['schemas']['NlQueryInterpretation']; +type TagHint = components['schemas']['TagHint']; let { interpretation, @@ -19,7 +20,8 @@ type Chip = | { key: string; type: 'sender'; label: string } | { key: string; type: 'directional'; from: string; to: string } | { key: string; type: 'date'; label: string } - | { key: string; type: 'keyword'; value: string; label: string }; + | { key: string; type: 'keyword'; value: string; label: string } + | { key: string; type: 'theme'; tag: TagHint; label: string }; // Locally removed chips. The parent remounts this component (via {#key}) on every // new NL search, so this set never needs an explicit reset. @@ -36,9 +38,22 @@ function dateRangeLabel(from: string | undefined, to: string | undefined): strin return fromYear ?? toYear ?? ''; } +function tagColorStyle(color: string | undefined): string | undefined { + if (!color) return undefined; + return `background-color: var(--c-tag-${color}); border-left-color: var(--c-tag-${color})`; +} + const chips = $derived.by(() => { const list: Chip[] = []; - const { resolvedPersons, dateFrom, dateTo, keywords, keywordsApplied } = interpretation; + const { + resolvedPersons, + dateFrom, + dateTo, + keywords, + keywordsApplied, + resolvedTags, + tagsApplied + } = interpretation; if (resolvedPersons.length >= 2) { list.push({ @@ -74,6 +89,17 @@ const chips = $derived.by(() => { } } + if (tagsApplied) { + for (const tag of resolvedTags) { + list.push({ + key: 'theme:' + tag.id, + type: 'theme', + tag, + label: `${m.search_chip_theme_prefix()}: ${tag.name}` + }); + } + } + return list.filter((chip) => !removed.has(chip.key)); }); @@ -83,7 +109,13 @@ const showKeywordsNotApplied = $derived( function remove(chip: Chip) { removed.add(chip.key); - onRemoveChip(chip.type, chip.type === 'keyword' ? chip.value : undefined); + if (chip.type === 'keyword') { + onRemoveChip(chip.type, chip.value); + } else if (chip.type === 'theme') { + onRemoveChip(chip.type, chip.tag.name); + } else { + onRemoveChip(chip.type, undefined); + } } const nameSpan = 'sm:max-w-[12rem] max-w-[8rem] truncate'; @@ -113,6 +145,21 @@ const removeButton = + {:else if chip.type === 'theme'} + + {m.search_chip_theme_prefix()}: + {chip.tag.name} + + {:else} {chip.label} diff --git a/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts b/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts index 59b82e0b..9cefc628 100644 --- a/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts +++ b/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts @@ -6,6 +6,7 @@ import type { components } from '$lib/generated/api'; type NlQueryInterpretation = components['schemas']['NlQueryInterpretation']; type PersonHint = components['schemas']['PersonHint']; +type TagHint = components['schemas']['TagHint']; afterEach(() => cleanup()); @@ -132,4 +133,79 @@ describe('InterpretationChipRow', () => { .element(page.getByRole('button', { name: new RegExp('Absender') })) .toBeInTheDocument(); }); + + // ── theme chips ───────────────────────────────────────────────────────────── + + const makeTag = (id: string, name: string, color?: string): TagHint => ({ id, name, color }); + + it('renders theme chips when tagsApplied is true', async () => { + const { container } = render(InterpretationChipRow, { + interpretation: makeInterpretation({ + resolvedTags: [makeTag('t1', 'Hochzeit')], + tagsApplied: true + }), + onRemoveChip: vi.fn() + }); + expect(container.querySelectorAll('[data-chip-type="theme"]')).toHaveLength(1); + await expect.element(page.getByText(/Thema: Hochzeit/)).toBeInTheDocument(); + }); + + it('renders no theme chips when tagsApplied is false', async () => { + const { container } = render(InterpretationChipRow, { + interpretation: makeInterpretation({ + resolvedTags: [makeTag('t1', 'Hochzeit')], + tagsApplied: false + }), + onRemoveChip: vi.fn() + }); + expect(container.querySelectorAll('[data-chip-type="theme"]')).toHaveLength(0); + }); + + it('renders exactly N theme chips for N resolved tags', async () => { + const { container } = render(InterpretationChipRow, { + interpretation: makeInterpretation({ + resolvedTags: [makeTag('t1', 'Krieg'), makeTag('t2', 'Hochzeit'), makeTag('t3', 'Familie')], + tagsApplied: true + }), + onRemoveChip: vi.fn() + }); + expect(container.querySelectorAll('[data-chip-type="theme"]')).toHaveLength(3); + }); + + it('calls onRemoveChip with "theme" and tag name when × is clicked', async () => { + const onRemoveChip = vi.fn(); + render(InterpretationChipRow, { + interpretation: makeInterpretation({ + resolvedTags: [makeTag('t1', 'Hochzeit')], + tagsApplied: true + }), + onRemoveChip + }); + await page.getByRole('button', { name: /Thema: Hochzeit/ }).click(); + expect(onRemoveChip).toHaveBeenCalledWith('theme', 'Hochzeit'); + }); + + it('applies inline color style for a tag with a color', async () => { + const { container } = render(InterpretationChipRow, { + interpretation: makeInterpretation({ + resolvedTags: [makeTag('t1', 'Hochzeit', 'sage')], + tagsApplied: true + }), + onRemoveChip: vi.fn() + }); + const chip = container.querySelector('[data-chip-type="theme"]') as HTMLElement; + expect(chip.style.backgroundColor).toBeTruthy(); + }); + + it('omits color style for a tag with no color', async () => { + const { container } = render(InterpretationChipRow, { + interpretation: makeInterpretation({ + resolvedTags: [makeTag('t1', 'Hochzeit')], + tagsApplied: true + }), + onRemoveChip: vi.fn() + }); + const chip = container.querySelector('[data-chip-type="theme"]') as HTMLElement; + expect(chip.getAttribute('style')).toBeFalsy(); + }); }); -- 2.49.1 From 2a7e13371704b825e72acab3188c3f9a2af7f3c9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 23:40:33 +0200 Subject: [PATCH 11/14] feat(search): wire theme chip removal to URL navigation in +page.svelte Co-Authored-By: Claude Sonnet 4.6 --- frontend/e2e/nl-search.spec.ts | 30 ++++++- frontend/src/routes/documents/+page.svelte | 6 ++ .../documents/theme-chip-removal.spec.ts | 85 +++++++++++++++++++ .../routes/documents/theme-chip-removal.ts | 26 ++++++ 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 frontend/src/routes/documents/theme-chip-removal.spec.ts create mode 100644 frontend/src/routes/documents/theme-chip-removal.ts diff --git a/frontend/e2e/nl-search.spec.ts b/frontend/e2e/nl-search.spec.ts index 65ede99f..210ad173 100644 --- a/frontend/e2e/nl-search.spec.ts +++ b/frontend/e2e/nl-search.spec.ts @@ -58,9 +58,10 @@ test.describe('NL (smart) search — happy path', () => { // Loading panel announced to screen readers. await expect(page.getByText(/Archiv wird befragt/)).toBeVisible(); - // Directional chip (Walter → Emma) + keyword chip render once the fixture resolves. + // Directional chip (Walter → Emma) + keyword chip + theme chip render once the fixture resolves. await expect(page.getByText('→')).toBeVisible(); await expect(page.getByText('Stichwort: krieg')).toBeVisible(); + await expect(page.getByText(/Thema:.*Weltkrieg/)).toBeVisible(); // Accessibility — light mode. const lightScan = await new AxeBuilder({ page }) @@ -82,4 +83,31 @@ test.describe('NL (smart) search — happy path', () => { await page.waitForURL(/senderId=11111111-1111-1111-1111-111111111111/); await expect(page).toHaveURL(/receiverId=22222222-2222-2222-2222-222222222222/); }); + + test('removing the last theme chip drops tag/tagOp but keeps person params', async ({ page }) => { + await page.route('**/api/search/nl', async (route) => { + await route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify(nlResponse) + }); + }); + + await page.goto('/documents'); + await page.waitForSelector('[data-hydrated]'); + await page.getByRole('button', { name: /Text/ }).click(); + + const input = page.getByPlaceholder('Titel, Personen, Tags durchsuchen…'); + await input.fill('Was hat Walter an Emma im Krieg geschrieben?'); + await input.press('Enter'); + + await expect(page.getByText(/Thema:.*Weltkrieg/)).toBeVisible(); + + // Remove the single theme chip — URL must carry sender UUID but no tag/tagOp. + await page.getByRole('button', { name: 'Filter entfernen: Thema: Weltkrieg' }).click(); + await page.waitForURL(/senderId=11111111-1111-1111-1111-111111111111/); + const url = page.url(); + expect(url).not.toMatch(/tag=/); + expect(url).not.toMatch(/tagOp=/); + }); }); diff --git a/frontend/src/routes/documents/+page.svelte b/frontend/src/routes/documents/+page.svelte index 5481e729..7e836964 100644 --- a/frontend/src/routes/documents/+page.svelte +++ b/frontend/src/routes/documents/+page.svelte @@ -11,6 +11,7 @@ import TimelineDensityFilter from '$lib/document/TimelineDensityFilter.svelte'; import SmartSearchStatus from '../search/SmartSearchStatus.svelte'; import InterpretationChipRow from '../search/InterpretationChipRow.svelte'; import type { ChipType } from '../search/chip-types.js'; +import { buildThemeRemovalUrl } from './theme-chip-removal.js'; import DisambiguationPicker from '../search/DisambiguationPicker.svelte'; import { bulkSelectionStore } from '$lib/document/bulkSelection.svelte'; import { getErrorMessage, parseBackendError } from '$lib/shared/errors'; @@ -284,6 +285,11 @@ function removeChip(type: ChipType, value?: string) { } else if (type === 'keyword' && value) { const remaining = nlInterpretation.keywords.filter((keyword) => keyword !== value); p.q = remaining.join(' '); + } else if (type === 'theme' && value) { + const url = buildThemeRemovalUrl(nlInterpretation, value); + resetNlState(); + goto(url, { keepFocus: true, noScroll: true }); + return; } applyResolvedAndSearch(p); } diff --git a/frontend/src/routes/documents/theme-chip-removal.spec.ts b/frontend/src/routes/documents/theme-chip-removal.spec.ts new file mode 100644 index 00000000..f39edec0 --- /dev/null +++ b/frontend/src/routes/documents/theme-chip-removal.spec.ts @@ -0,0 +1,85 @@ +import { describe, it, expect } from 'vitest'; +import { buildThemeRemovalUrl } from './theme-chip-removal.js'; +import type { components } from '$lib/generated/api'; + +type NlQueryInterpretation = components['schemas']['NlQueryInterpretation']; + +function makeInterp(overrides: Partial = {}): NlQueryInterpretation { + return { + resolvedPersons: [], + ambiguousPersons: [], + keywords: [], + resolvedTags: [], + rawQuery: '', + keywordsApplied: false, + tagsApplied: true, + ...overrides + }; +} + +function makeTag(id: string, name: string, color?: string) { + return color ? { id, name, color } : { id, name }; +} + +describe('buildThemeRemovalUrl', () => { + it('N remaining tags → N tag params + tagOp=OR', () => { + const interp = makeInterp({ + resolvedTags: [ + makeTag('aaa', 'Hochzeit'), + makeTag('bbb', 'Weltkrieg'), + makeTag('ccc', 'Familie') + ] + }); + const url = buildThemeRemovalUrl(interp, 'Hochzeit'); + const params = new URL(url, 'http://x').searchParams; + expect(params.getAll('tag')).toEqual(['Weltkrieg', 'Familie']); + expect(params.get('tagOp')).toBe('OR'); + }); + + it('last tag removed → no tag or tagOp params in URL', () => { + const interp = makeInterp({ + resolvedTags: [makeTag('aaa', 'Hochzeit')] + }); + const url = buildThemeRemovalUrl(interp, 'Hochzeit'); + const params = new URL(url, 'http://x').searchParams; + expect(params.getAll('tag')).toEqual([]); + expect(params.get('tagOp')).toBeNull(); + }); + + it('last tag removed with resolved sender person → sender param intact', () => { + const interp = makeInterp({ + resolvedPersons: [{ id: '11111111-1111-1111-1111-111111111111', displayName: 'Walter' }], + resolvedTags: [makeTag('aaa', 'Hochzeit')] + }); + const url = buildThemeRemovalUrl(interp, 'Hochzeit'); + const params = new URL(url, 'http://x').searchParams; + expect(params.get('senderId')).toBe('11111111-1111-1111-1111-111111111111'); + expect(params.getAll('tag')).toEqual([]); + expect(params.get('tagOp')).toBeNull(); + }); + + it('null-color tag → tag name emitted correctly; color does not affect params', () => { + const interp = makeInterp({ + resolvedTags: [makeTag('aaa', 'Erbschaft'), makeTag('bbb', 'Migration')] + }); + const url = buildThemeRemovalUrl(interp, 'Erbschaft'); + const params = new URL(url, 'http://x').searchParams; + expect(params.getAll('tag')).toEqual(['Migration']); + expect(params.get('tagOp')).toBe('OR'); + }); + + it('directional pair → senderId and receiverId both emitted', () => { + const interp = makeInterp({ + resolvedPersons: [ + { id: '11111111-1111-1111-1111-111111111111', displayName: 'Walter' }, + { id: '22222222-2222-2222-2222-222222222222', displayName: 'Emma' } + ], + resolvedTags: [makeTag('aaa', 'Krieg'), makeTag('bbb', 'Heimat')] + }); + const url = buildThemeRemovalUrl(interp, 'Krieg'); + const params = new URL(url, 'http://x').searchParams; + expect(params.get('senderId')).toBe('11111111-1111-1111-1111-111111111111'); + expect(params.get('receiverId')).toBe('22222222-2222-2222-2222-222222222222'); + expect(params.getAll('tag')).toEqual(['Heimat']); + }); +}); diff --git a/frontend/src/routes/documents/theme-chip-removal.ts b/frontend/src/routes/documents/theme-chip-removal.ts new file mode 100644 index 00000000..21e7a511 --- /dev/null +++ b/frontend/src/routes/documents/theme-chip-removal.ts @@ -0,0 +1,26 @@ +import type { components } from '$lib/generated/api'; + +type NlQueryInterpretation = components['schemas']['NlQueryInterpretation']; + +export function buildThemeRemovalUrl( + interp: NlQueryInterpretation, + removedTagName: string +): string { + const remaining = interp.resolvedTags.filter((t) => t.name !== removedTagName); + const params = new URLSearchParams(); + + const resolved = interp.resolvedPersons; + if (resolved.length >= 1) params.set('senderId', resolved[0].id); + if (resolved.length >= 2) params.set('receiverId', resolved[1].id); + if (interp.dateFrom) params.set('from', interp.dateFrom); + if (interp.dateTo) params.set('to', interp.dateTo); + if (interp.keywordsApplied && interp.keywords.length > 0) { + params.set('q', interp.keywords.join(' ')); + } + + remaining.forEach((tag) => params.append('tag', tag.name)); + if (remaining.length > 0) params.set('tagOp', 'OR'); + + const qs = params.toString(); + return qs ? `/documents?${qs}` : '/documents'; +} -- 2.49.1 From 64b7b2315d9e0af605f5689597cc0e1c510f335c Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 6 Jun 2026 23:42:23 +0200 Subject: [PATCH 12/14] docs(search): ADR-028 fix + glossary + C4 diagram for tag resolution (#743) Co-Authored-By: Claude Sonnet 4.6 --- docs/GLOSSARY.md | 8 +++++++- docs/adr/028-nl-search-ollama.md | 4 +++- docs/architecture/c4/l3-backend-3h-search.puml | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/GLOSSARY.md b/docs/GLOSSARY.md index 1c6e8cb6..7ee1b565 100644 --- a/docs/GLOSSARY.md +++ b/docs/GLOSSARY.md @@ -171,10 +171,16 @@ _See also [Chronik](#chronik-internal)._ **NlSearch** — the natural-language document search feature. Users type a plain-German query (e.g. "Was hat Walter im Krieg an Emma geschrieben?"); the backend parses it via Ollama, resolves person names to database UUIDs, and delegates to the standard `DocumentService.searchDocuments()` path. Endpoint: `POST /api/search/nl`. -**NlQueryInterpretation** — the structured result of parsing a natural-language query. Contains: `resolvedPersons` (persons whose names unambiguously matched one DB record), `ambiguousPersons` (all candidates when a name matched more than one person), `keywords` (LLM-extracted search terms), `dateFrom`/`dateTo` (extracted date range), `rawQuery` (the original user input), and `keywordsApplied` (whether keyword FTS was used in the search). +**NlQueryInterpretation** — the structured result of parsing a natural-language query. Contains: `resolvedPersons` (persons whose names unambiguously matched one DB record), `ambiguousPersons` (all candidates when a name matched more than one person), `keywords` (LLM-extracted search terms), `dateFrom`/`dateTo` (extracted date range), `rawQuery` (the original user input), `keywordsApplied` (whether keyword FTS was used), `resolvedTags` (tags matched by keyword→tag resolution), and `tagsApplied` (whether the OR-union tag filter was applied). + +**keyword→tag resolution** — the post-Ollama step in `NlQueryParserService` where each LLM-extracted keyword is substring-matched against the tag taxonomy via `TagService.findByNameContaining()`. Keywords that hit one or more tags are removed from the FTS text list and become an OR-union tag filter; keywords with no match remain as FTS text. Matching is case-insensitive and traverses the tag hierarchy via the recursive CTE `findDescendantIdsByName`. See ADR-033. **PersonHint** — a lightweight `{id, displayName}` pair used in `NlQueryInterpretation` to describe a resolved or ambiguous person without exposing the full `Person` entity to the frontend. +**TagHint** — a lightweight `{id, name, color?}` triple used in `NlQueryInterpretation.resolvedTags` to describe a tag matched by keyword→tag resolution. `color` is the tag's effective color (one-level inheritance from parent when the tag has no own color), or null if neither tag nor parent has a color. + +**theme chip** `[frontend]` — a removable chip rendered in `InterpretationChipRow` for each entry in `NlQueryInterpretation.resolvedTags` when `tagsApplied` is `true`. Displays "Thema: {tag.name}" (prefix varies by locale). Clicking × removes the tag from the OR-union filter and navigates to `/documents?tag=…&tagOp=OR` with remaining tag and person parameters preserved. + --- ## Infrastructure Terms diff --git a/docs/adr/028-nl-search-ollama.md b/docs/adr/028-nl-search-ollama.md index 41459992..ab166acc 100644 --- a/docs/adr/028-nl-search-ollama.md +++ b/docs/adr/028-nl-search-ollama.md @@ -26,7 +26,7 @@ Family members write their search intent in plain German ("Was hat Walter im Kri **DB-blind name resolution:** The Ollama prompt stays small (the raw query only); person database records are never sent to the model. Name resolution happens as a cheap SQL query after the model returns. This keeps the prompt short, avoids data leakage, and means adding 1,000 new persons requires no prompt change. -**Graceful degradation:** `RestClientOllamaClient.isHealthy()` is called inline before each inference request (calls `GET /api/tags` on a 2-second connect-timeout client). If Ollama is absent or times out, `NlQueryParserService` throws `DomainException` with `SMART_SEARCH_UNAVAILABLE` (HTTP 503). The regular structured search (`GET /api/documents/search`) is unaffected — it never calls Ollama. +**Graceful degradation:** In-path Ollama failures surface via `OllamaClient.parse()` — any `IOException`, read timeout, or non-2xx response is caught by `RestClientOllamaClient` and re-thrown as `DomainException(SMART_SEARCH_UNAVAILABLE, HTTP 503)`. `isHealthy()` has no callers inside `search/`; it is reserved for the ops/health-endpoint polling path only (e.g. a future `/api/health/ollama` endpoint). The regular structured search (`GET /api/documents/search`) is unaffected — it never calls Ollama. **Expected inference latency:** 2–15 seconds on the current CPU-only hardware. The frontend issue must show a persistent "Suche läuft…" indicator for the full duration (see `aria-live="polite"` requirement in issue #738 frontend notes). The backend timeout is 30 seconds (`app.ollama.timeout-seconds=30`) — chosen as a safe upper bound for Q4_K_M on the i7-6700 with a realistic 500-character query under modest concurrent load. @@ -44,6 +44,8 @@ Family members write their search intent in plain German ("Was hat Walter im Kri **`search/` → `person/` + `document/` dependency direction:** `NlQueryParserService` calls `PersonService.findByDisplayNameContaining()` and `DocumentService.searchDocuments()` — both are legitimate cross-domain service calls, not repository leaks. The `search/` package has no JPA entities of its own and never accesses `PersonRepository` or `DocumentRepository` directly. +**Keyword→tag resolution** (issue #743): After Ollama extracts the `keywords` list, `NlQueryParserService` calls `TagService.findByNameContaining()` for each keyword. Keywords that match one or more tags are removed from the FTS text list and added as OR-union tag filters; keywords with no tag match remain as FTS text. Resolved tags are returned to the frontend as `TagHint` objects in `NlQueryInterpretation.resolvedTags` and rendered as removable "Thema: X" chips. The `tagsApplied` flag signals whether the OR-union filter was actually passed to `DocumentService.searchDocuments()` — it is `false` when the `personRole:any` single-person path is taken, because that path has no tag filter slot. See ADR-033 for the tag name resolution and case-collision rules that `TagService.findByNameContaining()` relies on. + ## Decision **Introduce a new `search/` domain package** with a local Ollama integration via `RestClientOllamaClient`. The Ollama service runs as a separate Docker container, reachable only on the internal Docker network (`expose: ["11434"]`, not `ports:`). The backend calls Ollama's `/api/generate` endpoint with grammar-constrained JSON output. Name resolution and document search are performed by existing services after the model returns. diff --git a/docs/architecture/c4/l3-backend-3h-search.puml b/docs/architecture/c4/l3-backend-3h-search.puml index a0d643be..7ffa28be 100644 --- a/docs/architecture/c4/l3-backend-3h-search.puml +++ b/docs/architecture/c4/l3-backend-3h-search.puml @@ -10,7 +10,7 @@ Container(ollama, "Ollama", "ollama/ollama — port 11434 (internal only)") System_Boundary(backend, "API Backend (Spring Boot)") { Component(nlCtrl, "NlSearchController", "Spring MVC — POST /api/search/nl", "REST entry point for natural language search. Enforces READ_ALL permission. Uses @AuthenticationPrincipal UserDetails to obtain the caller's email for rate limiting. Delegates to NlQueryParserService and returns NlSearchResponse.") Component(rateLimiter, "NlSearchRateLimiter", "Spring Service", "Bucket4j + Caffeine LoadingCache keyed on user email. Allows 5 NL search requests per minute per user. Throws DomainException(SMART_SEARCH_RATE_LIMITED / HTTP 429) when the bucket is exhausted. Node-local — same caveat as LoginRateLimiter.") - Component(parserSvc, "NlQueryParserService", "Spring Service", "Orchestrates the full NL search pipeline: (1) validates query length, (2) calls OllamaClient.parse() to extract structured intent, (3) resolves each person name via PersonService.findByDisplayNameContaining(), (4) applies multi-name / personRole heuristics, (5) delegates to DocumentService.searchDocuments() or searchDocumentsByPersonId(). Returns NlSearchResponse. Never logs raw query content (PII).") + Component(parserSvc, "NlQueryParserService", "Spring Service", "Orchestrates the full NL search pipeline: (1) validates query length, (2) calls OllamaClient.parse() to extract structured intent, (3) resolves keywords to tags via TagService.findByNameContaining(), (4) resolves each person name via PersonService.findByDisplayNameContaining(), (5) applies multi-name / personRole heuristics, (6) delegates to DocumentService.searchDocuments() or searchDocumentsByPersonId(). Returns NlSearchResponse. Never logs raw query content (PII).") Component(ollamaClient, "RestClientOllamaClient", "Spring Service — implements OllamaClient + OllamaHealthClient", "HTTP client for the Ollama API. Uses two separate RestClient instances: inference client (30 s read timeout) and health-check client (2 s connect timeout). Calls POST /api/generate with grammar-constrained JSON schema (personNames, personRole, dateFrom, dateTo, keywords). isHealthy() polls GET /api/tags. Null-coalesces absent personNames/keywords to List.of(). Defaults unknown personRole to 'any' with a warning log. Maps timeout/5xx/parse errors to DomainException(SMART_SEARCH_UNAVAILABLE / HTTP 503).") Component(ollamaProps, "OllamaProperties", "@ConfigurationProperties(\"app.ollama\")", "Config bean: baseUrl, model (qwen2.5:7b-instruct-q4_K_M), timeoutSeconds (default: 30), healthCheckTimeoutSeconds (default: 2).") Component(rateLimitProps, "NlSearchRateLimitProperties", "@ConfigurationProperties(\"app.nl-search.rate-limit\")", "Config bean: maxRequestsPerMinute (default: 5).") @@ -18,6 +18,7 @@ System_Boundary(backend, "API Backend (Spring Boot)") { Component(personSvc, "PersonService", "Spring Service", "See diagram 3e. findByDisplayNameContaining(fragment) delegates to PersonRepository.searchByName() — covers first+last name, alias, and name aliases via LEFT JOIN.") Component(documentSvc, "DocumentService", "Spring Service", "See diagram 3b. searchDocuments() for keyword/sender/receiver/date queries. searchDocumentsByPersonId() for OR-semantics single-person queries (person as sender OR receiver, no keyword filter).") +Component(tagSvc, "TagService", "Spring Service", "See diagram 3b. findByNameContaining(fragment) delegates to TagRepository.findByNameContainingIgnoreCase(). resolveEffectiveColors() applies one-level color inheritance in-place on a collection of Tag entities.") Rel(frontend, nlCtrl, "POST /api/search/nl with JSON query", "HTTP / JSON") Rel(nlCtrl, rateLimiter, "checkAndConsume(userEmail)") @@ -25,9 +26,12 @@ Rel(nlCtrl, parserSvc, "parse(query)") Rel(parserSvc, ollamaClient, "parse(rawQuery) — extracts intent", "HTTP / JSON") Rel(ollamaClient, ollama, "POST /api/generate (grammar-constrained JSON schema)", "HTTP / REST") Rel(ollamaClient, ollama, "GET /api/tags (health check)", "HTTP / REST") +Rel(parserSvc, tagSvc, "findByNameContaining(keyword) — keyword→tag resolution") +Rel(parserSvc, tagSvc, "resolveEffectiveColors(tags)") Rel(parserSvc, personSvc, "findByDisplayNameContaining(name) for each extracted name") Rel(parserSvc, documentSvc, "searchDocuments() or searchDocumentsByPersonId()") Rel(documentSvc, db, "JPA queries", "JDBC") Rel(personSvc, db, "JPA queries", "JDBC") +Rel(tagSvc, db, "JPA queries", "JDBC") @enduml -- 2.49.1 From dc366ed403a6001c1a9f3242ae146beeda0e05a0 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Jun 2026 00:58:03 +0200 Subject: [PATCH 13/14] docs(search): add detached-entity safety comment in resolveTags Addresses @Markus review: tags fetched by findByNameContaining live outside any transaction; Hibernate's dirty-check never fires on them. The comment removes the ambiguity for cold readers. Co-Authored-By: Claude Sonnet 4.6 --- .../org/raddatz/familienarchiv/search/NlQueryParserService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java b/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java index 41d3dbd2..35e52994 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/search/NlQueryParserService.java @@ -161,6 +161,7 @@ public class NlQueryParserService { ? new ArrayList<>(seen).subList(0, MAX_RESOLVED_TAGS) : new ArrayList<>(seen); + // safe: entities are detached here; mutation is for DTO projection only, no dirty-check fires tagService.resolveEffectiveColors(capped); List hints = capped.stream() -- 2.49.1 From fb41affd4c6759a0df8af2fe6c8c42d584461a26 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Jun 2026 00:58:36 +0200 Subject: [PATCH 14/14] docs(search): note vitest-browser workaround for + in path Addresses @Sara review: browser tests in this spec fail silently when the project path contains '+' (common in git worktrees). The comment tells developers to copy the frontend directory to a clean path. Co-Authored-By: Claude Sonnet 4.6 --- .../src/routes/search/InterpretationChipRow.svelte.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts b/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts index 9cefc628..6242d16b 100644 --- a/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts +++ b/frontend/src/routes/search/InterpretationChipRow.svelte.spec.ts @@ -1,3 +1,6 @@ +// NOTE: vitest-browser fails silently when the project path contains '+' (common in git worktrees +// named 'feat+issue-NNN-slug'). If tests fail with iframe routing errors, copy the frontend +// directory to a path without '+' (e.g. /tmp/fe-copy) and run the suite from there. import { describe, expect, it, vi, afterEach } from 'vitest'; import { cleanup, render } from 'vitest-browser-svelte'; import { page } from 'vitest/browser'; -- 2.49.1