Skip to content

Add session history listing (sessions command) #14

@roeimichael

Description

@roeimichael

Problem

The status command only shows "active sessions" (events in the last 5 minutes). Once a session ends, there is no CLI command to see it or its stats. Users cannot review what happened in yesterday's sessions — the data is in the database but only accessible via SQLite directly.

What to do

  1. Add an API endpoint /api/sessions in routes.py:
    SELECT DISTINCT session_id, MIN(timestamp_ms) as started, 
           MAX(timestamp_ms) as ended, COUNT(*) as event_count 
    FROM events GROUP BY session_id ORDER BY ended DESC LIMIT ?
  2. Add a sessions CLI command with optional --days N filter
  3. Render a Rich table with: Session ID (truncated), Start Time, End Time, Duration, Event Count, Status (active/ended)

Files to look at

  • src/context_analyzer_tool/collector/routes.py — follow pattern of /api/status
  • src/context_analyzer_tool/cli.py — follow pattern of anomalies command

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliCLI commands and optionsdifficulty: intermediateRequires some familiarity with the codebaseenhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions