You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
[finding] plugin-chatbot's SDUI renderer casts messages as any across the @object-ui/types ↔ plugin-chatbot ChatMessage boundary #4399
Found while implementing #4383 (converging plugin-chatbot's two ChatMessage types). Out of that card's scope — it is a cross-package seam, not the barrel collision #4383 owns — so filing it rather than fixing it. Unassigned, finding-labelled, no pm:queue: nothing a user hits today (evidence below).
Fact
After #4383, @object-ui/plugin-chatbot exports one ChatMessage. @object-ui/typesalso exports a ChatMessage, and it is a different shape. Both are deliberate — one is the JSON/SDUI authoring contract, the other the React runtime contract — but they meet inside one file, and the meeting point is three as any casts:
renderer.tsx imports ChatMessage from @object-ui/types, feeds schema.messages through useObjectChat, and hands the result to components whose messages prop is the plugin's own ChatMessage. The cast is what makes that compile.
Three declared drifts between the two:
key
@object-ui/types (authoring)
@object-ui/plugin-chatbot (runtime)
role
'user' | 'assistant' | 'system' | 'tool'
'user' | 'assistant' | 'system'
timestamp
string | Date
string
metadata
Record (via z.record)
not declared
'tool' and Date are genuinely authorable: ChatMessageSchema in packages/types/src/zod/complex.zod.ts:229 declares z.enum([… 'tool']) and z.union([z.string(), z.date()]).
Why finding and not a defect
Both drifts are absorbed at the runtime seam, so no user-visible failure exists today — this is dormant type drift, not a bug:
timestamp: normalizeMessages in useObjectChat.ts:261 coerces msg.timestamp instanceof Date ? msg.timestamp.toISOString() : …, so a Date never reaches a React child. (Without that it would be the classic "Objects are not valid as a React child" throw when showTimestamp is on.)
role: 'tool': formatMessageProps at ChatbotEnhanced.tsx:847 returns role === 'user' ? 'user' : 'assistant', so a tool message renders as an assistant bubble. Content is shown, nothing is lost, nothing throws.
Why it is still worth a card
The as any is the only thing holding the two contracts apart, and it erases all of the drift rather than the parts that are intentional. If either vocabulary moves — a new schema role, a required runtime key — the cast will keep compiling and the mismatch will surface as rendering behaviour instead of a type error. The honest shapes would be an explicit adapter at the seam (schema message to runtime message, one function, its narrowing decisions written down and tested), which also gives role: 'tool' a named rendering decision instead of an implicit fallthrough.
Anchor
Measured on claude/issue-4383-chatmessage-collision at 14613a863 (branch point bb58d1d61, 2026-08-12). Reproduce: git grep -n "messages as any" -- packages/plugin-chatbot/src/renderer.tsx.
Related: #4383 (the in-package collision, fixed), #4040.
CLAIM + RULING — PM seat session_017Qqyix2QcnpUC9XeYVDzx3, branch claude/issue-4399-chatmessage-seam-adapter, one dev agent, one PR, Fixes #4399. finding → pm:queue.
Ruling (delegated, veto window open): the card's own adapter direction is adopted. One explicit typed conversion at the authoring↔runtime seam replaces the three as any casts; its narrowing decisions are written down and tested — including a named rendering decision for role: 'tool' (today's absorbed outcome, tool-renders-as-assistant-bubble, becomes the documented decision unless the measurement shows a reason to change it — this PR is a typing card, not a UX change; zero rendered-output change is the acceptance bar). Design constraint: the adapter must not become a THIRD dialect — normalizeMessages already owns the Date→ISO absorption, so the adapter composes or relocates the existing absorptions rather than restating them; the dev measures which placement leaves the logic singly-expressed. The intentional drifts stay intentional (authoring keeps 'tool' and Date); what dies is only the cast that erased ALL drift, so a future vocabulary move surfaces as a type error instead of rendering behavior.
Activity
yinlianghui commentedon Aug 12, 2026
CLAIM + RULING — PM seat
session_017Qqyix2QcnpUC9XeYVDzx3, branchclaude/issue-4399-chatmessage-seam-adapter, one dev agent, one PR,Fixes #4399.finding→pm:queue.Ruling (delegated, veto window open): the card's own adapter direction is adopted. One explicit typed conversion at the authoring↔runtime seam replaces the three
as anycasts; its narrowing decisions are written down and tested — including a named rendering decision forrole: 'tool'(today's absorbed outcome, tool-renders-as-assistant-bubble, becomes the documented decision unless the measurement shows a reason to change it — this PR is a typing card, not a UX change; zero rendered-output change is the acceptance bar). Design constraint: the adapter must not become a THIRD dialect —normalizeMessagesalready owns theDate→ISO absorption, so the adapter composes or relocates the existing absorptions rather than restating them; the dev measures which placement leaves the logic singly-expressed. The intentional drifts stay intentional (authoring keeps'tool'andDate); what dies is only the cast that erased ALL drift, so a future vocabulary move surfaces as a type error instead of rendering behavior.Generated by Claude Code
refactor(plugin-chatbot): one typed adapter at the ChatMessage seam (o…
refactor(plugin-chatbot): useObjectChat declares the message shape it…
refactor(app-shell): AiChatPage narrows the chat hook's messages thro…