Skip to content

Add MessageParts to render a message's parts #112

Closed

Description

@pratikbuilds

Add MessageParts, which renders a ConversationMessage's parts with the new chat components, so hosts stop mapping parts to components by hand.

Part of #94.

Depends on #97, #98, #104, #105, #110.

Why

Every host maps ConversationPart to components itself: the whole-chat story, the activity stories and the e2e fixtures each carry their own copy. Each copy also re-implements the approval focus handoff: when groupActivity folds a decided call into the run before it, the call's buttons unmount and focus falls to <body> unless the host moves it. The old PartsRenderer only knew the part type that #110 removes.

What

  • src/ui/message-parts.tsx: MessageParts groups a message's parts with groupActivity and renders each kind with its component: Activity for reasoning and tool runs, ToolApproval for a call waiting on a person, ToolGroup for a batch with a waiting call, MessageContent for text (markdown through a render prop), Attachments tiles for files, GeneratedImages, Sources and ConversationNotice.
  • A per-kind render override for every part kind, so a host can replace any one of them.
  • The focus handoff: after a keyboard decision folds a call away, focus moves to the run's ActivityTrigger, or to the next waiting call in a batch, and never to <body>.
  • Replace the hand-written mappings in the stories and e2e fixtures.
  • Export in src/index.ts.

Constraints

  • No new dependency or peer, no optional-peer import, token-only styling.
  • Markdown only through a render prop.

Done when

  • Unit tests cover every part kind, the overrides and focus after each decision (Approve, Approve always, Deny), including batches.
  • A browser spec asserts focus is never on <body> after a keyboard decision.
  • bun run check, bun run build, bun run test:e2e (with the Storybook axe sweep, known list unchanged) and bun run dep-guard pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions