improvement(condition): added variable and envvar highlighting for condition input#1718
Merged
waleedlatif1 merged 1 commit intostagingfrom Oct 22, 2025
Merged
improvement(condition): added variable and envvar highlighting for condition input#1718waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
Added syntax highlighting for variable references (<variable>) and environment variables ({{envVar}}) in the condition input editor. The implementation uses a placeholder replacement pattern similar to code-editor.tsx to prevent Prism from interfering with custom syntax.
Key changes:
- Added
shouldHighlightReference()function that validates variable references against accessible block prefixes - Replaced basic Prism highlighting with custom highlighter that preserves and highlights variables/env vars
- Variables and env vars are displayed in blue (
text-blue-500) - Only highlights valid variable references that pass
isLikelyReferenceSegment()and accessibility checks
Technical approach:
- Replace variables/env vars with temporary placeholders before Prism highlighting
- Apply JavaScript syntax highlighting via Prism
- Restore placeholders with custom blue styling
The implementation correctly escapes HTML entities for variable references to prevent XSS issues.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The changes are straightforward UI improvements that add syntax highlighting without modifying any logic. The implementation follows an existing pattern from code-editor.tsx, properly escapes HTML entities, and includes validation checks for variable references. No breaking changes or risky logic modifications.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/condition-input.tsx | 5/5 | Added syntax highlighting for variables and environment variables in condition input using placeholder replacement pattern. Implementation is safe and follows similar patterns from code-editor.tsx. |
Sequence Diagram
sequenceDiagram
participant User
participant ConditionInput
participant Editor
participant Highlighter
participant ValidationUtils
User->>ConditionInput: Type code with variables/env vars
ConditionInput->>Editor: onValueChange
Editor->>Highlighter: highlight(codeToHighlight)
Highlighter->>Highlighter: Replace {{envVar}} with __ENV_VAR_N__
Highlighter->>Highlighter: Replace <varRef> with __VAR_REF_N__
Note over Highlighter: Store originals in placeholders array
Highlighter->>ValidationUtils: shouldHighlightReference(<varRef>)
ValidationUtils->>ValidationUtils: Check isLikelyReferenceSegment()
ValidationUtils->>ValidationUtils: Check accessible prefixes
ValidationUtils-->>Highlighter: true/false
Highlighter->>Highlighter: Apply Prism JavaScript highlighting
Highlighter->>Highlighter: Restore placeholders with blue styling
Highlighter-->>Editor: Return highlighted HTML
Editor-->>User: Display syntax-highlighted code
1 file reviewed, no comments
waleedlatif1
added a commit
that referenced
this pull request
Oct 23, 2025
* fix(debug-mode): remove duplicate debug mode flag (#1714) * feat(i18n): update translations (#1709) * improvement(condition): added variable and envvar highlighting for condition input (#1718) * fix(dashboard): add additional context for paginated logs in dashboard, add empty state when selected cell has no data (#1719) * fix(dashboard): add additional context for paginated logs in dashboard, add empty state when selected cell has no data * apps/sim * renaming * remove relative import * feat(tools): added webflow OAuth + tools (#1720) * feat(tools): added webflow OAuth + tools * remove itemId from delete item * remove siteId * added webhook triggers + oauth scopes + site/collection selector * update sample payload for webflow triggers * cleanup * fix discord color * feat(i18n): update translations (#1721) * improvement(schedule): fix UI bug with schedule modal (#1722)
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.
Summary
added variable and envvar highlighting for condition input, the exact same way we do it in the code subblock and all other subblocks, just using a variant of formatDisplayText since this needs text back and not a react component
Type of Change
Testing
Tested manually.
Checklist