Skip to content

Conversation

@nsluss
Copy link

@nsluss nsluss commented Jan 15, 2026

Summary

Fixes #38 - Session outputs not stored due to missing currentSessionId

Root cause: In handleSessionNew, sessionManager.setSession() was only called when claudeId was truthy. When getAgentSessionId() provided the session ID instead, setSession() was never called, leaving currentId as null.

The fix: Always call setSession(newSessionId) regardless of which source provided the ID.

Bug reproduction

  1. Agent subprocess already running (reused, not restarted)
  2. handleSessionNew called
  3. claudeId is null (no notification received yet)
  4. getAgentSessionId() returns valid ID from ACP session/new response
  5. setSession() was NOT called → currentId stays null
  6. getCurrentSessionId() returns null in sendSessionNotification
  7. Outputs skipped: "No currentSessionId, skipping storage"

Changes

  • src/server/handlers/session.ts - Always call setSession(newSessionId)

Test plan

  • 27 unit tests for SessionManager added
  • 2 integration tests that fail without the fix, pass with it
  • Full test suite passes (629 tests)
  • Verified on VM: session ID correctly set in outputs response
  • Test plan document added

Verification

Tested on VM restored from golden commit 5931196c-f901-41eb-845d-859d279a168e:

sessionId in health:   ae21263c-016d-4a9d-b4f7-59a8b2c6bf45  ✓
sessionId in outputs:  ae21263c-016d-4a9d-b4f7-59a8b2c6bf45  ✓

Without the fix, these would be null.

🤖 Generated with Claude Code

Previously, sessionManager.setSession() was only called when claudeId
was truthy. When getAgentSessionId() provided the session ID instead,
setSession() was never called, leaving currentId as null. This caused
session outputs to not be stored.

The fix ensures setSession() is always called with the resolved
newSessionId, regardless of which source provided it.

Bug reproduction:
1. Agent subprocess already running (reused)
2. handleSessionNew called
3. claudeId is null (no notification yet)
4. getAgentSessionId() returns valid ID
5. setSession() was NOT called → currentId stays null
6. Outputs not stored due to null session ID check

Adds comprehensive tests:
- 27 unit tests for SessionManager
- 2 integration tests that fail without the fix
- Test plan document

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Session outputs not stored due to missing currentSessionId

2 participants