Skip to content

fix(cli, conversation): Defer replay trim to turn-start commit#862

Merged
JeanMertz merged 1 commit into
mainfrom
jp-c-edit-backup
Jul 9, 2026
Merged

fix(cli, conversation): Defer replay trim to turn-start commit#862
JeanMertz merged 1 commit into
mainfrom
jp-c-edit-backup

Conversation

@JeanMertz

Copy link
Copy Markdown
Collaborator

jp query --replay and the bare --no-edit replay-last-request path used to remove the trailing request event from the conversation stream while the request was still being built — during editor composition, MCP boot, or attachment loading. An interrupt or an empty query in that window persisted the removal without ever writing the replacement, silently dropping the last turn.

The removal is now described by a PendingStreamTrim and only applied inside the same lock scope that appends the new turn, so the stream goes from "old turn present" to "old turn replaced" in one write. Building the request is otherwise read-only: ConversationStream gains last_turn_event to peek at the trailing event without popping it, and ConversationLock/ConversationMut gain with_events for read-only access that never marks the conversation dirty.

Inline, piped, and replayed queries now also write their composed request to the conversation's recovery file before the turn starts, matching the existing editor-session behavior: an interrupt during MCP boot or model resolution no longer discards the request, and the next jp query --edit seeds its buffer from it. The file is still removed once the turn completes successfully.

The --cfg config delta is now recorded only after the empty-query check, so a query that turns out empty no longer leaves a stray config event in the stream.

`jp query --replay` and the bare `--no-edit` replay-last-request path
used to remove the trailing request event from the conversation stream
while the request was still being built — during editor composition,
MCP boot, or attachment loading. An interrupt or an empty query in that
window persisted the removal without ever writing the replacement,
silently dropping the last turn.

The removal is now described by a `PendingStreamTrim` and only applied
inside the same lock scope that appends the new turn, so the stream
goes from "old turn present" to "old turn replaced" in one write.
Building the request is otherwise read-only: `ConversationStream`
gains `last_turn_event` to peek at the trailing event without popping
it, and `ConversationLock`/`ConversationMut` gain `with_events` for
read-only access that never marks the conversation dirty.

Inline, piped, and replayed queries now also write their composed
request to the conversation's recovery file before the turn starts,
matching the existing editor-session behavior: an interrupt during MCP
boot or model resolution no longer discards the request, and the next
`jp query --edit` seeds its buffer from it. The file is still removed
once the turn completes successfully.

The `--cfg` config delta is now recorded only after the empty-query
check, so a query that turns out empty no longer leaves a stray config
event in the stream.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit 092f28b into main Jul 9, 2026
16 checks passed
@JeanMertz JeanMertz deleted the jp-c-edit-backup branch July 9, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant