@@ -38,6 +38,7 @@ type State = {
3838 config : Config
3939 path : Path
4040 session : Session [ ]
41+ sessionTotal : number
4142 session_status : {
4243 [ sessionID : string ] : SessionStatus
4344 }
@@ -98,6 +99,7 @@ function createGlobalSync() {
9899 agent : [ ] ,
99100 command : [ ] ,
100101 session : [ ] ,
102+ sessionTotal : 0 ,
101103 session_status : { } ,
102104 session_diff : { } ,
103105 todo : { } ,
@@ -117,8 +119,10 @@ function createGlobalSync() {
117119
118120 async function loadSessions ( directory : string ) {
119121 const [ store , setStore ] = child ( directory )
120- globalSDK . client . session
121- . list ( { directory } )
122+ const limit = store . limit
123+
124+ return globalSDK . client . session
125+ . list ( { directory, roots : true } )
122126 . then ( ( x ) => {
123127 const fourHoursAgo = Date . now ( ) - 4 * 60 * 60 * 1000
124128 const nonArchived = ( x . data ?? [ ] )
@@ -128,10 +132,12 @@ function createGlobalSync() {
128132 . sort ( ( a , b ) => a . id . localeCompare ( b . id ) )
129133 // Include up to the limit, plus any updated in the last 4 hours
130134 const sessions = nonArchived . filter ( ( s , i ) => {
131- if ( i < store . limit ) return true
135+ if ( i < limit ) return true
132136 const updated = new Date ( s . time ?. updated ?? s . time ?. created ) . getTime ( )
133137 return updated > fourHoursAgo
134138 } )
139+ // Store total session count (used for "load more" pagination)
140+ setStore ( "sessionTotal" , nonArchived . length )
135141 setStore ( "session" , reconcile ( sessions , { key : "id" } ) )
136142 } )
137143 . catch ( ( err ) => {
0 commit comments