Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

Consolidates 6 open PRs into master, resolving conflicts and maintaining compatibility with recently merged PR #27.

Changes

Bug Fixes

Dependencies & Code Generation

New Features

  • PR Add programmatic Chrome WebSocket URL discovery #26: Chrome WebSocket URL discovery - accepts HTTP URLs and auto-resolves via /json/version endpoint

    # Now works directly
    async with open_cdp('http://localhost:9222') as conn:
        ...
    
    # Or use the discovery function explicitly
    url = find_chrome_debugger_url(port=9222)
    async with open_cdp(url) as conn:
        ...
  • PR [WIP] Extend more abstract functions and classes using API #24: High-level automation utilities (Puppeteer-inspired, pure CDP)

    from trio_cdp.util import Keyboard, Mouse, query_selector
    
    async with conn.open_session(target_id) as session:
        element = await query_selector(session, 'input[name="search"]')
        await element.type('search query')
        
        keyboard = Keyboard(session)
        await keyboard.press('Enter')

Documentation

Implementation Notes

Merge strategy used manual cherry-picking to preserve PR #27's session detachment logic. Test fixtures updated to handle detach_from_target commands. Utility test timeouts remain (mock server lifecycle issues, doesn't affect library functionality).

Original prompt

can you merge all these for me please


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Note

Adds user-facing utilities and connection improvements, plus major dependency updates and docs/examples.

  • Introduces trio_cdp.util with Keyboard, Mouse, ElementHandle, and selector helpers (query_selector, wait_for_selector)
  • Supports connecting via HTTP and programmatic discovery with find_chrome_debugger_url(); open_cdp() auto-resolves /json/version
  • Expands docs: getting started connection patterns, event handling (wait_for()/listen()), new utilities page; updates README
  • Adds examples for form interaction, keyboard/mouse, network events, and HTTP/programmatic connection
  • Upgrades deps: trio 0.22+, trio_websocket 0.9+, chrome-devtools-protocol 0.4.0; regenerates bindings and refreshes lockfile
  • Improves codegen to handle typing.Optional/Dict/Generator
  • Fixes examples to use t.type_; adds tests for URL discovery and ensures listeners exit on connection/session close; adjusts fixtures for detachFromTarget

Written by Cursor Bugbot for commit 4d7b165. Configure here.

Copilot AI changed the title [WIP] Merge all existing branches into main Merge all open pull requests Nov 22, 2025
Copilot AI requested a review from P4X-ng November 22, 2025 11:55
@P4X-ng P4X-ng marked this pull request as ready for review January 10, 2026 07:29
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d7b165f64

ℹ️ 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".

'''
http_url = f'http://{host}:{port}/json/version'
try:
with urllib.request.urlopen(http_url) as response:

Choose a reason for hiding this comment

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

P2 Badge Avoid blocking URL discovery in async path

The HTTP discovery uses a synchronous urllib.request.urlopen call, and open_cdp() invokes this when given an HTTP URL. In a Trio application, a slow or unreachable Chrome endpoint will block the entire event loop here, stalling unrelated tasks and timeouts. Consider running the discovery in a worker thread (e.g., trio.to_thread.run_sync) or using an async HTTP client with a timeout so open_cdp() stays non-blocking.

Useful? React with 👍 / 👎.

targets = await target.get_targets()

for t in targets:
if (t.type == 'page' and
Copy link

Choose a reason for hiding this comment

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

New examples use wrong attribute t.type instead of t.type_

High Severity

The new example files use t.type to check target type, but this was explicitly fixed in PR #21 to use t.type_ due to an AttributeError in the updated chrome-devtools-protocol 0.4.0 bindings. The existing examples (get_title.py and screenshot.py) were correctly updated, but five new examples (form_interaction.py, get_title_http.py, get_title_programmatic.py, keyboard_mouse.py, network_events.py) still use the old incorrect attribute name. This will cause an AttributeError when running these examples.

🔬 Verification Test

Why verification test was not possible: This bug is in example scripts that require a running Chrome browser with remote debugging enabled. The bug is confirmed by comparing the diff: lines 36-37 in get_title.py show the fix from t.type to t.type_, while the new examples at the specified lines all use t.type. The PR description explicitly states "PR #21: Fixed AttributeError in examples - t.typet.type_" confirming the correct attribute is type_.

Additional Locations (2)

Fix in Cursor Fix in Web

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