GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): keep PTY daemon ownership and registration in sync by rekram1-node · Pull Request #61750 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 4, 2026

Copy link
Copy Markdown
Member

Problem

The PTY daemon transport tracked id, registration, owner and closed as four separate variables. They could drift apart:

  • a failed request cleared registration but kept owner, and the next connect only claimed when owner was missing, so I could end up registered to daemon B while still owning daemon A
  • shutdown cleared registration but left owner open
  • claim overwrote owner without closing the old socket
  • handoff returned null unless both were set, so a mismatch quietly dropped terminals across a restart

Change

I replaced them with one state. Every transition replaces the whole state, and swapping out an owner closes the old socket.

unregistered{id}
owned{id, registration, owner}   registration is trusted
stale{id, registration, owner}   rediscover before the next request, keep the owner open
closed{id}

stale exists because dropping the owner connection stops the daemon, so a transient connect error can't just throw it away. On reconnect:

 connect
   found = discover()
-  if (!owner) claim(found)
-  registration = found
+  if state has an owner for found.instance_id
+    owned{..., registration: found}
+  else
+    claim(found)   // closes the previous owner

shutdown now goes to unregistered and closes the owner. handoff works whenever there is an owner, since the owner always matches registration.instance_id. The public DaemonTransport API is unchanged.

Verification

  • Two new tests in packages/core/test/persistent-pty-daemon.test.ts: reconnecting after a rejected registration claims the new daemon and closes the old owner, and shutdown closes the owner. Both fail on origin/dev and pass here.
  • bun test test/persistent-pty-daemon.test.ts test/persistent-pty-session.test.ts in packages/core: 15 pass
  • bun typecheck in packages/core and bun run check at the root pass

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(core): keep PTY daemon ownership and registration in sync
423cd36
@github-actions github-actions Bot added the contributor label Nov 4, 2026
opencodejr[bot]
opencodejr Bot reviewed Nov 4, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The change looks sound. Every state transition now replaces the whole state, and swapping out an owner always closes the old socket. The old socket's close listener is ignored once a new owner has replaced it. A stale state keeps its owner when the daemon's instance_id is unchanged and claims the new daemon otherwise. shutdown and the finalizer release the owner, and handoff stays consistent with the stored registration.

I checked it by running the two new tests on the base, where both fail with an owner connection left open, and on this branch, where the persistent-pty daemon/session tests (15) and test/pty pass. tsc -b for packages/core passes.

Public API is unchanged: DaemonTransport and everything outside packages/core stay the same.

No concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Nov 15, 2026
shell: every tool call stalls ~5s while the PTY daemon fails to reconnect (ECONNREFUSED /tmp/opencode-pty-<uid>/*.sock) #64080
Open
shell: every tool call stalls ~5s while the PTY daemon fails to reconnect (ECONNREFUSED /tmp/opencode-pty-<uid>/*.sock) #64081
Closed

This branch has not been deployed

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

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.