Skip to content

feat: enable Computer Use on Windows and Linux#145

Merged
claude-code-best merged 1 commit intoclaude-code-best:mainfrom
yi7503:feat/computer-use-cross-platform
Apr 6, 2026
Merged

feat: enable Computer Use on Windows and Linux#145
claude-code-best merged 1 commit intoclaude-code-best:mainfrom
yi7503:feat/computer-use-cross-platform

Conversation

@yi7503
Copy link
Copy Markdown
Contributor

@yi7503 yi7503 commented Apr 6, 2026

Remove macOS-only guards so Computer Use works cross-platform:

  • main.tsx: allow CHICAGO_MCP on any known platform (not just macos)
  • swiftLoader.ts: remove darwin-only throw, let the backend handle it
  • computer-use-input: dispatch to darwin/win32/linux backends
  • computer-use-swift: rename loadDarwin→loadBackend, dispatch all platforms

Summary by CodeRabbit

  • New Features
    • Extended Computer Use functionality to support Windows and Linux platforms in addition to macOS.
    • Computer Use MCP feature is now available across all supported platforms with automatic platform-specific backend selection.

Remove macOS-only guards so Computer Use works cross-platform:
- main.tsx: allow CHICAGO_MCP on any known platform (not just macos)
- swiftLoader.ts: remove darwin-only throw, let the backend handle it
- computer-use-input: dispatch to darwin/win32/linux backends
- computer-use-swift: rename loadDarwin→loadBackend, dispatch all platforms

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

This PR expands Computer Use support from macOS-only to multi-platform (Windows, Linux, macOS) by replacing platform-specific loaders with a unified platform-dispatch backend selection mechanism that conditionally loads platform-specific implementations based on process.platform.

Changes

Cohort / File(s) Summary
Backend Loading Refactor
packages/@ant/computer-use-input/src/index.ts, packages/@ant/computer-use-swift/src/index.ts
Replaced loadDarwin() with loadBackend() that conditionally requires ./backends/darwin.js, ./backends/win32.js, or ./backends/linux.js based on process.platform, with null fallback for unsupported platforms. Updated internal variable wiring from darwin to backend throughout.
Platform Guard Relaxation
src/main.tsx
Updated Computer Use MCP activation condition from requiring getPlatform() === 'macos' to allowing any platform where getPlatform() !== 'unknown', enabling broader platform support.
Swift Loader Guard Removal
src/utils/computerUse/swiftLoader.ts
Removed runtime platform guard that threw error on non-darwin platforms inside requireComputerUseSwift(), allowing unconditional backend require attempts across all platforms.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • KonghaYao

Poem

🐰 A rabbit hops across the lands,
From Darwin's shores to Windows sands,
With platforms three in harmony,
The backend loads where it should be! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: enabling Computer Use feature on Windows and Linux platforms, moving from macOS-only to cross-platform support.

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

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

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/@ant/computer-use-swift/src/index.ts (1)

39-58: ⚠️ Potential issue | 🟡 Minor

Make the fallback error platform-agnostic.

If the win32 backend fails to load, the fallback still throws @ant/computer-use-swift: macOS only, which turns a real Windows packaging/runtime failure into a misleading platform-gate error.

Suggested change
+const unsupportedBackendMessage =
+  `@ant/computer-use-swift: no backend available for ${process.platform}`
+
 export class ComputerUseAPI {
   apps = backend?.apps ?? {
     async prepareDisplay() { return { activated: '', hidden: [] } },
     async previewHideSet() { return [] },
     async findWindowDisplays(ids: string[]) { return ids.map((b: string) => ({ bundleId: b, displayIds: [] as number[] })) },
     async appUnderPoint() { return null },
     async listInstalled() { return [] },
     iconDataUrl() { return null },
     listRunning() { return [] },
-    async open() { throw new Error('@ant/computer-use-swift: macOS only') },
+    async open() { throw new Error(unsupportedBackendMessage) },
     async unhide() {},
   }

   display = backend?.display ?? {
-    getSize() { throw new Error('@ant/computer-use-swift: macOS only') },
-    listAll() { throw new Error('@ant/computer-use-swift: macOS only') },
+    getSize() { throw new Error(unsupportedBackendMessage) },
+    listAll() { throw new Error(unsupportedBackendMessage) },
   }

   screenshot = backend?.screenshot ?? {
-    async captureExcluding() { throw new Error('@ant/computer-use-swift: macOS only') },
-    async captureRegion() { throw new Error('@ant/computer-use-swift: macOS only') },
+    async captureExcluding() { throw new Error(unsupportedBackendMessage) },
+    async captureRegion() { throw new Error(unsupportedBackendMessage) },
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/`@ant/computer-use-swift/src/index.ts around lines 39 - 58, The
fallback implementations for apps, display, and screenshot currently throw the
hardcoded macOS message (e.g., in apps.open, display.getSize/display.listAll,
screenshot.captureExcluding/screenshot.captureRegion), which is misleading on
Windows; change those thrown Error messages to a platform-agnostic message like
"@ant/computer-use-swift: unavailable on this platform" (or similar) in the
default objects for apps, display, and screenshot so any backend load failure
yields a neutral, accurate error across platforms.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/`@ant/computer-use-input/src/index.ts:
- Around line 24-36: The loadBackend() function is currently returning a Linux
backend which then causes the module-level isSupported flag to be set true for
Linux; remove Linux from the publicly supported set until the backend is ready
by either (A) deleting or commenting out the Linux branch in loadBackend() so it
returns null on Linux, or (B) leave loadBackend() but change the isSupported
determination so only process.platform === 'darwin' or 'win32' (not 'linux') set
isSupported = true; update references to loadBackend and isSupported accordingly
so Linux remains unsupported publicly.

In `@packages/`@ant/computer-use-swift/src/index.ts:
- Around line 21-33: The loader function loadBackend currently returns a Linux
backend when process.platform === 'linux', which exposes unfinished Linux
support; remove the linux branch and any require('./backends/linux.js')
reference so loadBackend only checks darwin and win32 (returning null
otherwise), ensuring unimplemented backends are not advertised; update the
function (and remove any import/require references to backends/linux.js) so
loadBackend returns null for non-darwin/win32 platforms.

In `@src/main.tsx`:
- Around line 2436-2438: The condition using getPlatform() !== 'unknown' is too
broad and lets WSL fall through to the Linux backend; change the guard around
feature('CHICAGO_MCP') so it uses an explicit platform allowlist instead of !=
'unknown' (e.g. check getPlatform() is one of the supported values such as
'linux' or 'darwin') and keep the getIsNonInteractiveSession() check; update the
expression surrounding feature('CHICAGO_MCP') / getPlatform() /
getIsNonInteractiveSession() so WSL (or other unsupported values returned by
getPlatform()) is excluded and only explicitly supported platforms reach the
backend loaders.

---

Outside diff comments:
In `@packages/`@ant/computer-use-swift/src/index.ts:
- Around line 39-58: The fallback implementations for apps, display, and
screenshot currently throw the hardcoded macOS message (e.g., in apps.open,
display.getSize/display.listAll,
screenshot.captureExcluding/screenshot.captureRegion), which is misleading on
Windows; change those thrown Error messages to a platform-agnostic message like
"@ant/computer-use-swift: unavailable on this platform" (or similar) in the
default objects for apps, display, and screenshot so any backend load failure
yields a neutral, accurate error across platforms.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82d11e7c-9195-448a-8f88-f7f8b9d28306

📥 Commits

Reviewing files that changed from the base of the PR and between 2782529 and aeb0326.

📒 Files selected for processing (4)
  • packages/@ant/computer-use-input/src/index.ts
  • packages/@ant/computer-use-swift/src/index.ts
  • src/main.tsx
  • src/utils/computerUse/swiftLoader.ts
💤 Files with no reviewable changes (1)
  • src/utils/computerUse/swiftLoader.ts

Comment on lines 24 to +36
function loadBackend(): InputBackend | null {
if (process.platform !== 'darwin') return null
try {
return require('./backends/darwin.js') as InputBackend
if (process.platform === 'darwin') {
return require('./backends/darwin.js') as InputBackend
} else if (process.platform === 'win32') {
return require('./backends/win32.js') as InputBackend
} else if (process.platform === 'linux') {
return require('./backends/linux.js') as InputBackend
}
} catch {
return null
}
return null
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don't flip isSupported on for Linux yet.

Line 31 feeds the Linux backend into loadBackend(), and line 41 turns that into isSupported = true. That widens the public support contract before Linux is declared ready.

Suggested change
 function loadBackend(): InputBackend | null {
   try {
     if (process.platform === 'darwin') {
       return require('./backends/darwin.js') as InputBackend
     } else if (process.platform === 'win32') {
       return require('./backends/win32.js') as InputBackend
-    } else if (process.platform === 'linux') {
-      return require('./backends/linux.js') as InputBackend
     }
   } catch {
     return null
   }
   return null
 }

As per coding guidelines, packages/@ant/computer-use-*/**/*.{ts,tsx}: Computer Use feature (CHICAGO_MCP flag) supports macOS and Windows; Linux backend implementation is pending.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function loadBackend(): InputBackend | null {
if (process.platform !== 'darwin') return null
try {
return require('./backends/darwin.js') as InputBackend
if (process.platform === 'darwin') {
return require('./backends/darwin.js') as InputBackend
} else if (process.platform === 'win32') {
return require('./backends/win32.js') as InputBackend
} else if (process.platform === 'linux') {
return require('./backends/linux.js') as InputBackend
}
} catch {
return null
}
return null
function loadBackend(): InputBackend | null {
try {
if (process.platform === 'darwin') {
return require('./backends/darwin.js') as InputBackend
} else if (process.platform === 'win32') {
return require('./backends/win32.js') as InputBackend
}
} catch {
return null
}
return null
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/`@ant/computer-use-input/src/index.ts around lines 24 - 36, The
loadBackend() function is currently returning a Linux backend which then causes
the module-level isSupported flag to be set true for Linux; remove Linux from
the publicly supported set until the backend is ready by either (A) deleting or
commenting out the Linux branch in loadBackend() so it returns null on Linux, or
(B) leave loadBackend() but change the isSupported determination so only
process.platform === 'darwin' or 'win32' (not 'linux') set isSupported = true;
update references to loadBackend and isSupported accordingly so Linux remains
unsupported publicly.

Comment on lines +21 to +33
function loadBackend() {
try {
return require('./backends/darwin.js')
if (process.platform === 'darwin') {
return require('./backends/darwin.js')
} else if (process.platform === 'win32') {
return require('./backends/win32.js')
} else if (process.platform === 'linux') {
return require('./backends/linux.js')
}
} catch {
return null
}
return null
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Keep the Linux branch out of this loader for now.

Lines 27-28 expand this package's contract to Linux, but the current Computer Use support matrix still treats that backend as unfinished. Shipping the branch here makes direct consumers think @ant/computer-use-swift is ready on Linux when it is not.

Suggested change
 function loadBackend() {
   try {
     if (process.platform === 'darwin') {
       return require('./backends/darwin.js')
     } else if (process.platform === 'win32') {
       return require('./backends/win32.js')
-    } else if (process.platform === 'linux') {
-      return require('./backends/linux.js')
     }
   } catch {
     return null
   }
   return null
 }

As per coding guidelines, packages/@ant/computer-use-*/**/*.{ts,tsx}: Computer Use feature (CHICAGO_MCP flag) supports macOS and Windows; Linux backend implementation is pending.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/`@ant/computer-use-swift/src/index.ts around lines 21 - 33, The
loader function loadBackend currently returns a Linux backend when
process.platform === 'linux', which exposes unfinished Linux support; remove the
linux branch and any require('./backends/linux.js') reference so loadBackend
only checks darwin and win32 (returning null otherwise), ensuring unimplemented
backends are not advertised; update the function (and remove any import/require
references to backends/linux.js) so loadBackend returns null for
non-darwin/win32 platforms.

Comment on lines 2436 to 2438
feature('CHICAGO_MCP') &&
getPlatform() === 'macos' &&
getPlatform() !== 'unknown' &&
!getIsNonInteractiveSession()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use an explicit platform allowlist here.

Line 2437 now includes wsl as well as linux. The backend loaders only switch on process.platform, so WSL will implicitly take the Linux backend path whether or not that is actually supported.

Suggested change
       if (
         feature('CHICAGO_MCP') &&
-        getPlatform() !== 'unknown' &&
+        (getPlatform() === 'macos' || getPlatform() === 'windows') &&
         !getIsNonInteractiveSession()
       ) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.tsx` around lines 2436 - 2438, The condition using getPlatform() !==
'unknown' is too broad and lets WSL fall through to the Linux backend; change
the guard around feature('CHICAGO_MCP') so it uses an explicit platform
allowlist instead of != 'unknown' (e.g. check getPlatform() is one of the
supported values such as 'linux' or 'darwin') and keep the
getIsNonInteractiveSession() check; update the expression surrounding
feature('CHICAGO_MCP') / getPlatform() / getIsNonInteractiveSession() so WSL (or
other unsupported values returned by getPlatform()) is excluded and only
explicitly supported platforms reach the backend loaders.

@claude-code-best claude-code-best merged commit 522a1a3 into claude-code-best:main Apr 6, 2026
2 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.

2 participants