Artifact

# BEFORE (buggy — iterates only the primary dir) def find_active_session() -> Optional[Path]: """Find the most recently modified .jsonl file (not reset/deleted/committed).""" if not SESSIONS_DIR.exists(): return None best = None best_mtime = 0 for entry in SESSIONS_DIR.iterdir(): if entry.suffix == ".jsonl" and entry.is_file(): name = entry.name if ".reset." in name or ".deleted." in name or ".committed" in name: continue try: mtime = entry.stat().st_mtime if mtime > best_mtime: best_mtime = mtime best = entry except OSError: continue return best # AFTER (fixed — iterates all configured session dirs) def find_active_session() -> Optional[Path]: best = None best_mtime = 0 for sdir in _all_session_dirs(): # union of primary + EXTRA_SESSION_DIRS for entry in sdir.iterdir(): if entry.suffix == ".jsonl" and entry.is_file(): name = entry.name if ".reset." in name or ".deleted." in name or ".committed" in name: continue try: mtime = entry.stat().st_mtime if mtime > best_mtime: best_mtime = mtime best = entry except OSError: continue return best

a91cbe27-8260-4929-bfd6-175d2217d742

BEFORE (buggy — iterates only the primary dir)

def find_active_session() -> Optional[Path]: """Find the most recently modified .jsonl file (not reset/deleted/committed).""" if not SESSIONS_DIR.exists(): return None best = None best_mtime = 0 for entry in SESSIONS_DIR.iterdir(): if entry.suffix == ".jsonl" and entry.is_file(): name = entry.name if ".reset." in name or ".deleted." in name or ".committed" in name: continue try: mtime = entry.stat().st_mtime if mtime > best_mtime: best_mtime = mtime best = entry except OSError: continue return best

AFTER (fixed — iterates all configured session dirs)

def find_active_session() -> Optional[Path]: best = None best_mtime = 0 for sdir in _all_session_dirs(): # union of primary + EXTRA_SESSION_DIRS for entry in sdir.iterdir(): if entry.suffix == ".jsonl" and entry.is_file(): name = entry.name if ".reset." in name or ".deleted." in name or ".committed" in name: continue try: mtime = entry.stat().st_mtime if mtime > best_mtime: best_mtime = mtime best = entry except OSError: continue return best