Skip to content

improvement(condition): added variable and envvar highlighting for condition input - #1718

Merged
waleedlatif1 merged 1 commit into
stagingfrom
improvement/condition
Oct 22, 2025
Merged

improvement(condition): added variable and envvar highlighting for condition input#1718
waleedlatif1 merged 1 commit into
stagingfrom
improvement/condition

Conversation

@waleedlatif1

@waleedlatif1waleedlatif1 commented Oct 22, 2025

Copy link
Copy Markdown
Collaborator

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

  • Other: 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

vercelBot commented Oct 22, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedOct 22, 2025 8:07pm

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. Replace variables/env vars with temporary placeholders before Prism highlighting
  2. Apply JavaScript syntax highlighting via Prism
  3. 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

FilenameScoreOverview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/condition-input.tsx5/5Added 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
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
waleedlatif1 merged commit e425d06 into stagingOct 22, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the improvement/condition branch October 22, 2025 20:12
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)
Sign up for freeto 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

@waleedlatif1