Skip to content

refactor(opencode): retire PTY Hono route tree - #1450

Merged
Astro-Han merged 1 commit into
devfrom
codex/i936-pty-hono-httpapi-retire
Jun 20, 2026
Merged

refactor(opencode): retire PTY Hono route tree#1450
Astro-Han merged 1 commit into
devfrom
codex/i936-pty-hono-httpapi-retire

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

Retire the legacy Hono route tree for PTY ordinary HTTP endpoints and keep PTY HTTP behavior on the Effect HttpApi handlers.

Why

The PTY JSON and connect-token endpoints already have local HttpApi coverage. Keeping InstanceRoutes().route("/pty", PtyRoutes()) left a retired ordinary Hono boundary in production inventory, while the real native PTY websocket surface still needs to remain explicit.

Related Issue

Related to #936

Human Review Status

Pending

Review Focus

Please check that ordinary PTY HTTP endpoints are no longer inventoried as Hono routes, while /pty/:ptyID/connect remains a native websocket special surface.

Risk Notes

PTY websocket compatibility is intentionally still native, not converted to ordinary HttpApi. The visible UI check is skipped because no UI or copy changed. No docs, generated files, dependencies, permissions, credentials, or local file behavior changed.

Fresh-eye result: no P0/P1 findings. I checked whether this was the simplest, most reassuring, and most complete boundary. The current split keeps only the websocket compatibility helper and removes the ordinary Hono tree without widening scope.

How To Verify

RED: bun test test/server/production-boundary.test.ts test/server/route-inventory-harness.test.ts failed before implementation on PTY Hono inventory and PtyRoutes mounting.
Focused tests: bun test test/server/production-boundary.test.ts test/server/route-inventory-harness.test.ts test/server/pty-routes.test.ts -> 68 pass, 0 fail.
Typecheck: GOMAXPROCS=2 bun run typecheck -> tsgo --noEmit passed.
Diff check: git diff --check -> no whitespace errors.

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.

Summary by CodeRabbit

  • Refactor

    • Refactored PTY connection handling to use an improved internal architecture while preserving all existing functionality.
  • Tests

    • Updated test coverage to validate the updated PTY routing infrastructure.

@github-actions github-actions Bot added harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority labels Jun 20, 2026

@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.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b5b57ad0-970a-4b57-ab26-e41223e604f9

📥 Commits

Reviewing files that changed from the base of the PR and between b1da821 and 98748e3.

📒 Files selected for processing (7)
  • packages/opencode/script/route-inventory.ts
  • packages/opencode/src/server/instance/index.ts
  • packages/opencode/src/server/instance/pty.ts
  • packages/opencode/src/server/routes/instance/pty.ts
  • packages/opencode/test/server/production-boundary.test.ts
  • packages/opencode/test/server/pty-routes.test.ts
  • packages/opencode/test/server/route-inventory-harness.test.ts
💤 Files with no reviewable changes (3)
  • packages/opencode/src/server/routes/instance/pty.ts
  • packages/opencode/script/route-inventory.ts
  • packages/opencode/src/server/instance/index.ts

📝 Walkthrough

Walkthrough

Removes the Hono-based PtyRoutes() router from pty.ts and its /pty registration from InstanceRoutes, retaining only the Effect-based connectPtySession and createPtyConnectEvents helpers. The route-inventory script, re-export module, and test files are updated to reflect the removal.

Changes

PTY Hono Route Removal

Layer / File(s) Summary
Remove PtyRoutes and /pty wiring
packages/opencode/src/server/instance/pty.ts, packages/opencode/src/server/instance/index.ts, packages/opencode/src/server/routes/instance/pty.ts
Strips Hono/OpenAPI routing imports from pty.ts and deletes the PtyRoutes() exported function along with all its REST endpoint effect definitions (list/create/get/update/remove and connect-token). Removes the PtyRoutes import and .route("/pty", PtyRoutes()) call from InstanceRoutes. Drops the re-export of PtyRoutes from the routes module. The connectPtySession Effect and createPtyConnectEvents helper remain.
Route inventory and test harness updates
packages/opencode/script/route-inventory.ts, packages/opencode/test/server/route-inventory-harness.test.ts, packages/opencode/test/server/pty-routes.test.ts, packages/opencode/test/server/production-boundary.test.ts
Removes pty.ts from honoRouteSources in the inventory script. Updates harness assertions to expect hono: false for POST /pty/:ptyID/connect-token and changes its classification match from "openapi-v2-sdk" to a `local-httpapi-(only

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Astro-Han/pawwork#1384: Adds the local Effect HttpApi PTY handlers including POST /pty/:ptyID/connect-token that this PR now treats as the canonical implementation, directly reflected in the updated hono: false / local-httpapi-* classification assertions.
  • Astro-Han/pawwork#1367: Introduces the Effect-based connectPtySession helper in pty.ts that this PR retains after stripping the Hono PtyRoutes() wrapper.
  • Astro-Han/pawwork#1427: Removes the legacy /session Hono route source using the same honoRouteSources mechanism that this PR modifies to drop /pty.

Suggested labels

P2, harness, task, tech-debt

Poem

🐇 Hop hop, the Hono routes are gone,
No more /pty to carry on!
Effect helpers stand in place,
connectPtySession wins the race.
The rabbit tidied every wire —
Clean inventories never tire! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor(opencode): retire PTY Hono route tree' clearly and concisely summarizes the main change—removing the legacy Hono route tree for PTY endpoints.
Description check ✅ Passed The description comprehensively covers Summary, Why, Related Issue, Human Review Status, Review Focus, Risk Notes, How To Verify, and Checklist with nearly all items checked.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/i936-pty-hono-httpapi-retire

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@Astro-Han Astro-Han added task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context labels Jun 20, 2026
@Astro-Han
Astro-Han merged commit 69b911e into dev Jun 20, 2026
44 of 47 checks passed
@Astro-Han
Astro-Han deleted the codex/i936-pty-hono-httpapi-retire branch June 20, 2026 15:41
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant