46825 frontend [ template ] Dashes escaped with backslash in workflow name#214
46825 frontend [ template ] Dashes escaped with backslash in workflow name#214EBirkenfeld wants to merge 1 commit into
Conversation
Maria-Lordwill
left a comment
There was a problem hiding this comment.
Review
The fix is correct and well-reasoned.
The change: Removing - from the escapeMarkdown regex is the right call. The field uses multiline={false}, so a dash can never appear at the start of a line in a markdown sense — it's not a list marker here. No need to escape it.
Tests: The test file is thorough — covers dash handling, variable preservation ({{...}}), markdown special characters, edge cases, and idempotency. 59 tests for a one-line change is exactly the right level of coverage for a utility function used in multiple places.
Risk: Low. The only behavioral change is that - will no longer be backslash-escaped in escapeMarkdown output. All other characters (*, _, `, !, etc.) continue to be escaped as before.
LGTM ✅
1. Description (Problem)
When launching a workflow from a template, backslashes appear before every dash (
\-) in the "Workflow name" field of the launch modal.Example: template
{{date}} — {{template-name}}-{{field-xxx}} -{{workflow-id}}renders asDate — Template name \- Checkbox Field \- Workflow id.Visible in the workflow launch modal ("Run" button on the template page) and in the template editor ("Workflow name" field in the Kick-off Form).
2. Context
The
escapeMarkdownfunction was introduced to prepare text before loading it into the Lexical editor — so that markdown special characters (*,_,`, etc.) are not interpreted as formatting. The dash (-) was incorrectly included in the list of escaped characters, even though it is not a markdown special character in inline context (only at line start as a list marker, but the field is single-line withmultiline={false}).3. Solution
Remove the dash character from the escaping regex pattern in
escapeMarkdown. This is a minimal one-line change that eliminates the issue without side effects.4. Implementation Details
Files affected:
frontend/src/public/utils/escapeMarkdown.ts— removed\-from regex character class on line 8frontend/src/public/utils/__tests__/escapeMarkdown.test.ts— new file, 59 testsRegex change:
/([\\*_[]{}()#+-.!|&%=:"'~])/g`/([\\*_[]{}()#+.!|&%=:"'~])/g`No API, type, or contract changes. Frontend-only change.
5. What to Test
5.1 Preconditions
5.2 Positive Scenarios
{{date}} — {{template-name}}-{{field-xxx}}\-){{date}} {{template-name}}still works correctly5.3 Negative Scenarios and Edge Cases
---{{date}}---→ should display as-is, no\-→ should remain just-**bold** _italic_→ asterisks and underscores should still be escaped (displayed as text, not formatting)5.4 Verification Points
\-namefield without\-5.5 API Checks
This PR does not change API requests or responses. The change is only in the client-side text preparation before displaying in the Lexical editor. However, verify:
POST /workflowsrequest, thenamefield should not contain\-wf_name_templatefield inGET /templates/{id}response remains unchanged (dashes without escaping)5.6 What Was NOT Tested
6. Affected Areas (Dependencies)
escapeMarkdownis used in theInputWithVariablescomponent, which is used in 3 places:WorkflowEditPopup\KickoffRedux\TaskForm\7. Refactoring
No refactoring was performed. The change is a 1-character bugfix in a regex.
8. Commits
7d0b0ab7—fix(frontend): stop escaping dashes in workflow name template9. Release Notes
Fixed: dashes in workflow name template no longer display with backslashes when launching a workflow.
Note
Low Risk
Low risk: a one-character regex change to stop escaping
-, plus comprehensive unit tests; main risk is a small behavior change where-will no longer be backslash-escaped in anyescapeMarkdownusage.Overview
Fixes workflow/template text rendering by updating
escapeMarkdownto no longer escape hyphens (-) while continuing to escape other markdown-relevant characters.Adds a comprehensive Jest test suite for
escapeMarkdown, covering variable placeholder preservation ({{...}}), special-character escaping, dash handling, and edge/idempotency cases.Reviewed by Cursor Bugbot for commit 7d0b0ab. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix dash escaping in workflow name template
escapeMarkdownfunctionRemoves
-from the set of characters backslash-escaped inescapeMarkdown.ts, so strings likea-bstay asa-binstead of becominga\-b. Adds a Jest test suite inescapeMarkdown.test.tscovering dash handling, variable preservation, and idempotency.Macroscope summarized 7d0b0ab.