Skip to content

Commit 5d96484

Browse files
authored
fix(variables): remove quote stripping from short & long inputs (#1375)
* fix(variables): remove quote stripping from short & long inputs * restore env * remove quote stripping everywhere * remove unused file
1 parent 6747a49 commit 5d96484

File tree

9 files changed

+15
-61
lines changed

9 files changed

+15
-61
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/combobox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ export function ComboBox({
432432
style={{ right: '42px' }}
433433
>
434434
<div className='w-full truncate text-foreground' style={{ scrollbarWidth: 'none' }}>
435-
{formatDisplayText(displayValue, true)}
435+
{formatDisplayText(displayValue)}
436436
</div>
437437
</div>
438438
{/* Chevron button */}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/long-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ export function LongInput({
406406
overflow: 'hidden',
407407
}}
408408
>
409-
{formatDisplayText(value?.toString() ?? '', true)}
409+
{formatDisplayText(value?.toString() ?? '')}
410410
</div>
411411

412412
{/* Wand Button */}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/short-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export function ShortInput({
417417
>
418418
{password && !isFocused
419419
? '•'.repeat(value?.toString().length ?? 0)
420-
: formatDisplayText(value?.toString() ?? '', true)}
420+
: formatDisplayText(value?.toString() ?? '')}
421421
</div>
422422
</div>
423423

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/starter/input-format.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,7 @@ export function FieldFormat({
471471
style={{ scrollbarWidth: 'none', minWidth: 'fit-content' }}
472472
>
473473
{formatDisplayText(
474-
(localValues[field.id] ?? field.value ?? '')?.toString(),
475-
true
474+
(localValues[field.id] ?? field.value ?? '')?.toString()
476475
)}
477476
</div>
478477
</div>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/tool-input/components/mcp-server-modal/mcp-server-modal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ export function McpServerModal({ open, onOpenChange, onServerCreated }: McpServe
337337
className='whitespace-nowrap'
338338
style={{ transform: `translateX(-${urlScrollLeft}px)` }}
339339
>
340-
{formatDisplayText(formData.url || '', true)}
340+
{formatDisplayText(formData.url || '')}
341341
</div>
342342
</div>
343343
</div>
@@ -389,7 +389,7 @@ export function McpServerModal({ open, onOpenChange, onServerCreated }: McpServe
389389
transform: `translateX(-${headerScrollLeft[`key-${index}`] || 0}px)`,
390390
}}
391391
>
392-
{formatDisplayText(key || '', true)}
392+
{formatDisplayText(key || '')}
393393
</div>
394394
</div>
395395
</div>
@@ -417,7 +417,7 @@ export function McpServerModal({ open, onOpenChange, onServerCreated }: McpServe
417417
transform: `translateX(-${headerScrollLeft[`value-${index}`] || 0}px)`,
418418
}}
419419
>
420-
{formatDisplayText(value || '', true)}
420+
{formatDisplayText(value || '')}
421421
</div>
422422
</div>
423423
</div>

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/mcp/mcp.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export function MCP() {
399399
className='whitespace-nowrap'
400400
style={{ transform: `translateX(-${urlScrollLeft}px)` }}
401401
>
402-
{formatDisplayText(formData.url || '', true)}
402+
{formatDisplayText(formData.url || '')}
403403
</div>
404404
</div>
405405

@@ -464,7 +464,7 @@ export function MCP() {
464464
transform: `translateX(-${headerScrollLeft[`key-${index}`] || 0}px)`,
465465
}}
466466
>
467-
{formatDisplayText(key || '', true)}
467+
{formatDisplayText(key || '')}
468468
</div>
469469
</div>
470470
</div>
@@ -500,7 +500,7 @@ export function MCP() {
500500
transform: `translateX(-${headerScrollLeft[`value-${index}`] || 0}px)`,
501501
}}
502502
>
503-
{formatDisplayText(value || '', true)}
503+
{formatDisplayText(value || '')}
504504
</div>
505505
</div>
506506
</div>
@@ -778,7 +778,7 @@ export function MCP() {
778778
className='whitespace-nowrap'
779779
style={{ transform: `translateX(-${urlScrollLeft}px)` }}
780780
>
781-
{formatDisplayText(formData.url || '', true)}
781+
{formatDisplayText(formData.url || '')}
782782
</div>
783783
</div>
784784

@@ -845,7 +845,7 @@ export function MCP() {
845845
transform: `translateX(-${headerScrollLeft[`key-${index}`] || 0}px)`,
846846
}}
847847
>
848-
{formatDisplayText(key || '', true)}
848+
{formatDisplayText(key || '')}
849849
</div>
850850
</div>
851851
</div>
@@ -881,7 +881,7 @@ export function MCP() {
881881
transform: `translateX(-${headerScrollLeft[`value-${index}`] || 0}px)`,
882882
}}
883883
>
884-
{formatDisplayText(value || '', true)}
884+
{formatDisplayText(value || '')}
885885
</div>
886886
</div>
887887
</div>

apps/sim/components/ui/formatted-text.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,19 @@
11
'use client'
22

33
import type { ReactNode } from 'react'
4-
import { VariableManager } from '@/lib/variables/variable-manager'
54

65
/**
76
* Formats text by highlighting block references (<...>) and environment variables ({{...}})
87
* Used in code editor, long inputs, and short inputs for consistent syntax highlighting
98
*
109
* @param text The text to format
11-
* @param stripQuotes Whether to strip unnecessary quotes from the text (for plain text variables)
1210
*/
13-
export function formatDisplayText(text: string, stripQuotes = false): ReactNode[] {
11+
export function formatDisplayText(text: string): ReactNode[] {
1412
if (!text) return []
1513

16-
// If stripQuotes is true, remove surrounding quotes that might have been added
17-
// This is needed when displaying plain type variables in inputs
18-
let processedText = text
19-
if (stripQuotes && typeof text === 'string') {
20-
// Use VariableManager to determine if quotes should be stripped
21-
if (VariableManager.shouldStripQuotesForDisplay(text)) {
22-
processedText = text.slice(1, -1)
23-
}
24-
}
25-
26-
// Split the text by both tag patterns <something.something> and {{ENV_VAR}}
27-
const parts = processedText.split(/(<[^>]+>|\{\{[^}]+\}\})/g)
14+
const parts = text.split(/(<[^>]+>|\{\{[^}]+\}\})/g)
2815

2916
return parts.map((part, index) => {
30-
// Handle block references
3117
if (part.startsWith('<') && part.endsWith('>')) {
3218
return (
3319
<span key={index} className='text-blue-500'>
@@ -36,7 +22,6 @@ export function formatDisplayText(text: string, stripQuotes = false): ReactNode[
3622
)
3723
}
3824

39-
// Handle environment variables
4025
if (part.match(/^\{\{[^}]+\}\}$/)) {
4126
return (
4227
<span key={index} className='text-blue-500'>

apps/sim/lib/variables/variable-manager.test.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,4 @@ describe('VariableManager', () => {
215215
expect(VariableManager.formatForCodeContext(undefined, 'number')).toBe('undefined')
216216
})
217217
})
218-
219-
describe('shouldStripQuotesForDisplay', () => {
220-
it.concurrent('should identify strings that need quotes stripped', () => {
221-
expect(VariableManager.shouldStripQuotesForDisplay('"hello world"')).toBe(true)
222-
expect(VariableManager.shouldStripQuotesForDisplay("'hello world'")).toBe(true)
223-
expect(VariableManager.shouldStripQuotesForDisplay('hello world')).toBe(false)
224-
expect(VariableManager.shouldStripQuotesForDisplay('""')).toBe(false) // Too short
225-
expect(VariableManager.shouldStripQuotesForDisplay("''")).toBe(false) // Too short
226-
})
227-
228-
it.concurrent('should handle edge cases', () => {
229-
expect(VariableManager.shouldStripQuotesForDisplay('')).toBe(false)
230-
expect(VariableManager.shouldStripQuotesForDisplay(null as any)).toBe(false)
231-
expect(VariableManager.shouldStripQuotesForDisplay(undefined as any)).toBe(false)
232-
expect(VariableManager.shouldStripQuotesForDisplay(42 as any)).toBe(false)
233-
})
234-
})
235218
})

apps/sim/lib/variables/variable-manager.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,24 +225,11 @@ export class VariableManager {
225225
return typeof value === 'string' ? value : String(value)
226226
}
227227
if (type === 'string') {
228-
// For backwards compatibility, add quotes only for string type in code context
229228
return typeof value === 'string'
230229
? JSON.stringify(value)
231230
: VariableManager.formatValue(value, type, 'code')
232231
}
233232

234233
return VariableManager.formatValue(value, type, 'code')
235234
}
236-
237-
/**
238-
* Determines whether quotes should be stripped for display.
239-
*/
240-
static shouldStripQuotesForDisplay(value: string): boolean {
241-
if (!value || typeof value !== 'string') return false
242-
243-
return (
244-
(value.startsWith('"') && value.endsWith('"') && value.length > 2) ||
245-
(value.startsWith("'") && value.endsWith("'") && value.length > 2)
246-
)
247-
}
248235
}

0 commit comments

Comments
 (0)