Skip to content

Reduce Markdown discovery output by filtering filenames at the source - #25148

Merged
nwparker merged 1 commit into
mainfrom
nwparker/ripgrep-usage-contracts
Oct 4, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/ripgrep-usage-contracts

Conversation

@nwparker

@nwparker nwparker commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 0 0 0 0
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 0

ELI5

The Markdown document picker currently receives every filename in the workspace and throws almost all of them away. Ask the scanner to send only Markdown filenames. The document list stays the same.

What Changed

Replace the all-file include glob with Markdown extension alternatives, including upper/lowercase combinations. Keep the existing directory exclusions, hidden-file rules, NUL framing, sorting, and final extension check. No API or remote wire changes.

The pattern deliberately uses --glob case classes: --iglob is processed after all ordinary globs, even when placed earlier on the command line, and can override the hidden-directory exclusions. Existing real-binary tests caught that issue and pass with the final pattern.

Why

On the current Orca checkout, the scan emitted 40,010 records / 2,475,372 bytes to return 293 Markdown documents. The filtered scan emits 293 records / 13,361 bytes: 99.46% less stdout, with identical document objects.

Measurement Before After
Scan + output collection median 37.94 ms 36.13 ms
Production document listing median 35.85 ms 34.29 ms
Filename records delivered 40,010 293
Stdout bytes 2,475,372 13,361

The latency difference is small and noisy; this is a reduction in process communication and JavaScript parsing work, not a claim of a major user-visible speedup. Forcing one scanning thread was also measured and rejected: roughly 58 ms versus 38 ms for the original scan.

Measurements ran serially on native macOS arm64, Node 24.20.0, bundled scanner 15.0.0, with warm filesystem caches. Scan measurements used eight counterbalanced samples after two warmups. Production measurements used ten samples after two warmups, bundling the actual unchanged document parser and replacing only the native spawn/WSL environment boundary to run the bundled executable. Every result was compared for exact parity. No synthetic or remote latency claim.

Linked Issue

N/A — maintainer-requested usage audit.

Visual Proof

N/A — the document list and interactions remain unchanged.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Existing bundled-binary and lifecycle suites: 20 tests pass. These cover case variants, extension-looking hidden directories, .github, hidden files, node_modules, ignored files, configuration isolation, symlinks, unusual filenames, cancellation/timeout errors, and WSL routing. No extra implementation-mirroring test was added for this two-line change.

pnpm tc:node, changed-code quality gate, and diff whitespace checks pass. Native macOS measurements only; real Windows/WSL/SSH measurements not performed. SSH document inventories use a separate full-inventory path and are unchanged. Full build and remaining suites are left to CI.

Review

The producer-filter proposal received adversarial review before coding. The existing real-binary regression suite caught an unsafe flag-order variant; the final case-class pattern preserves the exclusions.

Agent skill upstream boundary

  • Not applicable; no upstream skill material copied.

Notes

Applies to native and WSL document discovery in both repository and folder workspaces. Existing bundled binary resolution and lifecycle handling remain unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A visual proof explained
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path impact considered
  • Focused tests and code quality pass; remaining CI gates will cover full validation

@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3264cf07-211c-4684-986f-ee5d340041f1
📥 Commits

Reviewing files that changed from the base of the PR and between 3cc5e1d and 29bc829.

📒 Files selected for processing (1)
  • src/main/ipc/markdown-documents.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

listMarkdownDocuments now passes ripgrep a glob that matches .md, .mdx, and .markdown extensions in either case. The existing hidden-directory exclusion and other listing options remain unchanged.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 29bc8

The change narrows discovery to the intended Markdown extensions without an established behavior regression. It appears mergeable with normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to 29bc8

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/main/ipc/markdown-documents.ts: The ripgrep arguments replace the ** directory-only glob with a glob matching .md, .mdx, and .markdown extensions in either case; the comment now notes the case variants’ interaction with exclusions.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: filtering Markdown filenames during discovery to reduce output.
Description check ✅ Passed The description covers the required sections with clear scope, rationale, testing details, visual-proof status, and checklist responses. It explains that the linked issue is not applicable because thi…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor maintainability note inline. Verified the glob behavior against real ripgrep on the repo's own test fixture.

Reviewed changes

  • Filter Markdown at the source — listMarkdownDocuments now passes *.{[mM][dD],[mM][dD][xX],[mM][aA][rR][kK][dD][oO][wW][nN]} as its first --glob instead of **, so ripgrep emits only Markdown filenames. Directory exclusions and the final isMarkdownDocumentName check are unchanged.

I reproduced the markdown-documents-ripgrep-real.test.ts fixture against the exact new argument list with a real rg binary and confirmed: nested files still match, the post-filter accepted set equals the test's included list, non-Markdown files under the re-included .github/ directory are not emitted, and the --iglob variant does reopen hidden directories (.github/.md/hidden.md, docs/.md/hidden.md), validating the case-class rationale in the new comment.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

// Keep case variants in --glob: --iglob is applied after exclusions and can reopen hidden folders.
'--glob',
'**',
'*.{[mM][dD],[mM][dD][xX],[mM][aA][rR][kK][dD][oO][wW][nN]}',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This glob's extension set must stay a superset of isMarkdownDocumentName (line 14): if a fourth extension is ever added there (and to the app.ts picker filters) without updating this pattern, ripgrep drops those files before the final isMarkdownDocumentName(path) check on line 189 can accept them, so they silently vanish from the listing. Worth a one-line note in the comment above, or deriving the pattern from a shared extension list.

Technical details
# Keep the discovery glob a superset of the acceptance predicate

## Affected sites
- `src/main/ipc/markdown-documents.ts:116` — `--glob '*.{[mM][dD],[mM][dD][xX],...}'` duplicates the extension set in `isMarkdownDocumentName` (`:14`).
- `src/main/ipc/app.ts:50` — a third copy of the same extension list (`['md', 'mdx', 'markdown']`).

## Required outcome
- A reader (or future editor) understands the glob is an output-reduction optimization and must remain a superset of the final filter, so the two lists are updated together.

## Suggested approach (optional)
- Extend the existing `:114` comment with the invariant, or export a single `MARKDOWN_EXTENSIONS` list and build both the glob and `isMarkdownDocumentName` from it. The existing real-binary test only pins the three current extensions, so it will not catch a missing update on its own.

@nwparker
nwparker merged commit f8081c5 into main Oct 4, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant