Skip to content

Replay your coding agent sessions as a map and a timeline

fix(cli): use session start when source mtime is zero

gezerui888c965676ef5b4
diff --git a/README.md b/README.md
index 5d85cd0..490bd57 100644
--- a/README.md
+++ b/README.md
@@ -192,7 +192,7 @@ agentplay agents show which agents were found on this machine
| Flag | On | Meaning |
|---|---|---|
-| `--since 30d` | build, view, list | only sessions changed in the window (`12h`, `2w`, `2026-09-01`); list uses the stored transcript modification time, or the start time for imported maps |
+| `--since 30d` | build, view, list | only sessions changed in the window (`12h`, `2w`, `2026-09-01`); list uses the stored transcript modification time, or the start time when that time is unavailable |
| `--agents claude-code,codex` | build, view, list | limit to these agents |
| `--rebuild` | build, view | rebuild even unchanged sessions |
| `--path-mode dirs_only` | build, view | see [Privacy](#privacy) |
diff --git a/python/src/agentplay/cli.py b/python/src/agentplay/cli.py
index 6e0f099..d8daa56 100644
--- a/python/src/agentplay/cli.py
+++ b/python/src/agentplay/cli.py
@@ -248,9 +248,9 @@ def cmd_list(args: argparse.Namespace) -> int:
if agents is not None and row.get("agentTool") not in agents:
continue
if since is not None:
- # Imported maps have no transcript mtime; use their session start.
+ # Imported maps and discovery's zero sentinel have no transcript mtime.
changed = row.get("sourceMtime")
- if changed is None:
+ if changed is None or changed == 0:
try:
started = datetime.fromisoformat(row.get("startedAt") or "")
changed = (started if started.tzinfo else started.replace(tzinfo=UTC)).timestamp()
@@ -384,7 +384,7 @@ def parser() -> argparse.ArgumentParser:
ls = sub.add_parser("list", parents=[common], help="list built sessions")
ls.add_argument("--agents", help=f"comma-separated subset of: {', '.join(discover.AGENTS)}")
- ls.add_argument("--since", help="only sessions changed since (30d, 12h, 2w, YYYY-MM-DD); imported maps use start time")
+ ls.add_argument("--since", help="only sessions changed since (30d, 12h, 2w, YYYY-MM-DD); missing modification times use start time")
ls.add_argument("--limit", type=int)
ls.add_argument("--json", action="store_true")
ls.set_defaults(fn=cmd_list)
diff --git a/python/tests/test_cli_output.py b/python/tests/test_cli_output.py
index 4d13a81..82aab87 100644
--- a/python/tests/test_cli_output.py
+++ b/python/tests/test_cli_output.py
@@ -237,3 +237,17 @@ def test_list_empty_message(list_store, capsys, filtered):
assert cli.main(["list", *flags]) == 0
expected = "No sessions match these filters." if filtered else "No maps yet. Run `agentplay build`."
assert capsys.readouterr().out.strip() == expected
+
+
[email protected](("started", "expected"), [
+ ("2026-10-20T00:00:00Z", ["session"]),
+ ("2026-09-01T00:00:00Z", []),
+])
+def test_list_uses_start_time_for_zero_source_mtime(list_store, capsys, started, expected):
+ list_store.index.clear()
+ list_store.index["session"] = {
+ "sessionId": "session", "agentTool": "codex", "startedAt": started, "sourceMtime": 0.0,
+ }
+ list_store.save_index()
+ assert cli.main(["list", "--since", "2026-10-16", "--json"]) == 0
+ assert [r["sessionId"] for r in json.loads(capsys.readouterr().out)] == expected