[kernel-1116] CDP monitor core#214
[kernel-1116] CDP monitor core#214archandatta merged 3 commits intoarchand/kernel-1116/cdp-foundationfrom
Conversation
…creenshot, domains
…outine overlap, variable shadowing, duplicate time.Since, ffmpeg stderr capture, base64 threshold comment
70361be to
bfb6cd7
Compare
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: PR does not clearly modify API endpoints (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal); please opt in manually if this affects the kernel API. To monitor this PR anyway, reply with |
Final layer of the CDP monitor split. Replaces the no-op dispatchEvent stub with the full handler implementation and completes the test suite. Merges cleanly on top of #214 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Adds full CDP event dispatch/handling and emits richer network/page interaction events (including headers and optional response bodies), which can affect event volume and expose sensitive data to downstream consumers. > > **Overview** > Completes the CDP monitor split by replacing the no-op `dispatchEvent` stub with a full handler implementation that publishes console, page/navigation, target, interaction binding, timeline layout-shift, and detailed network request/response events (including optional truncated response bodies for textual resources). > > Improves lifecycle/computed-state correctness by handling redirects without inflating pending counters, ignoring subframe lifecycle events for main-frame settling logic, and standardizing published event timestamps to microseconds (including screenshots and monitor lifecycle events). Adds an extensive test suite covering these handlers, rate-limiting of binding events, auto-attach/attach-existing-targets flows, and the redirect/subframe edge cases; updates API wiring to pass a `slog` logger into `cdpmonitor.New`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b5b3e89. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
348243a
into
archand/kernel-1116/cdp-foundation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9092789. Configure here.
| m.failPendingCommands() | ||
|
|
||
| // pendingRequests is already empty above, so inflight=0 is correct. | ||
| m.computed.resetOnNavigation(0) |
There was a problem hiding this comment.
Stop starts spurious timer that fires after shutdown
Medium Severity
clearState() calls m.computed.resetOnNavigation(0), which — when inflight is 0 — starts a 500ms network_idle debounce timer via startNetIdleTimer. When clearState is called from Stop(), this timer fires after the monitor has fully shut down and publishes a spurious network_idle event through the publish function. The downstream consumer (captureSession.Publish) may have already been torn down by then.
Reviewed by Cursor Bugbot for commit 9092789. Configure here.


Second layer of the CDP monitor split. Adds the full Monitor struct, all lifecycle machinery, and the test infrastructure. dispatchEvent is a no-op stub - event handlers land in #213
Note
Medium Risk
Adds substantial new CDP monitoring/reconnect logic plus network event capture (including response bodies/headers), which can impact stability and exposes sensitive data on the event stream if mishandled.
Overview
Implements the core
cdpmonitor.Monitor: websocketStart/Stop, request/response correlation viasend, auto-attach + attach-existing-targets, upstream-driven reconnect with backoff, state reset/health reporting, and periodic cleanup of stuck network requests.Adds CDP domain enablement and script injection plus a full event dispatch/handler layer that publishes console, page lifecycle, target, interaction (rate-limited binding), layout-shift, and network request/response events (including optional truncated response bodies), and introduces ffmpeg-based screenshot capture with rate limiting/downscaling.
Updates the API service to pass a
sloglogger intocdpmonitor.New, and adds a full test harness (fake websocket server/upstream, event collector) with extensive unit tests covering lifecycle, reconnect, auto-attach, computed-state edge cases, handlers, and screenshots.Reviewed by Cursor Bugbot for commit 9092789. Bugbot is set up for automated code reviews on this repo. Configure here.