Skip to content

feat: add desktop CDP connection management#75

Open
Pleasurecruise wants to merge 1 commit intojackwener:mainfrom
Pleasurecruise:main
Open

feat: add desktop CDP connection management#75
Pleasurecruise wants to merge 1 commit intojackwener:mainfrom
Pleasurecruise:main

Conversation

@Pleasurecruise
Copy link
Contributor

Problem

Electron desktop adapters in opencli previously relied on manually configured CDP environment variables (e.g., OPENCLI_CDP_ENDPOINT). When a global PLAYWRIGHT_MCP_EXTENSION_TOKEN was set, desktop commands could incorrectly fall back to Playwright extension mode.

What This Change Introduces

New Commands

  • opencli connect <site> — validates and saves the app's CDP endpoint to ~/.opencli/connections.json
  • opencli disconnect <site> — removes the saved connection for a given site

Technical Changes

  • src/connections.ts — manages saved CDP endpoints, probes live connectivity, and provides per-site defaults
  • src/main.ts — adds connect and disconnect commands
  • Command execution flow — resolves saved endpoints and injects them into browser sessions
  • PlaywrightMCP and runtime — updated to accept an optional cdpEndpoint
  • READMEs — replaces environment-variable-based examples with opencli connect <site> instructions
  • .gitignore — adds .idea/

Future Extension

Can consider add an auto-launch layer on top of connect:

The current workflow requires the target Electron app to already be running with --remote-debugging-port. The next logical step is to have opencli connect <site> automatically launch the app in the background, wait for the CDP endpoint to become available, and then persist the connection — evolving the current "connect to a running app" workflow into a full "launch + connect" experience.

Copilot AI review requested due to automatic review settings March 18, 2026 18:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces managed Chrome DevTools Protocol (CDP) connection handling for desktop Electron “sites”, adding CLI commands to save/remove endpoints and wiring the saved endpoint into Playwright MCP sessions.

Changes:

  • Add opencli connect <site> / opencli disconnect <site> commands that persist CDP endpoints for supported desktop apps.
  • Route “desktop CDP commands” through a saved cdpEndpoint passed into browserSession/PlaywrightMCP.connect.
  • Update desktop adapter READMEs to use opencli connect ... instead of exporting CDP env vars.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/runtime.ts Extends browser session connection options to accept a CDP endpoint.
src/main.ts Adds connect/disconnect commands and uses saved endpoints for desktop CDP commands.
src/connections.ts New module for persisting endpoints, probing CDP availability, and building “disconnected” status output.
src/browser/mcp.ts Allows overriding the resolved CDP endpoint via connect({ cdpEndpoint }).
src/clis//README.md Updates setup instructions to use the new connect command.
.gitignore Ignores .idea/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Introduce managed CDP connections for desktop Electron apps: add a new connections module (src/connections.ts) to save, probe and resolve CDP endpoints, plus unit tests (src/connections.test.ts). Add CLI commands connect/disconnect in main.ts to persist endpoints and validate reachability, and update dynamic command execution to use resolved CDP endpoints for desktop sites. Propagate cdpEndpoint through runtime.browserSession and PlaywrightMCP.connect (src/runtime.ts, src/browser/mcp.ts). Update multiple README files to instruct using `opencli connect <site>`, and ignore .idea in .gitignore.
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