Skip to content

refactor(server): effectify pty json route handlers#1015

Merged
Astro-Han merged 1 commit into
devfrom
codex/i936-pty-route-effect
Jun 2, 2026
Merged

refactor(server): effectify pty json route handlers#1015
Astro-Han merged 1 commit into
devfrom
codex/i936-pty-route-effect

Conversation

@Astro-Han
Copy link
Copy Markdown
Owner

Summary

Effectify the ordinary JSON PTY route handlers while leaving the WebSocket connection path unchanged:

  • route PTY list/create/get/update/remove through AppRuntime.runPromise(Effect.gen(...));
  • yield Pty.Service from the runtime context instead of calling the async facade helpers;
  • preserve route entrypoints, operation IDs, response bodies, not-found mapping, and the existing connect-token/WebSocket behavior.

Why

Part of #936. The route handler effectification phase should move small, ordinary JSON handlers onto the shared Effect runtime before any larger route-group or HttpApi migration. PTY has focused route coverage and a clear boundary between JSON handlers and the WebSocket connect path.

Related Issue

Part of #936.

Human Review Status

Pending

Review Focus

Please review whether the JSON handlers preserve the old PTY service call order and whether the WebSocket/connect-token boundary is truly unchanged.

Risk Notes

  • This is intended as a no-behavior-change route-handler refactor.
  • The PTY WebSocket connect route and connect-token route are intentionally left on the existing path for this PR.
  • Visible UI/copy check skipped: no visible UI or app copy changed.
  • Platform impact considered: PTY behavior is platform-sensitive, but this PR does not change shell spawning, process lifecycle, WebSocket handling, or PTY implementation details.
  • No docs, release notes, dependencies, permissions, credentials, generated content, public SDK/API shape, or local file behavior changed.

How To Verify

Dependency setup: bun install --frozen-lockfile completed in the isolated worktree.
Focused PTY route tests: bun test ./test/server/pty-routes.test.ts in packages/opencode -> passed, 11 tests.
Opencode typecheck: bun run typecheck in packages/opencode -> passed.
Whitespace: git diff --check -> clean.

Screenshots or Recordings

Not applicable; no visible UI changes.

Checklist

How to use this checklist:

  • Tick a box by replacing [ ] with [x]. Do not edit, add, or remove items.
  • The bot-applied label items can only be honestly ticked AFTER the PR is opened and the labeler / priority-triage bots have run — return to the PR description and tick them then.
  • Most items are required. The few that are conditional are explicitly marked (conditional); for those, leave unticked if they truly do not apply and explain why in Risk Notes. All other items must be ticked before requesting human review.
  • 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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

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 50 minutes. 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: a972682b-5e86-4609-8dac-d23001cb425b

📥 Commits

Reviewing files that changed from the base of the PR and between c019c11 and 28889d0.

📒 Files selected for processing (1)
  • packages/opencode/src/server/instance/pty.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/i936-pty-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.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

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.

Copy link
Copy Markdown

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

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 PTY routes in packages/opencode/src/server/instance/pty.ts to utilize the Effect library and AppRuntime.runPromise for managing PTY operations (list, create, get, update, and remove) instead of direct asynchronous calls on static Pty methods. There are no review comments, and I have no feedback to provide.

@Astro-Han Astro-Han merged commit 1acec0f into dev Jun 2, 2026
29 of 30 checks passed
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