fix: handle special char search 500 & polish live badge (#144)
* fix(search): handle numeric query FTS errors regardless of table existence Remove the `no such table: messages_fts` condition so numeric queries fall back to LIKE search on any FTS failure (malformed MATCH, missing table, etc.). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(search): handle special char queries, polish live badge UI - Add hasUnsafeChars() to catch FTS5-breaking queries (¥, @, #, etc.) and fall back to LIKE search, preventing 500 errors - Polish session live badge: smaller size, remove border/shadow, add pulsing dot indicator for a cleaner look - Remove spinner drop-shadow glow effect Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -163,6 +163,10 @@ function isNumericQuery(text: string): boolean {
|
||||
return /^\d+(?:\s+\d+)*$/.test(text.trim())
|
||||
}
|
||||
|
||||
function hasUnsafeChars(text: string): boolean {
|
||||
return /[^\w\s\u4e00-\u9fff\u3400-\u4dbf\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/.test(text)
|
||||
}
|
||||
|
||||
function runLikeContentSearch(
|
||||
db: { prepare: (sql: string) => { all: (...params: any[]) => Record<string, unknown>[] } },
|
||||
source: string | undefined,
|
||||
@@ -358,7 +362,7 @@ export async function searchSessionSummaries(
|
||||
return [...merged.values()].slice(0, limit)
|
||||
}
|
||||
|
||||
if (message.includes('no such table: messages_fts') && isNumericQuery(trimmed)) {
|
||||
if (isNumericQuery(trimmed) || hasUnsafeChars(trimmed)) {
|
||||
const likeRows = runLikeContentSearch(db, source, trimmed)
|
||||
const merged = new Map<string, HermesSessionSearchRow>()
|
||||
for (const row of titleRows) {
|
||||
|
||||
Reference in New Issue
Block a user