feat: enhance input field and agent stream display with improved handling and sanitization

- Added blur handling for the textarea in the Input-field component to prevent errors when navigating away from the component.
- Improved the sanitization process in the AgentStreamDisplay component to preserve specific tags during markdown processing, ensuring accurate content display.
- Introduced new methods for handling FAQ-specific post-processing in the knowledge base service, optimizing retrieval and filtering of search results.

These changes enhance user experience by improving input handling and content rendering in the chat interface.
This commit is contained in:
wizardchen
2026-03-15 22:12:45 +08:00
parent 2984b21731
commit c27740f739
18 changed files with 3405 additions and 3120 deletions
@@ -1352,7 +1352,21 @@ const getTokens = (content: any) => {
const contentStr = typeof content === 'string' ? content : String(content || '');
if (!contentStr.trim()) return [];
const processed = preprocessMarkdown(sanitizeForDisplay(contentStr));
// Extract <kb.../> and <web.../> tags before sanitization to prevent
// sanitizeForDisplay from stripping chunk_id labels and UUIDs inside them.
const tagPlaceholders: string[] = [];
const preserved = contentStr.replace(/<(?:kb|web)\b[^>]*\/>/g, (match) => {
const idx = tagPlaceholders.length;
tagPlaceholders.push(match);
return `\x00TAG${idx}\x00`;
});
let sanitized = sanitizeForDisplay(preserved);
// Restore preserved tags
sanitized = sanitized.replace(/\x00TAG(\d+)\x00/g, (_, idx) => tagPlaceholders[Number(idx)]);
const processed = preprocessMarkdown(sanitized);
return marked.lexer(processed);
};