channel-mention.fixture.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { createRoot } from "react-dom/client";
  2. import { channelContentText, type ChannelContentPart } from "@zcode/shared";
  3. import { ConversationUserInputBubble } from "@/v4/ConversationUserInputBubble.js";
  4. import { BotTopicPreparationList } from "@/v4/BotTopicPreparation.js";
  5. import { ConversationQueuePanel } from "@/v4/ConversationQueuePanel.js";
  6. import type { QueueState } from "@zcode/shared/zcode-protocol-v4";
  7. import { ZCodeIntlProvider } from "@/i18n/IntlProvider.js";
  8. import { TooltipProvider } from "@/components/ui/tooltip.js";
  9. import "@/styles.css";
  10. const theme = new URLSearchParams(location.search).get("theme");
  11. document.documentElement.className =
  12. theme === "light" ? "light theme-zai-light" : "dark theme-zai-dark";
  13. const parts: ChannelContentPart[] = [
  14. { type: "text", text: "帮我 " },
  15. {
  16. type: "channelMention",
  17. refId: "m1",
  18. name: "Ryan Bot",
  19. targetId: "ou_target",
  20. channel: "feishu",
  21. idType: "open_id",
  22. entityType: "unknown",
  23. },
  24. { type: "text", text: " 确认进度" },
  25. ];
  26. const text = channelContentText(parts);
  27. const source = {
  28. provider: "feishu",
  29. botId: "bot",
  30. senderId: "ou_sender",
  31. senderName: "Alice",
  32. chatId: "oc_group",
  33. messageId: "om_input",
  34. contentParts: parts,
  35. };
  36. const queue = {
  37. items: [
  38. {
  39. queueItemId: "q1",
  40. dispatch: { state: "queued" },
  41. text,
  42. attachments: [],
  43. botGroupSource: source,
  44. },
  45. ],
  46. revision: 1,
  47. } as unknown as QueueState;
  48. createRoot(document.getElementById("root")!).render(
  49. <ZCodeIntlProvider initialLocale="zh-CN">
  50. <TooltipProvider>
  51. <main className="min-h-screen bg-background p-6 text-foreground">
  52. <div className="mx-auto flex max-w-3xl flex-col gap-6">
  53. <ConversationUserInputBubble text={text} contentParts={parts} rowId="native" />
  54. <BotTopicPreparationList
  55. provider="feishu"
  56. items={[
  57. {
  58. messageId: "preparing",
  59. senderName: "Alice",
  60. text,
  61. contentParts: parts,
  62. status: "preparing",
  63. },
  64. ]}
  65. acceptedRows={[]}
  66. />
  67. <ConversationQueuePanel queue={queue} />
  68. <div data-testid="typed">
  69. <ConversationUserInputBubble text={text} rowId="typed" />
  70. </div>
  71. </div>
  72. </main>
  73. </TooltipProvider>
  74. </ZCodeIntlProvider>,
  75. );