Skip to content

refactor(server): effectify instance root json handlers - #1031

Merged
Astro-Han merged 2 commits into
devfrom
codex/i936-instance-root-route-effect
Jun 2, 2026
Merged

refactor(server): effectify instance root json handlers#1031
Astro-Han merged 2 commits into
devfrom
codex/i936-instance-root-route-effect

Conversation

@Astro-Han

Copy link
Copy Markdown
Owner

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/raw and /vcs/apply unchanged 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/raw and /vcs/apply are deliberately left as-is; they are not ordinary JSON-only migration targets in this slice.

Skipped conditional checklist items:

  • Visible UI/copy check: not applicable; server-only route refactor.
  • Platform/packaging check: not applicable; no platform or packaging surface touched.
  • Docs/release/dependency/local file check: not applicable; no docs, dependencies, generated content, credentials, or local-only files changed.

How To Verify

Focused route tests: bun test test/server/instance-root-routes.test.ts -> 3 pass, 0 fail
Diff check: git diff --cached --check -> passed before commit

Screenshots or Recordings

Not applicable; no visible UI changes.

Checklist

  • Type label — this PR carries exactly one of 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.
  • Routing labels — this PR carries at least one of 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.
  • Priority label — this PR carries exactly one of P0, P1, P2, P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.
  • Human Review Status above is set to Pending, Approved by @<reviewer>, or Not required: <reason> (default is Pending; "not required" is restricted to bot-authored low-risk PRs).
  • I linked the related issue, or stated in Summary why there is no issue.
  • I described the review focus and any meaningful risks.
  • I replaced the example block in How To Verify with the real verification steps and the key result for each.
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope.
  • (conditional) I manually checked visible UI or copy changes when needed, with screenshots or recordings. Leave unticked only if no visible UI or copy changed.
  • (conditional) I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes. Leave unticked only if no platform/packaging surface was touched.
  • (conditional) I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant. Leave unticked only if none of those surfaces was touched.
  • I reviewed the final diff for unrelated changes and suspicious dependency changes.
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English.

@Astro-Han Astro-Han added P2 Medium priority upstream Tracked upstream or vendor behavior harness Model harness, prompts, tool descriptions, and session mechanics task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context labels May 31, 2026
@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1638daae-2a17-4af0-a274-75fed9be573a

📥 Commits

Reviewing files that changed from the base of the PR and between 043831b and 074f1c1.

📒 Files selected for processing (2)
  • packages/opencode/src/server/instance/index.ts
  • packages/opencode/test/server/instance-root-routes.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/i936-instance-root-route-effect

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested priority: P2 (includes non-doc, non-test paths outside the low-risk bucket).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/opencode/src/server/instance/index.ts
Comment thread packages/opencode/src/server/instance/index.ts
Astro-Han added 2 commits June 2, 2026 18:57
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.
@Astro-Han
Astro-Han force-pushed the codex/i936-instance-root-route-effect branch from 766c1c9 to 074f1c1 Compare June 2, 2026 11:10
@Astro-Han
Astro-Han merged commit c19c09e into dev Jun 2, 2026
33 checks passed
@Astro-Han
Astro-Han deleted the codex/i936-instance-root-route-effect branch June 3, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context upstream Tracked upstream or vendor behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant