Skip to content

Conversation

@oai-coding-agent
Copy link
Contributor

Summary
Implement basic session tracking to generate a unique session ID on each launch, append a structured JSONL record with timestamp and repo context, and expose a simple CLI command to view usage stats.

Implementation Details

  • New module oai_coding_agent.session:
    • record_session(): generates a UUID4 session ID and appends a JSONL record to XDG data dir: ~/.local/share/oai_coding_agent/sessions.jsonl (or XDG_DATA_HOME).
    • get_basic_stats(): returns total sessions and the timestamp of the most recent session.
    • Helper utilities to get the log path and read session entries.
  • CLI updates (oai_coding_agent.cli):
    • Record a session at startup with repo_path and app version (non-blocking; failures are logged but do not stop execution).
    • Added a new command stats that prints total sessions and last session timestamp.
  • Data captured per session: session_id (UUID4), timestamp (UTC ISO 8601), repo_path, github_repo (reserved; currently None at startup), branch_name (reserved; currently None), version, pid.

Assumptions Made

  • Session is recorded once per CLI invocation with the repo_path provided by --repo-path (or cwd). GitHub repo/branch are not required for the acceptance criteria; placeholders left for future enrichment.
  • Using JSON Lines for simple, append-only storage in the XDG data directory.

Testing

  • Added tests in tests/test_session.py covering:
    • UUID format for generated session IDs
    • Log append behavior (two entries written with distinct IDs and known timestamps)
    • Basic stats reporting (total count and last timestamp)
  • Full test suite run locally via uv run pytest; all tests passed.
  • Ran lint and type checks (ruff check, ruff format, mypy) and fixed issues.

Considerations / Future Work

  • Enrich session records post-preflight with detected github_repo and branch_name, or record additional telemetry as needed.
  • Provide more analytics commands (per-repo breakdowns, session durations, etc.).

closes #161

Note: Please add the oai label to this PR per repository guidelines.

- Add session tracking module to generate UUID session IDs
- Append session records to XDG data dir sessions.jsonl with timestamp and repo path
- Provide helpers to read sessions and compute simple stats (total, last timestamp)
- Add unit tests covering session ID generation and log append
- Record a session as early as possible during CLI startup
- New `stats` command prints total sessions and last session date
@mattmorgis mattmorgis closed this Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement basic session tracking with session ID

2 participants