feat(frontend): improve manual knowledge editor and chat citation rendering

- Replace manual knowledge editor dialog with SettingDrawer and refine toolbar/footer layout
- Add draft status resolution for manual knowledge items in the knowledge base
- Fix citation placement near fenced code blocks and add regression tests
- Update ChatRequestInfoButton icon and chat message/citation styles
- Add i18n strings for manual knowledge editor features
This commit is contained in:
wizardchen
2026-06-17 20:50:42 +08:00
committed by lyingbug
parent 4c5379df9c
commit e0d3c1dafd
15 changed files with 396 additions and 269 deletions
@@ -173,6 +173,32 @@ test('joinCitationTagsToPreviousLine keeps citations on a new line after a list'
assert.equal(joinCitationTagsToPreviousLine(input), `1. first\n2. second\n\n${tag}`)
})
test('joinCitationTagsToPreviousLine does not merge citations onto fenced code closing delimiter', () => {
const tag = '<kb doc="guide.pdf" chunk_id="1" />'
const input = '```bash\nunzip setup.zip\n```\n\n' + tag
assert.equal(joinCitationTagsToPreviousLine(input), '```bash\nunzip setup.zip\n```\n\n' + tag)
})
test('renderChatMarkdown keeps fenced code blocks closed when citations follow', () => {
const renderer = createChatMarkdownRenderer({
imageRenderer: ({ href, text }) => `<img src="${href}" alt="${text}">`,
isValidImageUrl: () => true,
})
const tag = '<kb doc="guide.pdf" chunk_id="1" />'
const html = renderChatMarkdown(
['```bash', 'unzip setup.zip', '```', '', tag, '', '#### Next step'].join('\n'),
{
renderer,
escapeMarkdown: (text) => text,
sanitizeHtml: (html) => html,
},
)
assert.doesNotMatch(html, /#### Next step/)
assert.match(html, /<h4>Next step<\/h4>/)
assert.equal((html.match(/<pre>/g) || []).length, 1)
})
test('collapseStandaloneCitationParagraphs merges citations across empty paragraphs', () => {
const html = '<p>Steps:</p><p></p><p><span class="citation citation-kb" data-chunk-id="x">doc</span></p>'
const out = collapseStandaloneCitationParagraphs(html)