fix: filter collector to only scan projects under CC_ROOT_PATH

This commit is contained in:
Vadym Samoilenko 2026-03-26 15:09:49 +00:00
parent 4d69a4ac64
commit 0ee3c3fbd9

View file

@ -163,6 +163,11 @@ def _slug_to_name(folder_name: str) -> str:
# ── Main scan ─────────────────────────────────────────────────────────────────
def _root_prefix(root_path: str) -> str:
"""Convert /Volumes/SSD/Projects/Oliver → -Volumes-SSD-Projects-Oliver"""
return root_path.rstrip("/").replace("/", "-")
def collect() -> list:
if not CLAUDE_PROJECTS.exists():
return []
@ -171,11 +176,19 @@ def collect() -> list:
cutoff = datetime.now(timezone.utc) - timedelta(hours=LOOKBACK_HOURS)
sessions_to_send = []
# Derive the expected folder name prefix from ROOT_PATH so we only pick up
# projects that live under the configured root (same logic as time_tracker.py).
folder_prefix = _root_prefix(ROOT_PATH) # e.g. "-Volumes-SSD-Projects-Oliver"
for folder in sorted(CLAUDE_PROJECTS.iterdir()):
if not folder.is_dir():
continue
folder_key = folder.name
# Only process folders that are exactly the root dir or a child of it
if folder_key != folder_prefix and not folder_key.startswith(folder_prefix + "-"):
continue
# Infer project slug: strip machine path prefix, use last component
slug = _infer_slug(folder_key)