Add result-flow paging#25
Draft
carldebilly wants to merge 21 commits intomainfrom
Draft
Conversation
- Map Space/PageDown/F explicitly to page-forward; Enter maps to line-forward (same as DownArrow); unknown keys are no-ops instead of silently advancing the viewport - Add regression tests: unrecognized key does not advance or fetch, Enter advances by one line only - Document O(offset/page) cost on FromAsyncEnumerable overloads and point callers toward the Create overload for large/expensive sources
- Replace char-by-char line splitter with EnumerateLines + trailing- empty trim; simpler, handles all newline conventions natively - Extract PagerState.Lines backing field so Reset does not expose a setter on the property - Pre-allocate emptyRow in MarkdownOutputTransformer table renderer to avoid one allocation per null item
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Draft PR for the new Result Flow paging experience.
This adds first-class paging support for commands that return large result sets. Handlers can now return one explicit
ReplPage<T>or anIReplPageSource<T>that lets Repl fetch later pages on demand. Human users can continue through results in the same command run, while MCP and machine outputs get structured page metadata.Functional Highlights
Page results
Handlers can return a page directly when they own the cursor contract:
JSON output now uses an explicit page envelope:
{ "$type": "page", "items": [ { "id": 1, "name": "Alice" } ], "pageInfo": { "cursor": null, "nextCursor": "page-2", "totalCount": 42, "pageSize": 1, "hasMore": true } }Page sources
Handlers can return a lazy source when Repl should fetch future pages interactively:
This improves terminal UX: the integrated pager can continue fetching data without asking users to rerun the command with
--result:cursor.Built-in helpers
This PR adds helpers for:
FromItems(...);FromOffset(...);FromAsyncEnumerable(...);Example with state and a client-side filter:
Client-side filtering is documented as a fallback because it may fetch and discard rows. Server-side filtering remains preferred.
Result Flow Help
Paged handlers now show a
Result Flowhelp section:The section appears only for handlers that support paging:
IReplPagingContext,ReplPage<T>, orIReplPageSource<T>.Integrated Pager
The human pager now has two paths:
morefallback for limited terminals, with no cursor movement or ANSI redraw;scrollviewport for ANSI terminals, inspired byless.The scroll pager enters the alternate screen, keeps an internal line buffer, redraws a viewport explicitly, supports up/down/page navigation, and fetches additional page-source payloads as the user reaches the buffered end.
MCP Behavior
MCP tools expose reserved paging inputs:
_replCursor_replPageSizePaged results are returned as structured content with
$type: "page". Text summaries stay short and avoid echoing raw cursor values:Hardening included:
$type: "page"instead ofitems + pageInfoheuristics;_replCursoris validated before becoming CLI tokens;_replPageSizemust be compact and numeric before normal clamping.Documentation And Samples
Updated docs cover:
totalCountscenarios;Core Basics and Spectre samples now demonstrate page-source driven activity feeds.
Safety Notes
FromAsyncEnumerablerequires a replayable, idempotent, deterministic factory.FromOffsetandFromAsyncEnumerablereject--result:allby default because they may be unbounded.FromItemscan honor--result:allbecause the source is already bounded.