/relaunch command - part c - #5593
Conversation
…the same session /relaunch reuses the /exit teardown path (engine shutdown, persistence flush, terminal restore) and then replaces the process image with the current executable run as `resume <session-id>`, so the resumed session owns the same terminal with no orphan process. - commands/groups/core/relaunch.rs: command; refuses unsaved sessions and in-flight runtime work, records the session id in App.pending_relaunch, and quits through the ordinary exit path. - relaunch.rs: argv builder (<exe> resume <id>), the process-wide handoff, and the Unix CommandExt::exec that runs after telemetry close-out; Windows consumes the handoff as a no-op and the quit-time resume hint is the instruction. - event_loop.rs: hands the pending id over after the persistence flush and suppresses the redundant resume hint; lib.rs execs after finish_telemetry so the old session's telemetry is recorded first. - localization: CmdRelaunchDescription in all 15 complete packs plus the command contract bridge; update.rs no longer claims there is no self-exec pattern. Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>
current_executable() trusted std::env::current_exe() whenever it returned Ok, but on Linux a binary replaced by rename resolves through /proc/self/exe to a path with a literal " (deleted)" suffix that no longer exists. exec_relaunch then exec'd the dead path and /relaunch failed with "could not relaunch (... (deleted)): No such file or directory". Resolve the image path, then keep it only when it is non-empty, exists, and its file name is not marked " (deleted)"; otherwise fall back to argv[0] (the PATH-resolvable invocation name), preserving the existing error-path fallback. relaunch_argv's "<exe> resume <session-id>" contract is unchanged. Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>
The Windows CI gate (cargo test --no-run) denies dead code under -D warnings. relaunch_argv is only called from the unix-only self-exec path, so the plain Windows lib build flagged it. Gate the item itself with #[cfg(any(unix, test))] — the portable argv-construction tests keep exercising it on every platform — instead of adding a dead-code lint allowance, so the dead-code budget is untouched. Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>
Regenerated crates/tui/CHANGELOG.md via scripts/sync-changelog.sh. Signed-off-by: M-Maciej <130112810+M-Maciej@users.noreply.github.com>
|
Thanks @M-Maciej for taking the time to contribute. This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered. Please read |
Resolves the only conflict: main's `## [Unreleased]` grew a `### Added` list while this branch appended its /relaunch bullet at the same insertion point. Kept both — main's list, with this PR's bullet appended — and regenerated crates/tui/CHANGELOG.md via scripts/sync-changelog.sh. No source files conflicted; every .rs change auto-merged.
|
Hi @M-Maciej — maintainer housekeeping on this PR, no code of yours was touched. What I found. Two separate things were keeping this un-judgeable:
I also prepended Heads-up on what CI will report.
Both are fixed by #5610, which is waiting to land. Anything else that goes red is worth your attention. Sorry this sat for so long without a real signal. Same treatment applied to #5592 and #5594. |
`/relaunch` saves like `/exit` then self-execs `resume <session-id>` (Unix). argv[0] fallback covers a deleted/renamed current_exe after `/update`. Authored by @M-Maciej; taken into the 0.9.12 integration branch with its authorship preserved. Adapted rather than clobbering integration locale keys: added CmdRelaunchDescription next to the existing /loop keys, left the FEAT-018 utility ContextualCommand surface intact, and only updated the `/update` module doc to point at the new relaunch handoff. Evidence: rustfmt --edition 2024 cargo test -p codewhale-tui --lib --locked --offline -- relaunch message_id_list_english_pack_stay_in_exact_sync -> 13 passed Co-Authored-By: M-Maciej <130112810+M-Maciej@users.noreply.github.com> Co-Authored-By: Grok 4.6 <noreply@anthropic.com>
/#5594 Replay tonight's M-Maciej PRs onto the integration commits that landed while the take was in flight (FEAT-019 /loop handler, image attach, computer-use fallbacks). No further adaptation. Co-Authored-By: Grok 4.6 <noreply@anthropic.com>
Take: - #5592 lifecycle outbox (`[lifecycle_outbox]`, opt-in JSONL + webhook) - #5593 /relaunch (save like /exit, Unix self-exec resume) - #5594 per-session control socket (`[control_socket]`, Unix JSON-RPC) Authorship of the original commits is preserved. Adapted onto the #5586 extracted modules (doctor_cli, exec_agent, cli_args, config/merge) and existing /loop locale keys rather than clobbering them. Did not merge origin/main. Co-Authored-By: M-Maciej <130112810+M-Maciej@users.noreply.github.com> Co-Authored-By: Grok 4.6 <noreply@anthropic.com> Entire-Checkpoint: 01M0W25Y7BH0J5342G4WRNQZJT
Closes #5532
Summary
/updateinstalls a new binary and then tells the user to restart the app.This adds the missing self-relaunch so a session switches to the current
binary in one step:
/relaunchbehaves like/exitfor persistence (save, restore terminal,telemetry flush,
session_endemission) and then self-execsresume <session-id>— the CLI's positional resume form, which thestandalone TUI binary also accepts. Atomic
execon Unix: no orphanprocess for a supervisor to reap.
argv[0]fallback: whencurrent_exeresolves to a deleted or renamedpath — the updater's rename-replacement case —
/relaunchfalls back toargv[0]instead of failing.exact
resumecommand to continue with.exec); theportable argv-construction tests still exercise the resume-form builder on
every platform.
Merge-order note
Merge order: after the cadence fix (a). No dependency on (b); the control
socket's
relaunchverb (d) dispatches/relaunchthrough the genericcommand seam, so it has no compile dependency on this branch — until this
merges the verb reports
command_error, after it the verb is functional.Windows build hygiene
The Windows CI gate denies dead code under
-D warnings.relaunch_argvisonly called from the unix-only self-exec path, so the plain Windows lib build
flagged it. It is gated with
#[cfg(any(unix, test))]— the item itself isomitted from the plain Windows lib build instead of being allowed — so the
dead-code budget is untouched.
Testing
<!-- Exact gate commands (including the clippy allow list) are in
CONTRIBUTING.md → "Pre-push verification". -->
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked(warning-free under the CI allow list)cargo test --workspace --all-features --lockedResults: clippy clean on stable 1.98.0 under the CONTRIBUTING.md allow
list; full suite 13,376 passed / 0 failed (same one pre-existing
environmental skip as the outbox PR). Focused
relaunchsuite: 12/12(argv construction incl. Windows-style path preservation,
deleted/renamed-
current_exefallback, resume-form args).Checklist
/update's module doc now explains why it does not chain/relaunch/relaunchexercisedlive on running sessions during development ( verified before split, not after )
every commit is authored under
130112810+M-Maciej@users.noreply.github.comSigned-off-by(DCO)