fix: normalize smart punctuation (em dash → --) in chat input#242
Merged
StephaneDelcroix merged 2 commits intomainfrom Feb 28, 2026
Merged
Conversation
macOS/WebKit automatically converts '--' to '—' (em dash) in textareas, breaking CLI commands with flag syntax (e.g., 'git log --oneline'). Three-layer fix: 1. HTML: Add autocorrect='off' to all command-input textareas to prevent WebKit smart text substitution at the source. 2. JS: Normalize smart punctuation (em dash, en dash, smart quotes) back to ASCII in getElementValue() before values reach C# code. 3. C#: SmartPunctuationNormalizer applied in SendPromptAsync as a final safety net for programmatic callers and pasted text. Fixes: typing '--' in ! mode produces '—' instead of '--' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove JS normalization from getElementValue() to avoid silently rewriting session/group/preset names. The C# layer in SendPromptAsync is the correctly-scoped safety net. Also fix Normalize() to accept string? and return string.Empty for null input instead of null. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
eaf4000 to
a809143
Compare
Collaborator
Author
✅ Multi-Model Review: Ready to MergeInitial 5-model review found 2 issues. Both fixed in commit 🟡 🟡 Post-fix re-review (5 models): Both issues confirmed fixed. All 10 normalizer tests pass. All prompt paths verified to converge on |
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.
Problem
On Mac Catalyst, WebKit's smart text substitution converts
--to—(em dash) in textarea inputs. This breaks CLI commands that use double-dash flags (e.g.,git log --oneline), especially in!mode.Fix
Three-layer defense:
HTML prevention: Added
autocorrect="off"to all command-input textareas (ExpandedSessionView,Dashboard,SessionSidebar) to prevent WebKit smart substitution at the source.JS normalization: Added
normalizeSmartPunctuation()ingetElementValue()(index.html) to convert em dashes, en dashes, and smart quotes back to ASCII before values reach C# code. This catches pasted text and edge cases.C# safety net: Added
SmartPunctuationNormalizerutility applied at theSendPromptAsyncentry point as a final defense for programmatic callers.Tests
Added 10 unit tests covering:
--conversion-conversionAll 1555 tests pass. Mac Catalyst build succeeds.