Skip to content

Refactor: Extract session relationship population into shared helper #3

@samkeen

Description

@samkeen

Background

The fix for session/sub-agent relationships (populating parentSessionId and subAgentIds) introduced repeated code in 4 places:

  • get_project()
  • list_sessions()
  • get_session()
  • get_activity()

Proposal

Extract the relationship population logic into a shared helper function:

def populate_session_relationships(sessions: list[dict], project_dir: Path) -> None:
    """Populate parentSessionId and subAgentIds on session dicts in-place."""
    ...

This would reduce code duplication and make future changes easier to maintain.

Files to modify

  • api/src/utils.py - Add helper function
  • api/src/routes/projects.py - Use helper in 3 places
  • api/src/routes/activity.py - Use helper in 1 place

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions