You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b66d9f5
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix: add pagination support for recap trace list (#596)
* fix: add pagination support for recap trace list (#418)
- Add `listTracesPaginated()` method to Trace class returning page of
traces with total count, offset, and limit metadata
- Add `--offset` CLI option to `trace list` command for navigating
past the first page of results
- Wire CLI handler to use `listTracesPaginated()` instead of manual
array slicing
- Remove hardcoded `.slice(0, 50)` cap in TUI dialog so all traces
are accessible via built-in scrolling
- Show "Showing X-Y of N" pagination footer with next-page hint
- Distinguish empty results (no traces exist) from offset-past-end
(offset exceeds total count) with clear messaging
Closes#418
Co-Authored-By: Vijay Yadav <[email protected]>
* fix: normalize pagination inputs to finite integers
Coerce offset/limit to finite integers via Number.isFinite and
Math.trunc before using them for slice and returning in metadata.
Prevents NaN, fractional, or infinite values from producing invalid
display ranges.
Co-Authored-By: Vijay Yadav <[email protected]>
* fix: cap TUI trace dialog at 500 items + add pagination boundary tests
Code review (GPT + Gemini) flagged two follow-ups:
1. TUI freeze risk after removing .slice(0, 50) — DialogSelect creates
reactive nodes per item via Solid's <For>, so unbounded rendering
can lag noticeably on trace directories with thousands of entries.
2. listTracesPaginated had no unit tests for boundary math.
Fixes:
- Cap dialog-trace-list at MAX_TUI_ITEMS=500 with an explicit '... N
more not shown' footer row pointing users to 'altimate-code trace
list --offset N' for the full set. 500 is 10× the old cap and
covers the vast majority of real usage, while leaving TUI rendering
bounded. The onSelect handler ignores the truncation marker row.
- Add 10 listTracesPaginated regression tests covering: empty dir,
bounded page size, multi-page traversal, offset === total, offset
> total, negative offset clamping, non-positive limit clamping,
fractional truncation, NaN → default fallback, and default options.
The I/O-layer optimization (slice filenames before JSON.parse) called
out by Gemini is a separate perf concern that requires embedding
timestamps in trace filenames; tracked as a follow-up.
* fix: address coderabbit + cubic review comments
- trace.ts:172-173 (coderabbit): switch pagination fallbacks from || to ??
so an explicit --offset 0 / --limit 0 reaches listTracesPaginated() for
clamping, rather than being swallowed as falsy and replaced with
defaults. The API already clamps limit<1 to 1, so --limit 0 now
routes through that clamp path correctly.
- tracing.test.ts:746 (cubic): create a fresh Trace instance per
iteration inside seedTraces() rather than reusing a single tracer.
Reusing a tracer across startTrace/endTrace cycles accumulates
spans in memory across iterations. Matches the pattern used by
the maxFiles test.
---------
Co-authored-by: Vijay Yadav <[email protected]>
Co-authored-by: anandgupta42 <[email protected]>
UI.println(UI.Style.TEXT_DIM+`Showing ${rangeStart}-${rangeEnd} of ${pagination.total} trace(s) in ${Trace.getTracesDir(tracesDir)}`+UI.Style.TEXT_NORMAL)
114
+
if(rangeEnd<pagination.total){
115
+
UI.println(UI.Style.TEXT_DIM+`Next page: altimate-code trace list --offset ${rangeEnd} --limit ${pagination.limit}`+UI.Style.TEXT_NORMAL)
116
+
}
102
117
UI.println(UI.Style.TEXT_DIM+"View a trace: altimate-code trace view <session-id>"+UI.Style.TEXT_NORMAL)
0 commit comments