Skip to content

[FEATURE] Let an app extension replace a chat message part rendererΒ #2894

Closed

Description

@Charlesthebird

πŸ€– written by Claude (start)

πŸ“ Feature Summary

Let an app extension replace the component that renders a chat message part, keyed by part kind.

❓ Problem Statement / Motivation

ChatMessageItem picks its component with a hardcoded ternary on part.dataKind (ChatMessageItem.tsx#L116). #2890 adds structured_output as a third branch. Every new part kind adds another.

The app extension system cannot reach it. All 13 points in EXTENSION_POINT_IDS are additive β€” ExtensionSlot mounts a component alongside the core one, never instead of it. Three of them sit in chat; none reaches part rendering.

So an extension that wants its own JSON viewer, its own tool-call card, or a domain renderer for an otherwise unknown payload has to fork ChatMessageItem.

πŸ’‘ Proposed Solution

Mirror providerIcons (types.ts#L298): a map keyed by a string, merged over the core map, later extension wins, unknown key simply added.

/** Replacement renderers for chat message parts, keyed by ChatDataPart["dataKind"]. */
chatPartRenderers?: Readonly<
  Partial<Record<ChatDataPart["dataKind"], ComponentType<{ part: ChatDataPart }>>>
>;

ChatMessageItem looks the kind up and falls back to the core component. That removes the ternary rather than growing it, and covers tool_call, tool_result, structured_output and unknown at once.

Open questions:

  • Key on ChatPart["kind"] as well, so text and approval records are replaceable?
  • Does a renderer need turn context (taskId, sessionId), the way app_agents_agentChat_agentChatMessage_additionalActionsButton does?

πŸ”„ Alternatives Considered

  • A new additive slot per part kind. Wrong shape β€” the core card still renders, so the reader sees two.
  • shell region replacement. Too coarse; it replaces navigation regions, not a leaf component.

🎯 Affected Service(s)

UI Service

πŸ“š Additional Context

Prompted by #2890, which hardcodes StructuredOutputCard into that ternary. Best done after it merges, so the change has something to replace.

Extension guide: ui/docs/app-extensions.md


πŸ€– written by Claude (end)

Activity

  1. added a commit that references this issue on Sep 26, 2026
    4ef51aa
  2. added a commit that references this issue on Oct 5, 2026
    7bafe1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions