Problem / Need
SessionInfoModal currently extracts session information from the init message sent when a session starts. This approach fails for newly established sessions that haven't had any messages sent yet, leaving the modal empty or showing stale data.
Current Behavior
Session info is extracted from the init SystemMessage:
- Works only after session initialization completes
- Fails to show info if no messages have been sent yet
- Requires init message to contain all session metadata
- No way to refresh session state without sending a message
Expected Behavior
Use the new get_session_info() function from claude-agent-sdk v0.1.50+ to poll current session metadata:
- Modal polls session info on open (not waiting for init message)
- Shows current session metadata even if no messages sent
- Can refresh to see updated session state
- Handles newly established sessions correctly
SDK Change Reference
PR: anthropics/claude-agent-sdk-python#667
New SDK Features (v0.1.50):
get_session_info() function for retrieving session metadata
- Session metadata fields:
tag, created_at, and other introspection data
- Allows querying session state independently from message flow
Implementation
Current (Init Message Approach)
# Extract from init message
session_info = parse_init_message(init_data)
Proposed (Polled Approach)
# Call get_session_info() via API
# Backend calls SDK's get_session_info()
# Modal polls periodically or on open
async def fetch_session_info(session_id):
return await session_coordinator.get_session_info(session_id)
Impact
User Experience
- SessionInfoModal works immediately on new sessions
- No need to send messages to see session info
- More reliable session metadata retrieval
- Can refresh to see current state
Code Quality
- Uses official SDK method (get_session_info) instead of parsing init messages
- More robust (doesn't depend on init message format)
- Cleaner separation of concerns
Acceptance Criteria
Test Scenarios
-
New session before sending message
- Create session
- Open SessionInfoModal immediately (before sending message)
- Modal shows session info (created_at, session_id, etc.)
-
Session with messages
- Create session and send messages
- Open modal
- Shows current session metadata
-
Refresh session info
- Modal open
- Manually refresh button updates metadata
- No need to restart session
-
API failure handling
- get_session_info() fails
- Modal shows error gracefully
- User can retry
Quality Standards
Reliability
Performance
Implementation Notes
Changes Required
-
Backend: Expose get_session_info() via REST API endpoint
- GET /api/sessions/{session_id}/info
- Returns session metadata from SDK
-
Frontend: Update SessionInfoModal
- Replace init message parsing with API call
- Poll on modal open
- Add refresh button if desired
-
SDK Integration: Ensure get_session_info() is properly wired in SessionCoordinator
Related Issues
Problem / Need
SessionInfoModal currently extracts session information from the init message sent when a session starts. This approach fails for newly established sessions that haven't had any messages sent yet, leaving the modal empty or showing stale data.
Current Behavior
Session info is extracted from the
initSystemMessage:Expected Behavior
Use the new
get_session_info()function from claude-agent-sdk v0.1.50+ to poll current session metadata:SDK Change Reference
PR: anthropics/claude-agent-sdk-python#667
New SDK Features (v0.1.50):
get_session_info()function for retrieving session metadatatag,created_at, and other introspection dataImplementation
Current (Init Message Approach)
Proposed (Polled Approach)
Impact
User Experience
Code Quality
Acceptance Criteria
Test Scenarios
New session before sending message
Session with messages
Refresh session info
API failure handling
Quality Standards
Reliability
Performance
Implementation Notes
Changes Required
Backend: Expose get_session_info() via REST API endpoint
Frontend: Update SessionInfoModal
SDK Integration: Ensure get_session_info() is properly wired in SessionCoordinator
Related Issues