[Streams] Bi-directional color coding for dissect processor#271246
Open
diogolima-elastic wants to merge 8 commits into
Open
[Streams] Bi-directional color coding for dissect processor#271246diogolima-elastic wants to merge 8 commits into
diogolima-elastic wants to merge 8 commits into
Conversation
|
Pinging @elastic/obs-onboarding-team (Team:obs-onboarding) |
628649c to
9a4f0b7
Compare
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To merge only after #269680
Closes https://github.com/elastic/streams-program/issues/1202
Summary
Adds bi-directional coloring for the Dissect processor, matching the existing Grok implementation. When editing a Dissect pattern, each field token in the editor is highlighted with a consistent color that also appears on the corresponding matched value in the sample preview table.
Before:

After:

What it does
%{clientip} %{method} %{status}, each%{field}token gets a distinct background color in the Monaco editor.clientiptoclient_ipcharacter-by-character keeps the same color). When a field name is changed while other tokens still use the old name, the renamed token gets a fresh color to distinguish it.How it works
Dissect patterns are structurally simpler than Grok (flat field references vs nested pattern resolution), so the color management uses a lighter architecture:
DissectColorManager: A single class that parses field tokens, assigns colors from the shared palette, and manages keystroke stability. Color transfer only happens when a field name is fully replaced (not when duplicates of the old name still exist in the pattern).DissectColorContext: React context that shares the color manager's field-to-color mapping between the editor and preview table, ensuring both always agree on colors.DissectSample: Converts the dissect pattern into a regex with named capture groups, matches it against sample text, and highlights the matched ranges using the sharedapplyHighlightsutility.Refactoring
To avoid code duplication between Grok and Dissect:
@kbn/grok-uiinto reusable modules: color palette constants (pattern_colour_utils.ts), highlight rendering (highlight_utils.tsx), and CSS class generation. Grok was refactored to consume these.processor_outcome_preview_helpers.tsto generic names (e.g.grokExpressionOverwritesSourceField-> kept + addeddissectPatternOverwritesSourceField).useProcessorHighlightModehook fromprocessor_outcome_preview.tsx, consolidating the duplicated processor-detection, source-field validation, overwrite checks, and column computation logic for both Grok and Dissect into a single reusable hook. This significantly simplified the preview component.Testing
DissectColorManager(color assignment, dedup, cleanup, rename transfer, stability, cycling, duplicate field rename).dissectPatternToRegex(group mapping, indices, delimiter escaping, greedy/non-greedy quantifiers, real-world patterns).+), skip keys, and various delimiters.