Repository navigation
Conversation
Project-wide discovery could adopt a sibling instance's PTY server. Filter runtime records by PID before health checks to isolate sessions. Attached TUIs now require a panel expansion per startup to discover their server through the existing instance-scoped bootstrap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The sidebar finds its PTY server through the origin records that servers publish for a project. Any record for the same project directory qualified as long as its server answered
/health, including one published by a different OpenCode process. This PR keeps only the records published by the current process.In plain terms: with two OpenCode windows open in the same project, one sidebar could connect to the other window's PTY server and list that window's terminals. Now each sidebar uses the server of its own process.
Cause
healthyRuntimeOrigins()took every record fromoriginsForProject(directory, worktree)and accepted the ones whose/healthanswered. The record carries the publishingpid, but nothing compared it with the current process, and the cache then kept the adopted server for as long as it answered.Changes
healthyRuntimeOrigins()skips records whosepidis notprocess.pid, before any health check. Two comments describe the new rule.Behavior changes
A TUI attached to a server that runs in another process no longer finds that server through the records. It falls back to the existing instance-scoped bootstrap, which means the panel needs to be expanded once per startup. The local TUI and its server run in the same process (worker threads share
process.pid), so that case is unchanged.Validation
One new test in
test/tui-index.test.ts: a healthy origin published by another process for the same project is not adopted. It fails on main, and deleting thepidfilter makes it fail again.I also ran this change, together with my other PTY fixes, in a live local OpenCode. The record of the running server had the host's
pid, and the sidebar listed that server's sessions.bun testovertest/*.test.ts, without the npm-pack and live suites, gives 185 passing.bun run typecheck,bun run lintandbunx biome format .are clean. The CI workflow passes on this tree in my fork, including the Playwright e2e. I did not try an attached TUI.Diff
Production: +2 lines (+7/-5) in
src/tui/index.ts.Tests: +40 lines (+42/-2) in
test/tui-index.test.ts.