MCPcopy Index your code
hub / github.com/jetify-com/devbox / handleOpenInVSCode

Function handleOpenInVSCode

vscode-extension/src/openinvscode.ts:18–49  ·  view source on GitHub ↗
(uri: Uri)

Source from the content-addressed store, hash-verified

16};
17
18export async function handleOpenInVSCode(uri: Uri) {
19 const queryParams = new URLSearchParams(uri.query);
20
21 if (queryParams.has('vm_id') && queryParams.has('token')) {
22 //Not yet supported for windows + WSL - will be added in future
23 if (os.platform() !== 'win32') {
24 window.showInformationMessage('Setting up devbox');
25 // getting ssh keys
26 try {
27 console.debug('Calling getVMInfo...');
28 const response = await getVMInfo(queryParams.get('token'), queryParams.get('vm_id'));
29 const res = await response.json() as VmInfo;
30 console.debug('getVMInfo response: ' + res);
31 // set ssh config
32 console.debug('Calling setupSSHConfig...');
33 await setupSSHConfig(res.vm_id, res.private_key);
34
35 // connect to remote vm
36 console.debug('Calling connectToRemote...');
37 connectToRemote(res.username, res.vm_id, res.working_directory);
38 } catch (err: any) {
39 console.error(err);
40 window.showInformationMessage('Failed to setup devbox remote connection.');
41 }
42 } else {
43 window.showErrorMessage('This function is not yet supported in Windows operating system.');
44 }
45 } else {
46 window.showErrorMessage('Error parsing information for remote environment.');
47 console.debug(queryParams.toString());
48 };
49}
50
51async function getVMInfo(token: string | null, vmId: string | null): Promise<any> {
52 // send post request to gateway to get vm info and ssh keys

Callers

nothing calls this directly

Calls 4

getVMInfoFunction · 0.85
setupSSHConfigFunction · 0.85
connectToRemoteFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected