Commit b66d9f5
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 <vijay@studentsucceed.com>
* 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 <vijay@studentsucceed.com>
* 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 <vijay@studentsucceed.com>
Co-authored-by: anandgupta42 <93243293+anandgupta42@users.noreply.github.com>1 parent 29e4267 commit b66d9f5
File tree
4 files changed
+200
-10
lines changed- packages/opencode
- src
- altimate/observability
- cli/cmd
- tui/component
- test/altimate
4 files changed
+200
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1000 | 1000 | | |
1001 | 1001 | | |
1002 | 1002 | | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1003 | 1029 | | |
1004 | 1030 | | |
1005 | 1031 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
59 | 69 | | |
60 | 70 | | |
61 | 71 | | |
| |||
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
100 | | - | |
101 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
102 | 117 | | |
103 | 118 | | |
104 | 119 | | |
| |||
134 | 149 | | |
135 | 150 | | |
136 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
137 | 157 | | |
138 | 158 | | |
139 | 159 | | |
| |||
148 | 168 | | |
149 | 169 | | |
150 | 170 | | |
151 | | - | |
152 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
153 | 181 | | |
154 | 182 | | |
155 | 183 | | |
| |||
168 | 196 | | |
169 | 197 | | |
170 | 198 | | |
171 | | - | |
| 199 | + | |
172 | 200 | | |
173 | 201 | | |
174 | 202 | | |
| |||
Lines changed: 22 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
| |||
61 | 70 | | |
62 | 71 | | |
63 | 72 | | |
64 | | - | |
| 73 | + | |
65 | 74 | | |
66 | 75 | | |
67 | 76 | | |
| |||
96 | 105 | | |
97 | 106 | | |
98 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
99 | 118 | | |
100 | 119 | | |
101 | 120 | | |
| |||
113 | 132 | | |
114 | 133 | | |
115 | 134 | | |
116 | | - | |
| 135 | + | |
117 | 136 | | |
118 | 137 | | |
119 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
737 | 737 | | |
738 | 738 | | |
739 | 739 | | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
740 | 857 | | |
741 | 858 | | |
742 | 859 | | |
| |||
0 commit comments