refactor(server): effectify instance root json handlers - #1031
Conversation
|
Warning Review limit reached
More reviews will be available in 3 minutes and 15 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. 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 (2)
✨ 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 |
There was a problem hiding this comment.
Code Review
This pull request refactors the route handlers in packages/opencode/src/server/instance/index.ts to use the Effect library, wrapping asynchronous operations in Effect.gen and executing them via AppRuntime.runPromise. It also adds a new test suite in packages/opencode/test/server/instance-root-routes.test.ts to verify these routes. The review feedback points out two critical issues: first, wrapping operations that can fail (such as Instance.dispose(), PawWorkHome.ensurePrimary(), and fs.mkdir) in Effect.promise can cause unrecoverable crashes, so they should be wrapped in Effect.tryPromise with proper error handling; second, relying on static or global accessors like Instance inside asynchronous generator blocks can cause context loss in multi-instance environments, and instance-specific references should be captured beforehand.
dev #1044 collapsed Vcs.Mode to git|branch; the route test still queried mode=unstaged, which the validator now rejects with 400 after rebase. Use mode=git (working-tree vs HEAD), the direct equivalent of the old unstaged.
766c1c9 to
074f1c1
Compare
Summary
Migrate instance root utility JSON handlers to the existing
AppRuntime.runPromise(Effect.gen(...))route runtime pattern.This covers
/instance/dispose,/path,/vcs,/vcs/diff,/vcs/status,/agent,/skill,/command,/lsp, and/formatter. It intentionally leaves/vcs/diff/rawand/vcs/applyunchanged because raw text and worktree mutation are outside this ordinary JSON slice.Why
This continues the #936 ordinary JSON route migration while keeping the same Hono route contracts and avoiding streaming, auth, workspace sync, v2, proxy, and SDK/OpenAPI source areas.
Related Issue
Refs #936
Human Review Status
Pending
Review Focus
Please check that this PR only changes route-level service delegation and does not alter VCS mode semantics, path resolution, or metadata response shapes.
Risk Notes
/vcs/diff/rawand/vcs/applyare deliberately left as-is; they are not ordinary JSON-only migration targets in this slice.Skipped conditional checklist items:
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.