Skip to content

[kernel-1116] browser events: add external events#227

Open
archandatta wants to merge 6 commits intoarchand/kernel-1116/cdp-foundationfrom
archand/kernel-1116/external-events
Open

[kernel-1116] browser events: add external events#227
archandatta wants to merge 6 commits intoarchand/kernel-1116/cdp-foundationfrom
archand/kernel-1116/external-events

Conversation

@archandatta
Copy link
Copy Markdown
Contributor

@archandatta archandatta commented Apr 24, 2026

As per plan -> #217

Note

Medium Risk
Adds new public API endpoints for injecting and streaming events and changes capture-session stop behavior to emit terminal frames; issues here could impact event delivery semantics and client reconnect behavior.

Overview
Adds a new external events API: POST /events/publish to inject validated events into the active capture session (with reserved types blocked and source.kind forced to kernel_api), and GET /events/stream to stream capture envelopes over SSE with Last-Event-ID resume, keepalives, and explicit handling for dropped events.

Updates the events pipeline to support this streaming lifecycle by introducing CaptureSession.Active, publishing a synthetic session_ended envelope on Stop, and adding an unfiltered publish path (PublishUnfiltered) for externally supplied events. OpenAPI/oapi-codegen output is regenerated accordingly (new schemas/client methods, SSE headers), and tests are updated for renamed enum constants.

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

@firetiger-agent
Copy link
Copy Markdown

Firetiger deploy monitoring skipped

This PR didn't match the auto-monitor filter configured on your GitHub connection:

Any PR that changes the kernel API. Monitor changes to API endpoints (packages/api/cmd/api/) and Temporal workflows (packages/api/lib/temporal) in the kernel repo

Reason: PR title and branch suggest browser events feature work, but no file changes are provided to confirm modifications to API endpoints or Temporal workflows.

To monitor this PR anyway, reply with @firetiger monitor this.

@archandatta archandatta force-pushed the archand/kernel-1116/external-events branch from 809321b to ca437c0 Compare April 24, 2026 14:06
Comment thread server/cmd/api/api/events.go
Comment thread server/lib/events/capturesession.go
Comment thread server/cmd/api/api/events.go
Comment thread server/lib/events/capturesession.go Outdated
@archandatta archandatta force-pushed the archand/kernel-1116/external-events branch from 7139fb3 to 0a89c58 Compare April 24, 2026 15:42
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 0a89c58. Configure here.

Comment thread server/cmd/api/api/events.go
@archandatta archandatta requested review from Sayan- and rgarcia April 24, 2026 16:23
Copy link
Copy Markdown
Contributor

@Sayan- Sayan- left a comment

Choose a reason for hiding this comment

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

matches plan well and deviations from it are reasonable!

return s.captureSessionID != ""
}

// Stop ends the current session. It publishes a synthetic session_ended
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should seq be monotonic across start/stop cycles? If so, I think Start shouldn't reset it here. That would make seq represent the process-wide event stream position rather than the position within a single capture session.

// PublishEvent handles POST /events/publish.
// Injects a caller-supplied event into the active capture session. Returns 400
// if no session is active or the event fails validation.
func (s *ApiService) PublishEvent(_ context.Context, req oapi.PublishEventRequestObject) (oapi.PublishEventResponseObject, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we add one lifecycle test for the new event flow? Something like start capture session, publish an event through PublishEvent, read it from StreamEvents, then stop and verify the stream receives session_ended.

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