fix(tui): refuse empty truncation on prompt.submit to prevent silent session wipe (#70516) - #70895
Closed
kshitijk4poor wants to merge 2 commits into
Closed
Conversation
Stale truncate_before_user_ordinal=0 from a desynced Desktop client resolved to history[:0] and replace_messages() wiped the durable transcript. Require confirm_empty_truncate for that edge and have intentional first-turn restore/regenerate paths send it.
Refuse ordinal-0 wipes without confirm_empty_truncate; allow the opt-in path used by first-turn restore/regenerate.
Contributor
|
Great salvage, @kshitijk4poor! 🎉 Glad to see #70516 getting a robust fix — the Since this closes the TUI session-wipe P1, I'm going to pick up the next hardest one: #70773 (P0 — TLS FD-reuse SQLite corruption with shared client pool). That concurrency/SSL race has been lurking since #67142 and needs a proper fix. Let me know if you want to collaborate on that one too. 🚀 |
kshitijk4poor
enabled auto-merge (rebase)
July 24, 2026 18:09
Collaborator
Author
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.
Summary
Refuses silent session-wipe when a stale
truncate_before_user_ordinal=0from a desynced desktop frontend resolves tohistory[:0] == []andreplace_messages()deletes every durable row (issue #70516: 308 messages lost, unrecoverable).Root cause: the ordinal is an index into the frontend's message array, treated as an index into the backend's history. A stale ordinal=0 on an ordinary fresh submit wipes the entire transcript with no log.
Changes
truncated == []) unlessconfirm_empty_truncate=trueis passed (error 4025). Usesis_truthy_value()so string falsey values ('false','no','0') are correctly rejected. Every truncation logged (WARNING for empty result, INFO for routine rewind).truncateSubmitParams()helper automatically attachesconfirm_empty_truncate: truewhen ordinal=0 (legitimate restore/regenerate of first user turn). Applied to all 3 call sites:runRewindSubmit,index.ts,session-tile-actions.ts.truncateSubmitParams()+ updated desktop integration tests.Based on #70570 by @HexLab98. Also closes #70718 by @webtecnica (same fix, same issue, #70570 is the more complete implementation).
Closes #70516. Closes #70570. Closes #70718.
Validation
ordinal=0no confirmordinal=0+confirm_empty_truncate=trueordinal=0+confirm_empty_truncate='false'ordinal=1(routine rewind)