fix(opencode): run tui worker shutdown on signal/terminal-exit paths#14238
fix(opencode): run tui worker shutdown on signal/terminal-exit paths#14238s2bomb wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
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. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs FoundBased on the search results, here are related PRs that may be addressing similar issues:
Recommendation: Check PR #13848 first, as it appears to be the most directly related to TUI signal handling. Verify if it already covers the current PR's scope or if this PR addresses remaining gaps. |
Fixes #14237
What does this PR do?
Ensures the TUI command routes process-exit signals through the existing worker
shutdown path, instead of only cleaning up during normal UI exit.
Why this change
thread.tscallsclient.call("shutdown")only insideonExit. There are nohandlers for
SIGINT,SIGTERM, orSIGHUP, so signal-based exits skip workercleanup and child resources can survive.
worker.tsalready has the canonical cleanup (Instance.disposeAll()with timeoutserver.stop(true)). This patch reliably invokes that existing logic from allexit paths.
Changes
packages/opencode/src/cli/cmd/tui/thread.ts— one idempotentshutdownwrapperwith a 5s timeout, signal handlers for
SIGINT/SIGTERM/SIGHUP, andonExitrouted through the same path. Mirrors signal-driven shutdown already used in other
command entrypoints. No new cleanup semantics introduced.
How did you verify your code works?
Reproduced leak before fix using a deterministic harness (local fake MCP server
under
script -q -c), then verified clean exit after fix:Full test suite:
bun test --timeout 30000inpackages/opencode— 1095 pass,5 skip, 0 fail.