mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
Both message parsers accepted untyped input and relied on scattered asRecord/asString calls to extract fields at runtime. With the discriminated ChatMessagePart union, both accept typed input directly and narrow via switch (part.type). parseMessageContent narrows from (content: unknown) to (content: readonly ChatMessagePart[] | undefined), removing legacy input shape handling the Go backend normalizes away. applyMessagePartToStreamState narrows from Record<string, unknown> to ChatMessagePart. The SSE type guards had a & Record<string, unknown> intersection that widened everything untyped downstream. Since the data comes from our own API, the intersection was removed and all handlers in ChatContext now use generated types directly. Fixes tool_call_id and tool_name variant tags in codersdk/chats.go: marked optional to match reality (Go guards against empty values, omitempty omits them at the wire level). Refs #23168, #23175