Skip to content

feat(cua-driver-rs): port Swift launch_app name fallbacks to Rust - #1577

Open
hippoley wants to merge 1 commit into
trycua:mainfrom
hippoley:feat/launch-app-name-fallbacks
Open

feat(cua-driver-rs): port Swift launch_app name fallbacks to Rust#1577
hippoley wants to merge 1 commit into
trycua:mainfrom
hippoley:feat/launch-app-name-fallbacks

Conversation

@hippoley

@hippoley hippoley commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Ports Swift AppLauncher.locate(name:) Pass 3 from PR #1492 (3b5c372d) to the Rust cua-driver-rs port. Closes #1523.

locate_by_name() now runs the same three-pass chain as Swift:

Pass What it does Status
1 Exact filesystem <name>.app lookup in canonical roots unchanged
2 LaunchServices bundle-id lookup (accepts bundle id in name slot) unchanged
3a localizedName from running NSRunningApplication (locale-aware) new
3b CFBundleDisplayName / CFBundleName / stem scan, case-insensitive new

Before / After

# Before (Rust binary)
launch_app name="com.apple.calculator"  -> Could not locate app
launch_app name="CALCULATOR"            -> Could not locate app

# After (Rust binary)
launch_app name="com.apple.calculator"  -> pid=..., resolved via Pass 2
launch_app name="CALCULATOR"            -> pid=..., resolved via Pass 3
launch_app name="Calculator"            -> pid=..., regression guard

Files changed

  • apps/mod.rs — expand locate_by_name with Pass 3 (3a + 3b)
  • tests/integration/test_api_parity.py — 3 new parity tests
  • PARITY.md — document Pass 3 under Fixed (macOS)

Closes #1523

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced application launching with support for case-insensitive app name matching and bundle identifier resolution.
  • Tests

    • Added integration tests to verify application name resolution in multiple scenarios and error handling.

Review Change Stack

…oses trycua#1523)

Ports Swift AppLauncher.locate(name:) Pass 3 from PR trycua#1492 (3b5c372)
to the Rust cua-driver-rs port.

locate_by_name() now runs a three-pass chain that mirrors Swift exactly:

  Pass 1 (unchanged): exact filesystem <name>.app lookup in canonical
  roots (/Applications, /System/Applications, ~/Applications, etc.).

  Pass 2 (unchanged): LaunchServices bundle-id lookup via
  NSWorkspace.URLForApplicationWithBundleIdentifier — lets callers pass
  a bundle identifier in the name slot (e.g. name=com.apple.calculator)
  without switching to the bundle_id parameter.

  Pass 3 (new): case-insensitive fuzzy scan:
    a) localizedName from running NSRunningApplication instances —
       locale-aware, covers e.g. 計算機 on JP macOS for Calculator.
    b) CFBundleDisplayName > CFBundleName > bundle stem from each
       candidate bundle's Info.plist in the canonical roots.

Before this PR (Rust binary):
  launch_app name=com.apple.calculator  -> Could not locate app
  launch_app name=CALCULATOR            -> Could not locate app

After this PR (Rust binary):
  launch_app name=com.apple.calculator  -> pid=..., resolved via Pass 2
  launch_app name=CALCULATOR            -> pid=..., resolved via Pass 3
  launch_app name=Calculator            -> pid=..., regression guard

Files changed:
- apps/mod.rs: expand locate_by_name with Pass 3 (3a + 3b)
- tests/integration/test_api_parity.py: add 3 new parity tests:
    test_mcp_launch_app_by_name_accepts_bundle_id
    test_mcp_launch_app_by_name_case_insensitive
    test_mcp_launch_app_by_name_unknown_raises_error
- PARITY.md: document Pass 3 under Fixed (macOS)
@vercel

vercel Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

@nishantpurohit04 is attempting to deploy a commit to the Cua Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 363213f4-609b-4265-bbf0-be2284628752

📥 Commits

Reviewing files that changed from the base of the PR and between 0f834c6 and e9bcadf.

📒 Files selected for processing (3)
  • libs/cua-driver-rs/PARITY.md
  • libs/cua-driver-rs/crates/platform-macos/src/apps/mod.rs
  • libs/cua-driver-rs/tests/integration/test_api_parity.py

📝 Walkthrough

Walkthrough

Enhanced macOS launch_app name resolution to accept bundle identifiers and case-insensitive application names alongside exact bundle filenames. The implementation mirrors Swift's three-pass resolution chain: filesystem exact match, LaunchServices bundle-ID lookup, and fuzzy case-insensitive matching using running apps' localized names and Info.plist metadata. Integration tests validate bundle-ID resolution, case-insensitive matching, and error handling.

Changes

macOS app name resolution with three-pass matching

Layer / File(s) Summary
Three-pass app name resolution implementation
libs/cua-driver-rs/crates/platform-macos/src/apps/mod.rs
Updated locate_by_name documentation to specify Pass 1 (filesystem exact match), Pass 2 (LaunchServices bundle-ID lookup), and Pass 3 (case-insensitive fuzzy matching). Implementation adds Pass 2 via resolve_bundle_id_to_locator and Pass 3 logic that checks running apps' localized names then scans installed bundles' Info.plist fields and bundle stem.
Integration tests for name resolution
libs/cua-driver-rs/tests/integration/test_api_parity.py
Added three MCP parity tests covering bundle-ID resolution, case-insensitive name matching, and error handling for unresolvable names.
Parity documentation
libs/cua-driver-rs/PARITY.md
Updated macOS launch_app notes to document Pass 3 case-insensitive fuzzy matching using running app localized names and Info.plist metadata, with examples distinguishing Pass 2 (bundle-ID) from Pass 3 (case-insensitive) resolution.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • trycua/cua#1492: Swift implementation of the same three-pass app name resolution with bundle-ID and locale-aware matching that this PR ports to Rust.

Suggested reviewers

  • f-trycua

Poem

🐰 A rabbit hops through bundles and plist files,
Finding apps by name, through fuzzy miles,
Case-insensitive, locale-aware with glee,
Three passes to match—now CALCULATOR is free! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: porting Swift's launch_app name fallback behavior to the Rust cua-driver implementation.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #1523: three-pass name resolution (filesystem, LaunchServices, fuzzy case-insensitive scan), parity tests for bundle IDs and case-insensitive matching, and updated documentation.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the PR objectives: macOS app resolution logic, integration tests for parity, and PARITY.md documentation. No unrelated changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

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