Skip to content

[kernel-1116] browser debug: externel events#203

Open
archandatta wants to merge 14 commits intoarchand/kernel-1116/cdp-monitorfrom
archand/kernel-1116/externel-events
Open

[kernel-1116] browser debug: externel events#203
archandatta wants to merge 14 commits intoarchand/kernel-1116/cdp-monitorfrom
archand/kernel-1116/externel-events

Conversation

@archandatta
Copy link
Copy Markdown
Contributor

@archandatta archandatta commented Apr 6, 2026

Test plan

Tested against local Docker container (chromium-headful-test on port 444).

Event publishing (POST /events/publish)

  • Liveview event with explicit category and kernel_api source → 200
  • Captcha event with extension source → 200, verified source.kind
    preserved (not overwritten to kernel_api)
  • Network event with category omitted → 200, verified category
    auto-derived from type prefix (network_request → network)
  • Missing type field → 400
  • Invalid JSON body → 400

SSE streaming (GET /events/stream)

  • Stream delivers all published events with correct id: and data:
    framing
  • CDP events (e.g. layout_shift) appear automatically from active browser
    session
  • Last-Event-ID: 2 reconnection returns only events with seq > 2

Category log files

  • /var/log/liveview.log — contains liveview events
  • /var/log/captcha.log — contains captcha events
  • /var/log/network.log — contains network events

Note

Medium Risk
Adds new HTTP endpoints for publishing and streaming captured events, which can affect runtime load/availability if misused (long-lived SSE connections, unbounded clients). Changes are otherwise localized and covered by new tests.

Overview
Adds external access to the events pipeline by introducing POST /events/publish (validates JSON, requires type, defaults missing category/source.kind) and GET /events/stream as an SSE feed with Last-Event-ID resume support.

Hardens shutdown and lifecycle handling by making ApiService.Shutdown tolerate nil cdpMonitor/captureSession and log close errors, and wires the new routes in main.go alongside the existing /events/start//events/stop controls. Includes focused tests for publish validation, log routing, and SSE streaming behavior.

Reviewed by Cursor Bugbot for commit 27856a3. Bugbot is set up for automated code reviews on this repo. Configure here.

Event is the agreed portable name. DetailStandard avoids Go keyword
ambiguity with "default".
…ut of Event

Event is now purely producer-emitted content. Pipeline-assigned metadata
(seq, capture_session_id) lives on the Envelope. truncateIfNeeded
operates on the full Envelope. Pipeline type comment now documents
lifecycle semantics.
Ring buffer now indexes by envelope.Seq directly, removing the separate
head/written counters. NewReader takes an explicit afterSeq for resume
support. Renamed notify to readerWake for clarity.
Drops are now stream metadata (ReadResult.Dropped) rather than fake
events smuggled into the Event schema. Transport layer decides how to
surface gaps on the wire.
truncateIfNeeded now warns if the envelope still exceeds the 1MB limit
after nulling data (e.g. huge url or source.metadata). Pipeline.Publish
skips the file write when marshal returns nil to avoid writing corrupt
bare-newline JSONL lines.
@archandatta archandatta marked this pull request as ready for review April 6, 2026 15:10
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9425b05. Configure here.

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