@@ -48,13 +48,23 @@ function truncate(str: string, len: number): string {
4848 return str . slice ( 0 , len - 1 ) + "…"
4949}
5050
51- // altimate_change start — recap: rename listTraces → listRecaps
52- function listRecaps ( traces : Array < { sessionId : string ; trace : TraceFile } > , tracesDir ?: string ) {
51+ // altimate_change start — recap: rename listTraces → listRecaps, add pagination info
52+ function listRecaps (
53+ traces : Array < { sessionId : string ; trace : TraceFile } > ,
54+ tracesDir ?: string ,
55+ pagination ?: { offset : number ; limit : number ; total : number } ,
56+ ) {
57+ // altimate_change start — recap: distinguish empty page from no recaps at all
5358 if ( traces . length === 0 ) {
54- UI . println ( "No recaps found. Run a command with tracing enabled:" )
55- UI . println ( " altimate-code run \"your prompt here\"" )
59+ if ( pagination && pagination . total > 0 ) {
60+ UI . println ( `No recaps on this page (offset ${ pagination . offset } ). Total: ${ pagination . total } in ${ Recap . getTracesDir ( tracesDir ) } ` )
61+ } else {
62+ UI . println ( "No recaps found. Run a command with tracing enabled:" )
63+ UI . println ( " altimate-code run \"your prompt here\"" )
64+ }
5665 return
5766 }
67+ // altimate_change end
5868
5969 // Header
6070 const header = [
@@ -97,8 +107,19 @@ function listRecaps(traces: Array<{ sessionId: string; trace: TraceFile }>, trac
97107 }
98108
99109 UI . empty ( )
100- // altimate_change start — recap: renamed messages and Recap.getTracesDir
101- UI . println ( UI . Style . TEXT_DIM + `${ traces . length } recap(s) in ${ Recap . getTracesDir ( tracesDir ) } ` + UI . Style . TEXT_NORMAL )
110+ // altimate_change start — recap: pagination-aware footer
111+ if ( pagination && pagination . total > 0 ) {
112+ const start = pagination . offset + 1
113+ const end = pagination . offset + traces . length
114+ UI . println ( UI . Style . TEXT_DIM + `Showing ${ start } -${ end } of ${ pagination . total } recap(s) in ${ Recap . getTracesDir ( tracesDir ) } ` + UI . Style . TEXT_NORMAL )
115+ if ( pagination . offset + pagination . limit < pagination . total ) {
116+ const nextOffset = pagination . offset + pagination . limit
117+ const limitFlag = pagination . limit !== 20 ? ` --limit ${ pagination . limit } ` : ""
118+ UI . println ( UI . Style . TEXT_DIM + `Next page: altimate-code recap list --offset ${ nextOffset } ${ limitFlag } ` + UI . Style . TEXT_NORMAL )
119+ }
120+ } else {
121+ UI . println ( UI . Style . TEXT_DIM + `${ traces . length } recap(s) in ${ Recap . getTracesDir ( tracesDir ) } ` + UI . Style . TEXT_NORMAL )
122+ }
102123 UI . println ( UI . Style . TEXT_DIM + "View a recap: altimate-code recap view <session-id>" + UI . Style . TEXT_NORMAL )
103124 // altimate_change end
104125}
@@ -134,6 +155,13 @@ export const RecapCommand = cmd({
134155 describe : "number of recaps to show" ,
135156 default : 20 ,
136157 } )
158+ // altimate_change start — recap: add offset option for pagination
159+ . option ( "offset" , {
160+ type : "number" ,
161+ describe : "number of recaps to skip (for pagination)" ,
162+ default : 0 ,
163+ } )
164+ // altimate_change end
137165 . option ( "live" , {
138166 type : "boolean" ,
139167 describe : "auto-refresh the viewer as the recap updates (for in-progress sessions)" ,
@@ -147,28 +175,34 @@ export const RecapCommand = cmd({
147175 const cfg = await Config . get ( ) . catch ( ( ) => ( { } as Record < string , any > ) )
148176 const tracesDir = ( cfg as any ) . tracing ?. dir as string | undefined
149177
178+ // altimate_change start — recap: use paginated listTraces
150179 if ( action === "list" ) {
151- const traces = await Recap . listTraces ( tracesDir )
152- listRecaps ( traces . slice ( 0 , args . limit || 20 ) , tracesDir )
180+ const limit = args . limit || 20
181+ const offset = args . offset || 0
182+ const { items, total } = await Recap . listTraces ( tracesDir , { offset, limit } )
183+ listRecaps ( items , tracesDir , { offset, limit, total } )
153184 return
154185 }
186+ // altimate_change end
155187
156188 if ( action === "view" ) {
157189 if ( ! args . id ) {
158190 UI . error ( "Usage: altimate-code recap view <session-id>" )
159191 process . exit ( 1 )
160192 }
161193
194+ // altimate_change start — recap: use paginated listTraces return type
162195 // Support partial session ID matching
163- const traces = await Recap . listTraces ( tracesDir )
164- const match = traces . find (
196+ const { items : allTraces } = await Recap . listTraces ( tracesDir )
197+ const match = allTraces . find (
165198 ( t ) => t . sessionId === args . id || t . sessionId . startsWith ( args . id ! ) || t . file . startsWith ( args . id ! ) ,
166199 )
167200
168201 if ( ! match ) {
169202 UI . error ( `Recap not found: ${ args . id } ` )
170203 UI . println ( "Available recaps:" )
171- listRecaps ( traces . slice ( 0 , 10 ) , tracesDir )
204+ listRecaps ( allTraces . slice ( 0 , 10 ) , tracesDir )
205+ // altimate_change end
172206 process . exit ( 1 )
173207 }
174208
0 commit comments