Skip to content

Fix literal tildes in terminal-inserted paths - #9734

Merged
austinywang merged 2 commits into
mainfrom
issue-9680-cd-space-tilde-path
Aug 11, 2026
Merged

austinywang merged 2 commits into
mainfrom
issue-9680-cd-space-tilde-path

Conversation

@austinywang

@austinywang austinywang commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Escape literal ~ characters in the shared terminal shell escaper used by paste, drag and drop, file explorer insertion, image transfer, and upload fallback paths.
  • Add a behavior-level regression that creates ~md/Mobile Documents/invest, passes the cmux-escaped relative path to a clean /bin/zsh -f, and verifies that zsh enters the literal directory.
  • Preserve the required red/green history: commit 1 adds the failing test; commit 2 fixes the shared escaper.

Refs #9680.

Issue analysis

The exact command in #9680 contains an unescaped space:

cd /Users/ren/Library/Mobile Documents/iCloud~md~obsidian/Documents/invest

That command is split into two arguments by zsh, which selects the documented cd old new form. Bare zsh and zsh with cmux integration sourced both emit the same string not in pwd error. Quoting the path or escaping the space succeeds. The mid-token iCloud~md~obsidian segment is not treated as named-directory syntax.

The investigation did uncover a related cmux-owned edge case: the shared app insertion escaper did not escape a literal tilde at the start of a token, so a relative path such as ~md/Mobile Documents/invest was interpreted by zsh as a named directory. This PR fixes that shared boundary and does not claim the cwd integration emitted the original error.

Testing

  • Confirmed the new test fails before the fix with zsh:1: no such user or named directory: md.
  • swift test --package-path Packages/macOS/CmuxTerminal --filter TerminalShellEscapingTests
  • swift test --package-path Packages/macOS/CmuxTerminal (178 Swift Testing tests and 11 XCTest tests passed)
  • ./scripts/reload.sh --tag issue-9680-cd-space-tilde-path
  • Manually compared the reported unquoted command under bare zsh and cmux-integrated zsh; both returned status 1 with identical output. The quoted path returned status 0 and preserved spaces and mid-path tildes.

Demo Video

Not applicable: this is deterministic non-visual shell escaping behavior.

Checklist

  • Tested locally
  • Added behavior-level regression coverage
  • No documentation or changelog update is needed
  • Localization audit complete; no user-facing strings changed

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Escape literal ~ in terminal-inserted paths so zsh doesn’t treat them as home or named directories. Adds a regression test to cover ~md/... paths; addresses an edge case found while investigating #9680.

  • Bug Fixes
    • Escape ~ in the shared terminal shell escaper used by paste, drag-and-drop, file explorer insertion, image transfer, and upload fallback.
    • Add a behavior test that creates ~md/Mobile Documents/invest, runs /bin/zsh -f, and verifies cd enters the literal directory.

Written for commit 4bfa6df. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@austinywang, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 90c5f49e-de4d-42a7-8098-e45680f54384

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0c47f and 4bfa6df.

📒 Files selected for processing (2)
  • Packages/macOS/CmuxTerminal/Sources/CmuxTerminal/Services/Pasteboard/String+TerminalShellEscaping.swift
  • Packages/macOS/CmuxTerminal/Tests/CmuxTerminalTests/Services/TerminalPasteboardServiceTests.swift

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@austinywang

Copy link
Copy Markdown
Contributor Author

Tagged dev verification on HEAD 4bfa6df57b:

  • ./scripts/reload.sh --tag issue-9680-cd-space-tilde-path --launch completed successfully.
  • The launched tagged app reported cmux 0.64.22 (102) over its isolated socket.
  • The live debug.terminal.simulate_file_drop route synthesized a file-URL pasteboard payload for /tmp/repro space/iCloud~md~obsidian/invest.
  • The terminal received cd /tmp/repro\\ space/iCloud\\~md\\~obsidian/invest.
  • Executing that app-inserted command returned CMUX_9680_CD_STATUS=0; pwd -P returned /private/tmp/repro space/iCloud~md~obsidian/invest.
  • Neither string not in pwd nor space was not specified appeared.

The focused Swift Testing suite also executed all 3 TerminalShellEscapingTests successfully, including the real /bin/zsh -f regression case.

@austinywang
austinywang merged commit 6edd0be into main Aug 11, 2026
6 checks passed
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.

1 participant