Skip to content

improvement(search-replace): pass down to subblocks#4712

Merged
icecrasher321 merged 2 commits into
stagingfrom
improvement/search-replace-exact
May 22, 2026
Merged

improvement(search-replace): pass down to subblocks#4712
icecrasher321 merged 2 commits into
stagingfrom
improvement/search-replace-exact

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

Pass down search highlighting to the subblocks

Type of Change

  • Other: UX Improvement

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 22, 2026 1:59am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 22, 2026

PR Summary

Medium Risk
Broad UI changes across many sub-block input components to render search highlights (including HTML-injected code highlighting), which could cause regressions in editor rendering/selection behavior if edge cases were missed.

Overview
Workflow search highlighting is now propagated into sub-block UI components. Many inputs/selectors (ShortInput, LongInput, Code, ConditionInput, dropdowns/comboboxes, checkbox lists, file upload, selectors, skills/credentials/KB pickers, filter/sort builders, etc.) accept activeSearchTarget and render the active match via formatDisplayText/combobox overlays, with correct valuePath handling for nested array fields.

Highlighting logic is centralized and hardened. formatted-text now supports a workflowSearchHighlight range, validates ranges against the current text (getValidWorkflowSearchRange) to avoid stale/duplicate matches, and adds tests; code/condition syntax highlighters also inject a single <mark> for the active match with explicit HTML escaping. UI behavior is tweaked to expand/scroll nested editors when the active search target is inside collapsed/modal content (e.g., grouped checkbox modal, input mapping, filter builder).

Reviewed by Cursor Bugbot for commit 68b6c03. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 22, 2026

Greptile Summary

This PR extends the workflow search-replace feature so that search highlights propagate from the top-level panel all the way into individual sub-block components (dropdowns, condition inputs, sort/filter builders, skill lists, etc.) instead of only highlighting the parent field label. It also enriches ActiveSearchTarget with the match range, raw value, and query string, splits the ephemeral search state into a dedicated non-persisted Zustand store, and improves multi-value resource replacement so it can target the correct index.

  • Display-label indexingindexer.ts now emits non-editable display-label matches for fixed-option controls (dropdown labels, time-input display strings, table column names, checkbox-list option text, sort/filter builder visible values, skill names, variable names); these are surfaced to the user but blocked from replacement.
  • Inline highlightingformatted-text.tsx gains a workflowSearchHighlight context option that wraps the matched range in <mark>; condition-input.tsx replicates the short-input overlay pattern (transparent textarea + visible overlay) for router mode, and injects a placeholder into the Prism pass for condition mode to render the <mark>.
  • Resource path precisionregistry.ts attaches a valuePath to each structured-resource reference for multi-value fields; replacements.ts adds getResourceReplacementScope to walk the path prefix until the containing value is found, preventing stale-conflict false positives.

Confidence Score: 4/5

Safe to merge after addressing the Prism placeholder issue; all other changes are well-tested and follow established patterns.

The placeholder string __WORKFLOW_SEARCH_MATCH__ inserted into code before Prism runs is a valid JavaScript identifier, but Prism can tokenize it as multiple adjacent tokens (e.g. two __ operator tokens wrapping an identifier). When that happens the literal string never appears in the resulting HTML and String.prototype.replace silently skips it, leaving the placeholder text visible in the code editor overlay. All other changes — display-label indexing, the new highlight store, resource path precision — are clean and well-covered by the added tests.

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/condition-input/condition-input.tsx — specifically the WORKFLOW_SEARCH_MATCH_PLACEHOLDER definition and its use in createHighlightFunction.

Important Files Changed

Filename Overview
apps/sim/lib/workflows/search-replace/indexer.ts Major extension: adds display-label indexing for dropdown, time-input, table columns, checkbox-lists, filter/sort builders, skill-input, and variables-input. MCP dynamic-arg enum fields are de-duplicated from plain-text leaves. valuePath now populated for resource references in multi-value fields.
apps/sim/lib/workflows/search-replace/replacements.ts getResourceReplacementScope walks up the valuePath prefix to find the correct scope for structured-resource replacement, needed because multi-select resources now carry a specific [index] path instead of [].
apps/sim/stores/panel/editor/store.ts Splits activeSearchTarget into a separate, non-persisted usePanelEditorSearchStore and enriches ActiveSearchTarget with range, rawValue, query, subBlockType, displayLabel, and structuredOccurrenceIndex fields needed for inline highlighting.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/workflow-search-highlight.ts New utility: isWorkflowSearchTargetForField, getActiveWorkflowSearchHighlight (exact-range match), and getWorkflowSearchLabelHighlight (falls back to case-insensitive scan for display labels with different casing).
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/formatted-text.tsx formatDisplayText now accepts a workflowSearchHighlight range and wraps the matched slice in a mark element before recursively formatting the before/after segments; keys are now properly namespaced via keyPrefix to avoid collisions.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/condition-input/condition-input.tsx Router mode: adds a transparent-text textarea + visible highlight overlay (matching the short-input pattern). Condition mode: adds createHighlightFunction that injects a placeholder before Prism runs, then substitutes it with a mark tag post-highlighting. overlayRefs map tracks overlay divs for height sync.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/dropdown/dropdown.tsx Multi-select: highlights matched label in each Badge. Single-select: new singleSelectOverlay memo shows formatted text when a search range is active, overlaying the combobox trigger.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/search-replace/workflow-search-replace.tsx createActiveSearchTarget now carries the full match payload (range, rawValue, query, subBlockType). The query change effect gains a return early to avoid a double setActiveSearchTarget call when selecting a new first match.
apps/sim/lib/workflows/search-replace/resources/registry.ts scalarResourceCodec and fileUploadResourceCodec now attach a valuePath to each reference so multi-value resources can be targeted at the right index. StructuredResourceReference gains the optional valuePath field.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx Removes hasNestedWorkflowSearchHighlight helper and highlightParentLabel logic; passes activeSearchTarget directly to all sub-block components instead of the old boolean isSearchHighlighted approach for label highlighting.

Sequence Diagram

sequenceDiagram
    participant SR as WorkflowSearchReplace
    participant Store as usePanelEditorSearchStore
    participant Editor as Editor
    participant SubBlock as SubBlock
    participant Component as Sub-block Component
    participant FT as formatDisplayText

    SR->>Store: setActiveSearchTarget(match + range + query)
    Store-->>Editor: activeSearchTarget (reactive)
    Editor->>Editor: filter by currentBlockId
    Editor->>SubBlock: activeSearchTarget (block-scoped)
    SubBlock->>Component: activeSearchTarget
    Component->>Component: getActiveWorkflowSearchHighlight(valuePath)
    Component->>FT: "formatDisplayText(value, {workflowSearchHighlight})"
    FT->>FT: slice before/match/after
    FT-->>Component: ReactNode[] with mark around match
Loading

Reviews (2): Last reviewed commit: "fix local lowercasing bug" | Re-trigger Greptile

@icecrasher321
Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321 icecrasher321 merged commit 1af6538 into staging May 22, 2026
13 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/search-replace-exact branch May 22, 2026 06:27
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