fix(advisor): generic — drop trailing source list in answer + de-duplicate source card

Two structural fixes (not query-specific):
- Proxy prompt: forbid ANY trailing "Quellen:"/"Quellen im RAG-System" list and make it
  the LAST instruction so it overrides the soul file's answer-structure + example that
  teach a closing sources section. Applies to every answer.
- KnowledgeUnitCard: render the label only when it differs from regulation.short, so a
  source whose label == short name no longer prints twice. Applies to every source.

Answer text is still never parsed in the FE (sources live in the pane). + card test.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-07-01 10:13:58 +02:00
parent 49171e841f
commit 3884038b06
3 changed files with 37 additions and 2 deletions
@@ -0,0 +1,28 @@
import { describe, it, expect } from 'vitest'
import { render } from '@testing-library/react'
import { KnowledgeUnitCard } from './KnowledgeUnitCard'
import type { KnowledgeUnit } from '@/lib/sdk/advisor/evidence'
const base: KnowledgeUnit = { id: 's1', regulation: { code: 'dsk', short: 'DSK Sdm B51' } }
describe('KnowledgeUnitCard', () => {
it('does not duplicate the regulation when label equals the short name', () => {
const { container } = render(<KnowledgeUnitCard unit={{ ...base, label: 'DSK Sdm B51' }} />)
const occurrences = (container.textContent?.match(/DSK Sdm B51/g) || []).length
expect(occurrences).toBe(1)
})
it('shows the label when it differs from the short name (no breadcrumb)', () => {
const { container } = render(<KnowledgeUnitCard unit={{ ...base, label: 'Art. 30 DSGVO' }} />)
expect(container.textContent).toContain('DSK Sdm B51')
expect(container.textContent).toContain('Art. 30 DSGVO')
})
it('renders the section/paragraph breadcrumb when present', () => {
const { container } = render(
<KnowledgeUnitCard unit={{ ...base, section: 'Art. 5', paragraph: 'Abs. 2' }} />,
)
expect(container.textContent).toContain('Art. 5')
expect(container.textContent).toContain('Abs. 2')
})
})
@@ -30,7 +30,10 @@ export function KnowledgeUnitCard({ unit }: { unit: KnowledgeUnit }) {
))}
</div>
) : (
unit.label && <div className="mt-0.5 text-[11px] text-gray-500">{unit.label}</div>
unit.label &&
unit.label !== unit.regulation.short && (
<div className="mt-0.5 text-[11px] text-gray-500">{unit.label}</div>
)
)}
</div>
{canOpen && (