@@ -119,6 +119,8 @@ type ChildOptions = {
119119 bootstrap ?: boolean
120120}
121121
122+ const cmp = ( a : string , b : string ) => ( a < b ? - 1 : a > b ? 1 : 0 )
123+
122124function normalizeProviderList ( input : ProviderListResponse ) : ProviderListResponse {
123125 return {
124126 ...input ,
@@ -297,7 +299,7 @@ function createGlobalSync() {
297299 const aUpdated = sessionUpdatedAt ( a )
298300 const bUpdated = sessionUpdatedAt ( b )
299301 if ( aUpdated !== bUpdated ) return bUpdated - aUpdated
300- return a . id . localeCompare ( b . id )
302+ return cmp ( a . id , b . id )
301303 }
302304
303305 function takeRecentSessions ( sessions : Session [ ] , limit : number , cutoff : number ) {
@@ -325,7 +327,7 @@ function createGlobalSync() {
325327 const all = input
326328 . filter ( ( s ) => ! ! s ?. id )
327329 . filter ( ( s ) => ! s . time ?. archived )
328- . sort ( ( a , b ) => a . id . localeCompare ( b . id ) )
330+ . sort ( ( a , b ) => cmp ( a . id , b . id ) )
329331
330332 const roots = all . filter ( ( s ) => ! s . parentID )
331333 const children = all . filter ( ( s ) => ! ! s . parentID )
@@ -342,7 +344,7 @@ function createGlobalSync() {
342344 return sessionUpdatedAt ( s ) > cutoff
343345 } )
344346
345- return [ ...keepRoots , ...keepChildren ] . sort ( ( a , b ) => a . id . localeCompare ( b . id ) )
347+ return [ ...keepRoots , ...keepChildren ] . sort ( ( a , b ) => cmp ( a . id , b . id ) )
346348 }
347349
348350 function ensureChild ( directory : string ) {
@@ -457,7 +459,7 @@ function createGlobalSync() {
457459 const nonArchived = ( x . data ?? [ ] )
458460 . filter ( ( s ) => ! ! s ?. id )
459461 . filter ( ( s ) => ! s . time ?. archived )
460- . sort ( ( a , b ) => a . id . localeCompare ( b . id ) )
462+ . sort ( ( a , b ) => cmp ( a . id , b . id ) )
461463
462464 // Read the current limit at resolve-time so callers that bump the limit while
463465 // a request is in-flight still get the expanded result.
@@ -559,7 +561,7 @@ function createGlobalSync() {
559561 "permission" ,
560562 sessionID ,
561563 reconcile (
562- permissions . filter ( ( p ) => ! ! p ?. id ) . sort ( ( a , b ) => a . id . localeCompare ( b . id ) ) ,
564+ permissions . filter ( ( p ) => ! ! p ?. id ) . sort ( ( a , b ) => cmp ( a . id , b . id ) ) ,
563565 { key : "id" } ,
564566 ) ,
565567 )
@@ -588,7 +590,7 @@ function createGlobalSync() {
588590 "question" ,
589591 sessionID ,
590592 reconcile (
591- questions . filter ( ( q ) => ! ! q ?. id ) . sort ( ( a , b ) => a . id . localeCompare ( b . id ) ) ,
593+ questions . filter ( ( q ) => ! ! q ?. id ) . sort ( ( a , b ) => cmp ( a . id , b . id ) ) ,
592594 { key : "id" } ,
593595 ) ,
594596 )
@@ -986,7 +988,7 @@ function createGlobalSync() {
986988 . filter ( ( p ) => ! ! p ?. id )
987989 . filter ( ( p ) => ! ! p . worktree && ! p . worktree . includes ( "opencode-test" ) )
988990 . slice ( )
989- . sort ( ( a , b ) => a . id . localeCompare ( b . id ) )
991+ . sort ( ( a , b ) => cmp ( a . id , b . id ) )
990992 setGlobalStore ( "project" , projects )
991993 } ) ,
992994 ) ,
0 commit comments