import { useSyncExternalStore } from "react"; import { createRoot } from "react-dom/client"; import { QueuedSummaryContent } from "@/ToolCallBlocks/QueuedSummaryContent.js"; import { ConsecutiveSummaryGroup } from "@/ToolCallBlocks/ToolSummaryRow.js"; import { Reasoning, ReasoningTrigger } from "@/components/ai-elements/reasoning.js"; import { SummaryGroupBoundaryContext } from "@/v4/conversationRowContext.js"; import { ZCodeIntlProvider } from "@/i18n/IntlProvider.js"; import "@/styles.css"; const params = new URLSearchParams(location.search); const theme = params.get("theme") === "dark" ? "dark" : "light"; document.documentElement.className = `${theme} theme-zai-${theme}`; let snapshot = { key: "A", text: "A initial", secondary: "secondary 0", trailing: "+0", enabled: true, disabled: false, streaming: true, mounted: true, }; const listeners = new Set<() => void>(); const subscribe = (listener: () => void) => { listeners.add(listener); return () => listeners.delete(listener); }; const getSnapshot = () => snapshot; const update = (patch: Partial) => { snapshot = { ...snapshot, ...patch }; for (const listener of listeners) listener(); }; // 同步订阅通知与真实投影 store 同形;microtask 连续交付固定触发旧实现的嵌套更新问题。 Object.assign(window, { summaryFixture: { update, async burst() { for (let i = 1; i <= 200; i++) { update({ text: `${"stream ".repeat(i)}A token ${i}`, secondary: `secondary ${i}`, trailing: `+${i}`, }); await Promise.resolve(); } }, }, }); function Fixture() { const state = useSyncExternalStore(subscribe, getSnapshot); const thought = ( ); return (
{state.mounted && (
{params.has("group") ? ( {thought} ) : params.has("reasoning") ? ( thought ) : ( {state.text}} secondaryText={{state.secondary}} trailingText={{state.trailing}} enabled={state.enabled} disableAnimation={state.disabled} /> )}
)}
); } createRoot(document.getElementById("root")!).render( , );