MCPcopy Create free account
hub / github.com/Noumena-Network/code / DesktopHandoff

Function DesktopHandoff

src/components/DesktopHandoff.tsx:22–180  ·  view source on GitHub ↗
(t0)

Source from the content-addressed store, hash-verified

20 }) => void;
21};
22export function DesktopHandoff(t0) {
23 const $ = _c(20);
24 const {
25 onDone
26 } = t0;
27 const [state, setState] = useState("checking");
28 const [error, setError] = useState(null);
29 const [downloadMessage, setDownloadMessage] = useState("");
30 let t1;
31 if ($[0] !== error || $[1] !== onDone || $[2] !== state) {
32 t1 = input => {
33 if (state === "error") {
34 onDone(error ?? "Unknown error", {
35 display: "system"
36 });
37 return;
38 }
39 if (state === "prompt-download") {
40 if (input === "y" || input === "Y") {
41 openBrowser(getDownloadUrl()).catch(_temp);
42 onDone(`Starting download. Re-run /desktop once you\u2019ve installed the app.\nLearn more at ${DESKTOP_DOCS_URL}`, {
43 display: "system"
44 });
45 } else {
46 if (input === "n" || input === "N") {
47 onDone(`The desktop app is required for /desktop. Learn more at ${DESKTOP_DOCS_URL}`, {
48 display: "system"
49 });
50 }
51 }
52 }
53 };
54 $[0] = error;
55 $[1] = onDone;
56 $[2] = state;
57 $[3] = t1;
58 } else {
59 t1 = $[3];
60 }
61 useInput(t1);
62 let t2;
63 let t3;
64 if ($[4] !== onDone) {
65 t2 = () => {
66 const performHandoff = async function performHandoff() {
67 setState("checking");
68 const installStatus = await getDesktopInstallStatus();
69 if (installStatus.status === "not-installed") {
70 setDownloadMessage("NCode Desktop is not installed.");
71 setState("prompt-download");
72 return;
73 }
74 if (installStatus.status === "version-too-old") {
75 setDownloadMessage(`NCode Desktop needs to be updated (found v${installStatus.version}, need v1.1.2396+).`);
76 setState("prompt-download");
77 return;
78 }
79 setState("flushing");

Callers

nothing calls this directly

Calls 6

openBrowserFunction · 0.85
getDownloadUrlFunction · 0.85
useInputFunction · 0.85
performHandoffFunction · 0.85
onDoneFunction · 0.50
errorMessageFunction · 0.50

Tested by

no test coverage detected