| 1 | import React, { useState } from "react"; |
| 2 | import { createRoot } from "react-dom/client"; |
| 3 | import { WorkspaceDockRegion } from "../src/app-shell/WorkspaceDockRegion"; |
| 4 | import { PresentedFiles } from "../src/components/PresentedFiles"; |
| 5 | import { LocaleProvider } from "../src/lib/i18n"; |
| 6 | import { useActivityBarStore } from "../src/store/activityBar"; |
| 7 | import { useRemoteStore } from "../src/store/remote"; |
| 8 | import { installDesktopHostStub } from "../src/__tests__/desktopHostStub"; |
| 9 | import "../src/styles.css"; |
| 10 | |
| 11 | const file = (path: string) => ({ path, body: `NAVIGATION CONTENT ${path}`, size: 40, binary: false, truncated: false, mtimeUnix: 1 }); |
| 12 | let finishSave = () => {}; |
| 13 | installDesktopHostStub({ |
| 14 | ListDirForTab: async () => [], SearchFileRefsForTab: async () => [], |
| 15 | WorkspaceChanges: async () => ({ files: [], gitAvailable: true }), WorkspaceGitHistory: async () => [], |
| 16 | ResolveWorkspacePathForTab: async (_tab: string, path: string) => path.startsWith("/") ? path : `/fixture/${path}`, |
| 17 | ResolvePresentedPathForTab: async (_tab: string, _tool: string, path: string) => path.startsWith("/") ? path : `/fixture/${path}`, |
| 18 | ResolveRemoteWorkspacePathForTab: async (_tab: string, _host: string, _tool: string, path: string) => path, |
| 19 | ResolveRemotePresentedPathForTab: async (_tab: string, _host: string, _tool: string, path: string) => path, |
| 20 | ReadFileForTab: async (_tab: string, path: string) => file(path), |
| 21 | ReadPresentedFileForTab: async (_tab: string, _tool: string, path: string) => file(path), |
| 22 | ReadPresentedFileSourceForTab: async (_tab: string, _tool: string, path: string) => file(path), |
| 23 | ListRemoteDir: async () => ["a.txt", "b.txt"].map(name => ({ name, path: name, isDir: false, size: 40 })), |
| 24 | ReadRemoteFile: async (_host: string, path: string) => file(path), |
| 25 | WriteRemoteFile: () => new Promise(resolve => { finishSave = () => resolve({ conflict: false, newMtimeUnix: 2 }); }), |
| 26 | }); |
| 27 | useActivityBarStore.setState({ workspaceRoot: "/fixture", tabs: [], activeTabId: null }); |
| 28 | useRemoteStore.setState({ statuses: { remote: { state: "connected" } } }); |
| 29 | |
| 30 | function Fixture() { |
| 31 | const [hostId, setHostId] = useState("local"); |
| 32 | return <LocaleProvider> |
| 33 | <button id="switch-host" onClick={() => setHostId(value => value === "local" ? "remote" : "local")}>Switch host</button> |
| 34 | <button id="finish-save" onClick={() => finishSave()}>Finish save</button> |
| 35 | <PresentedFiles tabId={hostId} hostId={hostId} files={[{ path: `${hostId}.txt`, toolCallId: "present", description: "Navigation regression" }]} /> |
| 36 | <WorkspaceDockRegion visible overlay={false} mode="files" creation={false} showContext={false} |
| 37 | t={key => key} onPickEntry={() => {}} remote={{ onClose: () => {} }} context={{} as never} |
| 38 | workspace={{ open: true, tabId: hostId, cwd: "/fixture", maximized: false, onClose: () => {}, onToggleMaximized: () => {} }} |
| 39 | workspaceRoot="/fixture" workspaceKey="fixture" /> |
| 40 | </LocaleProvider>; |
| 41 | } |
| 42 | createRoot(document.getElementById("root")!).render(<Fixture />); |
| 43 |