feat(grunt/tui): in-process wake listener — rip out daemon#7
Merged
Conversation
The daemon + auto-attach architecture was a workaround for stock opencode's
non-wakeable TUI. With this patch the TUI worker itself binds an HTTP
listener on a pre-picked free localhost port, exposing the same
/session/<id>/prompt_async endpoint used by 'opencode serve' but
in-process. Wake POSTs land directly in the same process that owns the
session, so rendering Just Works (no SSE relay, no attach client, no
display bug).
Concretely:
- New pickFreePort() helper picks a free port via node:net before spawning
the worker.
- Worker spawn env gets OPENCODE_WAKE_PORT + OPENCODE_SERVER_URL stamped
in so MCP children inherit them via sanitizedProcessEnv (hivemind-mcp
auto-announce reads OPENCODE_WAKE_PORT to register peers as wakeable).
- Right after worker boot, TUI calls client.call('server', {port, host})
which makes Server.listen() bind. Existing 'external' path (server, port
flag) is preserved as before.
- Escape hatch: OPENCODE_DISABLE_WAKE_LISTENER=1 skips the bind (legacy
non-wakeable mode, same as upstream).
Drops auto-serve.ts (the daemon-discovery module). The daemon mode is
gone. Closes anomalyco#224 follow-up.
bun typecheck clean.
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
terrxo
added a commit
that referenced
this pull request
May 28, 2026
) The daemon + auto-attach architecture was a workaround for stock opencode's non-wakeable TUI. With this patch the TUI worker itself binds an HTTP listener on a pre-picked free localhost port, exposing the same /session/<id>/prompt_async endpoint used by 'opencode serve' but in-process. Wake POSTs land directly in the same process that owns the session, so rendering Just Works (no SSE relay, no attach client, no display bug). Concretely: - New pickFreePort() helper picks a free port via node:net before spawning the worker. - Worker spawn env gets OPENCODE_WAKE_PORT + OPENCODE_SERVER_URL stamped in so MCP children inherit them via sanitizedProcessEnv (hivemind-mcp auto-announce reads OPENCODE_WAKE_PORT to register peers as wakeable). - Right after worker boot, TUI calls client.call('server', {port, host}) which makes Server.listen() bind. Existing 'external' path (server, port flag) is preserved as before. - Escape hatch: OPENCODE_DISABLE_WAKE_LISTENER=1 skips the bind (legacy non-wakeable mode, same as upstream). Drops auto-serve.ts (the daemon-discovery module). The daemon mode is gone. Closes anomalyco#224 follow-up. bun typecheck clean.
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.
Replaces the daemon + auto-attach dance (v1.15.10-grunt.2/.3) with an in-process HTTP wake listener bound by the TUI worker itself. Wakes land in the same process that owns the session — no SSE relay, no render bug.
Deletes auto-serve.ts. Closes anomalyco#224 follow-up.