-
Notifications
You must be signed in to change notification settings - Fork 127
Add GitHub Copilot parser and fix incremental timestamps for resumed sessions #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ def parse_jsonl_file(self, file_path: Path) -> Optional[AgentEvent]: | |
| session_data: Dict[str, Any] = { | ||
| "id": None, | ||
| "timestamp": None, | ||
| "last_event_timestamp": None, | ||
| "cwd": None, | ||
| "model": None, | ||
| "messages": [], | ||
|
|
@@ -94,7 +95,7 @@ def parse_jsonl_file(self, file_path: Path) -> Optional[AgentEvent]: | |
| ) | ||
|
|
||
| return AgentEvent( | ||
| timestamp=session_data["timestamp"] or datetime.now(timezone.utc), | ||
| timestamp=session_data["last_event_timestamp"] or session_data["timestamp"] or datetime.now(timezone.utc), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One-time mass re-export on upgrade: the first run after deploying this change re-exports essentially every session in the retention window, even with zero new activity. (Same for the The incremental filter compares the freshly parsed timestamp against the one embedded in the existing file's name, and skips only when Related edge in the same comparison: both sides are truncated to whole seconds ( Worth handling the transition explicitly (e.g. migrate existing filenames once, or dedup by session_id downstream) rather than letting the burst happen. |
||
| source="codex", | ||
| session_id=f"codex_{session_data['id']}", | ||
| project_path=session_data["cwd"], | ||
|
|
@@ -174,6 +175,16 @@ def _process_event(self, event: Dict[str, Any], session_data: Dict[str, Any]): | |
| evt_type = event.get("type") | ||
| payload = event.get("payload", {}) | ||
|
|
||
| event_timestamp = event.get("timestamp") | ||
| if event_timestamp: | ||
| try: | ||
| normalized = normalize_timestamp(event_timestamp) | ||
| current = session_data.get("last_event_timestamp") | ||
| if current is None or normalized > current: | ||
| session_data["last_event_timestamp"] = normalized | ||
| except Exception: | ||
| pass | ||
|
|
||
| if evt_type == "session_meta": | ||
| session_data["id"] = payload.get("id") | ||
| if payload.get("timestamp"): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With latest-event timestamps in the export filename, every active session now accumulates one full-history snapshot per run — and nothing prunes the old ones. (Applies equally to the same change in
codex_parser.py:98; the mechanism lives inobserver.py:289.)Before this change the embedded timestamp was the stable session start, so one session mapped to one file and each run overwrote it in place. Now the timestamp moves forward whenever the session has activity,
save_sessions_to_individual_filesopens the new path with'w', and no code deletes prior snapshots. A session used daily leaves one full-chat-history file per day:The output dir grows without bound, and any consumer watching it re-ingests the session's entire history each time — every earlier message duplicated downstream unless the consumer dedups by
session_id.Together with the upgrade-time re-export (comment on
codex_parser.py:98), this suggests the moving timestamp shouldn't be part of the file's identity: either keep a stable filename per session and track the latest-exported-event time in the file contents or a sidecar index, or prune a session's older snapshots when writing the new one.