Skip to content

feat: update SessionInfoModal to use polled get_session_info() from SDK v0.1.50+ #908

@EdanStarfire

Description

@EdanStarfire

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:

  1. Modal polls session info on open (not waiting for init message)
  2. Shows current session metadata even if no messages sent
  3. Can refresh to see updated session state
  4. 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

  • SessionInfoModal uses polled get_session_info() instead of init message parsing
  • Works for newly established sessions (before any messages sent)
  • Modal shows current session metadata on open
  • Can refresh modal to update session info
  • Handles API failures gracefully
  • Compatible with SDK v0.1.50+

Test Scenarios

  1. New session before sending message

    • Create session
    • Open SessionInfoModal immediately (before sending message)
    • Modal shows session info (created_at, session_id, etc.)
  2. Session with messages

    • Create session and send messages
    • Open modal
    • Shows current session metadata
  3. Refresh session info

    • Modal open
    • Manually refresh button updates metadata
    • No need to restart session
  4. API failure handling

    • get_session_info() fails
    • Modal shows error gracefully
    • User can retry

Quality Standards

Reliability

  • Works for sessions at any lifecycle stage
  • Doesn't depend on init message
  • Graceful error handling

Performance

  • Minimal API calls (only on modal open/refresh)
  • No background polling unless user interacts

Implementation Notes

Changes Required

  1. Backend: Expose get_session_info() via REST API endpoint

    • GET /api/sessions/{session_id}/info
    • Returns session metadata from SDK
  2. Frontend: Update SessionInfoModal

    • Replace init message parsing with API call
    • Poll on modal open
    • Add refresh button if desired
  3. SDK Integration: Ensure get_session_info() is properly wired in SessionCoordinator

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions