fix(coding-agent): replace TUI process after update - #1631
Merged
Conversation
samsja
previously approved these changes
Aug 26, 2026
sethkarten
force-pushed
the
fix/update-relaunch-tui
branch
from
August 26, 2026 22:28
c8ad10e to
b1b1ae4
Compare
…s back The relaunch chdirs before replacing the process; a thrown execve (Node >=26.1) left the old process on the update cwd while the child fallback ran. The seam now restores the captured previous cwd on the throw path so a failed attempt leaves no silent process-state difference.
…atform restriction
snimu
approved these changes
Sep 1, 2026
ketema
added a commit
to ketema/prime-agent
that referenced
this pull request
Sep 1, 2026
- Direct session transport between TUI and worker (ENG-5817, PrimeIntellect-ai#1926) - Event-driven supervisor agent roster with push subscriptions (PrimeIntellect-ai#1897, PrimeIntellect-ai#1900, PrimeIntellect-ai#1895) - Hardened daemon startup, recovery ownership, and worker launch diagnostics (PrimeIntellect-ai#1929, PrimeIntellect-ai#1918) - Python REPL runtime single-dump snapshots and bash preview tool (PrimeIntellect-ai#1945, PrimeIntellect-ai#1911) - Non-blocking RLM subagent deletion and snapshot update suppression (PrimeIntellect-ai#1954, PrimeIntellect-ai#1944) - Saved catalog loading on Agents View open (PrimeIntellect-ai#1960) - Advanced Anthropic prompt caching marker across tool results (PrimeIntellect-ai#1927) - TUI process replacement on update and empty draft eviction (PrimeIntellect-ai#1631, PrimeIntellect-ai#1946, PrimeIntellect-ai#1920)
paralin
pushed a commit
to paralin/prime-agent
that referenced
this pull request
Sep 2, 2026
…i#1631) * fix(coding-agent): replace TUI process after update * fix(coding-agent): guard unsafe execve failures * fix(coding-agent): restore the previous cwd when a thrown execve falls back The relaunch chdirs before replacing the process; a thrown execve (Node >=26.1) left the old process on the update cwd while the child fallback ran. The seam now restores the captured previous cwd on the throw path so a failed attempt leaves no silent process-state difference. * docs(coding-agent): qualify the update-relaunch changelog with the platform restriction --------- Co-authored-by: Sebastian <sebastian@primeintellect.ai>
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 POSIX Node 26.1 and newer, 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(15/15)execvefailures on Node 22.22, 24.13, 25.8, and 26.0; verified thrownENOENTon Node 26.1 and 26.2git diff --checkNote
Medium Risk
Changes interactive self-update process replacement and terminal/shell job ownership; mitigated by platform/version gating and spawnSync fallback, with env reduced to string values on the execve path.
Overview
After a successful interactive
/update, the relaunch step no longer relies solely onspawnSync, which left the old TUI process running until the child exited.On POSIX with Node ≥ 26.1 (where failed
execvethrows instead of aborting), the agent now triestryExecUpdateRelaunch:chdirto the update cwd, thenprocess.execvewith a launch spec fromcreateCliSubprocessLaunchSpec, string-only env, and argv0 preserved. Windows, IBM i, older Node, missingexecve, or exec failures still use the childspawnSyncrelaunch, with a console message on exec failure.Tests cover execve behavior, platform/version gates, cwd restore on thrown execve, and update teardown ordering ending in execve instead of waiting on a child TUI.
Reviewed by Cursor Bugbot for commit 40bd188. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Replace TUI process in place via
execveafter/updateon Node 26.1+tryExecUpdateRelaunchin interactive-mode.ts to replace the current process viaexecveon non-win32/non-os400 platforms and Node >= 26.1, preserving argv0 and string-only environment entries.handleUpdateCommandnow tries in-place replacement first; on failure or unsupported platforms it logs a message and falls back to the previousspawnSyncchild-process approach.tryExecUpdateRelaunchfilters environment to string-only values before callingexecve; any non-string env entries (e.g. injected by native addons) will be silently dropped during relaunch.Changes since #1631 opened
Macroscope summarized 7fb4798.
Dormancy note: on today's Node 24.x runtimes the execve path is dormant and everyone takes the existing child-relaunch fallback; the in-place replacement activates when the runtime reaches Node >=26.1, the version where a failed
process.execvethrows instead of aborting (confirmed against the official Node docs).