Skip to content

Distinguish Precmd hooks with completion metadata from prompt-only hooks#12854

Draft
vorporeal wants to merge 2 commits into
david/add-precmd-completion-fieldsfrom
david/type-precmd-completion-metadata
Draft

Distinguish Precmd hooks with completion metadata from prompt-only hooks#12854
vorporeal wants to merge 2 commits into
david/add-precmd-completion-fieldsfrom
david/type-precmd-completion-metadata

Conversation

@vorporeal

@vorporeal vorporeal commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Description

Stack PR 3/8; depends on #12853.

Context

Once the new fields begin reaching clients, the parser must distinguish three meaningfully different inputs. A new sharer's Precmd contains a complete completion identity; an older sharer's Precmd contains prompt metadata only; and a payload containing just one completion field is malformed. Treating those cases as one partially optional value would spread ambiguity into the model and risk using incomplete or prompt-only evidence as proof that a command completed.

Approach

This PR makes the distinction explicit at the parser boundary. A canonical PrecmdValue contains non-optional CompletionMetadata plus reusable PromptMetadata; a prompt with neither completion field becomes a separate prompt-only event; and a prompt with exactly one completion field is rejected. Both JSON and key-value decoding follow the same classification rule.

The prompt-only portion is also separated so BlockList, Block, HeaderGrid, restoration, and cached prompt paths do not need to know about completion evidence. Canonical completion metadata reaches TerminalModel, but this PR intentionally sends Precmd hooks with completion metadata and prompt-only Precmd hooks through the existing prompt behavior. Recovery is deferred until the normal mutation pipeline and lifecycle gate exist.

Review guidance

  • Is the both/neither/partial classification exhaustive and consistent across JSON and key-value hooks?
  • Can malformed or prompt-only payloads accidentally acquire default completion evidence?
  • Does the broad PromptMetadata refactor preserve current prompt and lifecycle behavior despite changing many call sites?

Testing

  • Added parser coverage for payloads with completion metadata, prompt-only payloads, malformed partial payloads, invalid payloads, and unknown-field payloads.
  • Updated affected block, terminal-model, restoration, and shared-session coverage for the typed prompt metadata refactor.
  • 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

vorporeal and others added 2 commits June 20, 2026 00:11
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
@vorporeal vorporeal force-pushed the david/add-precmd-completion-fields branch from 6897525 to 709d251 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
@vorporeal vorporeal changed the title Distinguish correlated and legacy Precmd hooks Distinguish Precmd hooks with completion metadata from prompt-only hooks 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