Skip to content

feat: improve filter to match title and values - #110

Merged
lordrip merged 3 commits into
KaotoIO:1.xfrom
PVinaches:filter-improve-backport
Jul 30, 2026
Merged

feat: improve filter to match title and values#110
lordrip merged 3 commits into
KaotoIO:1.xfrom
PVinaches:filter-improve-backport

Conversation

@PVinaches

@PVinaches PVinaches commented Jul 28, 2026

Copy link
Copy Markdown
Member

What changed

  • getFilteredProperties now accepts an optional model parameter (current form data) and matches properties on three criteria: property key, schema title, and the current runtime value.
  • Nested object properties are recursively filtered using the model slice for that key.
  • Array properties with nested item schemas are surfaced when either the item schema titles match or any item's runtime values match the filter.
  • Empty-filter path is short-circuited: returns the original properties reference unchanged when there's nothing to filter or omit (avoids unnecessary re-renders).
  • ObjectFieldGrouping passes the relevant model slice down to getFilteredProperties and strips spaces from the query term before matching.
  • Import cleanup: replaced KaotoSchemaDefinition with the standard JSONSchema4 type in tests.

Tests added

  • get-filtered-properties.test.ts: 10 new cases covering title matching, value matching, object/array recursion, empty-filter short-circuit, and edge cases (null array items, plain-string arrays).
  • ObjectFieldGrouping.test.tsx: 2 new cases — space-stripping in the filter and required-field indicator rendering.
Screen.Recording.2026-07-28.at.16.11.32.mov

fix: KaotoIO/kaoto#3068

Summary by CodeRabbit

  • New Features

    • Enhanced form field filtering to match property keys, schema titles, and current model values.
    • Improved support for filtering within nested objects and array fields (including deeper nested structures).
    • Filters now handle extra whitespace more reliably.
    • Object-schema required properties now show a required-field indicator, while non-required properties do not.
  • Bug Fixes

    • Fixed cases where matches for nested fields, runtime values, and primitive/array inputs were not correctly surfaced.
  • Tests

    • Added comprehensive coverage for the new filtering behavior.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@PVinaches, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 08f3db87-d2e5-4955-a3e5-30b2c61ca845

📥 Commits

Reviewing files that changed from the base of the PR and between b40e2f8 and b6edc1d.

⛔ Files ignored due to path filters (1)
  • src/form/utils/__snapshots__/get-filtered-properties.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/form/utils/SchemaPropertyFilter.test.ts
  • src/form/utils/index.ts
📝 Walkthrough

Walkthrough

Search filtering now uses a recursive schema filter that matches property keys, titles, nested objects, arrays, and runtime model values. ObjectFieldGrouping supplies the relevant model slice, and tests cover whitespace normalization, required indicators, omission behavior, and nested matching.

Changes

Property search

Layer / File(s) Summary
Recursive model-aware filtering
src/form/utils/SchemaPropertyFilter.ts, src/form/utils/SchemaPropertyFilter.test.ts, src/form/utils/get-filtered-properties.ts, src/form/utils/get-filtered-properties.test.ts
SchemaPropertyFilter replaces the removed filtering utility and supports schema titles, primitive runtime values, nested objects, arrays, omissions, case-insensitive matching, and undefined properties.
ObjectFieldGrouping integration and UI coverage
src/form/fields/ObjectField/ObjectFieldGrouping.tsx, src/form/fields/ObjectField/ObjectFieldGrouping.test.tsx
ObjectFieldGrouping passes a model slice into filtering and tests whitespace-insensitive search and required-field labels.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

A rabbit searched through fields so wide,
Through nested hops and arrays inside.
“beanName!” it found with joyful cheer,
Titles and values now appear.
Required marks stand bright and true—
Bunny’s filter knows what to do!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: improving filtering by matching titles and runtime values.
Linked Issues check ✅ Passed The PR adds recursive property filtering by key, title, and runtime values, which addresses the Kamelet search issues in #3068.
Out of Scope Changes check ✅ Passed The changes stay focused on search/filtering behavior and related tests, with no clear unrelated feature work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@PVinaches
PVinaches marked this pull request as ready for review July 28, 2026 15:26
@PVinaches
PVinaches requested a review from a team July 28, 2026 15:29

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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/form/fields/ObjectField/ObjectFieldGrouping.tsx`:
- Around line 16-23: Split the combined memo in the ObjectFieldGrouping
component into separate filtering and grouping memos. Keep the
filtered-properties memo dependent on filteredFieldText, schema.properties,
model, and propName, then memoize getFieldGroups using only the
filtered-properties result so unchanged properties preserve groupedProperties
identity during unrelated model updates.

In `@src/form/utils/get-filtered-properties.ts`:
- Around line 33-39: Guard the model value in the valueMatched logic of
getFilteredProperties before calling .some, ensuring iteration only occurs when
model[property] is actually an array. Preserve the existing recursive filtering
and null-item handling, while treating non-array values as unmatched rather than
throwing.
- Around line 4-42: Update getFilteredObjectProperty and
getFilteredArrayProperty to first match the container’s own property key or
definition.title against filter, returning the original container definition
when matched. Preserve the existing descendant schema/model matching behavior
when the container itself does not match, and add coverage for object and array
key/title searches with no matching child.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c3a58bf6-f27a-4d6e-8f64-aa39dc0de719

📥 Commits

Reviewing files that changed from the base of the PR and between 773f8bb and ce55903.

📒 Files selected for processing (4)
  • src/form/fields/ObjectField/ObjectFieldGrouping.test.tsx
  • src/form/fields/ObjectField/ObjectFieldGrouping.tsx
  • src/form/utils/get-filtered-properties.test.ts
  • src/form/utils/get-filtered-properties.ts

Comment thread src/form/fields/ObjectField/ObjectFieldGrouping.tsx
Comment thread src/form/utils/get-filtered-properties.ts Outdated
Comment thread src/form/utils/get-filtered-properties.ts Outdated
@PVinaches
PVinaches force-pushed the filter-improve-backport branch from ce55903 to 1562811 Compare July 28, 2026 16:18
#1)

Replace functional implementation with SchemaPropertyFilter class for better
code organization and maintainability.

Changes:
- Rename get-filtered-properties.ts → SchemaPropertyFilter.ts
- Convert from functional to class-based static methods
- Add type guards (hasNestedProperties, hasArrayItemProperties, isMatchablePrimitive)
- Extract helper methods for better separation of concerns:
  - matchesKeyOrTitle() - centralized key/title matching
  - matchesModelValue() - value-based matching logic
  - getNestedModelSlice() - type-safe model extraction for objects
  - getArrayModelSlice() - type-safe model extraction for arrays
  - filterObjectProperty() - dedicated object filtering
  - filterArrayProperty() - dedicated array filtering
  - matchesPrimitiveProperty() - primitive property matching
- Improve documentation with JSDoc comments
- Enhance type safety throughout the implementation
- Maintain all existing functionality and test coverage

The new structure makes the code more maintainable by breaking down complex
logic into focused, well-documented methods while preserving the original
filtering behavior.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/form/utils/SchemaPropertyFilter.ts (1)

26-30: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Case-insensitivity is only true if the caller already lowercased filter.

The docstring says the filter param is "case-insensitive", but matchesKeyOrTitle and matchesModelValue only lowercase the key/title/value side of the comparison — filter itself is never normalized inside this class. Today's sole caller (ObjectFieldGrouping.tsx) happens to lowercase before calling, so it works, but any future caller that passes a mixed-case term (e.g. SchemaPropertyFilter.filter(props, 'UserName')) will silently get zero matches even though the docstring promises case-insensitive matching. There's also no test exercising a raw, non-pre-lowered filter argument, so this gap isn't caught by the current suite.

Normalize once at the entry point so every recursive call (which re-enters filter()) benefits automatically:

🛡️ Proposed fix
     // Early return for undefined properties
     if (!isDefined(properties)) {
       return {};
     }
 
+    // Normalize case here so callers don't need to pre-lowercase, and all
+    // recursive matchers (key/title/model-value) stay consistent.
+    filter = filter.toLowerCase();
+
     // Early return for empty filter (optimization)
     if (filter.length === 0) {

Also applies to: 121-135

🤖 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/form/utils/SchemaPropertyFilter.ts` around lines 26 - 30, Normalize the
filter term once at the entry point of SchemaPropertyFilter.filter before
matching or recursive calls, so mixed-case input is handled case-insensitively
throughout matchesKeyOrTitle and matchesModelValue. Preserve the existing
space-removal contract and ensure recursive filter calls reuse the normalized
term.
🤖 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/form/utils/SchemaPropertyFilter.ts`:
- Around line 91-109: Update hasNestedProperties to recognize any schema with
defined properties, regardless of whether schema.type is 'object'; preserve the
existing type guard return shape and isDefined(properties) check so schemas with
omitted type recurse through nested matching.

---

Nitpick comments:
In `@src/form/utils/SchemaPropertyFilter.ts`:
- Around line 26-30: Normalize the filter term once at the entry point of
SchemaPropertyFilter.filter before matching or recursive calls, so mixed-case
input is handled case-insensitively throughout matchesKeyOrTitle and
matchesModelValue. Preserve the existing space-removal contract and ensure
recursive filter calls reuse the normalized term.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e62b48ec-a389-426c-8534-6580292a228d

📥 Commits

Reviewing files that changed from the base of the PR and between ce55903 and b40e2f8.

📒 Files selected for processing (6)
  • src/form/fields/ObjectField/ObjectFieldGrouping.test.tsx
  • src/form/fields/ObjectField/ObjectFieldGrouping.tsx
  • src/form/utils/SchemaPropertyFilter.test.ts
  • src/form/utils/SchemaPropertyFilter.ts
  • src/form/utils/get-filtered-properties.test.ts
  • src/form/utils/get-filtered-properties.ts
💤 Files with no reviewable changes (2)
  • src/form/utils/get-filtered-properties.test.ts
  • src/form/utils/get-filtered-properties.ts

Comment thread src/form/utils/SchemaPropertyFilter.ts
@sonarqubecloud

Copy link
Copy Markdown

@lordrip
lordrip merged commit 98f8f77 into KaotoIO:1.x Jul 30, 2026
7 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.

3 participants