@@ -53,14 +53,14 @@ initLogger();
53
53
const sessions : Array < { id : string } > = [ ] ;
54
54
if ( fs . existsSync ( sessionsRoot ) ) {
55
55
for ( const file of fs . readdirSync ( sessionsRoot ) ) {
56
- const m = file . match ( / ^ r o l l o u t - ( [ ^ . ] + ) \. j s o n $ / ) ;
56
+ const m = file . match ( / ^ ( . + ) \. j s o n $ / ) ;
57
57
if ( m && m [ 1 ] ) {
58
58
sessions . push ( { id : m [ 1 ] } ) ;
59
59
}
60
60
}
61
61
}
62
62
for ( const session of sessions ) {
63
- const sessionPath = path . join ( sessionsRoot , `rollout- ${ session . id } .json` ) ;
63
+ const sessionPath = path . join ( sessionsRoot , `${ session . id } .json` ) ;
64
64
const stats = fs . statSync ( sessionPath ) ;
65
65
const size = stats . size ;
66
66
const formattedDate = new Intl . DateTimeFormat ( undefined , {
@@ -351,15 +351,17 @@ if (
351
351
console . error ( "session id required" ) ;
352
352
process . exit ( 1 ) ;
353
353
}
354
+ // Use provided session id for new or resuming sessions
355
+ if ( cli . flags . session ) {
356
+ setSessionId ( sessionIdFlag ) ;
357
+ }
354
358
355
359
let targetFile : string | undefined ;
356
360
if ( fs . existsSync ( sessionsDir ) ) {
357
- const files = fs
358
- . readdirSync ( sessionsDir )
359
- . filter ( ( f ) => f . endsWith ( `-${ sessionIdFlag } .json` ) ) ;
360
- if ( files . length > 0 ) {
361
- files . sort ( ) ;
362
- targetFile = path . join ( sessionsDir , files [ files . length - 1 ] ?? "" ) ;
361
+ const candidateFile = `${ sessionIdFlag } .json` ;
362
+ const candidatePath = path . join ( sessionsDir , candidateFile ) ;
363
+ if ( fs . existsSync ( candidatePath ) ) {
364
+ targetFile = candidatePath ;
363
365
}
364
366
}
365
367
if ( ! targetFile ) {
381
383
console . error ( `error loading session ${ sessionIdFlag } : ${ e } ` ) ;
382
384
process . exit ( 1 ) ;
383
385
}
384
- // Start or resume the named session
385
- setSessionId ( sessionIdFlag ) ;
386
+ // Resume the named session (session id already set above)
386
387
}
387
388
388
389
if ( cli . flags . sessionPath ) {
0 commit comments