feat(filtering): support columnOverrides.read in findRow/findRows/countRows - #398
Conversation
…ntRows (#385) Columns with a `read` override are split out of the DOM filter chain and post-filtered in Node.js by evaluating the override's `read` function. DOM filters still use Playwright's fast locator chain; override filters run after, matching the read value against string/number/RegExp filters. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Bot HQ🔗 Issue Link🔗 Closes #385 🔍 AI Review
📊 This PR: $0.0403 · Repo today: $0.04 / $1.00 · Month: $1.35 / $10.00 Review History (1 round)
This comment is managed by the bot — do not edit directly. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (2)
src/engine/rowFinder.ts (2)
260-276: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate "Ambiguous Row" error construction across both branches.
The sample-data collection and error-throwing logic (Lines 260-276 and 290-305) are near-identical, differing only in the source array (
matchedRowsvsoverrideMatches). Consider extracting a private helper, e.g.private async throwIfAmbiguous(matches: Locator[], filters, map): Promise<void>, called from both branches, so the message format can't drift between the DOM-only and override paths.Also applies to: 290-305
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/engine/rowFinder.ts` around lines 260 - 276, Extract the duplicated ambiguity handling from both branches into a private helper, such as throwIfAmbiguous, that accepts the matching rows source, filters, and map, collects sample data, and throws the existing “Ambiguous Row” error when multiple matches are found. Replace the near-identical logic in the matchedRows and overrideMatches paths with calls to this helper, preserving the current message and sample behavior.
279-288: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winSequential per-candidate override evaluation.
matchesOverrideFiltersis awaited one candidate at a time (Lines 283-287). Since each call may perform a page read viaoverride.read, this serializes what could be parallel round trips. ConsiderPromise.all(candidates.map(c => this.matchesOverrideFilters(c, overrideFilters, map, options.exact || false)))and filtering the results, preserving candidate order for the sample-data reporting above.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/engine/rowFinder.ts` around lines 279 - 288, Update the override-filter evaluation in the candidate loop to invoke matchesOverrideFilters for all candidates concurrently via Promise.all, then retain only candidates whose results are true. Preserve the original candidate order when constructing overrideMatches and keep the surrounding logging unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/engine/rowFinder.ts`:
- Around line 44-76: The override-filter matching logic must handle
function-typed FilterValue instead of silently treating it as a match. Update
matchesOverrideFilters in src/engine/rowFinder.ts (lines 44-76) and
countOverrideMatches in src/useTable.ts (lines 357-387) to apply function
filters to the resolved cell or throw a clear unsupported-filter error;
preferably centralize the shared value-matching logic so both paths remain
consistent.
In `@src/useTable.ts`:
- Around line 357-387: Update countOverrideMatches to validate the result of
tableMapper.getMapSync() before using it, matching the descriptive
initialization-error guard already used by resolveRows. Remove the bare non-null
assertion and throw the same established error when the map is unavailable.
- Around line 389-395: Update the no-pagination override-filter branch in the
counting flow to reuse the candidates returned by the existing rows.all() call
when invoking countOverrideMatches, rather than allowing it to query the locator
again. Adjust countOverrideMatches and its callers as needed so the same fetched
row set supplies both indices and matching, preserving the existing count
behavior without a second DOM query.
In `@tests/override-filter.spec.ts`:
- Around line 40-46: Update the findRows test to query the Link override with
the selective value `/d/beta` and `{ exact: true }`, then assert exactly one
result is returned and that it is the Beta row, ensuring override filtering is
actually applied.
- Around line 16-29: Replace the any parameter in makeTable with Playwright’s
Page type by importing type Page from `@playwright/test` and annotating the page
argument as Page. Keep the existing useTable configuration and Link read
behavior unchanged.
---
Nitpick comments:
In `@src/engine/rowFinder.ts`:
- Around line 260-276: Extract the duplicated ambiguity handling from both
branches into a private helper, such as throwIfAmbiguous, that accepts the
matching rows source, filters, and map, collects sample data, and throws the
existing “Ambiguous Row” error when multiple matches are found. Replace the
near-identical logic in the matchedRows and overrideMatches paths with calls to
this helper, preserving the current message and sample behavior.
- Around line 279-288: Update the override-filter evaluation in the candidate
loop to invoke matchesOverrideFilters for all candidates concurrently via
Promise.all, then retain only candidates whose results are true. Preserve the
original candidate order when constructing overrideMatches and keep the
surrounding logging unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b27aea8b-1688-467b-b5d7-f89f92c0944a
📒 Files selected for processing (3)
src/engine/rowFinder.tssrc/useTable.tstests/override-filter.spec.ts
…uity logic - Add RowFinder.matchReadValue() — centralized value matching used by both rowFinder and countRows; throws on unsupported function-typed FilterValue - Extract throwIfAmbiguous() helper to deduplicate ambiguity error handling - Evaluate override filters concurrently via Promise.all in findRowLocator - Guard tableMapper.getMapSync() in countOverrideMatches instead of bare ! - Eliminate double DOM query in no-pagination override counting path - Type test helper parameter as Page instead of any - Strengthen findRows test to filter selectively and assert the matched row Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
AI ReviewPR #398 adds support for filtering on columnOverrides.read values in findRow, findRows, and countRows. Implementation splits filters into DOM and override filters, applies overrides post-DOM-match for accurate filtering. All 193 E2E tests pass. Found 3 issues: incomplete ColumnOverrideReadContext type usage, missing null check for column name resolution, and potential barrier leak in override filter path. 📋 3 issues — expand to copy prompt⚙️ [1] ColumnOverrideReadContext not passed completely in countRows — src/useTable.ts:374The ⚙️ [2] Unsafe column index lookup without null check in countRows — src/useTable.ts:365The code assumes ⚙️ [3] Navigation barrier not marked finished on early continue in findRows — src/engine/rowFinder.ts:180When override filters don't match, the code continues without calling |
|
@rickcedwhat-ai override all |
|
Summary
columnOverrides.readfunction are now respected when filtering viafindRow,findRows, andcountRows(feat(findRow): support filtering on columnOverrides / synthetic columns #385)readfunction against string/number/RegExp values)splitFilters()andmatchesOverrideFilters()toRowFinder, and override-aware counting incountRowsCloses #385
Test plan
findRowfilters on override-produced value (reads<a href>from Link cell)findRowsfilters on override-produced value (substring match)findRowcombines DOM filter + override filterfindRowthrowsAmbiguous Rowwhen override filter matches multiplecountRowswith override filter counts only matching rows🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes