Skip to content

fix: align frontend DepartmentHealth type with backend model #892

@Aureliolo

Description

@Aureliolo

Problem

The frontend DepartmentHealth interface (web/src/api/types.ts) does not match the backend DepartmentHealth Pydantic model (src/synthorg/api/controllers/departments.py).

Frontend has:

interface DepartmentHealth {
  name: DepartmentName
  display_name: string
  health_percent: number
  agent_count: number
  task_count: number
  cost_usd: number | null
}

Backend returns:

class DepartmentHealth(BaseModel):
    department_name: NotBlankStr
    agent_count: int
    active_agent_count: int
    currency: str
    avg_performance_score: float | None
    department_cost_7d: float
    cost_trend: tuple[TrendDataPoint, ...]
    collaboration_score: float | None
    utilization_percent: float  # computed

Every field except agent_count is mismatched. Components reading health_percent, task_count, display_name, or cost_usd get undefined at runtime.

Why not fixed in #888

The type is consumed by 26 files across the codebase (analytics store, Dashboard page, Org Chart, utilities, and their tests). Fixing it cascades far beyond the Company page PR scope.

Scope

  1. Update DepartmentHealth in web/src/api/types.ts to match the backend model
  2. Update all 26 consumers to use the new field names
  3. Update DeptHealthBar component props if needed (currently expects health, agentCount, taskCount)
  4. Update all test factories and story mock data
  5. Verify the Dashboard and Org Chart pages still render correctly

Found by

api-contract-drift review agent during PR #888 review (confidence: 98).

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:medium1-3 days of workspec:company-structureDESIGN_SPEC Section 4 - Company Structuretype:fixBug fixes and correctionsv0.5Minor version v0.5

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions