forked from dries/ocman
fix(opencode): refresh port discovery during tmux launch #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "codex/opencode-fresh-port-discovery"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
opencode --port 0instances are found promptly.Current stack
This branch is rebased on latest upstream
main(97fa317). The earlier tmux availability fix has already merged upstream, so this PR's intended review delta is only the OpenCode port-discovery launch fix.Follow-up stack branch:
codex/opencode-port-affinity, which handles duplicate same-directory OpenCode servers by keeping a session's live traffic on one selected port.Actual issue encountered
After fixing the earlier tmux availability issue, creating a new session could still fail even though ocman successfully started OpenCode in tmux. The UI got past launch/wait and then failed while creating the session:
This was a real session-start failure observed while using ocman, not a theoretical cleanup. The important clue was that the tmux launch step succeeded, but ocman still could not create a session against the newly-started OpenCode server.
What we observed while debugging
OpenCode did not start in time...after the retry window expires.opencode --port 0, so ocman has to discover the assigned HTTP port after launch.lsofand keeps a short-lived directory -> port cache for normal dashboard/read paths.What we inferred / assumed
lsofscans.Important caveats / implications
lsofscans during launch/wait flows, especially if OpenCode takes several polling attempts to bind. Normal dashboard discovery still uses the cache.EvalSymlinksfails because a path is missing or inaccessible, ocman falls back to the cleaned path, so unusual path cases can still miss.Validation
Run on
codex/opencode-fresh-port-discovery:go test ./internal/platforms/opencode -run 'Test(InvalidateOpenCodePortCache|DiscoverOpenCodePortFresh)'go test ./internal/platforms/opencodego test ./internal/mcp ./internal/servergo test ./...make teston the rebased stack tip after the latest upstream rebase.265b9a9457todbd9ae0045dbd9ae0045tobbc152ee10bbc152ee10toefa335f30befa335f30bto1086db8131Pull request closed