Skip to content

Normalize Content shapes before message categorization #123

@DrumRobot

Description

@DrumRobot

Problem

categorizeMessage in packages/web/src/lib/utils/message.ts assumes Content is always an array, but Content can also be a string, a single content item, or messages may use a top-level msg field. This causes incorrect categorization for non-array content shapes.

Origin

CodeRabbit review on PR #97 (commit 6d447a6) — identified as out of PR scope.

Proposed Solution

  • Add a normalizeContent(content: Content): ContentItem[] helper:
    • string[{ type: 'text', text: content }]
    • Single ContentItem[content]
    • ContentItem[] → pass through
    • msg field fallback
  • Apply normalization before categorization in categorizeMessage

Acceptance Criteria

  • All Content shapes (string, single item, array, msg field) correctly categorized
  • Unit tests covering each Content shape variant
  • No regression in existing message display

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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