Skip to content

fix(coding-agent): replace TUI process after update - #1631

Open
sethkarten wants to merge 1 commit into
mainfrom
fix/update-relaunch-tui
Open

fix(coding-agent): replace TUI process after update#1631
sethkarten wants to merge 1 commit into
mainfrom
fix/update-relaunch-tui

Conversation

@sethkarten

@sethkarten sethkarten commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Linear: ENG-5434

Summary

  • replace the current TUI process in place after a successful interactive self-update
  • preserve the current session, cwd, environment, CLI arguments, terminal, and shell job
  • keep the existing child relaunch on Windows, IBM i, and Node runtimes without process.execve
  • cover the full update teardown, daemon coordination, and process replacement order

Design

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 execve after 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 --check
  • independent process/lifecycle review: approved
  • independent test/maintainability review: approved after fixing its repo-convention finding

Note

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 /update leaving 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 without execve still use the inherited-stdio spawnSync child relaunch, including if replacement fails.

Relaunch now goes through createCliSubprocessLaunchSpec instead of assembling execPath/execArgv/entrypoint by hand. Tests cover tryExecUpdateRelaunch and the teardown → update → daemon coordinator → execve order.

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 /update on supported platforms

  • Adds tryExecUpdateRelaunch to replace the current process via execve during self-update relaunch on non-win32/non-os400 platforms
  • Filters environment to string values, chdir to the working directory, and preserves argv0 when calling execve
  • Falls back to spawning a child process with spawnSync when execve is unavailable or unsupported
  • Adds unit tests for environment filtering, argv0 preservation, and platform gating in interactive-update-relaunch.test.ts
  • Risk: InteractiveMode.handleUpdateCommand changes the relaunch path; if tryExecUpdateRelaunch incorrectly reports success, the process may exit without a fallback child spawn

Macroscope summarized c8ad10e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant