Skip to content

feat: session-level passive network capture for explore#813

Closed
jackwener wants to merge 2 commits intomainfrom
feat/session-network-capture
Closed

feat: session-level passive network capture for explore#813
jackwener wants to merge 2 commits intomainfrom
feat/session-network-capture

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • Implement startNetworkCapture() / readNetworkCapture() on CDPPage using CDP Network domain events
  • Explore now starts capture before navigation, getting complete request data (method, status, headers, body)
  • Falls back to performance API (networkRequests()) when capture is unavailable (daemon mode)
  • parseNetworkRequests() updated to handle NetworkCaptureEntry format (responseContentType, string body → JSON)

Architecture

This is the first transport implementation of the session-level passive capture contract (IPage.startNetworkCapture?() / readNetworkCapture?()). It establishes the pattern for PR B (diagnostic + operate consumption) and future daemon mode support.

Key design decisions:

  • CDP events are registered on the bridge, not injected as JS — no timing gaps, no detection by websites
  • Response bodies fetched only for textual content types (JSON, text, XML, JS) — images/fonts skipped
  • Max 200 entries per session, response previews capped at 10KB
  • readNetworkCapture() includes a 200ms settle delay for pending response body fetches

Test plan

  • 4 new unit tests for CDPPage capture (start, capture flow, idempotency, content-type filtering)
  • Full unit suite passes (546/546)
  • Type check clean
  • Manual: OPENCLI_CDP_ENDPOINT=... opencli explore <url> shows richer endpoint data

Ref #810

Implement startNetworkCapture() and readNetworkCapture() on CDPPage
using CDP Network domain events (requestWillBeSent, responseReceived,
loadingFinished). This provides rich network data (method, status,
headers, response body) without JS injection or timing gaps.

Update explore to start capture before navigation and prefer it over
the performance API fallback, giving endpoint discovery access to
complete request/response data.

Part of #810
readNetworkCapture() now clears _captureEntries and _captureRequestMap
after returning, matching the drain semantics of the daemon and
extension implementations. Prevents stale data on repeated reads.
@jackwener
Copy link
Copy Markdown
Owner Author

Closing in favor of opus0's #815 (has complete _pendingBodyFetches implementation)

@jackwener jackwener closed this Apr 5, 2026
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.

1 participant