[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
server/cmd/api/api/events.go
Outdated
|
|
||
| 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
server/cmd/api/api/events.go
Outdated
| // 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
Introduces new capture-session lifecycle endpoints and wiring that affects API startup/shutdown and event persistence; while mostly scaffolding, it adds concurrency/lifecycle management and new disk writes that could misbehave under load or during shutdown.
Overview
Adds a new capture session resource backed by an events pipeline and CDP monitor scaffold, including
POST/GET/PATCH/DELETE /events/capture_sessionto start, inspect, reconfigure (category filtering), and stop capture.Wires the API service to own a long-lived
events.CaptureSessionandcdpmonitor.Monitor, constructs them inmain, and ensures they are stopped/closed duringApiService.Shutdown.Refactors the
eventspackage to support reusable sessions (Start/Stop), category validation/filtering, ring buffer reset, and safer file writing (create log dir, filename-based writes), and updates generatedoapitypes/clients plus new unit tests for the capture session handlers.Reviewed by Cursor Bugbot for commit a7b2e54. Bugbot is set up for automated code reviews on this repo. Configure here.