ConversationUserInputBubble.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import type { ChannelContentPart } from "@zcode/shared";
  2. import { ChannelMentionContent } from "@/v4/ChannelMentionContent.js";
  3. import { ConversationUserInputEpilogue } from "@/v4/ConversationUserInputEpilogue.js";
  4. import { ConversationUserInputBody } from "@/v4/ConversationUserInputBody.js";
  5. import { ConversationUserInputContent } from "@/v4/ConversationUserInputContent.js";
  6. /** 正式消息和准备态共用完整正文渲染;状态由消息来源行展示。 */
  7. export function ConversationUserInputBubble({
  8. text,
  9. contentParts,
  10. rowId,
  11. attachments,
  12. contextAttachmentCount,
  13. epilogue,
  14. }: {
  15. text: string;
  16. contentParts?: readonly ChannelContentPart[];
  17. rowId: string | number;
  18. attachments?: readonly unknown[];
  19. contextAttachmentCount?: number;
  20. epilogue?: string;
  21. }) {
  22. if (!text.trim() && epilogue === undefined) return null;
  23. return (
  24. <div
  25. data-v4-user-input-bubble="true"
  26. className="flex max-w-full flex-col gap-2 rounded-xl rounded-tr-xs border border-border bg-surface px-4 py-3 text-ui-base text-foreground @min-[624px]/conversation:max-w-xl"
  27. >
  28. {text.trim() ? (
  29. <ConversationUserInputBody contentText={text} rowId={rowId}>
  30. {contentParts?.some((part) => part.type === "channelMention") ? (
  31. <ChannelMentionContent parts={contentParts} text={text} />
  32. ) : (
  33. <ConversationUserInputContent
  34. text={text}
  35. attachments={attachments}
  36. contextAttachmentCount={contextAttachmentCount}
  37. />
  38. )}
  39. </ConversationUserInputBody>
  40. ) : null}
  41. {epilogue === undefined ? null : <ConversationUserInputEpilogue text={epilogue} />}
  42. </div>
  43. );
  44. }