fix(opencode): stabilize production OpenAPI docs - #1402
Conversation
|
Warning Review limit reached
More reviews will be available in 43 minutes and 1 second. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthrough
ChangesFiltered OpenAPI event schema generation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
fe673d7 to
fea6bd5
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/opencode/src/server/control-openapi.ts`:
- Around line 145-183: The OpenAPI specification for the "/pty/{ptyID}/connect"
endpoint's GET operation incorrectly documents a 200 response with
application/json content type, but the actual implementation uses WebSocket
upgrade which returns HTTP 101 Switching Protocols instead. Update the responses
section in the get operation to use a 101 response code that reflects the
WebSocket protocol upgrade, removing the application/json schema and replacing
it with appropriate WebSocket upgrade documentation (or an empty/null response
schema since WebSocket connections don't return JSON).
In `@packages/opencode/test/server/openapi-generation-source.test.ts`:
- Around line 107-113: The test function "generates the full production event
schema without import-order dependence" mutates the global BusEvent registry by
calling BusEvent.define() with "test.openapi.leak", and since there is no
teardown mechanism to remove this registration, it contaminates the shared test
runtime and causes order-dependencies for subsequent tests that call
BusEvent.payloads() without filters. To fix this, either add a cleanup/teardown
step that unregisters the event after the test completes, or isolate the
BusEvent.define() mutation by running it in a separate module or process context
so the registration does not leak into other tests in the same test suite
execution.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: cbc3d984-dea0-43e2-a683-0e72261261c0
📒 Files selected for processing (8)
packages/opencode/src/bus/bus-event.tspackages/opencode/src/server/control-openapi.tspackages/opencode/src/server/global-openapi-schema.tspackages/opencode/src/server/production-api.tspackages/opencode/src/server/production-event-sources.tspackages/opencode/src/server/production-httpapi.tspackages/opencode/src/sync/index.tspackages/opencode/test/server/openapi-generation-source.test.ts
fea6bd5 to
c1a4f7b
Compare
Summary
ProductionApibetween dispatch and OpenAPI documentation./docdocument from that Effect HttpApi source while retaining the special/event,/global/event,/global/sync-event, and/pty/{ptyID}/connectsurfaces.Why
The OpenAPI/SDK drift should not be closed from the old Hono documentation tree. This narrows the migration step to the source that production
/docalready serves: make that Effect HttpApi source stable and verifiable first, then leave the SDK generator switch for the follow-up that can make the generated SDK types compile.Related Issue
Related to #936.
Human Review Status
Pending
Review Focus
ProductionApiis now the single Effect HttpApi declaration shared by production routing and/docgeneration.AgentConfigzod override schemas and/questionremoval stay guarded.Risk Notes
The CLI/SDK generator is intentionally not switched in this PR. Switching it to this production source still needs the session/acp and related
Schema.Anyroute schemas made SDK-ready first; otherwisepackages/opencodetypecheck goes red. The checked-in SDK spec therefore still trails the production source by the 24 paths asserted inopenapi-generation-source.test.ts.No visible UI or copy changed, so no screenshot was taken. No platform, packaging, updater, signing, path, shell, or permission surface was touched. No generated SDK artifacts were updated.
How To Verify
Screenshots or Recordings
Not applicable; no visible UI changes.
Checklist
bug,enhancement,task,documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.app,ui,platform,harness,ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.P0,P1,P2,P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.Pending,Approved by @<reviewer>, orNot required: <reason>(default isPending; "not required" is restricted to bot-authored low-risk PRs).dev, and my PR title and commit messages use Conventional Commits in English.Summary by CodeRabbit
New Features
Tests