feat: enable Computer Use on Windows and Linux#145
Conversation
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>
📝 WalkthroughWalkthroughThis 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 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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 | 🟡 MinorMake the fallback error platform-agnostic.
If the
win32backend 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
📒 Files selected for processing (4)
packages/@ant/computer-use-input/src/index.tspackages/@ant/computer-use-swift/src/index.tssrc/main.tsxsrc/utils/computerUse/swiftLoader.ts
💤 Files with no reviewable changes (1)
- src/utils/computerUse/swiftLoader.ts
| 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 |
There was a problem hiding this comment.
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.
| 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.
| 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 |
There was a problem hiding this comment.
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.
| feature('CHICAGO_MCP') && | ||
| getPlatform() === 'macos' && | ||
| getPlatform() !== 'unknown' && | ||
| !getIsNonInteractiveSession() |
There was a problem hiding this comment.
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.
Remove macOS-only guards so Computer Use works cross-platform:
Summary by CodeRabbit