Skip to content

fix(core): only advertise persistent PTY support when the daemon is runnable - #54583

Closed
samm-git wants to merge 1 commit into
anomalyco:devfrom
samm-git:persistent-pty-available
Closed

samm-git wants to merge 1 commit into
anomalyco:devfrom
samm-git:persistent-pty-available

Conversation

@samm-git

@samm-git samm-git commented Oct 11, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #

Related: #51796

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

PersistentPty.available is process.platform !== "win32", and the server reports it as capabilities.persistentPty (packages/server/src/handlers/server.ts). A build with no runnable opencode-pty daemon therefore still advertises persistent terminals: the client offers them, and every create fails with HTTP 503 (only "Unable to load terminal" in the TUI), while the server log says Executable not found in $PATH: "opencode-pty".

This changes packages/core/src/persistent-pty/binary.bun.ts so availability also requires the daemon to be resolvable — an embedded asset, OPENCODE_PTY_BIN, or opencode-pty on $PATH.

No schema change, so no client/OpenAPI regeneration is needed. binary.node.ts has the same platform-only assumption but no Bun.which; I left it alone to keep this focused.

How did you verify your code works?

Ran the exact predicate with Bun on FreeBSD under each condition:

asset OPENCODE_PTY_BIN opencode-pty on PATH result
none unset absent false
string or object unset absent true
none set absent true
none unset present true

Also the real case this comes from: a FreeBSD build that embeds the daemon via OPENCODE_PTY_BIN reports capabilities.persistentPty: true and creates terminals without a 503.

Screenshots / recordings

N/A, no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #51796

…unnable

PersistentPty.available was `process.platform !== "win32"`, so any build without
a runnable opencode-pty binary still reported
`capabilities.persistentPty: true`. A platform with no @opencode-ai/pty package,
or a build that did not embed the binary and has no `opencode-pty` on $PATH,
therefore offered persistent terminals in the client while every create failed
with HTTP 503 and a misleading "Unable to load terminal" (the server log only
showed "Executable not found in $PATH: \"opencode-pty\"").

Report availability only when a daemon can actually be resolved: an embedded
asset, OPENCODE_PTY_BIN, or `opencode-pty` on $PATH.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

samm-git added a commit to samm-git/freebsd-ports that referenced this pull request Oct 11, 2026
The TUI's persistent terminals are backed by a separate opencode-pty daemon
(Rust, linking Ghostty's VT parser).  Upstream ships no FreeBSD build and
@opencode-ai/pty has no freebsd package, so creating a terminal failed with
HTTP 503 ("Unable to load terminal"): the client spawned `opencode-pty` from
$PATH and found nothing.

Build it from source, pinned to the @opencode-ai/pty release (and its
ghostty-revision), and embed it into the executable through OPENCODE_PTY_BIN.
The Ghostty Zig dependencies are warmed into an offline cache at fetch time,
like the existing bun and WebAssembly caches, so the build stays offline.
See files/opencode-pty-build.rs.patch and files/ghostty-zig-0.16-std.patch.

Also enable OpenTUI's Ghostty VT backed embedded terminal, which the client
uses to render terminal panes.  OpenTUI only builds it for linux/macos/windows
and otherwise installs a stub whose createEmbeddedTerminal() reports
"embedded terminal support is unavailable", which crashed the TUI as soon as
a terminal pane opened.  See files/opentui-ghostty-vt-freebsd.patch.

Reported upstream as:
- opencode: anomalyco/opencode#54583
- opentui:  anomalyco/opentui#1445

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix works. With the PTY binding mocked as missing, no OPENCODE_PTY_BIN and no opencode-pty on $PATH, PersistentPty.available is true on the base and false with this PR. In the normal Linux dev setup the embedded binary still resolves, so available stays true and supported builds are unchanged. The existing persistent-PTY tests in packages/core and packages/server and the packages/core typecheck pass.

Public API: no schema change. Only the value of capabilities.persistentPty is now accurate; clients already gate on it.

The check still can't tell when a binary is found but can't run (e.g. the old-glibc case in #51796), so that issue stays open. binary.node.ts keeps the platform-only check, as you noted; not blocking.

Related: #51796

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@samm-git

Copy link
Copy Markdown
Author

@neriousy - may I kindly ask you to review?

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@samm-git

Copy link
Copy Markdown
Author

I have a feeling that its impossible to contribute to the project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant