From 9cda0d85772d30358e2f859b0f2fd11a2c8f2303 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 20 Mar 2026 16:25:48 +0100 Subject: [PATCH] Add sanitizeGeneratedChatTitle function and update sendMessage logic --- src/App.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/App.jsx b/src/App.jsx index 8ca2ecd..0dfe652 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -12,6 +12,15 @@ import { loadStoredWebsearchEngines, normalizeWebsearchEngines, } from './websearchEngines' + +function sanitizeGeneratedChatTitle(title) { + return (title || '') + .replace(/[\s\S]*?<\/think(?:ing)?>/gi, '') + .replace(/[*#]/g, '') + .replace(/\s+/g, ' ') + .trim() +} + // Extract or block (first occurrence) and return { think, answer } function splitThinkBlocks(text) { if (!text) return { think: null, answer: '' }; @@ -1495,7 +1504,7 @@ async function sendMessage() { }) .then(r => r.json()) .then(data => { - const sanitizedTitle = data.title.replace(/[\s\S]*?<\/think(?:ing)?>/i, '').trim() + const sanitizedTitle = sanitizeGeneratedChatTitle(data.title) setChatSessions(prevSessions => prevSessions.map(session => session.session_id === targetSessionId ? { ...session, name: sanitizedTitle } : session