Repository navigation
fix: decouple ffgrep per-file cap from page size (#825) - #832
Conversation
pi-fff passed pageSize as maxMatchesPerFile for grep/multi-grep. Since grep cursors advance by file offset, clamping the per-file cap to the page size made same-file matches beyond the cap permanently unreachable across cursor pagination. Use a dedicated GREP_MAX_MATCHES_PER_FILE (200, the engine default) so page size only bounds total matches per page while the current file is always finished. Adds a regression test asserting the two limits stay decoupled. Closes #825
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe grep tools now keep ChangesGrep pagination
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change allows later matches in the same file to remain reachable across pages while retaining bounded result processing. No actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The implementation addresses the core pagination bug in
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #825
Root cause
packages/pi-fff/src/index.tspassedmaxMatchesPerFile: pageSizefor grep (:908,:941) and multi-grep (:1191). The engine's grep cursor is a file offset (crates/fff-core/src/grep/types.rs:87-89,next_file_offset), andmaxMatchesPerFilecaps per-file matches (types.rs:84). Clamping the per-file cap down to the page size means once a file's firstpageSizematches are collected, the next cursor advances past that file, so its remaining matches are unreachable on every later page.page_limitis only a soft cap that finishes the current file (types.rs:209-215), so the two limits must stay decoupled.Fix
Add
GREP_MAX_MATCHES_PER_FILE = 200(the engine default) and pass it asmaxMatchesPerFileat all three grep call sites.pageSizestill bounds total matches per page; the per-file cap no longer discards same-file overflow.Steps to reproduce
Build the native lib and prepare the bun package on pre-fix
main:Save as
packages/fff-bun/repro825.mjs(exercises the exact options pi-fff passes to the engine):Run:
cd packages/fff-bun && bun repro825.mjsExpected: all 33 matches retrieved by walking cursors to exhaustion.
Actual (pre-fix,
maxMatchesPerFile === pageSize === 20):{ "current_pi_fff": { "pages": [21, 2], "retrieved": 23, "missing": ["TODO fix 21","TODO fix 22","TODO fix 23","TODO fix 24","TODO fix 25","TODO fix 26","TODO fix 27","TODO fix 28","TODO fix 29","TODO fix 30"] }, "decoupled_cap": { "pages": [31, 2], "retrieved": 33, "missing": [] } }How verified
ffgrep per-file cap (#825)asserting the tool passesmaxMatchesPerFile: 200decoupled frompageSize.cd packages/pi-fff && bun test test/→80 pass, 0 fail.oxfmt --checkandoxlintclean on both changed files.Note: files with more than
GREP_MAX_MATCHES_PER_FILE(200) matches still truncate — that is the deeper file-offset limitation tracked in #365, out of scope here.Automated triage via Gustav. Honk-Honk 🪿
Summary by CodeRabbit