Skip to content

Self-hosted AI workspace.

Python

Merge remote-tracking branch 'origin/dev'

pewdiepie-archdaemon1933201117b2
diff --cc routes/document_routes.py
index f222e3a24,d7c5d13a9..18253d038
--- a/routes/document_routes.py
+++ b/routes/document_routes.py
@@@ -800,21 -799,16 +800,26 @@@ def setup_document_routes(session_manag
from src.document_actions import _JUNK_TITLES
to_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 count
stripped = _re.sub(r"^#{1,6}\s+", "", content, flags=_re.MULTILINE)
diff --cc src/document_actions.py
index 142d0bfc9,b22091794..b70f3ba46
--- a/src/document_actions.py
+++ b/src/document_actions.py
@@@ -6,7 -6,7 +6,7 @@@ Reusable document actions callable fro
import logging
import re
--from datetime import datetime
++from datetime import datetime, timezone
logger = logging.getLogger(__name__)
@@@ -77,20 -77,17 +77,28 @@@ async def run_document_tidy(owner: str
deleted = 0
kept = 0
survivors = [] # 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 count
stripped = re.sub(r"^#{1,6}\s+", "", content, flags=re.MULTILINE) # headers