-
Notifications
You must be signed in to change notification settings - Fork 20
feat(cli): add lazy loading support to paginated table #857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add on-demand page loading for paginated tables to support API pagination without requiring all data upfront. New API: - `paginatedTable(_:pageSize:totalPages:loadPage:)` with TableData - `paginatedTable(headers:pageSize:totalPages:loadPage:)` with strings Features: - Pages are loaded on-demand when navigating - Loaded pages are cached to avoid re-fetching - Loading indicator shown during page fetch - Error handling with retry (r) option - Column widths retained during loading state to prevent visual jumps - Non-interactive mode fallback (loads first page only) Includes example command: `swift run examples-cli table lazyPaginated` Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Allow starting pagination from a specific page instead of always starting at page 0. Useful for resuming pagination or starting at a specific point based on context. - Add startPage parameter (0-indexed, defaults to 0) - Clamp invalid startPage values to valid range - Add tests for startPage functionality Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Simplify the lazy loading API by keeping only the headers: [String] variant. This provides a cleaner, more consistent interface without the need for users to construct TableData objects directly for lazy loading. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The renderer parameter was being ignored in the implementation, so remove it from the protocol and all implementations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Swift can disambiguate between sync run() and async run() based on context, so there's no need for separate method names. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extract common rendering and keyboard handling logic - For static mode, pre-populate cache so it uses the same code path - Fix inout issue by returning target page in KeyStrokeResult.loadPage - Unified renderPage and renderFooter methods handle both modes - Reduces code duplication significantly (~700 lines -> ~550 lines) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The public API in Noora.swift guarantees correct usage, so internal defensive guards are not needed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reduces duplication by consolidating the load-render pattern into loadAndRenderPage helper. Also unifies retry with regular page loading. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Also remove unused loadPageAsync parameter from runPaginationLoop. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add lazy loading example with async API - Document new loadPage, totalPages, startPage parameters - Fix navigation controls to match actual implementation - Update interactivity to show it falls back gracefully - Add non-interactive terminal behavior section - Update performance considerations for lazy loading Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| | `→` / `Page Down` / `l` | Go to next page | | ||
| | `←` / `Page Up` / `h` | Go to previous page | | ||
| | `Home` / `g` | Go to first page | | ||
| | `End` / `G` | Go to last page | | ||
| | `↑` / `k` | Scroll up within current page | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not something I've actually changed in this PR, it's just the documentation was not inline with the implementation.
- g: Go to first page (same as Home) - G: Go to last page (same as End) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Hide Home/End controls when already on first or last page since one of them would be useless in those positions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- First page: show "End (G)" only - Last page: show "Home (g)" only - Middle pages: show "Home/End (g/G)" Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The navigation config links to /components/tables/selectable but the file was named interactive.md. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| | --- | --- | | ||
| | `→` / `Page Down` / `l` | Go to next page | | ||
| | `←` / `Page Up` / `h` | Go to previous page | | ||
| | `→` / `n` / `Space` | Go to next page | | ||
| | `←` / `p` | Go to previous page | | ||
| | `Home` / `g` | Go to first page | | ||
| | `End` / `G` | Go to last page | | ||
| | `↑` / `k` | Scroll up within current page | | ||
| | `↓` / `j` | Scroll down within current page | | ||
| | `r` | Retry loading (when error occurs) | | ||
| | `q` / `Esc` | Exit pagination view | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the keys were actually not in line with the implementation, so I'm updating the docs
Split the struct into extensions to reduce body length from 443 to under 350 lines (the SwiftLint limit). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Screen.Recording.2026-01-22.at.13.01.46.mov
Summary
startPageparameter to start at a specific pageg/Gkeyboard shortcuts for first/last page navigationAPI
Keyboard Controls
→/n/Space←/pHome/gEnd/Grq/EscTest plan
swift run examples-cli table lazyPaginated🤖 Generated with Claude Code