fix(coding-agent): replace TUI process after update - #1631
Open
sethkarten wants to merge 1 commit into
Open
Conversation
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.
Linear: ENG-5434
Summary
process.execveDesign
The existing updater already completes the package update, session teardown, and daemon restart before relaunch. The last step used
spawnSync, which kept the old TUI process alive until the new TUI quit.On supported POSIX Node runtimes, the relaunch now uses
execveafter cleanup. This replaces the old process while keeping its PID and foreground terminal ownership. A detached frontend would break shell job and TTY ownership, so the existing inherited-stdio child relaunch remains the compatibility fallback where process replacement is unavailable or fails.Validation
npm run check../../node_modules/.bin/vitest run test/interactive-update-relaunch.test.ts(11/11)git diff --checkNote
Medium Risk
Touches interactive self-update process lifecycle (execve vs child spawn), which can affect TTY/job control if replacement is wrong, but keeps a fallback and is well tested.
Overview
Fixes
/updateleaving the old TUI process running until the relaunched TUI quit.On POSIX Node runtimes with
process.execve, the post-update relaunch now replaces the current process in place (same PID, cwd, env, argv, and foreground TTY/job). Windows, IBM i, and runtimes withoutexecvestill use the inherited-stdiospawnSyncchild relaunch, including if replacement fails.Relaunch now goes through
createCliSubprocessLaunchSpecinstead of assemblingexecPath/execArgv/entrypoint by hand. Tests covertryExecUpdateRelaunchand the teardown → update → daemon coordinator →execveorder.Reviewed by Cursor Bugbot for commit c8ad10e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Replace TUI process in-place after
/updateon supported platformstryExecUpdateRelaunchto replace the current process viaexecveduring self-update relaunch on non-win32/non-os400 platformsexecvespawnSyncwhenexecveis unavailable or unsupportedInteractiveMode.handleUpdateCommandchanges the relaunch path; iftryExecUpdateRelaunchincorrectly reports success, the process may exit without a fallback child spawnMacroscope summarized c8ad10e.