通过 author 命名发送者,parts 提供有稳定 id 的内容序列。align="end" 使用逻辑末端对齐;variant="soft" 为正文添加轻背景气泡,不会把过程和扩展内容也套进气泡。
消息默认居中于最大 48rem 的阅读列,作者、过程、正文与尾部操作有各自的层级。在共同祖先设置 --qk-chat-content-width 可同时调整 Message、MessageList 与 Composer 的阅读宽度。
消息与操作
parts 默认呈现正文、推理、工具、提示和自定义回退。copyText 开启内置复制;actions 配置常用与更多操作,点击只发出 action 请求。branch 提供受控的版本导航,宿主通过 branchChange 更新选中项。
state 支持 pending / streaming / complete / stopped / error,statusText 可补充原因。停止或报错不删除已有内容。默认不重复显示作者行;多人场景可开启 showHeader。meta 显示尾部时间等次要信息。
pending / streaming 的短状态文字使用公共 Shimmer,终态保持静态;系统减少动效时不扫光。无正文的等待消息也可以直接呈现状态。
消息操作的 when 默认为 settled,生成时隐藏复制和完成态命令;停止使用 active,必要恢复与确认使用 always。actionsVisibility="auto" 配合 latest:最新消息的操作和时间作为一组低强调常驻,历史消息的整组 footer 在桌面 hover/focus 时显示,触屏保持入口。always / hover 可显式覆盖,必要动作不受隐藏策略影响。独立 Message 默认按最新消息展示;放入 Message List 时,列表只按顺序标记最后一条消息,不根据是否有操作跳过尾部用户消息。
内容与交互状态
text、reasoning、tool-input、tool-output 和 custom slots 只替换对应内容,保留 Part 的状态与交互。正文可直接使用 Prose 和 CodeBlock,组件不解析 Markdown。独立 Part 用法见 Chat Message Part。
仍可用默认 slot 接管整段内容;此时 parts 不重复渲染。avatar、header、status 和 actions slots 用于高级覆盖;actions({ latest, visibility }) 会替换内置操作组,宿主应将这两个参数传给自定义操作组并自行保持 hover/焦点/触屏可达性。
保持 messageId 与 Part 的 id 稳定,内容追加和终态变化不会重建已有实例。切换消息或版本会清理内容的局部状态;分支导航自身保持。组件不逐 token 播报正文。
界面文案与排版方向跟随 Locale Provider。正文 renderer 可以使用 dir="auto",代码保持 dir="ltr"。
独立组件组合
已有内容模型可以直接组合 Reasoning、Tool 和 Process。Actions、Action 和 Branch 也可独立使用,无需重写这些交互。
API
QuireChatMessage Props
Slots 内容位置
avatar发送者头像或标记。
anyheader替换发送者标题,例如加入时间。
anydefault正文、Prose、代码或业务 part;宿主提供稳定 key。
anystatus可读的生成、失败或停止状态。
anyactions复制、重试、反馈等宿主操作;替换内置组时可沿用解析后的展示策略。
{ /** 是否为最新消息。 */ latest: boolean; /** 操作组的展示模式。 */ visibility: "always" | "auto" | "hover"; }text正文/Markdown renderer。
{ part: { /** 正文判别项。 */ kind: "text"; /** 原始内容,默认安全转义并保留换行。 */ text: string; /** plain 为默认值;markdown 无 renderer 时显示带说明的源文本。 */ format?: undefined | "plain" | "markdown"; /** 内容接收状态,默认 complete。 */ state?: undefined | "error" | "complete" | "streaming" | "stopped"; /** 消息内唯一、非空的稳定 ID,跨 chunk 和终态保持。 */ id: string; /** 可选的局部操作。 */ actions?: undefined | readonly ({ /** 在所属操作组内稳定且唯一的标识。 */ id: string; /** 可见名称或图标操作的辅助名称。 */ label: string; /** IconProvider 中的图标名;省略时显示文字按钮。 */ icon?: string | undefined; /** 明确不可执行时禁用。 */ disabled?: boolean | undefined; /** 宿主正在处理此操作;阻止重复触发。 */ busy?: boolean | undefined; /** 内联反馈/开关类操作的受控按下状态;有此状态的操作保持内联。 */ pressed?: boolean | undefined; /** 需要危险语义的操作。 */ danger?: boolean | undefined; /** inline 留在操作栏,more 放进紧凑的公共 Menu。 */ placement?: "inline" | "more" | undefined; /** 消息级默认 settled,Part 级默认 always;active 用于停止,always 用于必要恢复/确认。 */ when?: "settled" | "active" | "always" | undefined; })[]; }; }reasoning推理详情 renderer;展开行为仍由 Part 持有。
{ part: { /** 推理判别项。 */ kind: "reasoning"; /** 标题;省略时使用语言包中的默认标题。 */ title?: undefined | string; /** 可选单行摘要,不由 UI 猜测或定时生成。 */ summary?: string | undefined; /** 宿主提供的耗时等次要文案。 */ meta?: string | undefined; /** 完整推理文本。 */ text: string; /** 推理状态,默认 complete;不会改变用户的展开选择。 */ state?: undefined | "error" | "complete" | "streaming" | "stopped"; /** 消息内唯一、非空的稳定 ID,跨 chunk 和终态保持。 */ id: string; /** 可选的局部操作。 */ actions?: undefined | readonly ({ /** 在所属操作组内稳定且唯一的标识。 */ id: string; /** 可见名称或图标操作的辅助名称。 */ label: string; /** IconProvider 中的图标名;省略时显示文字按钮。 */ icon?: string | undefined; /** 明确不可执行时禁用。 */ disabled?: boolean | undefined; /** 宿主正在处理此操作;阻止重复触发。 */ busy?: boolean | undefined; /** 内联反馈/开关类操作的受控按下状态;有此状态的操作保持内联。 */ pressed?: boolean | undefined; /** 需要危险语义的操作。 */ danger?: boolean | undefined; /** inline 留在操作栏,more 放进紧凑的公共 Menu。 */ placement?: "inline" | "more" | undefined; /** 消息级默认 settled,Part 级默认 always;active 用于停止,always 用于必要恢复/确认。 */ when?: "settled" | "active" | "always" | undefined; })[]; }; }tool-input工具参数 renderer。
{ part: { /** 工具判别项。 */ kind: "tool"; /** 可读工具名称。 */ title: string; /** 公共 Icon 名称,默认 terminal;由宿主表达读取、编辑、图片等工具类别。 */ icon?: undefined | string; /** 一行任务摘要。 */ summary?: string | undefined; /** 耗时等由宿主提供的元信息。 */ meta?: string | undefined; /** 权威展示状态,不能根据 output 是否存在猜测。 */ state: "failed" | "queued" | "running" | "waiting" | "succeeded" | "cancelled" | "interrupted"; /** 自定义状态文案,例如具体等待原因。 */ stateLabel?: string | undefined; /** 可选原始输入文本。 */ input?: string | undefined; /** 可选原始输出文本。 */ output?: string | undefined; /** 输入代码语言标签,默认 text。 */ inputLanguage?: string | undefined; /** 输出代码语言标签,默认 text。 */ outputLanguage?: string | undefined; /** 可读错误说明;不替换已有输出。 */ error?: string | undefined; /** 仅提供部分输出时必须传入的截断说明;默认禁止复制不完整输出。 */ outputTruncated?: string | undefined; /** 消息内唯一、非空的稳定 ID,跨 chunk 和终态保持。 */ id: string; /** 可选的局部操作。 */ actions?: undefined | readonly ({ /** 在所属操作组内稳定且唯一的标识。 */ id: string; /** 可见名称或图标操作的辅助名称。 */ label: string; /** IconProvider 中的图标名;省略时显示文字按钮。 */ icon?: string | undefined; /** 明确不可执行时禁用。 */ disabled?: boolean | undefined; /** 宿主正在处理此操作;阻止重复触发。 */ busy?: boolean | undefined; /** 内联反馈/开关类操作的受控按下状态;有此状态的操作保持内联。 */ pressed?: boolean | undefined; /** 需要危险语义的操作。 */ danger?: boolean | undefined; /** inline 留在操作栏,more 放进紧凑的公共 Menu。 */ placement?: "inline" | "more" | undefined; /** 消息级默认 settled,Part 级默认 always;active 用于停止,always 用于必要恢复/确认。 */ when?: "settled" | "active" | "always" | undefined; })[]; }; }tool-output工具输出 renderer,包括业务预览或审批组合。
{ part: { /** 工具判别项。 */ kind: "tool"; /** 可读工具名称。 */ title: string; /** 公共 Icon 名称,默认 terminal;由宿主表达读取、编辑、图片等工具类别。 */ icon?: undefined | string; /** 一行任务摘要。 */ summary?: string | undefined; /** 耗时等由宿主提供的元信息。 */ meta?: string | undefined; /** 权威展示状态,不能根据 output 是否存在猜测。 */ state: "failed" | "queued" | "running" | "waiting" | "succeeded" | "cancelled" | "interrupted"; /** 自定义状态文案,例如具体等待原因。 */ stateLabel?: string | undefined; /** 可选原始输入文本。 */ input?: string | undefined; /** 可选原始输出文本。 */ output?: string | undefined; /** 输入代码语言标签,默认 text。 */ inputLanguage?: string | undefined; /** 输出代码语言标签,默认 text。 */ outputLanguage?: string | undefined; /** 可读错误说明;不替换已有输出。 */ error?: string | undefined; /** 仅提供部分输出时必须传入的截断说明;默认禁止复制不完整输出。 */ outputTruncated?: string | undefined; /** 消息内唯一、非空的稳定 ID,跨 chunk 和终态保持。 */ id: string; /** 可选的局部操作。 */ actions?: undefined | readonly ({ /** 在所属操作组内稳定且唯一的标识。 */ id: string; /** 可见名称或图标操作的辅助名称。 */ label: string; /** IconProvider 中的图标名;省略时显示文字按钮。 */ icon?: string | undefined; /** 明确不可执行时禁用。 */ disabled?: boolean | undefined; /** 宿主正在处理此操作;阻止重复触发。 */ busy?: boolean | undefined; /** 内联反馈/开关类操作的受控按下状态;有此状态的操作保持内联。 */ pressed?: boolean | undefined; /** 需要危险语义的操作。 */ danger?: boolean | undefined; /** inline 留在操作栏,more 放进紧凑的公共 Menu。 */ placement?: "inline" | "more" | undefined; /** 消息级默认 settled,Part 级默认 always;active 用于停止,always 用于必要恢复/确认。 */ when?: "settled" | "active" | "always" | undefined; })[]; }; }custom扩展内容 renderer,不存在时保留可读回退。
{ part: { /** 扩展判别项,未知业务类型应显式投影到这里。 */ kind: "custom"; /** 扩展内容的可读名称。 */ name: string; /** 无 renderer 时显示的安全回退文本,不自动转储 data。 */ fallback: string; /** 不透明业务数据,仅转交自定义 slot。 */ data?: unknown; /** 消息内唯一、非空的稳定 ID,跨 chunk 和终态保持。 */ id: string; /** 可选的局部操作。 */ actions?: undefined | readonly ({ /** 在所属操作组内稳定且唯一的标识。 */ id: string; /** 可见名称或图标操作的辅助名称。 */ label: string; /** IconProvider 中的图标名;省略时显示文字按钮。 */ icon?: string | undefined; /** 明确不可执行时禁用。 */ disabled?: boolean | undefined; /** 宿主正在处理此操作;阻止重复触发。 */ busy?: boolean | undefined; /** 内联反馈/开关类操作的受控按下状态;有此状态的操作保持内联。 */ pressed?: boolean | undefined; /** 需要危险语义的操作。 */ danger?: boolean | undefined; /** inline 留在操作栏,more 放进紧凑的公共 Menu。 */ placement?: "inline" | "more" | undefined; /** 消息级默认 settled,Part 级默认 always;active 用于停止,always 用于必要恢复/确认。 */ when?: "settled" | "active" | "always" | undefined; })[]; }; }
Events 组件事件
action[details: QuireKitChatActionDetails]copy[]copyError[details: QuireKitClipboardErrorDetails]attachmentAction[details: QuireKitChatAttachmentActionDetails]sourceNavigate[details: QuireKitChatSourceNavigateDetails]confirmationDecision[details: QuireKitChatConfirmationDecisionDetails]questionDraftChange[details: QuireKitChatQuestionDraftDetails]questionOpen[details: QuireKitChatQuestionOpenPartDetails]questionSubmit[details: QuireKitChatQuestionSubmitPartDetails]branchChange[details: QuireKitChatBranchChangeDetails]