Skip to content

Recover missing CommandFinished hooks from Precmd completion metadata#12858

Draft
vorporeal wants to merge 2 commits into
david/reconcile-repeated-and-legacy-promptsfrom
david/recover-block-lifecycle-from-precmd
Draft

Recover missing CommandFinished hooks from Precmd completion metadata#12858
vorporeal wants to merge 2 commits into
david/reconcile-repeated-and-legacy-promptsfrom
david/recover-block-lifecycle-from-precmd

Conversation

@vorporeal

@vorporeal vorporeal commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Description

Stack PR 7/8; depends on #12857.

Context

A dropped CommandFinished is the key recoverable failure this stack targets. The shell can finish a command and emit Precmd, while Warp still believes the old block is submitted or executing. Without trustworthy completion evidence, advancing would require inventing an exit code or next-block identity; not advancing leaves the controller and block model stuck and risks applying the new prompt to the old command block.

The earlier stack PRs make recovery safe: #12853 gives Precmd the real completion identity, #12854 distinguishes Precmd hooks with completion metadata from prompt-only Precmd hooks, #12855 provides one completion pipeline, #12856 gates every transition, and #12857 makes prompt application and refresh safe.

Approach

When a Precmd with completion metadata carries a novel next block ID, the coordinator now treats it as completion evidence. It runs the same completion pipeline used by CommandFinished with the shell-provided exit code and exact next block ID, then applies the received prompt metadata only to the fresh block. If the active block was already finished, the model advances without finishing or emitting completion again; if Warp missed earlier start/pre-execution evidence, it performs the minimal transition needed to preserve truthful completed-block state.

All non-normal state-mutating recovery remains behind TerminalLifecycleRecovery. Duplicate, stale, or colliding completion metadata, partial payloads, and prompt-only evidence still cannot trigger completion. Shared-session and version-skew paths preserve the same conservative rules.

Review guidance

  • Does recovery use only the shell-provided exit code and next block ID from completion metadata, without guessing or accepting weaker evidence?
  • Does recovered completion preserve the normal cleanup/event ordering and emit every once-per-block side effect exactly once?
  • Is prompt metadata applied only after advancing to the fresh block?
  • Do feature-flag and shared-session/version-skew boundaries prevent unsupported clients from taking the recovery path?

Testing

  • Added model recovery-matrix and shared-session old-sharer/new-viewer compatibility coverage.
  • Added an all-shell real-shell regression that suppresses CommandFinished; confirmed it fails on the preceding PR and passes here.
  • Final-stack validation: focused lifecycle tests, cargo check -p warp --tests, ./script/format, and git diff --check.

vorporeal commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

@vorporeal vorporeal changed the title Recover block lifecycle from Precmd Recover missing CommandFinished hooks from correlated Precmd Jun 20, 2026
vorporeal and others added 2 commits June 20, 2026 00:36
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
@vorporeal vorporeal force-pushed the david/recover-block-lifecycle-from-precmd branch from da9c6a2 to c12ed03 Compare June 20, 2026 05:14
@vorporeal vorporeal force-pushed the david/reconcile-repeated-and-legacy-prompts branch from 8ea8d92 to 2a89b87 Compare June 20, 2026 05:14
@vorporeal vorporeal changed the title Recover missing CommandFinished hooks from correlated Precmd Recover missing CommandFinished hooks from Precmd completion metadata Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant