[Streams] Improve condition filtering#251129
Conversation
- Fixed type error in pattern_suggestion_helpers.ts by adding missing selectedConditionId parameter to selectPreviewRecords call - Updated simulation_condition_noops.test.ts assertions to match actual processor counts (3 and 5 instead of 4 and 7) - Updated utils.test.ts to reflect new condition filtering behavior where condition IDs are directly included in processed_by array
…lters to zero documents When creating/editing processors under conditions with 0% match rate, field suggestions would be empty because they relied on condition-filtered preview records. This fix makes field suggestions fall back to all samples when the filtered records are empty.
…ring Adds playwright tests for the new condition filtering behavior: - Verify condition match rate badges appear on WHERE blocks - Test 0%, 50%, and 100% match rate scenarios - Validate "Selected X%" indicator when editing processors under conditions - Test badge persistence after saving and page reload - Verify nested conditions show match rate badges
CleanShot.2026-02-03.at.15.54.03.mp4this is really close overall |
@LucaWintergerst What would you expect to show in this scenario? |
…t status The remove processor in condition noop pairs was missing a tag, causing: 1. Documents matching conditions without sub-processors to show as "Failed 100%" 2. Documents with sub-processors to show as "Partially parsed" instead of "Parsed" Added a distinct tag suffix (:noop-cleanup) to the remove processor so it gets filtered out without double-counting in processor metrics.
| return docIndexes | ||
| .filter((docIndex) => samples.at(docIndex) !== undefined) | ||
| .map((index) => samples[index]); | ||
| // Always simulate on the full sample set. |
There was a problem hiding this comment.
selectSamplesForSimulation should be simplified since it just fetches the samples and nothing else. Is it even used anymore? If not, we should remove it.
|
/ralph
|
Co-authored-by: Cursor <cursoragent@cursor.com>
- Remove `selectSamplesForSimulation` and inline `context.samples` for simulation input - Update `computeSimulationDocDiff` tests to pass `conditionProcessorTags` - Fix Scout UI test to import `expect` from `@kbn/scout/ui` Co-authored-by: Cursor <cursoragent@cursor.com>
|
Updated the PR branch and addressed the remaining review/CI follow-ups. Changes:
Written by cursor, wait for @flash1293 to chime in |
|
@LucaWintergerst finally got to review this properly, sorry for the delay. I think it works really well, only nit I can see is this behavior: After clicking "Update" on a processor, it unselects the current condition again. Is that on purpose or should we keep the focus? Also, this should definitely be split out, but do we want something similar for the yaml mode? It's quite useful to scope the simulation like this, I can also imagine it for YAML, but we need to think the interaction through. |
|
/ralph |
Avoid clearing the auto-selected condition filter when saving a processor edit so the currently focused condition remains selected after clicking Update. Add a regression test for the save flow.
|
Addressed the review note about processor Update clearing the selected condition.\n\n- Saving/updating a processor no longer clears the auto-selected condition filter, so the condition focus stays where it was.\n- Cancel still clears the auto condition filter (unchanged).\n- Added a regression test: .\n\n(waiting for @flash1293 to chime in if anything else is needed) |
|
Follow-up: the regression test added for this behavior is at: x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_enrichment/state_management/interactive_mode_machine/interactive_mode_machine.test.ts |
|
The type error should be fixed on main already, let's see |
|
/ralph there are failing jest tests: Jest Tests Command Line: Error: expect(received).toBeDefined() Received: undefined Fix them, validate locally it works, then push the fix |
- Fix test to send step.save to child stepRefs instead of parent actor (matching actual UI behavior) - Add htmlIdGenerator mock to generate unique IDs (EUI test-env mock returns the same ID for all calls, breaking multi-step tests) - Fix grokCollection mock to include setCustomPatterns method - Add step.filterByCondition and step.clearConditionFilter event handlers to creating and editing states in interactiveModeMachine (previously only handled in idle state, but needed when editing) Co-authored-by: Cursor <cursoragent@cursor.com>
|
Fixed the failing Jest test for condition focus on processor save. Root causes identified:
(written by cursor, wait for @flash1293 to chime in) |
…condition-filtering
| @@ -710,10 +723,14 @@ export const computeSimulationDocDiff = ( | |||
There was a problem hiding this comment.
Perhaps we can consider passing an object instead with descriptive key names, so we don't have to rely as much on arguments being descriptively named when the function is used
|
/ralph Address @CoenWarmer s comment on the PR - I think it's a good idea. |
Addresses @CoenWarmer's review comment to use an object parameter with descriptive key names instead of positional arguments, improving readability at call sites. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed @CoenWarmer's review comment about converting Changes:
(written by cursor, wait for @flash1293 to chime in) |
💔 Build Failed
Failed CI StepsMetrics [docs]Async chunks
History
|
|
/ralph xstate5 got renamed to xstate, please fix the linting and type failures. |
The package was renamed from xstate5 to xstate. Update the import in the interactive mode machine test file to fix linting and type check failures. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Fixed the xstate5 → xstate import issue. Change:
Validation:
(written by cursor, wait for @flash1293 to chime in) |
|
@CoenWarmer should be good for another look. |
|
A little hard to judge without more context or a related ticket but code looks good. |
…condition-filtering
Update test files to use proper type annotations instead of `as any` casts to comply with the no-explicit-any ESLint rule that was added to the streams plugins. Co-authored-by: Cursor <cursoragent@cursor.com>
## Summary Improves condition filtering metrics in Streams data enrichment by tagging simulation-only no-op processors per condition block so the UI can show accurate match-rate badges and filter simulation results by condition. This branch is now up to date with `upstream/main` (conflicts resolved). ## Changes - Add simulation-only no-op processors (set+remove) per condition to track match rates. - Filter out condition no-op processors from document status/diff calculations. - UI: show condition match-rate badges on WHERE blocks and filter derived document metrics based on the selected condition. - UX: auto-select parent condition when creating/editing processors under it. - UX: when updating/saving a processor, keep the current condition focus (don’t clear the condition filter). ## Follow-ups from review / CI - Removed `selectSamplesForSimulation` (it only returned `context.samples`) and inlined `context.samples` at the call site. - Updated streams simulation tests to pass the now-required `conditionProcessorTags` argument. - Fixed Scout spec import to use `expect` from `@kbn/scout/ui`. - Re-ran the OAS snapshot tooling locally after merging `upstream/main`; it produced **no diff** under `oas_docs/`. ## Test plan - `yarn test:jest x-pack/platform/plugins/shared/streams/server/routes/internal/streams/processing/simulation_handler.test.ts x-pack/platform/plugins/shared/streams/server/routes/internal/streams/processing/simulation_condition_noops.test.ts` - `yarn test:jest x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_enrichment/state_management/simulation_state_machine/utils.test.ts` - `yarn test:jest x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_enrichment/state_management/interactive_mode_machine/interactive_mode_machine.test.ts` - `node scripts/scout.js run-tests --stateful --testFiles x-pack/platform/plugins/shared/streams_app/test/scout/ui/tests/data_management/data_processing/condition_filtering.spec.ts` --------- Co-authored-by: LucaWintergerst <luca.wintergerst@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: flash1293 <flash1293@users.noreply.github.com>



Summary
Improves condition filtering metrics in Streams data enrichment by tagging simulation-only no-op processors per condition block so the UI can show accurate match-rate badges and filter simulation results by condition.
This branch is now up to date with
upstream/main(conflicts resolved).Changes
Follow-ups from review / CI
selectSamplesForSimulation(it only returnedcontext.samples) and inlinedcontext.samplesat the call site.conditionProcessorTagsargument.expectfrom@kbn/scout/ui.upstream/main; it produced no diff underoas_docs/.Test plan
yarn test:jest x-pack/platform/plugins/shared/streams/server/routes/internal/streams/processing/simulation_handler.test.ts x-pack/platform/plugins/shared/streams/server/routes/internal/streams/processing/simulation_condition_noops.test.tsyarn test:jest x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_enrichment/state_management/simulation_state_machine/utils.test.tsyarn test:jest x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_enrichment/state_management/interactive_mode_machine/interactive_mode_machine.test.tsnode scripts/scout.js run-tests --stateful --testFiles x-pack/platform/plugins/shared/streams_app/test/scout/ui/tests/data_management/data_processing/condition_filtering.spec.ts