File tree Expand file tree Collapse file tree 4 files changed +34
-5
lines changed
sessions/WebSocketSession Expand file tree Collapse file tree 4 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export class Sandbox {
103103 opts : SessionCreateOptions
104104 ) : Promise < SandboxSession > {
105105 if ( opts . id . length > 20 ) {
106- throw new Error ( "Session ID must be 32 characters or less" ) ;
106+ throw new Error ( "Session ID must be 20 characters or less" ) ;
107107 }
108108
109109 const response = await vmCreateSession ( {
@@ -151,6 +151,8 @@ export class Sandbox {
151151 ? await this . createSession ( customSession )
152152 : this . globalSession ;
153153
154+ console . log ( "SESSION" , session ) ;
155+
154156 const pitcherClient = await initPitcherClient (
155157 {
156158 appId : "sdk" ,
@@ -208,6 +210,7 @@ export class Sandbox {
208210 ) ;
209211
210212 return new WebSocketSession ( pitcherClient , {
213+ sessionId : customSession ?. id ,
211214 env : customSession ?. env ,
212215 hostToken : customSession ?. hostToken ,
213216 } ) ;
@@ -237,6 +240,7 @@ export class Sandbox {
237240 return {
238241 id : this . id ,
239242 env : customSession ?. env ,
243+ sessionId : customSession ?. id ,
240244 hostToken : customSession ?. hostToken ,
241245 bootupType : this . bootupType ,
242246 cluster : this . cluster ,
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ export class FileSystem {
4242 private disposable = new Disposable ( ) ;
4343 constructor (
4444 sessionDisposable : Disposable ,
45- private pitcherClient : IPitcherClient
45+ private pitcherClient : IPitcherClient ,
46+ private sessionId ?: string
4647 ) {
4748 sessionDisposable . onWillDispose ( ( ) => {
4849 this . disposable . dispose ( ) ;
@@ -212,7 +213,21 @@ export class FileSystem {
212213 const result = await this . pitcherClient . clients . fs . watch (
213214 path ,
214215 options ,
215- ( event ) => emitter . fire ( event )
216+ ( event ) => {
217+ if ( this . sessionId ) {
218+ emitter . fire ( {
219+ ...event ,
220+ paths : event . paths . map ( ( path ) =>
221+ path . replace (
222+ `home/csb-session-${ this . sessionId } /workspace/` ,
223+ "sandbox/"
224+ )
225+ ) ,
226+ } ) ;
227+ } else {
228+ emitter . fire ( event ) ;
229+ }
230+ }
216231 ) ;
217232
218233 if ( result . type === "error" ) {
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ export class WebSocketSession {
3131 /**
3232 * Namespace for all filesystem operations on this Sandbox
3333 */
34- public readonly fs = new FileSystem ( this . disposable , this . pitcherClient ) ;
34+ public readonly fs : FileSystem ;
3535
3636 /**
3737 * Namespace for hosts
@@ -75,7 +75,15 @@ export class WebSocketSession {
7575
7676 constructor (
7777 protected pitcherClient : IPitcherClient ,
78- { env, hostToken } : { env ?: Record < string , string > ; hostToken ?: HostToken }
78+ {
79+ env,
80+ hostToken,
81+ sessionId,
82+ } : {
83+ env ?: Record < string , string > ;
84+ hostToken ?: HostToken ;
85+ sessionId ?: string ;
86+ }
7987 ) {
8088 // TODO: Bring this back once metrics polling does not reset inactivity
8189 // const metricsDisposable = {
@@ -84,6 +92,7 @@ export class WebSocketSession {
8492 // };
8593
8694 // this.addDisposable(metricsDisposable);
95+ this . fs = new FileSystem ( this . disposable , this . pitcherClient , sessionId ) ;
8796 this . terminals = new Terminals ( this . disposable , this . pitcherClient , env ) ;
8897 this . commands = new Commands ( this . disposable , this . pitcherClient , env ) ;
8998
Original file line number Diff line number Diff line change @@ -237,6 +237,7 @@ export type SandboxOpts = {
237237
238238export type SandboxBrowserSession = PitcherManagerResponse & {
239239 id : string ;
240+ sessionId ?: string ;
240241 env ?: Record < string , string > ;
241242 hostToken ?: HostToken ;
242243} ;
You can’t perform that action at this time.
0 commit comments