Skip to content

refactor: add ActivityEventType literal union for type-safe event matching #877

@Aureliolo

Description

@Aureliolo

Problem

AgentActivityEvent.event_type is typed as string, but the codebase uses a finite, known set of event type values in ACTIVITY_ICON_MAP (utils/agents.ts). This means key typos are invisible to the compiler.

In contrast, CareerEvent.event_type correctly uses the CareerEventType literal union -- the inconsistency reduces type safety.

Proposed fix

  1. Define ActivityEventType literal union in web/src/api/types.ts with the known values: hired, fired, promoted, demoted, onboarded, task_completed, task_started, cost_incurred, tool_used, delegation_sent, delegation_received
  2. Use it in AgentActivityEvent.event_type (with | (string & {}) fallback for unknown future types)
  3. Update ACTIVITY_ICON_MAP to use Record<ActivityEventType, LucideIcon>

Found during PR #874 review (type-design-analyzer agent).

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec:human-interactionDESIGN_SPEC Section 13 - Human Interaction Layertype:refactorCode restructuring, cleanupv0.5Minor version v0.5

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions