MCPcopy
hub / github.com/claude-code-best/claude-code / DesktopHandoff

Function DesktopHandoff

src/components/DesktopHandoff.tsx:29–131  ·  view source on GitHub ↗
({ onDone }: Props)

Source from the content-addressed store, hash-verified

27};
28
29export function DesktopHandoff({ onDone }: Props): React.ReactNode {
30 const [state, setState] = useState<DesktopHandoffState>('checking');
31 const [error, setError] = useState<string | null>(null);
32 const [downloadMessage, setDownloadMessage] = useState<string>('');
33
34 // Handle keyboard input for error and prompt-download states
35 useInput(input => {
36 if (state === 'error') {
37 onDone(error ?? 'Unknown error', { display: 'system' });
38 return;
39 }
40 if (state === 'prompt-download') {
41 if (input === 'y' || input === 'Y') {
42 openBrowser(getDownloadUrl()).catch(() => {});
43 onDone(
44 `Starting download. Re-run /desktop once you\u2019ve installed the app.\nLearn more at ${DESKTOP_DOCS_URL}`,
45 { display: 'system' },
46 );
47 } else if (input === 'n' || input === 'N') {
48 onDone(`The desktop app is required for /desktop. Learn more at ${DESKTOP_DOCS_URL}`, { display: 'system' });
49 }
50 }
51 });
52
53 useEffect(() => {
54 async function performHandoff(): Promise<void> {
55 // Check Desktop install status
56 setState('checking');
57 const installStatus = await getDesktopInstallStatus();
58
59 if (installStatus.status === 'not-installed') {
60 setDownloadMessage('Claude Desktop is not installed.');
61 setState('prompt-download');
62 return;
63 }
64
65 if (installStatus.status === 'version-too-old') {
66 setDownloadMessage(`Claude Desktop needs to be updated (found v${installStatus.version}, need v1.1.2396+).`);
67 setState('prompt-download');
68 return;
69 }
70
71 // Flush session storage to ensure transcript is fully written
72 setState('flushing');
73 await flushSessionStorage();
74
75 // Open the deep link (uses claude-dev:// in dev mode)
76 setState('opening');
77 const result = await openCurrentSessionInDesktop();
78
79 if (!result.success) {
80 setError(result.error ?? 'Failed to open Claude Desktop');
81 setState('error');
82 return;
83 }
84
85 // Success - exit the CLI
86 setState('success');

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected