import { useEffect, useState } from "react"; import { createRoot } from "react-dom/client"; import type { FileMediaPreview, IPlatformService } from "@zcode/shared"; import { ToolCallBody } from "@/ToolCallBlocks/ToolCallBody.js"; import { ToolPresentationCapabilitiesProvider } from "@/ToolCallBlocks/presentationCapabilities.js"; import { OpenSplitButton } from "@/OpenSplitButton.js"; import { PlatformProvider } from "@/hooks/usePlatform.js"; import { TabStoreProvider, useTabStoreApi } from "@/store/TabStoreProvider.js"; import { ZCodeIntlProvider } from "@/i18n/IntlProvider.js"; import { Button } from "@/components/ui/button.js"; import "@/styles.css"; const params = new URLSearchParams(location.search); const icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+a9K0AAAAASUVORK5CYII="; document.documentElement.className = `${params.get("theme")} theme-zai-${params.get("theme")}`; let releaseOld: ((value: FileMediaPreview) => void) | undefined; const readMediaPreview = async (path: string): Promise => { if (path === "failure") throw new Error("fixture image read failure"); if (path === "pending") return new Promise((resolve) => { releaseOld = resolve; }); return { path, dataBase64: path === "empty" ? "" : icon, totalBytes: 1, mediaType: "image/png" }; }; const platform = { canOpenLocalFiles: true, getInstalledEditors: async () => [ { id: "vscode", name: "VS Code", iconDataUrl: icon }, { id: "word", name: "Word", iconDataUrl: icon }, ], openInEditor: async (_id: string, _path: string, options: unknown) => { document.querySelector("#opened")!.textContent = JSON.stringify(options); if (params.get("failure") === "reject") throw new Error("fixture open rejection"); return { success: false, error: "fixture open failure" }; }, } as unknown as IPlatformService; function Fixture() { const tabs = useTabStoreApi(); const [path, setPath] = useState("pending"); useEffect(() => { tabs.getState().addTab("/workspace", { workspaceIdentity: "remote-fixture", remoteTarget: { kind: "ssh", host: "example.com", username: "dev" }, }); }, [tabs]); return (
{["pending", "failure", "empty", "success"].map((value) => ( ))}
{}} renderCard={(button) =>
Report{button}
} />
); } createRoot(document.getElementById("root")!).render( , );