Locate the JSONL transcript for this session inside the isolated config.
(config_dir: Path, cwd: str, session_id: str | None)
| 63 | |
| 64 | |
| 65 | def find_transcript(config_dir: Path, cwd: str, session_id: str | None) -> Path | None: |
| 66 | """Locate the JSONL transcript for this session inside the isolated config.""" |
| 67 | projects = config_dir / "projects" |
| 68 | candidates: list[Path] = [] |
| 69 | |
| 70 | if session_id: |
| 71 | # Fast path: <config>/projects/<slug>/<session_id>.jsonl |
| 72 | slug_dir = projects / project_slug(cwd) |
| 73 | direct = slug_dir / f"{session_id}.jsonl" |
| 74 | if direct.exists(): |
| 75 | return direct |
| 76 | candidates.extend(projects.rglob(f"{session_id}.jsonl")) |
| 77 | if candidates: |
| 78 | return candidates[0] |
| 79 | |
| 80 | # Fallback: newest transcript under the matching project slug. |
| 81 | slug_dir = projects / project_slug(cwd) |
| 82 | if slug_dir.is_dir(): |
| 83 | jsonls = sorted( |
| 84 | slug_dir.glob("*.jsonl"), key=lambda p: p.stat().st_mtime, reverse=True |
| 85 | ) |
| 86 | if jsonls: |
| 87 | return jsonls[0] |
| 88 | |
| 89 | # Last resort: newest transcript anywhere in the isolated config. |
| 90 | all_jsonls = sorted( |
| 91 | projects.rglob("*.jsonl"), key=lambda p: p.stat().st_mtime, reverse=True |
| 92 | ) if projects.is_dir() else [] |
| 93 | return all_jsonls[0] if all_jsonls else None |
| 94 | |
| 95 | |
| 96 | def is_tracedecay_tool(name: str) -> bool: |
no test coverage detected