[kernel 1116] browser logging: cdp pipeline#194
Conversation
1e544a7 to
6d929c8
Compare
6d929c8 to
76d837f
Compare
…ies and fix delimiter in CategoryFor
| } | ||
|
|
||
| func (s *ApiService) Shutdown(ctx context.Context) error { | ||
| s.monitorMu.Lock() |
There was a problem hiding this comment.
Is this going to add a latency in delete browsers request? If so, how much?
There was a problem hiding this comment.
Shouldn't add any latency, shutdown holds the lock briefly to stop the CDP monitor and close the capture session i think both are fast synchronous teardown calls
|
|
||
| s.captureSession.Start(uuid.New().String()) | ||
|
|
||
| if err := s.cdpMonitor.Start(context.Background()); err != nil { |
There was a problem hiding this comment.
the comment says this restarts an existing monitor, but the handler never checks/stops an already-running one. might be worth making that behavior explicit here instead of relying on Start() side effects.
There was a problem hiding this comment.
Ah yeah this was just a scaffolding I did for the actual implementation. I should've mentioned that there is a chained PR #202 that is capturing this https://github.com/kernel/kernel-images/pull/202/changes#diff-0ddb00e75e5f21a1deb16fb852c7f352f234bbf0b9ddcc3d11639b1d3293c572R90
| // Generates a new capture session ID, seeds the pipeline, then starts the | ||
| // CDP monitor. If already running, the monitor is stopped and | ||
| // restarted with a fresh session ID | ||
| func (s *ApiService) StartCapture(w http.ResponseWriter, r *http.Request) { |
There was a problem hiding this comment.
question: is a no-arg /events/start intentional? i'd expect callers to want some capture config here over time (categories, detail level, screenshot/network verbosity, etc.), or at least an explicit note that this is a fixed server-defined profile for now.
There was a problem hiding this comment.
yeah good point, added a body field to be able to send something like
{
"categories": ["console", "network"],
"detailLevel": "verbose"
}
| } | ||
|
|
||
| // New creates a Monitor. displayNum is the X display for ffmpeg screenshots. | ||
| func New(_ UpstreamProvider, _ PublishFunc, _ int) *Monitor { |
There was a problem hiding this comment.
i don't think we'll need displayNum for a pure CDP monitor, so i'd remove this until actual implementation lands.
… and category validation
rgarcia
left a comment
There was a problem hiding this comment.
api binary needs to be removed
This binary is tracked on main and was incidentally deleted earlier on this branch. Restoring it keeps the 13.4MB binary out of this PR's diff. Removing the tracked binary from main should be done in a separate PR.
rgarcia
left a comment
There was a problem hiding this comment.
one small thing but otherwise i think this is good to go!
| return oapi.StartCaptureSession400JSONResponse{BadRequestErrorJSONResponse: oapi.BadRequestErrorJSONResponse{Message: err.Error()}}, nil | ||
| } | ||
|
|
||
| id := uuid.New().String() |
There was a problem hiding this comment.
let's use github.com/nrednav/cuid2 to be consistent with the rest of the api (and remove format: uuid for this id field in the openapi.yaml spec)
Sayan-
left a comment
There was a problem hiding this comment.
I think the last bugbot comment is worth resolving. Thanks for iterating - interfaces, components, and integration are looking great!
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 a4fd0d6. Configure here.

Scaffolding of the CDP Pipeline implementation on the functions are in -> #202
Note
Medium Risk
Adds new capture-session lifecycle endpoints and introduces a new in-process event pipeline with file/ring-buffer writers, plus new shutdown/constructor wiring; concurrency and lifecycle handling are the main risk areas. CDP monitor is currently scaffolded, but the new API surface and persistence paths still warrant careful review.
Overview
Adds an event capture session feature, exposing
GET/POST/PATCH/DELETE /events/capture_sessionto start/stop and reconfigure capture (including category filtering) and report sessionid,status,seq, andcreated_at.Wires a new
events.CaptureSessionandcdpmonitor.MonitorintoApiService/main, including lifecycle cancellation and shutdown cleanup, and refactors the events pipeline to be reusable (Start/Stop), category-filtered, and backed by a validated/resettable ring buffer plus a filename-based JSONL writer.Regenerates OpenAPI (
oapi.go,openapi.yaml) and updates/extends tests to cover the new capture session handlers and the updated events/ring buffer/file writer behaviors.Reviewed by Cursor Bugbot for commit 33c07d3. Bugbot is set up for automated code reviews on this repo. Configure here.