Skip to content

Add command completion metadata to Precmd#12853

Draft
vorporeal wants to merge 1 commit into
david/harden-block-lifecycle-against-edge-casesfrom
david/add-precmd-completion-fields
Draft

Add command completion metadata to Precmd#12853
vorporeal wants to merge 1 commit into
david/harden-block-lifecycle-against-edge-casesfrom
david/add-precmd-completion-fields

Conversation

@vorporeal

@vorporeal vorporeal commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Description

Stack PR 2/8; depends on #12852.

Context

CommandFinished is Warp's early completion signal, while Precmd arrives later when the shell is ready to display the next prompt. If CommandFinished is lost but Precmd still arrives, the current Precmd payload does not carry enough information to prove which command completed, preserve its real exit code, or identify the exact next block. Recovery must not guess any of those values.

This matters especially for shared sessions: viewers parse the raw shell hooks emitted by the sharer's installed client. When recovery eventually launches, it will only be useful for sessions whose sharers already emit the additional completion metadata fields.

Approach and sequencing

Each supported shell now captures the previous command's exit code and allocates the next block ID once, then sends that exact pair in both CommandFinished and Precmd. The fields are redundant by design: normal clients continue using the earlier CommandFinished, while a later Precmd can serve as trustworthy reconciliation evidence if the earlier hook was dropped.

This is intentionally a standalone, behavior-preserving PR so it can reach stable ahead of the recovery implementation. That lead time increases the population of shared-session sharers sending Precmd hooks with completion metadata before newer viewers begin acting on them. Existing clients continue ignoring unknown JSON fields, and the current key-value decoder accepts these two fields without changing lifecycle behavior.

Review guidance

  • Do all bash, zsh, fish, and PowerShell emission paths reuse the same exit code and next block ID for both hooks?
  • Does this remain protocol-only, with no client-side lifecycle behavior change?
  • Will older clients and version-skewed shared-session viewers continue to parse or ignore the additional fields safely?

Testing

  • Added parser compatibility coverage proving the current decoder accepts and ignores the extra Precmd fields.
  • Final-stack validation: cargo check -p warp --tests, ./script/format, and git diff --check.

@cla-bot cla-bot Bot added the cla-signed label Jun 20, 2026

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/add-precmd-completion-fields branch from 6897525 to 709d251 Compare June 20, 2026 05:14
@vorporeal vorporeal changed the title Correlate Precmd with command completion metadata Add command completion metadata to Precmd 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