feat(computer): add health check in connect method#2014
Conversation
Adds a health check that runs after device connection to verify screenshot capture and mouse control are functional. Prints each step's progress and result, and calls process.exit(1) on failure. https://claude.ai/code/session_01Hq1A7zcygrUbksNURbj3Hk
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e181353799
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| console.error(`[HealthCheck] Screenshot failed: ${error}`); | ||
| process.exit(1); | ||
| } |
There was a problem hiding this comment.
Throw health-check failures instead of exiting process
Calling process.exit(1) here makes ComputerDevice.connect() terminate the entire Node.js process on a transient screenshot/mouse failure, which is a breaking behavior change for library consumers (for example agentFromComputer() and MCP tool hosts) that previously could catch and recover from connection errors. This should propagate an exception instead so callers can decide whether to retry, degrade, or shut down gracefully.
Useful? React with 👍 / 👎.
| const movedPos = libnut.getMousePos(); | ||
| console.log( | ||
| `[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`, | ||
| ); |
There was a problem hiding this comment.
Assert the mouse position changed during health check
This health check logs the post-move cursor position but never validates it, so the method can still report success even when mouse movement is effectively non-functional (for example when the move call is ignored/no-op in restricted desktop environments). Since the feature’s purpose is to verify control works, this should fail when movedPos does not reflect the requested move.
Useful? React with 👍 / 👎.
Adds a health check that runs after device connection to verify
screenshot capture and mouse control are functional. Prints each
step's progress and result, and calls process.exit(1) on failure.
https://claude.ai/code/session_01Hq1A7zcygrUbksNURbj3Hk