From ec08af46402891d47ef0845146b2905e5661b6c0 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 15 Jun 2026 01:15:35 +0200 Subject: [PATCH] Improve change detection and enhance content extraction logic --- backend/local_rag.py | 4 +++- backend/websearch.py | 3 +++ src/LibraryManager.jsx | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/local_rag.py b/backend/local_rag.py index 33ff4c4..220b831 100644 --- a/backend/local_rag.py +++ b/backend/local_rag.py @@ -1388,6 +1388,8 @@ async def refresh_library_website(slug: str, item_id: str): source_path = Path(str(entry.get("path") or "")) previous_hash = str(entry.get("sha256") or "") + previous_title = str(entry.get("title") or "") + previous_url = str(entry.get("url") or "") _write_text_atomic(source_path, str(snapshot["text"])) next_hash = _sha256_file(source_path) entry.update({ @@ -1407,7 +1409,7 @@ async def refresh_library_website(slug: str, item_id: str): entry["name"] = title job_id = None - changed = next_hash != previous_hash + changed = next_hash != previous_hash or str(entry.get("title") or "") != previous_title or str(entry.get("url") or "") != previous_url if changed: _mark_entry_pending(entry) job_id = await _save_library_change(slug, data) diff --git a/backend/websearch.py b/backend/websearch.py index eeb7fcc..0a11aa8 100644 --- a/backend/websearch.py +++ b/backend/websearch.py @@ -263,6 +263,9 @@ async def fetch_website_snapshot(url: str) -> Dict[str, Any]: text = clean_text(html) if len(text.strip()) < 80: raise ValueError("The website did not contain enough readable text to save.") + if not title: + first_line = next((line.strip() for line in text.splitlines() if line.strip()), "") + title = re.sub(r"^[#>*_`\-\s]+", "", first_line).strip()[:240] return { "requested_url": requested_url, diff --git a/src/LibraryManager.jsx b/src/LibraryManager.jsx index 4463784..e8b7990 100644 --- a/src/LibraryManager.jsx +++ b/src/LibraryManager.jsx @@ -108,7 +108,10 @@ export default function LibraryManager({ apiBase, library, jobs, onRefresh }) { }) } - useEffect(() => () => clearToasts(), []) + useEffect(() => () => { + toastTimeoutsRef.current.forEach(timeoutId => clearTimeout(timeoutId)) + toastTimeoutsRef.current.clear() + }, []) function closeForm() { setFormMode(null)