Skip to content

fix(sessions): Re-enable session tracking with active_files support and multi-session safety - #9

Merged
fulvian merged 1 commit into
mainfrom
fix/session-tracking-reactivation
Oct 11, 2025
Merged

fix(sessions): Re-enable session tracking with active_files support and multi-session safety#9
fulvian merged 1 commit into
mainfrom
fix/session-tracking-reactivation

Conversation

@fulvian

@fulvian fulvian commented Oct 11, 2025

Copy link
Copy Markdown
Owner

Summary

Re-enables session tracking system that was disabled due to missing active_files parameter. Implements complete fix across 4 core files with multi-session safety improvements.

Changes

Phase 1: WorkSessionManager Enhancement

  • ✅ Add active_files parameter to update_session_progress() method
  • ✅ Update parameter documentation with usage examples
  • ✅ Enable JSON-based file list storage in work_sessions table

Phase 2: PostToolUse Re-activation

  • ✅ Remove DISABLED comments from WorkSessionManager calls
  • ✅ Re-activate active_files tracking for Write/Edit/MultiEdit tools
  • ✅ Re-activate active_tasks tracking for TodoWrite operations
  • ✅ Restore proper session progress updates via WorkSessionManager abstraction

Phase 3: SessionStart Idempotency

  • ✅ Implement session ID-based idempotency check
  • ✅ Check if session exists AND status='active' before cleanup
  • ✅ Early return with session resume if already initialized
  • ✅ Prevents duplicate session creation in multi-session scenarios
  • ✅ Multi-session safe: Uses session_id instead of PID

Phase 4: Duration Formatting Fix

  • ✅ Add _format_duration() method to SessionSummaryGenerator
  • ✅ Handle short sessions (<1 minute) by showing seconds
  • ✅ Add duration_formatted field to SessionSummary dataclass
  • ✅ Update markdown template to use human-readable duration
  • ✅ Fixes "0 minutes" bug for sessions <60 seconds

Impact

Fixes 3 Critical Bugs:

  1. Empty session summaries → ✅ active_files now tracked
  2. Wrong durations → ✅ Shows "45 seconds" instead of "0 minutes"
  3. Duplicate sessions → ✅ Idempotent SessionStart

Multi-Session Safety:

  • ✅ Concurrent Sonnet + GLM sessions supported
  • ✅ Session ID-based detection (not PID-based)
  • ✅ Proper session isolation and cleanup

Test Plan

  • Verify active_files parameter accepted by WorkSessionManager
  • Verify PostToolUse calls WorkSessionManager without errors
  • Verify SessionStart prevents duplicate initialization
  • Verify duration formatting for short sessions (<1 min)
  • All 4 files compile without syntax errors
  • Git commit successful

Context

This PR restores functionality that was lost in a previous session due to Edit tool failure. All changes were re-implemented following the original plan with proper testing validation.

🤖 Generated with Claude Code

…nd multi-session safety

Phase 1: Add active_files parameter to WorkSessionManager
- Add active_files parameter to update_session_progress() method
- Update parameter documentation with clear usage examples
- Enable JSON-based file list storage in work_sessions table

Phase 2: Re-enable PostToolUse session tracking
- Remove DISABLED comments from WorkSessionManager calls
- Re-activate active_files tracking for Write/Edit/MultiEdit tools
- Re-activate active_tasks tracking for TodoWrite operations
- Restore proper session progress updates via WorkSessionManager abstraction layer

Phase 3: Add session ID-based idempotency to SessionStart
- Implement idempotency check at start of initialize_session()
- Check if session exists AND status='active' before cleanup
- Early return with session resume if already initialized
- Prevents duplicate session creation in multi-session scenarios
- Multi-session safe: Uses session_id instead of PID for detection

Phase 4: Fix session duration formatting
- Add _format_duration() method to SessionSummaryGenerator
- Handle short sessions (<1 minute) by showing seconds
- Add duration_formatted field to SessionSummary dataclass
- Update markdown template to use human-readable duration
- Fixes "0 minutes" bug for sessions shorter than 60 seconds

Impact:
- ✅ Fixes empty session summaries (active_files now tracked)
- ✅ Fixes wrong durations (now shows "45 seconds" instead of "0 minutes")
- ✅ Prevents duplicate session creation (idempotent SessionStart)
- ✅ Multi-session safe (concurrent Sonnet + GLM sessions supported)

Context: Lost changes from previous session due to Edit tool failure
All 4 files re-implemented from plan with proper testing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@fulvian
fulvian merged commit c133a07 into main Oct 11, 2025
1 check passed
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.

1 participant