?
TRCKR-293
agent-reporting enhancement
Created: 2025-12-12 Updated: 2025-12-16
Relationships Loading...
Attachments
Loading...
Comments (1)
agent · 2025-12-12
Implemented session ID tracking for agent reporting feature. All components updated and tested. ## Changes Made: ### 1. Database Schema (client/schema.py:521) Added `session_id TEXT` column to `AGENTS_TABLE` schema to store Claude Code session IDs. ### 2. API Models (server/models.py) - Added `session_id: Optional[str] = None` to `AgentBase` model (line 406) - Added `session_id: Optional[str] = None` to `AgentResponse` model (line 437) ### 3. API Routes (server/routes/agents.py) - Updated INSERT query to include session_id column (line 132) - Updated UPDATE query to include session_id column (line 174) - Updated response mapping to include session_id (line 236) ### 4. CLI Command (trckr.py) - Added `--session-id` option to `trckr agent heartbeat` command (line 3154) - Added session_id to heartbeat payload (line 3204) ### 5. Hook Script (scripts/hooks/agent-heartbeat.sh) - Extract session_id from hook input JSON (line 26) - Pass session_id to trckr command when available (lines 66-70) ### 6. Web UI (server/templates/partials/agents_table.html) - Added sortable "Session ID" column header (line 16) - Display truncated session_id in table (lines 61-67, shows first 12 chars) - Added full session_id to expanded details section (lines 108-113) - Updated colspan from 9 to 10 for detail rows ### 7. Tests (tests/test_agent_api.py) - Updated sample_heartbeat fixture to include session_id (line 69) - Added assertions for session_id in test cases - Verified session_id updates correctly (line 186) ## Verification: - ✅ All tests pass: 1229 passed, 39 skipped - ✅ Installed locally via `make install` - ✅ Deployed to trckr.roboalch.com successfully - ✅ Health check passed: {"status":"healthy"} ## How It Works: 1. Claude Code hooks provide `session_id` in their JSON input 2. Hook script extracts it with `jq -r '.session_id // empty'` 3. Script passes it to CLI: `--session-id $SESSION_ID` 4. CLI sends it to server in heartbeat payload 5. Server stores it in agents table 6. Web UI displays it (truncated in table, full in details) Session IDs help distinguish between different Claude Code sessions running on the same machine/repo combination.