Skip to content

46825 frontend [ template ] Dashes escaped with backslash in workflow name#214

Closed
EBirkenfeld wants to merge 1 commit into
masterfrom
frontend/template/46825__dashes_escaped_with_backslash
Closed

46825 frontend [ template ] Dashes escaped with backslash in workflow name#214
EBirkenfeld wants to merge 1 commit into
masterfrom
frontend/template/46825__dashes_escaped_with_backslash

Conversation

@EBirkenfeld

@EBirkenfeld EBirkenfeld commented May 20, 2026

Copy link
Copy Markdown
Collaborator

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 as Date — 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 escapeMarkdown function 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 with multiline={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 8
  • frontend/src/public/utils/__tests__/escapeMarkdown.test.ts — new file, 59 tests

Regex change:

  • Before: /([\\*_[]{}()#+-.!|&%=:"'~])/g`
  • After: /([\\*_[]{}()#+.!|&%=:"'~])/g`
    No API, type, or contract changes. Frontend-only change.

5. What to Test

5.1 Preconditions

  • Environment: dev
  • Account with template editor access
  • A template with "Workflow name" field containing dashes between variables

5.2 Positive Scenarios

  1. Launch workflow with dashes in name:
    • Open template → Kick-off Form → set "Workflow name" to: {{date}} — {{template-name}}-{{field-xxx}}
    • Save template → click "Run"
    • In the launch modal, verify dashes display without backslashes
    • Launch the workflow → check that the workflow name in the list is correct (no \-)
  2. Edit name in the launch modal:
    • Open the launch modal for a template with dashes in Workflow name
    • Edit the name: add/remove a dash
    • Click Run → verify the name is saved correctly
  3. Template without dashes (regression):
    • Verify that a template like {{date}} {{template-name}} still works correctly

5.3 Negative Scenarios and Edge Cases

  1. Multiple consecutive dashes: Workflow name ---{{date}}--- → should display as-is, no \
  2. Dash only: Workflow name - → should remain just -
  3. Markdown formatting in name: Enter **bold** _italic_ → asterisks and underscores should still be escaped (displayed as text, not formatting)
  4. Empty workflow name: Leave field empty → Run button should be disabled

5.4 Verification Points

  • Launch modal UI: dashes without backslashes
  • Template editor UI (Kick-off Form → Workflow name): dashes without backslashes
  • Created workflow name in the list: correct, no \-
  • DevTools → Network → launch request payload: name field 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:

  • In the POST /workflows request, the name field should not contain \-
  • The wf_name_template field in GET /templates/{id} response remains unchanged (dashes without escaping)

5.6 What Was NOT Tested

  • Not tested on mobile devices
  • Not tested in production
  • Locales were not checked (change does not affect i18n)
  • Public form was not tested separately

6. Affected Areas (Dependencies)

escapeMarkdown is used in the InputWithVariables component, which is used in 3 places:

Location Component What to verify
Workflow launch modal WorkflowEditPopup "Workflow name" field — dashes without \
Template editor, Kick-off Form KickoffRedux "Workflow name" field — dashes without \
Template editor, task description TaskForm Task name field — dashes without \

7. Refactoring

No refactoring was performed. The change is a 1-character bugfix in a regex.

8. Commits

  • 7d0b0ab7fix(frontend): stop escaping dashes in workflow name template

9. 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 any escapeMarkdown usage.

Overview
Fixes workflow/template text rendering by updating escapeMarkdown to 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 escapeMarkdown function

Removes - from the set of characters backslash-escaped in escapeMarkdown.ts, so strings like a-b stay as a-b instead of becoming a\-b. Adds a Jest test suite in escapeMarkdown.test.ts covering dash handling, variable preservation, and idempotency.

Macroscope summarized 7d0b0ab.

@EBirkenfeld EBirkenfeld self-assigned this May 20, 2026
@EBirkenfeld EBirkenfeld added bug Something isn't working Frontend Web client changes request labels May 20, 2026
@EBirkenfeld EBirkenfeld requested a review from pneumojoseph May 20, 2026 01:11

@Maria-Lordwill Maria-Lordwill left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Frontend Web client changes request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants