Skip to content

Centralize terminal lifecycle mutations#12855

Draft
vorporeal wants to merge 1 commit into
david/type-precmd-completion-metadatafrom
david/centralize-normal-lifecycle-mutations
Draft

Centralize terminal lifecycle mutations#12855
vorporeal wants to merge 1 commit into
david/type-precmd-completion-metadatafrom
david/centralize-normal-lifecycle-mutations

Conversation

@vorporeal

@vorporeal vorporeal commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

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, and Block.

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. BlockList and Block gain 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. TerminalModel becomes the single place that composes those primitives with model-wide completion, prompt, and handler side effects.

Normal CommandFinished, Precmd, and Preexec hooks 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

  • Does the centralized path preserve the previous ordering and exactly-once behavior of cleanup, block events, ordered shared-session events, and handler notifications?
  • Are the new block-level helpers mutation primitives rather than places that independently decide lifecycle policy?
  • Does this PR avoid changing how exceptional or out-of-order hooks behave?

Testing

  • Added normal lifecycle parity coverage for completion and prompt side effects, bootstrap, user, in-band, background-finalization, alternate-screen, and shared ordered-completion paths.
  • Final-stack validation: cargo check -p warp --tests, ./script/format, and git diff --check.

vorporeal commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Co-Authored-By: Oz <oz-agent@warp.dev>
@vorporeal vorporeal force-pushed the david/centralize-normal-lifecycle-mutations branch from 4b956c1 to bc95293 Compare June 20, 2026 05:14
@vorporeal vorporeal force-pushed the david/type-precmd-completion-metadata branch from 66999d5 to 05ed27e Compare June 20, 2026 05:14
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