Repository navigation
cmdio: fix pager dropping a page when the next fetch is fast - #7804
Merged
Merged
Conversation
A non-final page was printed by a bare tea.Println cmd, which bubbletea runs on its own goroutine. ENTER or SPACE could start the next fetch before that print reached the event loop; if the next page was the last, its Sequence(print, Quit) could win the race and the earlier page's rows were never printed (or pages printed out of order). Keep the model in the fetching state until a pagePrintedMsg, sent in the same tea.Sequence as the print, confirms the page is queued. The deferred ENTER chains the next fetch from there. Test helpers now emulate carriage returns, so a spinner or prompt that tea erased and overwrote is not mistaken for row content. Co-authored-by: Isaac <no-reply@databricks.com>
Collaborator
✅ Integration test reportCommit: 44c086e
Top 5 slowest tests (at least 2 minutes):
|
…sible Track the pending print in its own printing flag so View keeps showing the prompt instead of the spinner, and q/esc wait for the print too. DrainsFullIterator now checks row order, not just presence. Co-authored-by: Isaac <no-reply@databricks.com>
denik
marked this pull request as ready for review
November 19, 2026 12:55
denik
requested review from
Sankalp-Mittal,
andrewnester and
parthban-db
and removed request for
parthban-db
November 19, 2026 12:56
andrewnester
approved these changes
Nov 19, 2026
Collaborator
❌ Integration test reportCommit: fb245a2
958 interesting tests: 926 MISS, 12 FAIL, 8 KNOWN, 6 PANIC, 6 RECOVERED
Top 50 slowest tests (at least 2 minutes):
|
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.
Changes
Fix a race in the interactive list pager (
libs/cmdio/pager.go) that could drop or reorder a page of rows, and the macOS flake it caused inTestPagedTemplateRespectsLimit.A non-final page was printed by returning a bare
tea.Printlncmd. bubbletea runs every returned cmd on its own goroutine, so nothing ordered that print before later messages. When ENTER (or SPACE) started the next fetch and that page was the last one, itstea.Sequence(print, tea.Quit)could reach the event loop first, and the program quit before the earlier page was printed. In the test (page size 5, limit 7) that leaves only the last 2 rows:expected: 7, actual: 2.A non-final page is now followed by a
pagePrintedMsgin the sametea.Sequenceas its print.tea.Sequencedelivers each message before running the next cmd, andp.Sendis unbuffered, so whenpagePrintedMsgarrives the page's lines are already queued. Until then a newprintingflag holds keys back: SPACE is ignored, ENTER setsdrainAll, andq/esc/Ctrl+C setquitPending. ThepagePrintedMsghandler then quits or chains the next fetch, replacing the oldSequence(print, fetch)branch.Viewis unchanged: the prompt shows as soon as the batch arrives.Also in the tests:
countContentLinesandTestPagedTemplateMatchesNonPagedForSmallListnow read the output the way a terminal shows it, keeping only the text after each line's last\r. tea redraws its spinner and prompt in place, so plain ANSI stripping left that text glued to real rows ("\r⣽ loading...\r1 1").TestPagedTemplateMatchesNonPagedForSmallListfailed once that way, andcountContentLineswould skip a row that lands on the prompt's line.Introduced with the pager in #5015.
Why
Users can lose rows of
listoutput in the pager. It is rare at human typing speed, but it fails CI on unrelated PRs (macOS runners).Tests
TestPagerModelKeysWaitForPagePrintandTestPagerModelQuitWaitsForPagePrintfail without the fix (SPACE/ENTER fetch, q quits, before the page is printed).TestPagedTemplateDrainsFullIteratornow checks row order, not just presence. UpdatedTestPagerModelBatchPromptsWhenMoreandTestPagerModelBatchDrainingChainsFetchto the new message flow.TestPagedTemplateDrainsFullIteratorgot 18 of 23 rows andTestPagedTemplateRespectsLimit2 of 7. With the fix, everyTestPagedTemplate*passes with the sleep in place.go test -race ./libs/cmdio/ -count=200,go test ./libs/cmdio/ -count=1000andGOMAXPROCS=1 ... -count=200pass.Dashboard
paged_template_test.go:90: Not equal: expected: 7 actual : 2(3 failures in 3 days, macOS, PRs #4738, #7552, #7780)expected: "1 1" actual : "\r⣽ loading...\r1 1"(1 failure, 2026-11-16, Windows)This pull request and its description were written by Isaac.