fix(macos): disable automatic text substitutions in tray app (#538)#548
Merged
Conversation
macOS smart-dash substitution rewrites "--" as an em-dash "—" in the native tray's text fields (Add Server, server config, etc.), silently corrupting CLI flags typed into Command/Arguments/Env fields (e.g. "--flag" -> "—flag") and producing broken MCP server configs. Disable all automatic text substitutions (dashes, quotes, text replacement, spelling correction, capitalization) app-wide by writing the corresponding defaults to the application domain in applicationWillFinishLaunching, before any window / NSTextView field editor exists. None of the app's text fields hold prose, so every automatic substitution is unwanted everywhere; one global setting covers all input fields. SwiftUI exposes no modifier for smart dashes (.autocorrectionDisabled() does not affect dash substitution), so the AppKit defaults the field editor reads at creation are the reliable lever. Also unwraps an optional in ModelsTests so the test target compiles (pre-existing: XCTAssertEqual(_:_:accuracy:) needs a non-optional). Related #538
Deploying mcpproxy-docs with
|
| Latest commit: |
e7f295b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1393ffd1.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-538-macos-autocorrect.mcpproxy-docs.pages.dev |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 26705683965 --repo smart-mcp-proxy/mcpproxy-go
|
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
Fixes the bug reported in #538. On macOS, the native tray app's text fields have automatic smart-dash substitution enabled (the system default). Typing
--is silently rewritten to an em-dash—, which corrupts CLI flags entered into the Add Server Command / Arguments / Environment fields (e.g.--flag→—flag), producing broken MCP server configs. The reporter notes the per-field context-menu toggle resets on every edit, so they expect it disabled throughout the app.The reported flow (
Add Server → Manual → type into a field) and the attached screenshot are the native SwiftUI tray (AddServerView.swift) — the strings "Local Command (stdio)" / "Remote URL (HTTP)" and the free-text Command field exist only there, and the screenshot's context menu is the AppKit NSTextView Substitutions menu.Fix
Disable all automatic text substitutions (dashes, quotes, text replacement, spelling correction, capitalization) app-wide by writing the corresponding
UserDefaultskeys inapplicationWillFinishLaunching— before any window /NSTextViewfield editor is created, so every field inherits the disabled state. None of the app's text fields hold prose (commands, flags, paths, URLs, KEY=VALUE, names, tokens), so every automatic substitution is unwanted everywhere; one global setting covers all 29TextField/TextEditor/SecureFieldsites across the 7 view files. SwiftUI exposes no modifier for smart dashes (.autocorrectionDisabled()does not affect dash substitution), so the AppKit defaults the field editor reads at creation time are the reliable lever.Logic is extracted into
TextSubstitution.disableAutomaticTextSubstitutions()so it can be unit-tested.Changes
MCPProxy/TextSubstitution.swift(new) — the helper + the substitution-default keys.MCPProxy/MCPProxyApp.swift— call it fromapplicationWillFinishLaunching.MCPProxyTests/TextSubstitutionTests.swift(new) — 3 tests, incl. a freshNSTextViewreporting dash substitution off after the helper runs.MCPProxyTests/ModelsTests.swift— unwrap an optional so the test target compiles (pre-existing breakage:XCTAssertEqual(_:_:accuracy:)requires a non-optional; the whole Swift test target failed to build before this).Verification
swift test --filter TextSubstitutionTests→ 3/3 pass..devtray bundle, opened Add Server, typed a fresh--(system smart-dashes at default ON) → preserved as--in both aTextFieldand the ArgumentsTextEditor(pixel-verified two glyphs, not one em-dash).Related #538