Self-hosted AI workspace.
Python
Merge remote-tracking branch 'origin/dev'
pewdiepie-archdaemon1933201117b2
diff --cc routes/document_routes.pyindex f222e3a24,d7c5d13a9..18253d038--- a/routes/document_routes.py+++ b/routes/document_routes.py@@@ -800,21 -799,16 +800,26 @@@ def setup_document_routes(session_managfrom src.document_actions import _JUNK_TITLESto_delete = []- now = datetime.now(timezone.utc).replace(tzinfo=None)-+ now = datetime.now(timezone.utc)for doc in docs:- content = (doc.current_content or "").strip()- title_raw = (doc.title or "").strip()- title = title_raw.lower()+ created = doc.created_at+ if created and created.tzinfo is None:+ created = created.replace(tzinfo=timezone.utc)+++ # Skip freshly created documents to avoid deleting them while the user is actively editing- if doc.created_at and (now - doc.created_at).total_seconds() < 900: # 15 minutes++ if created and (now - created).total_seconds() < 900: # 15 minutes+ continue++ content = (doc.current_content or "").strip()+ title_raw = (doc.title or "").strip()+ title = title_raw.lower()+ is_fresh_empty = (+ not content+ and created is not None+ and (now - created).total_seconds() < 1800+ )+ if is_fresh_empty:+ continue# Strip markdown noise to get a "real" character countstripped = _re.sub(r"^#{1,6}\s+", "", content, flags=_re.MULTILINE)diff --cc src/document_actions.pyindex 142d0bfc9,b22091794..b70f3ba46--- a/src/document_actions.py+++ b/src/document_actions.py@@@ -6,7 -6,7 +6,7 @@@ Reusable document actions callable froimport loggingimport re--from datetime import datetime++from datetime import datetime, timezonelogger = logging.getLogger(__name__)@@@ -77,20 -77,17 +77,28 @@@ async def run_document_tidy(owner: strdeleted = 0kept = 0survivors = [] # docs that pass the junk rules, considered for dedup--- now = datetime.utcnow()++ now = datetime.now(timezone.utc)for doc in docs:++ created = doc.created_at++ if created and created.tzinfo is None:++ created = created.replace(tzinfo=timezone.utc)+++ # Skip freshly created documents to avoid deleting them while the user is actively editing- if doc.created_at and (now - doc.created_at).total_seconds() < 900: # 15 minutes++ if created and (now - created).total_seconds() < 900: # 15 minutes+ survivors.append(doc)+ continue+content = (doc.current_content or "").strip()title = (doc.title or "").strip().lower()- created = doc.created_at+ is_fresh_empty = (+ not content+ and created is not None+ and (now - created).total_seconds() < 1800+ )+ if is_fresh_empty:+ survivors.append(doc)+ continue# Strip markdown noise to get "real" character countstripped = re.sub(r"^#{1,6}\s+", "", content, flags=re.MULTILINE) # headers