Centralize terminal lifecycle mutations#12855
Draft
vorporeal wants to merge 1 commit into
Draft
Conversation
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Jun 20, 2026
Co-Authored-By: Oz <oz-agent@warp.dev>
4b956c1 to
bc95293
Compare
66999d5 to
05ed27e
Compare
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.

Description
Stack PR 4/8; depends on #12854.
Context
Normal command completion is not a single block mutation. It also cleans up terminal-wide state, finalizes background and in-band bookkeeping, advances the block list, emits ordered shared-session state, and notifies downstream handlers. Prompt and pre-execution hooks have similarly coupled side effects spread across
TerminalModel,BlockList, andBlock.Adding recovery directly to those existing paths would require duplicating that behavior for every exceptional sequence. That would make it easy for recovered commands to miss cleanup, emit events in a different order, or complete the same block twice.
Approach
This PR is a behavior-preserving refactor that establishes one normal lifecycle mutation pipeline before any coordinator or recovery policy is added.
BlockListandBlockgain focused primitives for classifying next-block IDs, ensuring a block is started, completing and advancing the active block, applying a prompt, and applying pre-execution evidence.TerminalModelbecomes the single place that composes those primitives with model-wide completion, prompt, and handler side effects.Normal
CommandFinished,Precmd, andPreexechooks are routed through the new helpers, but exceptional sequences are not recovered yet. Keeping this slice policy-free makes normal-flow parity independently reviewable before later PRs reuse the same pipeline for recovery.Review guidance
Testing
cargo check -p warp --tests,./script/format, andgit diff --check.