refactor: extract session event stream - #787
Conversation
Terraform Validation Results
Pushed by: @ColeMurray, Action: |
📝 WalkthroughWalkthroughIntroduces a new ChangesSessionEventStream abstraction
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/control-plane/src/session/event-stream.ts`:
- Around line 101-109: The toEventResponse function lacks error handling for the
JSON.parse call on line 105, which will crash the listEvents request if
event.data contains invalid JSON. Add a try-catch block around the JSON.parse
statement in toEventResponse to handle parse failures, matching the error
handling pattern used in parseSandboxEvents. Either catch the error and return
null (filtering nulls in listEvents), or catch and provide a fallback value for
the data field to prevent the entire request from crashing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 08cc99f7-39e6-45e4-9a45-17c48f852caf
📒 Files selected for processing (8)
packages/control-plane/src/session/durable-object.tspackages/control-plane/src/session/event-stream.test.tspackages/control-plane/src/session/event-stream.tspackages/control-plane/src/session/http/handlers/messages.handler.test.tspackages/control-plane/src/session/http/handlers/messages.handler.tspackages/control-plane/src/session/services/message.service.test.tspackages/control-plane/src/session/services/message.service.tspackages/control-plane/src/types.ts
Summary
SessionDOintoSessionEventStreamWhy
SessionDOwas carrying Session Event Stream replay and paginated history projection inline. Moving this into a focused class reduces Durable Object surface area and gives the event stream behavior its own testable interface without adding callback-heavy dependencies.Validation
npm test -w @open-inspect/control-plane -- src/session/event-stream.test.ts src/session/services/message.service.test.ts src/session/http/handlers/messages.handler.test.tsnpm run build -w @open-inspect/sharednpm run test:integration -w @open-inspect/control-plane -- test/integration/websocket-client.test.tsnpm run typecheck -w @open-inspect/control-planenpx prettier --check packages/control-plane/src/session/durable-object.ts packages/control-plane/src/session/event-stream.ts packages/control-plane/src/session/event-stream.test.ts packages/control-plane/src/session/http/handlers/messages.handler.ts packages/control-plane/src/session/http/handlers/messages.handler.test.ts packages/control-plane/src/session/services/message.service.ts packages/control-plane/src/session/services/message.service.test.ts packages/control-plane/src/types.tsnpx eslint packages/control-plane/src/session/durable-object.ts packages/control-plane/src/session/event-stream.ts packages/control-plane/src/session/event-stream.test.ts packages/control-plane/src/session/http/handlers/messages.handler.ts packages/control-plane/src/session/http/handlers/messages.handler.test.ts packages/control-plane/src/session/services/message.service.ts packages/control-plane/src/session/services/message.service.test.ts packages/control-plane/src/types.tsgit diff --checkSummary by CodeRabbit
Refactor
Tests