@@ -145,10 +145,10 @@ export class JupyterExtension {
145
145
cwd : string = '/home/user' ,
146
146
kernelName ?: string
147
147
) : Promise < string > {
148
- const data = { path : cwd , kernel : { name : " python3" } , type : "notebook" , name : id ( 16 ) }
149
- if ( kernelName ) {
150
- data . kernel . name = kernelName
151
- }
148
+ kernelName = kernelName || ' python3'
149
+
150
+
151
+ const data = { path : id ( 16 ) , kernel : { name : kernelName } , type : "notebook" , name : id ( 16 ) }
152
152
153
153
const response = await fetch (
154
154
`${ this . sandbox . getProtocol ( ) } ://${ this . sandbox . getHostname (
@@ -164,9 +164,27 @@ export class JupyterExtension {
164
164
throw new Error ( `Failed to create kernel: ${ response . statusText } ` )
165
165
}
166
166
167
+
167
168
const sessionInfo = await response . json ( )
168
169
const kernelID = sessionInfo . kernel . id
169
- await this . connectToKernelWS ( kernelID , sessionInfo . id )
170
+ const sessionID = sessionInfo . id
171
+
172
+ const patchResponse = await fetch (
173
+ `${ this . sandbox . getProtocol ( ) } ://${ this . sandbox . getHostname (
174
+ 8888
175
+ ) } /api/sessions/${ sessionID } `,
176
+ {
177
+ method : 'PATCH' ,
178
+ body : JSON . stringify ( { path : cwd } )
179
+ }
180
+ )
181
+
182
+ if ( ! patchResponse . ok ) {
183
+ throw new Error ( `Failed to create kernel: ${ response . statusText } ` )
184
+ }
185
+
186
+
187
+ await this . connectToKernelWS ( kernelID , sessionID )
170
188
171
189
return kernelID
172
190
}
0 commit comments