Skip to content

fix(macos): disable automatic text substitutions in tray app (#538)#548

Merged
Dumbris merged 1 commit into
mainfrom
fix/538-macos-autocorrect
May 31, 2026
Merged

fix(macos): disable automatic text substitutions in tray app (#538)#548
Dumbris merged 1 commit into
mainfrom
fix/538-macos-autocorrect

Conversation

@Dumbris

@Dumbris Dumbris commented May 31, 2026

Copy link
Copy Markdown
Member

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 UserDefaults keys in applicationWillFinishLaunching — before any window / NSTextView field 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 29 TextField/TextEditor/SecureField sites 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 from applicationWillFinishLaunching.
  • MCPProxyTests/TextSubstitutionTests.swift (new) — 3 tests, incl. a fresh NSTextView reporting 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 TextSubstitutionTests3/3 pass.
  • Built a fixed .dev tray bundle, opened Add Server, typed a fresh -- (system smart-dashes at default ON) → preserved as -- in both a TextField and the Arguments TextEditor (pixel-verified two glyphs, not one em-dash).
  • Personal-edition Go build unaffected (no Go changes).

Note: the full swift test target has 6 pre-existing, unrelated failures (SSE parser / merge-patch / SSE decode) that were masked because the target didn't compile; not addressed here. No CI currently runs the Swift test target.

Related #538

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
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/538-macos-autocorrect

Available Artifacts

  • archive-darwin-amd64 (28 MB)
  • archive-darwin-arm64 (25 MB)
  • archive-linux-amd64 (16 MB)
  • archive-linux-arm64 (14 MB)
  • archive-windows-amd64 (27 MB)
  • archive-windows-arm64 (24 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (21 MB)
  • installer-dmg-darwin-arm64 (19 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 26705683965 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris Dumbris merged commit 392c0a1 into main May 31, 2026
28 checks passed
@Dumbris Dumbris deleted the fix/538-macos-autocorrect branch May 31, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants