Safely reconcile repeated and prompt-only Precmd hooks#12857
Draft
vorporeal wants to merge 3 commits into
Draft
Conversation
This was referenced Jun 20, 2026
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>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
d5c5fd1 to
1ea3538
Compare
8ea8d92 to
2a89b87
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 6/8; depends on #12856.
Context
Precmdis not always a one-time event. Shells can repaint or resend a prompt, and a newer shared-session viewer can receive prompt-only hooks from an older sharer. Re-running the original prompt path against an already populated active block can overwrite command/input state, move the cursor, mutate a finished prompt grid, or repeat once-per-block events. Ignoring every repeat is safer, but it also discards legitimate newer prompt, session, and environment context.Prompt-only
Precmdhooks need a separate policy: they are useful when the model is already safely awaiting or displaying a prompt, but they cannot prove that an executing command completed or identify the next block.Approach
This PR adds an explicit safe refresh path. A same-active-ID
Precmdwith completion metadata applies normally when the active block is fresh; if that block already has a prompt, it refreshes the active prompt and context while preserving the current command content, input, and cursor position. A prompt disposition tells downstream dispatch whether this was the first application or a refresh, allowing session/environment state to update without re-emitting public once-per-block prompt events.Prompt-only evidence is accepted only in the safe prompt phases defined by the coordinator and is ignored elsewhere with diagnostics. It never completes or advances a block. State-mutating repeated-prompt reconciliation remains selected by the recovery gate, while rejection of unsafe prompt-only transitions is unconditional.
Review guidance
Precmdevent?Testing
Precmdcoverage for prompt-grid, input, and cursor preservation plus exact once-per-block event counts.Precmdupdates the active session without emitting a duplicate publicPrecmdevent.cargo check -p warp --tests,./script/format, andgit diff --check.