Skip to content

Replace any-typing in the SSE/event layer with a typed discriminated union #101

Description

@lucastononro

Problem. ChatItem.meta is any (page.tsx:148), generatedFiles/restoredFiles are any[] (page.tsx:226, 1036), the SSE handler casts event.data as any then reads dozens of untyped fields (page.tsx:332, 553, 608, 655, 665, 688), and ChartTooltip props are any (MetricsTab.tsx:185, 193).

Why it matters. This defeats the type system exactly where malformed backend payloads are most likely.

Suggested fix. Define a discriminated union SSEEvent ({ type: 'metric'; data: MetricEvent } | …) in src/lib/types.ts and narrow on event.type; type meta per ChatItem.type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priorityarea:frontendFrontend (Next.js)code-qualityMaintainability / cleanliness

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions